/** * Returns XHTML formatted form fields for this Href * * @param CMS_language $cms_language, the language to build the form with * @param string $module, the module codename (default : MOD_STANDARD_CODENAME) * @param constant $dataLocation, the current data location (RESOURCE_DATA_LOCATION_EDITED (default), RESOURCE_DATA_LOCATION_PUBLIC, etc.) * @param array $options, array of possible link options (default false : all options actived) * Example : * Array ( * 'label' => true|false, // Link has label ? * 'internal' => true|false, // Link can target an Automne page ? * 'external' => true|false, // Link can target an external resource ? * 'file' => true|false, // Link can target a file ? * 'destination'=> true|false, // Can select a destination for the link ? * 'no_admin' => true|false, // Deprecated : Remove all admin class reference (default = false) * 'admin' => true|false, // Use admin JS and classes instead of direct actions (default = true) * 'currentPage'=> int|false, // Current page to open tree panel (default : CMS_tree::getRoot()) * ) * @return string HTML formated expected * @access public */ function getHTMLFields($cms_language, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $options = false) { global $cms_user; if (!is_a($this->_href, 'CMS_href')) { $this->raiseError("\$this->_href isn't a CMS_href"); return ''; } $tdClass = $tdClassLight = $tdClassDark = $inputClass = ''; if (!isset($options['no_admin']) || $options['no_admin'] === false) { $tdClass = ' class="admin"'; $tdClassLight = ' class="admin_lightgreybg"'; $tdClassDark = ' class="admin_darkgreybg"'; $inputClass = ' class="admin_input_text"'; } $s = ''; if (!isset($options['destination']) || $options['destination'] == true) { $s .= ' <script type="text/javascript"> if (typeof CMS_openPopUpPage != "function") { function CMS_openPopUpPage(href, id, width, height) { if (href != "") { pagePopupWin = window.open(href, \'CMS_page_\'+id, \'width=\'+width+\',height=\'+height+\',resizable=yes,menubar=no,toolbar=no,scrollbars=yes,status=no,left=0,top=0\'); } } } </script>'; } $s .= ' <table>'; if (!isset($options['label']) || $options['label'] == true) { $s .= ' <!-- link label --> <tr> <th' . $tdClass . '><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_LABEL) . '</th> <td' . $tdClassLight . ' colspan="2"><input style="width:100%;" type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_label" value="' . io::htmlspecialchars($this->_href->getLabel()) . '" /></td> </tr>'; } $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_NONE ? ' checked="checked"' : ''; $rowspan = 4; if (isset($options['internal']) && $options['internal'] == false) { $rowspan--; } if (isset($options['external']) && $options['external'] == false) { $rowspan--; } if (isset($options['file']) && $options['file'] == false) { $rowspan--; } $s .= ' <tr> <th' . $tdClass . ' rowspan="' . $rowspan . '"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_DESTINATION) . '</th> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_0" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_NONE . '"' . $checked . ' /></td> <td' . $tdClassDark . '><label for="' . $this->_prefix . 'link_type_0">' . $cms_language->getMessage(self::MESSAGE_PAGE_NOLINK) . '</label></td> </tr> '; if (!isset($options['internal']) || $options['internal'] == true) { $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL ? ' checked="checked"' : ''; // Build tree link $grand_root = isset($options['currentPage']) && sensitiveIO::isPositiveInteger($options['currentPage']) ? CMS_tree::getPageByID($options['currentPage']) : CMS_tree::getRoot(); $grand_rootID = $grand_root->getID(); if ($cms_user && is_a($cms_user, 'CMS_profile_user')) { if (!$cms_user->hasPageClearance($grand_rootID, CLEARANCE_PAGE_VIEW)) { // If user don't have any clearance view for page root : search a "first root" and viewable page sections $sections_roots = array(); $sections_roots = $cms_user->getViewablePageClearanceRoots(); if ($sections_roots) { CMS_session::setSessionVar('sectionsRoots', $sections_roots); $sections_roots = array_reverse($sections_roots); foreach ($sections_roots as $pageID) { $lineages[count(CMS_tree::getLineage($grand_rootID, $pageID, false))] = $pageID; } } ksort($lineages); $grand_rootID = array_shift($lineages); } } if (!isset($options['admin']) || $options['admin'] == false) { //build tree link $href = '/automne/admin-v3/tree.php'; $href .= '?root=' . $grand_rootID; $href .= '&heading=' . $cms_language->getMessage(self::MESSAGE_PAGE_TREEH1); $href .= '&encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $this->_prefix . "link_internal').value = '%s';self.close();"); $href .= '&encodedPageLink=' . base64_encode('false'); $treeLink = '<a href="' . $href . '"' . $tdClass . ' target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>'; } else { $treeLink = '<a href="#" onclick="Automne.view.tree(\'' . $this->_prefix . 'link_internal\', \'' . sensitiveIO::sanitizeJSString($cms_language->getMessage(self::MESSAGE_PAGE_TREEH1)) . '\', \'' . $grand_rootID . '\')"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>'; } $s .= '<tr> <td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_1" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_INTERNAL . '"' . $checked . ' /></td> <td' . $tdClassLight . '> <label for="' . $this->_prefix . 'link_type_1">' . $cms_language->getMessage(self::MESSAGE_PAGE_INTERNALLINK) . '</label> <input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_internal" name="' . $this->_prefix . 'link_internal" value="' . $this->_href->getInternalLink() . '" size="6" /> ' . $treeLink . ' </td> </tr>'; } if (!isset($options['external']) || $options['external'] == true) { $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_EXTERNAL ? ' checked="checked"' : ''; $s .= ' <tr> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_2" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_EXTERNAL . '"' . $checked . ' /></td> <td' . $tdClassDark . '> <label for="' . $this->_prefix . 'link_type_2">' . $cms_language->getMessage(self::MESSAGE_PAGE_EXTERNALLINK) . '</label> <input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_external" name="' . $this->_prefix . 'link_external" value="' . io::htmlspecialchars($this->_href->getExternalLink()) . '" size="30" /> </td> </tr> '; } if (!isset($options['file']) || $options['file'] == true) { $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_FILE ? ' checked="checked"' : ''; $s .= ' <tr> <td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_3" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_FILE . '"' . $checked . ' /></td> <td' . $tdClassLight . '> <label for="' . $this->_prefix . 'link_type_3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINKFILE) . '</label> <input type="file"' . $inputClass . ' name="' . $this->_prefix . 'link_file" /><br /> <label for="' . $this->_prefix . 'link_edit_linkfile"><input type="checkbox" id="' . $this->_prefix . 'link_edit_linkfile" name="' . $this->_prefix . 'link_edit_linkfile" value="1" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_FIELD_EDITFILE) . '</label>'; if ($this->_href->getFileLink(false, $module, $dataLocation)) { $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : <a href="' . $this->_href->getFileLink(true, $module, $dataLocation) . '" target="_blank">' . $this->_href->getFileLink(false, $module, $dataLocation) . '</a>'; } else { $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : ' . $cms_language->getMessage(self::MESSAGE_PAGE_NO_FILE); } $s .= ' </td> </tr>'; } if (!isset($options['destination']) || $options['destination'] == true) { $popup = $this->_href->getPopup(); $checked_pop = isset($popup['width']) && $popup['width'] > 0 ? ' checked="checked"' : ''; $checked_top = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_top' ? ' checked="checked"' : ''; $checked_bl = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_blank' ? ' checked="checked"' : ''; if (!$checked_pop && !$checked_top && !$checked_bl) { $checked_top = ' checked="checked"'; } $width = isset($popup['width']) ? $popup['width'] : 0; $height = isset($popup['height']) ? $popup['height'] : 0; $s .= ' <!-- Link target --> <tr> <th' . $tdClass . ' rowspan="3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_SHOW) . '</th> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_top" name="' . $this->_prefix . 'link_target" value="top"' . $checked_top . ' /></td> <td' . $tdClassDark . '> <label for="' . $this->_prefix . 'link_target_top"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_TOP) . '</label> </td> </tr> <tr> <td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_target_blank" name="' . $this->_prefix . 'link_target" value="blank"' . $checked_bl . ' /></td> <td' . $tdClassLight . '> <label for="' . $this->_prefix . 'link_target_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_blank.gif" alt="" border="0" align="absmiddle" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_BLANK) . '</label> </td> </tr> <tr> <td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_popup" name="' . $this->_prefix . 'link_target" value="popup"' . $checked_pop . ' /></td> <td' . $tdClassDark . '> <label for="' . $this->_prefix . 'link_target_popup"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_POPUP) . ' : </label> ' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_WIDTH) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_width" value="' . $width . '" size="3" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_HEIGHT) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_height" value="' . $height . '" size="3" /> </td> </tr>'; } $s .= '</table>'; return $s; }
/** * Build the targets from the selection start and stop nodes * Uses the websites catalog to exclude (for desclinks and sublinks) pages that are not part of the current website * * @return boolean true on success, false on failure * @access private */ protected function _buildTargets() { if (!$this->_selectionStartPages || !$this->_selectionStartPages) { return false; } $targets = array(); switch ($this->_type) { case "direct": $targets = $this->_selectionStartPages; //apply the selection to the builded targets $targets = $this->_selectTargets($targets); break; case "desclinks": if (!$this->_selectionStopPage) { //$this->raiseError("No stop page found for desclinks"); return false; } foreach ($this->_selectionStartPages as $start) { $targets_temp = CMS_tree::getLineage($start, $this->_selectionStopPage, true, $this->_publicTree); if ($targets_temp && is_array($targets_temp)) { $targets_temp = array_reverse($targets_temp); $root_found = false; foreach ($targets_temp as $aTarget) { if (CMS_websitesCatalog::isWebsiteRoot($aTarget->getID())) { if ($root_found) { break; } else { $root_found = true; } } $targets[] = $aTarget; } $targets = array_reverse($targets); } } //apply the selection to the builded targets $targets = $this->_selectTargets($targets); break; case "sublinks": foreach ($this->_selectionStartPages as $start) { $targets_temp = CMS_tree::getSiblings($start, $this->_publicTree); if ($targets_temp && is_array($targets_temp)) { foreach ($targets_temp as $aTarget) { if ($this->_crosswebsite || !CMS_websitesCatalog::isWebsiteRoot($aTarget->getID())) { $targets[] = $aTarget; } } } } //apply the selection to the builded targets $targets = $this->_selectTargets($targets); break; case "recursivelinks": //construct targets and recursive targets then apply the selection to the builded targets foreach ($this->_selectionStartPages as $start) { $targets[$start->getID()] = $start; $returnedDatas = $this->_buildRecursiveTargets($start->getID()); $targets = $targets + $returnedDatas["targets"]; $this->_recursiveTargets[$start->getID()] = $returnedDatas["recursiveTree"]; //add this page to father watches $this->_fatherWatches[] = $this->_page->getID(); } break; } return $targets; }
/** * Get the recursive HTML display for a recursivelinks, if it passes the condition of course. * * @param CMS_page $parsedPage The page in which the linx tag is * @param integer $level The current level of recursivity * @param multidimentionnal array $recursiveTree The tree to display * @param array $pages array of pages objects (indexed by id) * @param boolean $public Is the page data to show the public or edited one ? * @param array $lineage The lineage of the pages (used to see wich recursions need to be done in closed link display mode) * @return string The html of the recursive link * @access public */ function getRecursiveOutput(&$parsedPage, $level = 0, $recursiveTree, &$pages, $public, $lineage = array()) { $html = ''; if (is_array($recursiveTree) && $recursiveTree) { $rank = 1; $levelhtml = ''; foreach ($recursiveTree as $pageID => $subPages) { //get Page Object $page = $pages[$pageID]; //instanciate page if not exists as object if (!is_object($page) && sensitiveIO::isPositiveInteger($page)) { $page = CMS_tree::getPageByID($page); } $pagehtml = ''; //check if page pass the condition if (is_object($page) && (!$this->hasCondition() || $this->pagePassesConditions($parsedPage, $page, $public, $rank)) && (!$public || $public && $page->isUseable() && $page->getPublication() == RESOURCE_PUBLICATION_PUBLIC)) { //get pages infos $linkTitle = $page->getLinkTitle($public); $title = $page->getTitle($public); //set pages infos in html template $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, "{{lvlClass}}" => "CMS_lvl" . ($level + 1), "{{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 $pagelineage = CMS_tree::getLineage($page->getID(), $parsedPage->getID(), false); $replace['class="{{isParent}}"'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'class="CMS_parent"' : ""; $replace['{{isParent}}'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? 'CMS_parent' : ""; $replace['id="{{isParent}}"'] = is_array($pagelineage) && in_array($parsedPage->getID(), $pagelineage) ? '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); } $pagehtml = str_replace(array_keys($replace), $replace, $this->_htmlTemplate); if ($level == 0 && ($this->_root === 'false' || !$this->_root)) { $pagehtml = str_replace(array_keys($replace), $replace, $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public, $lineage)); } else { //check if link is in open or closed mode if ($this->_mode == "open") { //if it is open mode recurse indefinitely (until end of tree) //then mark info of sublevels or not $replace = array("{{typeClass}}" => $subPages ? "CMS_sub" : "CMS_nosub", "{{sublevel}}" => $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public)); $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml); } else { //if it is 'close' mode recurse only for pages in current lineage $recurse = false; if (is_array($lineage)) { $recurse = in_array($page->getID(), $lineage) ? true : false; } //then mark info of sublevels or not and if level is open or not $sub = $recurse ? "CMS_open" : "CMS_sub"; $replace = array("{{typeClass}}" => $subPages ? $sub : "CMS_nosub", "{{sublevel}}" => $recurse ? $this->getRecursiveOutput($parsedPage, $level + 1, $subPages, $pages, $public, $lineage) : ""); if (!$recurse) { //needed to update link targets which is used after to register watched links $it = new RecursiveArrayIterator($subPages); foreach ($it as $pageID => $element) { unset($pages[$pageID]); } } $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml); } } //add APPLICATION_ENFORCES_ACCESS_CONTROL php access checking if (APPLICATION_ENFORCES_ACCESS_CONTROL && $public) { $pagehtml = $this->_addSlashAroundPHPContent($pagehtml); $replace = array("<?php" => "';", "?>" => "echo '"); $pagehtml = str_replace(array_keys($replace), $replace, $pagehtml); $pagehtml = '<?php if ($cms_user->hasPageClearance(' . $page->getID() . ', CLEARANCE_PAGE_VIEW)) {' . "\n" . 'echo \'' . $pagehtml . '\';' . "\n" . '}' . "\n" . '?>'; } $rank++; } else { //needed to update link targets which is used after to register watched links unset($pages[$pageID]); } $levelhtml .= $pagehtml; } if ($level == 0 && ($this->_root === 'false' || !$this->_root)) { $html = $levelhtml; } else { if ($levelhtml && io::strpos($this->_subleveltemplate, "{{sublevel}}") !== false) { $replace = array("{{sublevel}}" => $levelhtml, "{{lvlClass}}" => "CMS_lvl" . ($level + 1)); $html = str_replace(array_keys($replace), $replace, $this->_subleveltemplate); } else { $html = $levelhtml; } } } return $html; }
/** * Get the page clearance root for a given page (this function must be as fast as possible * because it is often used with APPLICATION_ENFORCES_ACCESS_CONTROL) * * @param integer $pageId The DB ID of the page we test * @return The root page (CMS_page if $outputCMS_page is true, else pageID) * @access public * @static */ function getPageClearanceRoot($pageId, $outputCMS_page = true) { static $clearances; $hash = md5($this->getId() . '-' . serialize(func_get_args())); if (isset($clearances[$hash])) { return $clearances[$hash]; } if (!$this->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $clearances = $this->_pageClearances->getElements(); $nearestRoot = false; //get the full lineage of queried page $lineage = CMS_tree::getLineage(APPLICATION_ROOT_PAGE_ID, $pageId, false); if (!$lineage) { CMS_grandFather::raiseError('Lineage error for page : ' . $pageId); $clearances[$hash] = false; return $clearances[$hash]; } else { $lineage = array_reverse($lineage); foreach ($lineage as $ancestor) { foreach ($clearances as $clearance) { if ($ancestor == $clearance[0]) { $nearestRoot = $ancestor; break 2; } } } } } else { $nearestRoot = APPLICATION_ROOT_PAGE_ID; } if ($outputCMS_page) { $clearances[$hash] = CMS_tree::getPageByID($nearestRoot); } else { $clearances[$hash] = $nearestRoot; } return $clearances[$hash]; }
// | The license text is bundled with this package in the file | // | LICENSE-GPL, and is available through the world-wide-web at | // | http://www.gnu.org/copyleft/gpl.html. | // +----------------------------------------------------------------------+ // | Author: Sébastien Pauchet <*****@*****.**> | // +----------------------------------------------------------------------+ // // $Id: tree-lineage.php,v 1.3 2010/03/08 16:41:22 sebastien Exp $ /** * PHP page : Load tree window infos * Used accross an Ajax request render page tree in the tree window * * @package Automne * @subpackage admin * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; //load interface instance $view = CMS_view::getInstance(); //set default display mode for this page $view->setDisplayMode(CMS_view::SHOW_JSON); //This file is an admin file. Interface must be secure $view->setSecure(); $rootId = (int) sensitiveIO::request('root', 'sensitiveIO::isPositiveInteger', APPLICATION_ROOT_PAGE_ID); $nodeId = (int) sensitiveIO::request('node', 'sensitiveIO::isPositiveInteger', APPLICATION_ROOT_PAGE_ID); $lineage = CMS_tree::getLineage($rootId, $nodeId, false); if (!$lineage) { $lineage = array(); } $view->setContent($lineage); $view->show();
if ($heading) { $content .= '<div class="admin">' . urldecode($heading) . '</div><br />'; } //then display all Trees (queried Root and other user sections) $content .= '<table border="0" cellpadding="2" cellspacing="0">'; foreach ($getRoot as $aRootID) { if ($pages[$aRootID]) { $treeRoot = $pages[$aRootID]; } else { $treeRoot = CMS_tree::getPageByID($aRootID); $pages[$aRootID] = $treeRoot; } $pl = SensitiveIO::sanitizeHTMLString($pageLink); $pl = str_replace(chr(167) . chr(167), "?", $pl); $pl = str_replace(chr(167), "&", $pl); $lineage = is_array($lineages[$aRootID]) ? $lineages[$aRootID] : CMS_tree::getLineage($cms_root->getID(), $treeRoot->getID(), false); $grand_grand_father = CMS_tree::getAncestor($treeRoot, '3', false); $grand_father = CMS_tree::getAncestor($treeRoot, '2', false); $father = CMS_tree::getAncestor($treeRoot, '1', false); if ($grand_grand_father && $cms_user->hasPageClearance($grand_grand_father->getID(), CLEARANCE_PAGE_VIEW)) { $brothers = CMS_tree::getSiblings($grand_grand_father, '0'); } elseif ($grand_father && $cms_user->hasPageClearance($grand_father->getID(), CLEARANCE_PAGE_VIEW)) { $brothers = array($grand_father); } elseif ($father && $cms_user->hasPageClearance($father->getID(), CLEARANCE_PAGE_VIEW)) { $brothers = array($father); } else { $brothers = array($treeRoot); } foreach ($brothers as $aBrother) { if ($cms_user->hasPageClearance($aBrother->getID(), CLEARANCE_PAGE_VIEW)) { if (!in_array($aBrother->getID(), $displayed)) {
$disabledHttps = ''; if (!$editable || !$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $disabledHttps = 'disabled:true,'; } $httpsValue = $cms_page->isHTTPS() ? 'true' : 'false'; $httpsField = ",{\n\t\t{$disabledHttps}\n\t\tfieldLabel:\t\t'<span ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_HTTPS_INFO)}\" class=\"atm-help\">{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_HTTPS)}</span>',\n\t\tname:\t\t\t'https',\n\t\tinputValue:\t\t'1',\n\t\txtype:\t\t\t'checkbox',\n\t\tchecked:\t\t{$httpsValue},\n\t\tboxLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_HTTPS_DESC)}'\n\t}"; } /***************************************\ * PAGE PROPERTIES * \***************************************/ $pageId = $cms_page->getID(); $pageTitle = $cms_page->getTitle(); $pageLinkTitle = $cms_page->getLinkTitle(); $website = $cms_page->getWebsite(); $status = $cms_page->getStatus()->getHTML(false, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getID()); $lineage = CMS_tree::getLineage($website->getRoot(), $cms_page); //Page templates replacement $pageTemplate = $cms_page->getTemplate(); //hack if page has no valid template attached if (!is_a($pageTemplate, "CMS_pageTemplate")) { $pageTemplate = new CMS_pageTemplate(); } $pageTplId = CMS_pageTemplatesCatalog::getTemplateIDForCloneID($pageTemplate->getID()); $pageTplLabel = $pageTemplate->getLabel(); //print $print = $cms_page->getPrintStatus() ? $cms_language->getMessage(MESSAGE_PAGE_FIELD_YES) : $cms_language->getMessage(MESSAGE_PAGE_FIELD_NO); //page relations $linksFrom = CMS_linxesCatalog::searchRelations(CMS_linxesCatalog::PAGE_LINK_FROM, $cms_page->getID()); $linksTo = CMS_linxesCatalog::searchRelations(CMS_linxesCatalog::PAGE_LINK_TO, $cms_page->getID()); //page redirection $redirectlink = $cms_page->getRedirectLink();
} if ($rootLineage && $lastAncestor && !isset($siblings['ancestor' . $lastAncestor])) { //lineage has a break in pages rights so append page to siblings $pageRoot = CMS_tree::getPageByID($lastAncestor); if ($pageRoot->hasError()) { CMS_grandFather::raiseError('Node page ' . $lastAncestor . ' has error ...'); } else { $siblings['ancestor' . $lastAncestor] = $pageRoot; } } } } } } //get lineage for current page if any $currentPageLineage = $currentPage ? CMS_tree::getLineage($rootId, $currentPage, false) : array(); if (!is_array($currentPageLineage)) { $currentPageLineage = array(); } $nodes = array(); foreach ($siblings as $sibling) { if ($cms_user->hasPageClearance($sibling->getID(), $editable ? CLEARANCE_PAGE_EDIT : CLEARANCE_PAGE_VIEW)) { //property display if ($pageProperty) { $property = ''; switch ($pageProperty) { case "last_creation_date": $date = $sibling->getLastFileCreationDate(); if (is_a($date, "CMS_date")) { $date->setFormat($cms_language->getDateFormat()); $property = '(' . $date->getLocalizedDate() . ')';
$view->setDisplayMode(CMS_view::SHOW_JSON); //This file is an admin file. Interface must be secure $view->setSecure(); $query = sensitiveIO::request('query', '', ''); $start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0); $limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', 10); if (!$query || io::strlen($query) < 3) { CMS_grandFather::raiseError('Missing query or query is too short : ' . $query); $view->show(); } //lauch search $results = CMS_search::getSearch($query, $cms_user, false, false); //pr($results); $pages = array(); $count = 0; if (isset($results['results']) && is_array($results['results'])) { foreach ($results['results'] as $result) { if ($count >= $start && sizeof($pages) < $limit) { $page = CMS_tree::getPageById($result); if ($page && !$page->hasError()) { $pages[] = array('pageId' => $page->getID(), 'title' => $page->getTitle() . ' (' . $page->getID() . ')', 'status' => $page->getStatus()->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $page->getID()), 'lineage' => CMS_tree::getLineage(APPLICATION_ROOT_PAGE_ID, $page->getID(), false)); } else { $results['nbresult']--; } } $count++; } } $return = array('pages' => $pages, 'totalCount' => $results['nbresult']); $view->setContent($return); $view->show();
/** * Get the tree string needed by the text edition applet * format is : * pageID/roottitle/subroottitle/pagetitle:::[SAME AS BEFORE...] * where ::: is the separator passed as argument * Static function. * Recursive function * * @param string $separator The pages separator. * @return string the tree string * @access public */ static function getTreeString(&$user, $pageID, $separator, &$treeString) { static $treeStringInfos; $root = CMS_tree::getRoot(); $lineage = CMS_tree::getLineage($root->getID(), $pageID, false); $treeString .= $pageID; //add ancestors if (is_array($lineage) && $lineage) { foreach ($lineage as $ancestor) { //to reduce the total time of the function (really long on big websites). if (!$treeStringInfos[$ancestor]) { $ancestor = CMS_tree::getPageByID($ancestor); $ancestorTitle = $treeStringInfos[$ancestor->getID()] = $ancestor->getTitle(); } else { $ancestorTitle = $treeStringInfos[$ancestor]; } //test the presence of the separator in the sibling title if (io::strpos($ancestorTitle, $separator) !== false) { CMS_grandFather::raiseError("Page has the separator in its title (transformed) : " . $ancestorTitle); $title = str_replace($separator, "[SEPARATOR]", $ancestorTitle); } else { $title = $ancestorTitle; } $treeString .= "/" . addslashes($title); } } $treeString .= $separator; //get siblings and recursively show them $sibs = CMS_tree::getSiblings($pageID, false, false); if (!$sibs) { return $treeString; } foreach ($sibs as $sib) { CMS_tree::getTreeString($user, $sib, $separator, $treeString); } }