/** * Get the HTML display for a page, if it passes the condition of course. * * @param CMS_page $parsedPage The page in which the linx tag is * @param CMS_page $page The page to get the display of * @param boolean $public Is the page data to show the public or edited one ? * @param integer $rank The rank of the page in the linx targets * @param boolean $noerror : Hide all link error (default : false) * @return string The html or false if page fails to pass the condition * @access public */ function getOutput(&$parsedPage, &$page, $public, $rank, $noerror = false, $noselection = false) { if (!is_a($page, "CMS_page")) { if (!$noerror) { $tpl = $parsedPage->getTemplate(); if (is_a($tpl, 'CMS_pageTemplate')) { $tplName = $tpl->getID() . "\t : " . $tpl->getLabel(); } else { $tplName = 'No template set !'; } $this->raiseError("Page parameter not defined\n - Page : " . $parsedPage->getID() . "\n - Template : " . $tplName . "\n"); } return false; } if (!$this->hasCondition() || $this->pagePassesConditions($parsedPage, $page, $public, $rank)) { //get pages infos $linkTitle = $page->getLinkTitle($public); $title = $page->getTitle($public); $replace = array("{{title}}" => io::sanitizeHTMLString($linkTitle), "{{jstitle}}" => io::sanitizeHTMLString($linkTitle), "{{pagetitle}}" => io::sanitizeHTMLString($title), "{{jspagetitle}}" => io::sanitizeHTMLString($title), "{{desc}}" => io::sanitizeHTMLString($page->getDescription($public)), "{{href}}" => $page->getURL(), "{{id}}" => $page->getID(), "{{codename}}" => $page->getCodename($public), "{{number}}" => $rank - 1, "{{modulo}}" => ($rank - 1) % 2, "{{currentClass}}" => $parsedPage->getID() == $page->getID() ? "CMS_current" : "", 'id="{{currentID}}"' => $parsedPage->getID() == $page->getID() ? 'id="CMS_current"' : ""); if (io::strpos($this->_htmlTemplate, '{{isParent}}') !== false) { //only if needed because getLineage require a lot of query $lineage = CMS_tree::getLineage($page->getID(), $parsedPage->getID(), false, $public); $replace['class="{{isParent}}"'] = is_array($lineage) && in_array($parsedPage->getID(), $lineage) ? 'class="CMS_parent"' : ""; $replace['{{isParent}}'] = is_array($lineage) && in_array($parsedPage->getID(), $lineage) ? 'CMS_parent' : ""; $replace['id="{{isParent}}"'] = is_array($lineage) && in_array($parsedPage->getID(), $lineage) ? 'id="CMS_parent"' : ""; } if (io::strpos($this->_htmlTemplate, '{{website') !== false) { //only if needed because getWebsite require a lot of query $website = $page->getWebsite(); $replace['{{websitetitle}}'] = $website->getLabel(); $replace['{{websitecodename}}'] = $website->getCodename($public); } $html = str_replace(array_keys($replace), $replace, $this->_htmlTemplate); if (APPLICATION_ENFORCES_ACCESS_CONTROL && $public) { $html = $this->_addSlashAroundPHPContent($html); //pr($html); $replace = array("<?php" => "';", "?>" => "echo '"); $html = str_replace(array_keys($replace), $replace, $html); //if link has noselection flag, use alternative when user has no right on linked page if (is_object($noselection)) { $noSelectionContent = $this->_addSlashAroundPHPContent(CMS_DOMDocument::DOMElementToString($noselection, true)); $html = '<?php if ($cms_user->hasPageClearance(' . $page->getID() . ', CLEARANCE_PAGE_VIEW)) {' . "\n" . 'echo \'' . $html . '\';' . "\n" . '} else {' . "\n" . 'echo \'' . $noSelectionContent . '\';' . "\n" . '}' . "\n" . '?>'; } else { $html = '<?php if ($cms_user->hasPageClearance(' . $page->getID() . ', CLEARANCE_PAGE_VIEW)) {' . "\n" . 'echo \'' . $html . '\';' . "\n" . '}' . "\n" . '?>'; } } return $html; } else { return false; } }