/** * Get all pages codenames for website * * @return array(codename => pageId) * @access public */ function getAllPagesCodenames() { $pageIds = CMS_tree::getAllSiblings($this->_root->getID(), false, true); if (!is_array($pageIds)) { $pageIds = array(); } $pageIds[] = $this->_root->getID(); //pr($pagesIds); $q = new CMS_query("\n\t\t\tselect\n\t\t\t\tpage_pbd, codename_pbd\n\t\t\tfrom\n\t\t\t\tpagesBaseData_edited\n\t\t\twhere\n\t\t\t\tpage_pbd in (" . implode(',', $pageIds) . ")\n\t\t\t\tand codename_pbd != ''\n\t\t"); $pagesCodenames = $q->getAll(); $codenames = array(); foreach ($pagesCodenames as $pageCodename) { $codenames[$pageCodename['codename_pbd']] = $pageCodename['page_pbd']; } return $codenames; }
/** * 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; } }
//force language if none exists if (!isset($cms_language) || !is_object($cms_language)) { $cms_language = new CMS_language(ADMINISTRATION_DEFAULT_LANGUAGE); } //get page if (isset($_GET['pageId']) && sensitiveIO::isPositiveInteger($_GET['pageId'])) { $page = CMS_tree::getPageById($_GET['pageId']); } if (isset($page) && !$page->hasError()) { $redirect = ''; $redirectlink = $page->getRedirectLink(true); if ($redirectlink->hasValidHREF()) { if ($redirectlink->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL) { $redirectPage = new CMS_page($redirectlink->getInternalLink()); if (!$redirectPage->hasError()) { $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $redirectPage->getTitle() . '" (' . $redirectPage->getID() . ')'; } $redirect = '<a href="' . $redirectPage->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>'; } else { $label = $redirectlink->getExternalLink(); $redirectlink->setTarget('_blank'); $redirect = $redirectlink->getHTML(io::ellipsis($label, '80'), MOD_STANDARD_CODENAME, RESOURCE_DATA_LOCATION_EDITED); } } else { $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $page->getTitle() . '" (' . $page->getID() . ')'; $redirect = '<a href="' . $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>'; } $content = ' <div id="atm-center"> <div class="atm-alert">' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array($redirect)) . '</div> </div>';
/** * Create datas from definition. * Parse definition and create PHP / HTML string * * @param serialized datas $rawDatas : The user specified parameters for the row * @param CMS_page $page The reference of the current page using block * @param boolean $public The needed precision for USERSPACE location (default : false) * @param constant $type The needed return type of datas (default : CMS_polymod_definition_parsing::OUTPUT_RESULT) * @return string The PHP / HTML datas * @access private */ protected function _createDatasFromDefinition($rawDatas, &$page, $visualizationMode, $type = CMS_polymod_definition_parsing::OUTPUT_RESULT) { $public = $visualizationMode == PAGE_VISUALMODE_PRINT || $visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC; $parameters = $rawDatas ? array_merge($rawDatas, $this->_attributes) : $this->_attributes; // If no language parameter : set page language $parameters['language'] = isset($parameters['language']) && $parameters['language'] ? $parameters['language'] : $page->getLanguage(); $parameters = array('block_attributes' => $parameters, 'module' => $this->_attributes['module'], 'language' => $parameters['language'], 'pageID' => $page->getID(), 'public' => $public); $polymodParsing = new CMS_polymod_definition_parsing($this->_definition, true, CMS_polymod_definition_parsing::PARSE_MODE, $this->_attributes['module'], $visualizationMode); $content = $polymodParsing->getContent($type, $parameters); if (!$public) { return $content; } //Cache management $cacheHash = md5(serialize(array('definition' => $content, 'parameters' => $parameters))); $lifetime = isset($this->_attributes['cache']) ? $this->_attributes['cache'] : 'auto'; $content = CMS_cache::wrapCode($cacheHash, $content, $lifetime); return $content; }
/** * Get all edited blocks found for a given page * Detect all blocks * Sends an array of all blocks of given page * * @param CMS_page $page the page we want data from * @param boolean $public, if only public datas are concerned * @return array of CMS_block */ function getAllBlocksForPage(&$page, $public = false) { $_blocks = array(); //@var : array ( array(Table prefix, Class name) ) $_blockTypes = array(array('blocksRawDatas', false), array('blocksImages', 'CMS_block_image'), array('blocksFlashes', 'CMS_block_flash'), array('blocksFiles', 'CMS_block_file'), array('blocksTexts', 'CMS_block_text'), array('blocksVarchars', 'CMS_block_varchar')); //Rotate all block types availables foreach ($_blockTypes as $b) { $table = $public ? $b[0] . '_public' : $b[0] . '_edited'; $class = $b[1]; $sql = "\n\t\t\t\tselect\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\t" . $table . "\n\t\t\t\twhere\n\t\t\t\t\tpage=" . $page->getID() . "\n\t\t\t\t"; $q = new CMS_query($sql); while ($r = $q->getArray()) { if (isset($r['type']) && $r['type'] && class_exists($r['type'])) { $_blocks[] = new $r['type']($r['id'], RESOURCE_LOCATION_USERSPACE, $public); } elseif ($class && class_exists($class)) { $_blocks[] = new $class($r['id'], RESOURCE_LOCATION_USERSPACE, $public); } } } return $_blocks; }
CMS_grandFather::raiseError('Error, can\'t get a valid page to work with.'); $view->show(); } //check if page is useable (public or edited at least) if (!$cms_page->isUseable() || $followRedirect) { if (!$cms_page->isUseable()) { //page is deleted, go to root $cms_page = CMS_tree::getRoot(); } //redirect to subpage if any redirection exists $redirectlink = $cms_page->getRedirectLink(true); while ($redirectlink->hasValidHREF() && sensitiveIO::IsPositiveInteger($redirectlink->getInternalLink())) { $cms_page = new CMS_page($redirectlink->getInternalLink()); $redirectlink = $cms_page->getRedirectLink(true); } $pageId = $cms_page->getID(); } pr('View page : ' . $cms_page->getID() . ($reload ? ' (Force reload queried by interface)' : '')); //set page into user context CMS_session::setPage($cms_page); //for the page, create all javascript informations needed $hasPreviz = $hasPublic = $hasDraft = $isEditable = $hasLock = $hasRedirect = false; //which panels can be seen by user (according to his rights) //this array represent the order of each panel (left to right) $userPanels = array('search' => array('type' => 'searchPanel', 'visible' => true), 'tree' => array('type' => 'winPanel', 'visible' => false), 'favorite' => array('type' => 'favoritePanel', 'visible' => $cms_user->hasModuleClearance(MOD_STANDARD_CODENAME, CLEARANCE_MODULE_VIEW)), 'action' => array('type' => 'menuPanel', 'visible' => false), 'add' => array('type' => 'winPanel', 'visible' => false), 'properties' => array('type' => 'winPanel', 'visible' => false), 'edit' => array('type' => 'framePanel', 'visible' => false), 'edited' => array('type' => 'framePanel', 'visible' => false), 'public' => array('type' => 'framePanel', 'visible' => true), 'nopages' => array('type' => 'framePanel', 'visible' => false), 'norights' => array('type' => 'framePanel', 'visible' => false)); //check for public page if ($cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_VIEW)) { if ($cms_page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { $hasPublic = true; } }
/** * Set Page * * @param CMS_page $page * @return void * @access public */ public static function setPage(&$page) { if ($page instanceof CMS_page) { $sessionNS = new Zend_Session_Namespace('atm-page'); $sessionNS->pageId = $page->getID(); } else { $this->raiseError("Incorrect Page type"); } }
$property = '(' . $date->getLocalizedDate() . ')'; } break; case "template": $tmp = $sibling->getTemplate(); $property = '(' . (is_a($tmp, "CMS_pageTemplate") ? $tmp->getLabel() : '???') . ')'; break; } } else { $property = '(' . $sibling->getID() . ')'; $redirectlink = $sibling->getRedirectLink(true); if ($redirectlink->hasValidHREF()) { if ($redirectlink->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL) { $redirectPage = new CMS_page($redirectlink->getInternalLink()); if (!$redirectPage->hasError()) { $property .= '<small class="atm-help" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array('\'' . $redirectPage->getTitle(true) . '\' (' . $redirectPage->getID() . ')')) . '"> ⇒ ' . $redirectPage->getID() . '</small>'; } } else { $label = $redirectlink->getExternalLink(); $property .= '<small class="atm-help" ext:qtip="' . $cms_language->getMessage(MESSAGE_PAGE_REDIRECT, array(io::ellipsis($label, '80'))) . '"> ⇒ ' . io::ellipsis($label, '50') . '</small>'; } } } $pageTitle = PAGE_LINK_NAME_IN_TREE ? $sibling->getLinkTitle() : $sibling->getTitle(); $hasSiblings = CMS_tree::hasSiblings($sibling) ? true : false; $ddtext = ''; $draggable = $allowDrop = false; $editableSibling = $cms_user->hasPageClearance($sibling->getId(), CLEARANCE_PAGE_EDIT); if ($enableDD) { //does this node draggable ? (/!\ only public nodes can be draggable) $draggable = !$sibling->isProtected() && $editableSibling && (!$hasSiblings || $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) && $sibling->getID() != APPLICATION_ROOT_PAGE_ID) && $sibling->getPublication() == RESOURCE_PUBLICATION_PUBLIC;