function sDisplay() { global $goApp, $webyep_bOpenFullURLsInNewWindow, $webyep_iUseImageBox, $webyep_oCurrentLoop; $sHTML = ""; $oImg = od_clone($this->oImage()); $sAltText = $this->sAltText(); $sAtt = ""; $sAnchor = ""; $iLoop = 0; $oURL = od_nil; $iDW = $this->bIsThumb ? $this->iThumbWidth : $this->iImageWidth; $iDH = $this->bIsThumb ? $this->iThumbHeight : $this->iImageHeight; if ($oImg) { if ($iDW != 0 || $iDH != 0) { $iW = $oImg->iWidth(); $iH = $oImg->iHeight(); if ($iW != 0 && $iH != 0) { // if image size could be determined if ($iW > $iDW || $iH > $iDH) { // image has not the correct size list($iW, $iH) = $this->aContrainedSize($iW, $iH, $this->bIsThumb); $this->sAttributes .= ($this->sAttributes ? " " : "") . "width=\"{$iW}\" height=\"{$iH}\""; } } } if ($this->sAttributes) { if (stristr($this->sAttributes, "width=") || stristr($this->sAttributes, "height=")) { // width or height can only be set in attributes if $this->iImageWidth/iThumbWidth are _not_ used! $oImg->removeAttribute("width"); $oImg->removeAttribute("height"); } if (stristr($this->sAttributes, "alt=")) { $oImg->removeAttribute("alt"); } } if ($this->sAttributes) { $sAtt = " " . $this->sAttributes; } if ($sAltText) { $oImg->setAttribute("alt", $sAltText); } $sHTML .= str_replace("<img", "<img{$sAtt}", $oImg->sDisplay()); $oLink = od_nil; $sURL = $this->dContent[WY_DK_URL] ? $this->dContent[WY_DK_URL] : $this->sURL; if ($sURL) { $oURL = new WYURL($sURL); if (!$this->dContent[WY_DK_URL]) { $iLoop = $goApp->oDocument->iLoopID(); if ($iLoop) { $oURL->dQuery[WY_QK_DI] = $goApp->oDocument->iDocumentInstanceForLoopID($iLoop); } } $oLink = new WYLink($oURL, "", true); if ($webyep_bOpenFullURLsInNewWindow && WYURL::bIsAbsolute($sURL)) { $this->sTarget = "_blank"; } if ($this->sTarget) { $oLink->setAttribute("target", $this->sTarget); } } if ($this->bIsThumb && !$oLink) { if ($webyep_iUseImageBox == WEBYEP_LIGHTBOX) { $oImg = $this->oDetailImage(); $oURL = $oImg->oURL; if (!$oLink) { $oLink = new WYLink($oURL); if ($webyep_oCurrentLoop != od_nil) { $sGroup = $webyep_oCurrentLoop->sFieldNameForFile(); } else { $sGroup = ""; } $oLink->setAttribute("rel", "lightbox" . ($sGroup ? "[{$sGroup}]" : "")); $oLink->setAttribute("class", "WYPopUpImage"); } } else { if ($webyep_iUseImageBox == WEBYEP_FANCYBOX) { // use jquery.fancybox $oImg = $this->oDetailImage(); $oURL = $oImg->oURL; if (!$oLink) { $oLink = new WYLink($oURL); if ($webyep_oCurrentLoop != od_nil) { $sGroup = $webyep_oCurrentLoop->sFieldNameForFile(); } else { $sGroup = md5($oURL->sEURL()); } // 'unique' ID to prevent Fancybox from grouping single pictures $oLink->setAttribute("rel", "fancybox" . ($sGroup ? "_{$sGroup}" : "")); $oLink->setAttribute("class", "WYPopUpImage"); } } else { $oURL = $this->oDetailWindowURL(); $oImg = $this->oDetailImage(); $iW = $oImg->iWidth(); $iH = $oImg->iHeight(); if ($iW == 0) { $iW = 400; } if ($iH == 0) { $iH = 400; } $oURL->dQuery[WY_QK_IMAGE_DETAIL] = $oImg->oURL->sBasename(); $oURL->dQuery[WY_QK_IMAGE_ALTTEXT] = $sAltText; $oURL->dQuery[WY_QK_IMAGE_DEMOCONTENT] = $this->bDemoContent; if (!$oLink) { $oLink = new WYLink(new WYURL("javascript:void(0)")); } $oLink->setAttribute("onclick", sprintf("wydw=window.open(\"%s\", \"WYDetail\", \"width=%d,height=%d,status=yes,scrollbars=yes,resizable=yes\"); wydw.focus();", $oURL->sEURL(true, true, true), $iW, $iH)); $oLink->setAttribute("class", "WYPopUpImage"); if (!$sAltText) { $oLink->setToolTip(WYTS("ClickToZoom")); } } } } if ($oLink) { // $oLink->setAttribute("class", "WYPopUpImage"); if ($sAltText) { $oLink->setToolTip($sAltText); } $oLink->setInnerHTML($sHTML); $sHTML = $oLink->sDisplay(); } } return $sHTML; }
/** * Recursive function to build an HTML tree from a nested dictionary (v2) * * @param mixed $subtree The (nested) dictionary, containing the menu data * @return string Nested list (HTML) */ function buildHtmlTree($subtree) { global $goApp, $webyep_iMenuID, $webyep_bUseJavaScriptMenus, $webyep_bMenuJSInserted, $webyep_bAutoCloseMenus, $webyep_bOpenFullURLsInNewWindow, $webyep_bTitleAlwaysOpensPage; $sElementID = "WYMUTREE_{$webyep_iMenuID}_" . $this->iLastTitleID; if ($this->iLastTitleID != 0 && !in_array($this->iLastTitleID, $this->aCurrentPath) && !in_array($sElementID, $this->aOpenTrees)) { $this->aCloseTrees[] = $this->iLastTitleID; } if ($this->iLastTitleID == 0) { // first ul doesn't get an ID $sHTML = "\n<" . $this->sListType . ' class="' . WEBYEP_MENU_CSS . "\">\n"; } else { $sHTML = "\n<" . $this->sListType . ' class="' . WEBYEP_MENU_CSS . " WYMUTREE_{$webyep_iMenuID}\" id=\"{$sElementID}\">\n"; } $iEntryNr = 0; foreach ($subtree as $dEntry) { $iEntryNr++; $aClass = array(WEBYEP_MENU_CSS_ITEM); $bIsTitle = count($dEntry['SUBITEMS']) ? true : false; $bUseTitleAsItem = false; $bIsCurrentEntry = false; if ($dEntry['VISIBLE']) { if ($dEntry['URL']) { $oURL = new WYURL($dEntry['URL']); $bOpenInNewWindow = $webyep_bOpenFullURLsInNewWindow && WYURL::bIsAbsolute($dEntry['URL']); $bUseTitleAsItem = true; } else { $oURL = od_clone($this->oURL); } // new feature: suppress DI, if user specifies somepage.php?DOC_INST=0 in URL field if (!isset($oURL->dQuery[WY_QK_DI]) || $oURL->dQuery[WY_QK_DI] > 0) { $oURL->dQuery[WY_QK_DI] = $dEntry[WY_DK_ITEMID]; // overwrite existing DI, otherwise we could not delete those contents! if ($webyep_bTitleAlwaysOpensPage) { $bUseTitleAsItem = true; } } else { unset($oURL->dQuery[WY_QK_DI]); // really dispose } $sURL = $oURL->sEURL(true, true, $dEntry['URL'] != ""); // is this entry expanded? if (!$webyep_bUseJavaScriptMenus || in_array($dEntry[WY_DK_ITEMID], $this->aCurrentPath) || in_array($sElementID, $this->aOpenTrees)) { $bIsExpanded = true; } // CSS $bIsCurrentEntry = $this->_bIsCurrentEntry($dEntry[WY_DK_ITEMID], $dEntry['URL']); if (!$bIsCurrentEntry && in_array($dEntry[WY_DK_ITEMID], $this->aCurrentPath)) { $aClass[] = WEBYEP_MENU_CSS_CURRENT_PATH; } if ($bIsCurrentEntry) { $aClass[] = WEBYEP_MENU_CSS_CURRENT_ITEM; } if ($iEntryNr == 1) { $aClass[] = WEBYEP_MENU_CSS_FIRST_ITEM; } if ($bIsTitle) { unset($aClass[0]); // no WEBYEP_MENU_CSS_ITEM for titles $aClass[] = WEBYEP_MENU_CSS_TITLE; $aClass[] = WEBYEP_MENU_CSS_EXPANDED; } $sClass = implode(' ', $aClass); // assemble HTML $sText = str_replace("\\", "<br />", webyep_sHTMLEntities($dEntry['TITLE'])); $sID = $bIsTitle ? ' id="WYMUTITLE' . $webyep_iMenuID . $dEntry[WY_DK_ITEMID] . '"' : ''; $sHTML .= '<li class="' . $sClass . '"' . $sID . '>'; $sHTML .= $this->buildLink($bIsTitle, $bUseTitleAsItem, $bIsExpanded, $sClass, $dEntry[WY_DK_ITEMID], $sText, $sURL); if ($bIsTitle) { $this->iLastTitleID = $dEntry[WY_DK_ITEMID]; $sHTML .= $this->buildHtmlTree($dEntry['SUBITEMS']); } $sHTML .= "</li>\n"; } } $sHTML .= '</' . $this->sListType . ">\n"; return $sHTML; }