public function setPage($pageId)
 {
     if (!CMS_tree::getPageByID($pageId)) {
         return array('error' => true, 'message' => 'Ce numéro ne correspond pas à une page valide');
     }
     $this->setValue('page', $pageId);
     return array('error' => false);
 }
        $content .= '
			</ul>
			<input type="hidden" id="type-' . $hash . '" value="' . ($isUser ? 'user' : 'group') . '" />
			<input type="hidden" id="catIds-' . $hash . '" value="' . implode(',', $items_ids) . '" />
			<input type="hidden" id="profile-' . $hash . '" value="' . ($isUser ? $userId : $groupId) . '" />
			<input type="hidden" id="module-' . $hash . '" value="' . $moduleCodename . '" />
		</div>';
    }
} else {
    //get siblings
    if ($moduleCodename != MOD_STANDARD_CODENAME) {
        $item = CMS_moduleCategories_catalog::getByID($item);
        $attrs = array("module" => $moduleCodename, "language" => $cms_language, "level" => $item->getID(), "root" => false, "attrs" => false, "cms_user" => &$cms_user);
        $siblings = CMS_module::getModuleCategories($attrs);
    } else {
        $item = CMS_tree::getPageByID($item);
        $siblings = CMS_tree::getSiblings($item);
    }
    $clearances = array_reverse($modules_clearances, true);
    // Current item clearance
    $i_current_clearance = false;
    foreach ($clearances as $clearance) {
        if ($i_current_clearance === false) {
            if ($moduleCodename != MOD_STANDARD_CODENAME) {
                if ($profile->hasModuleCategoryClearance($item->getID(), $clearance, $moduleCodename)) {
                    $i_current_clearance = $clearance;
                }
            } else {
                if ($profile->hasPageClearance($item->getID(), $clearance)) {
                    $i_current_clearance = $clearance;
                }
Example #3
0
 /**
  * Gets the internal link (a page or false if no link)
  *
  * @return CMS_page
  * @access public
  */
 function getInternalLinkPage()
 {
     if (io::isPositiveInteger($this->_internalLink)) {
         return CMS_tree::getPageByID($this->_internalLink);
     } else {
         return false;
     }
 }
 protected function checkTagValues(&$tag, $requirements)
 {
     if (!is_array($requirements)) {
         $this->raiseError('Tag requirements must be an array');
         return false;
     }
     foreach ($requirements as $name => $requirementType) {
         //check parameter existence
         if ($requirementType['mandatory'] && !isset($tag['attributes'][$name])) {
             if ($this->_mode == self::CHECK_PARSING_MODE) {
                 $this->_parsingError .= "\n" . 'Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute';
                 return false;
             } else {
                 $this->raiseError('Malformed ' . $tag['nodename'] . ' tag : missing \'' . $name . '\' attribute');
                 return false;
             }
         } elseif (isset($tag['attributes'][$name])) {
             //if any, check value requirement
             $message = false;
             switch ($requirementType['value']) {
                 case 'alphanum':
                     if ($tag['attributes'][$name] != sensitiveIO::sanitizeAsciiString($tag['attributes'][$name], '', '_')) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be composed with alphanumeric caracters (0-9a-z_) : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'language':
                     if (isset($this->_parameters['module'])) {
                         $languages = CMS_languagesCatalog::getAllLanguages($this->_parameters['module']);
                     } else {
                         $languages = CMS_languagesCatalog::getAllLanguages();
                     }
                     if (!isset($languages[$tag['attributes'][$name]])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must only be a valid language code : ' . $tag['attributes'][$name];
                     }
                     break;
                 case 'object':
                     if (!sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], 9, -3))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object';
                     }
                     break;
                 case 'field':
                     if (strrpos($tag['attributes'][$name], 'fields') === false || !sensitiveIO::isPositiveInteger(io::substr($tag['attributes'][$name], strrpos($tag['attributes'][$name], 'fields') + 9, -2))) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute does not represent a valid object field';
                     }
                     break;
                 case 'page':
                     if (!io::isPositiveInteger($tag['attributes'][$name])) {
                         // Assuming the structure {websitecodename:pagecodename}
                         $page = trim($tag['attributes'][$name], "{}");
                         if (strpos($page, ":") !== false) {
                             list($websiteCodename, $pageCodename) = explode(':', $page);
                             $website = CMS_websitesCatalog::getByCodename($websiteCodename);
                             if (!$website) {
                                 $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow Website codename : ' . $websiteCodename . '';
                             } else {
                                 $pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
                                 if (!$pageID) {
                                     $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow page codename ' . $pageCodename . ' in website : ' . $websiteCodename . '';
                                 }
                             }
                         } else {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must be an integer or use the format websitecodename:pagecodename';
                         }
                     } else {
                         if (!CMS_tree::getPageByID($tag['attributes'][$name])) {
                             $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute : unknow pageID : ' . $tag['attributes'][$name];
                         }
                     }
                     break;
                 default:
                     //check
                     if (!preg_match('#^' . $requirementType['value'] . '$#i', $tag['attributes'][$name])) {
                         $message = 'Malformed ' . $tag['nodename'] . ' tag : \'' . $name . '\' attribute must match expression \'' . $requirementType['value'] . '\' : ' . $tag['attributes'][$name];
                     }
                     break;
             }
             if ($message) {
                 if ($this->_mode == self::CHECK_PARSING_MODE) {
                     $this->_parsingError .= "\n<br />" . $message;
                     return false;
                 } else {
                     $this->raiseError($message);
                     return false;
                 }
             }
         }
     }
     return true;
 }
Example #5
0
 /**
  * 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;
 }
 }
 $pages = array_unique($pages);
 sort($pages);
 if (sizeof($pages)) {
     $validPages = CMS_tree::pagesExistsInUserSpace($pages);
     if (sizeof($validPages)) {
         if (sizeof($validPages) > 3) {
             //submit pages to regenerator
             CMS_tree::submitToRegenerator($validPages, true);
             $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE) . ' : ' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_SUBMITED, array(sizeof($validPages)));
         } else {
             //regenerate pages
             @set_time_limit(1000);
             $regenok = $regenerror = 0;
             foreach ($validPages as $pageID) {
                 $pg = CMS_tree::getPageByID($pageID);
                 if (is_a($pg, 'CMS_page') && !$pg->hasError()) {
                     if ($pg->regenerate(true)) {
                         $regenok++;
                     } else {
                         $regenerror++;
                     }
                 }
             }
             if ($regenok) {
                 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE) . ' : ' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATED, array($regenok));
             }
             if ($regenerror) {
                 $cms_message .= $cms_message ? '<br />' . $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror)) : $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGENERATION_ERROR, array($regenerror));
             }
         }
Example #7
0
 /**
  * Computes the target of the tag.
  *
  * @param CMS_page $page The page where the linx tag is.
  * @param string $publicTree Is the calculus made in the public or edited tree ?
  * @return CMS_page The target page, of false if no target.
  * @access public
  */
 function getTarget(&$page, $publicTree)
 {
     $pg = false;
     switch ($this->_type) {
         case "node":
             $pg = CMS_tree::getPageByID($this->_value);
             if ($pg && !$pg->hasError()) {
                 return $pg;
             } else {
                 return false;
             }
             break;
         case "codename":
             if ($this->_website) {
                 $website = CMS_websitesCatalog::getByCodename($this->_website);
                 if ($website) {
                     $pg = CMS_tree::getPageByCodename($this->_value, $website, $publicTree, true);
                 }
             } else {
                 if ($this->_crosswebsite) {
                     return CMS_tree::getPagesByCodename($this->_value, $publicTree, true);
                 } else {
                     $pg = CMS_tree::getPageByCodename($this->_value, $page->getWebsite(), $publicTree, true);
                 }
             }
             if ($pg && !$pg->hasError()) {
                 return $pg;
             } else {
                 return false;
             }
             break;
         case "relative":
             switch ($this->_value) {
                 case "root":
                     if ($this->_website) {
                         $website = CMS_websitesCatalog::getByCodename($this->_website);
                         if ($website) {
                             $pg = $website->getRoot();
                         }
                     } else {
                         $offset = abs($this->_relativeOffset) * -1;
                         $pg = CMS_tree::getAncestor($page, $offset, !$this->_crosswebsite, false);
                         //here we do not want to use public tree because, in public tree, some page may be unpublished or in this case, it break the lineage and root page cannot be found
                     }
                     break;
                 case "father":
                     $offset = abs($this->_relativeOffset);
                     $pg = CMS_tree::getAncestor($page, $offset, !$this->_crosswebsite, $publicTree);
                     break;
                 case "self":
                     $pg = $page;
                     break;
                 case "brother":
                     $pg = CMS_tree::getBrother($page, $this->_relativeOffset, $publicTree);
                     break;
             }
             if ($this->_website && is_a($pg, 'CMS_page') && !$pg->hasError()) {
                 if ($pg->getCodename()) {
                     $website = CMS_websitesCatalog::getByCodename($this->_website);
                     $pg = $website ? CMS_tree::getPageByCodename($pg->getCodename(), $website, $publicTree, true) : false;
                 } else {
                     $pg = false;
                 }
             }
             if (is_a($pg, 'CMS_page') && !$pg->hasError()) {
                 return $pg;
             } else {
                 return false;
             }
             break;
     }
 }
Example #8
0
     header("Location: websites.php?cms_message_id=" . MESSAGE_FORM_ERROR_MANDATORY_FIELDS . "&" . session_name() . "=" . session_id());
     exit;
 } else {
     $website->setURL($_POST["url"]);
     $website->setAltDomains($_POST["altdomains"]);
     if ($website->getID()) {
         $page = CMS_tree::getPageByID($_POST["root"]);
         $website_root = $website->getRoot();
         if ($page->getID() != $website_root->getID()) {
             $website->setRoot($page);
         }
     } else {
         if (!$website->setCodename(io::sanitizeAsciiString($_POST["codename"]))) {
             $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ERROR_CODENAME);
         }
         $page = CMS_tree::getPageByID($_POST["root"]);
         $website->setRoot($page);
     }
     //set meta values
     $website->setLabel($_POST["label"]);
     $website->set404($_POST["page404"]);
     $website->set403($_POST["page403"]);
     $website->setRedirectAltDomain($_POST["altredir"]);
     $website->setMeta('description', $_POST['description']);
     $website->setMeta('keywords', $_POST['keywords']);
     $website->setMeta('category', $_POST['category']);
     $website->setMeta('robots', $_POST['robots']);
     $website->setMeta('author', $_POST['author']);
     $website->setMeta('replyto', $_POST['replyto']);
     $website->setMeta('copyright', $_POST['copyright']);
     $website->setMeta('language', $_POST['language']);
Example #9
0
 /**
  * Return pages IDs coresponding of a given row ID
  *
  * @param integer rowID : the row to get pagesIDs
  * @param boolean returnObjects : to return pages objects or pages IDs
  * @param boolean public : targets edited or public clientspaces
  * @return array : pages IDs or pages objects
  * @access public
  */
 static function getPagesByRow($rowID, $returnObjects = false, $public = false)
 {
     $return = array();
     if (!SensitiveIO::isPositiveInteger($rowID)) {
         CMS_grandFather::raiseError('rowID must be a positive integer');
         return $return;
     }
     $clientSpacesTable = $public ? 'mod_standard_clientSpaces_public' : 'mod_standard_clientSpaces_edited';
     $sql = "\n\t\t\tselect\n\t\t\t\tdistinct id_pag\n\t\t\tfrom\n\t\t\t\tpages,\n\t\t\t\t" . $clientSpacesTable . "\n\t\t\twhere\n\t\t\t\ttype_cs = '" . $rowID . "'\n\t\t\t\tand template_cs = template_pag\n\t\t\torder by\n\t\t\t\tid_pag\n\t\t";
     $q = new CMS_query($sql);
     if ($q->getNumRows()) {
         while ($id = $q->getValue('id_pag')) {
             if ($returnObjects) {
                 if ($page = CMS_tree::getPageByID($id)) {
                     $return[$id] = $page;
                 }
             } else {
                 $return[$id] = $id;
             }
         }
     }
     return $return;
 }
        if ($description != $pageTemplate->getDescription()) {
            $description = '<span ext:qtip="' . io::htmlspecialchars(strip_tags($pageTemplate->getDescription())) . '">' . io::htmlspecialchars($description) . '</span>';
        } else {
            $description = io::htmlspecialchars($description);
        }
        $description = $description ? $description . '<br />' : '';
        array_unshift($templates, array('id' => $pageTplId, 'label' => $pageTemplate->getLabel(), 'image' => $src, 'groups' => implode(', ', $pageTemplate->getGroups()), 'compatible' => true, 'description' => '<div' . (!$pageTemplate->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . (PATH_TEMPLATES_IMAGES_WR . '/' . ($pageTemplate->getImage() ? $pageTemplate->getImage() : 'nopicto.gif')) . '" style="float:left;margin-right:3px;max-width:80px;" />' . '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_MATCHING_TEMPLATE) . '</strong><br />' . $description . $cms_language->getMessage(MESSAGE_PAGE_GROUPS) . ' : <strong>' . implode(', ', $pageTemplate->getGroups()) . '</strong><br />' . '<br class="x-form-clear" />' . '</div>'));
    }
    $templatesDatas = array();
    $templatesDatas = array('results' => $templates);
} else {
    if (!$items) {
        //filter by page if needed
        $pageTplIds = array();
        if ($pageId) {
            $page = CMS_tree::getPageByID($pageId);
            if (is_object($page)) {
                $pageTemplate = $page->getTemplate();
                if (is_object($pageTemplate)) {
                    $pageTplIds = array(CMS_pageTemplatesCatalog::getTemplateIDForCloneID($pageTemplate->getID()));
                }
            }
        }
        if (io::isPositiveInteger($keyword)) {
            $pageTplIds[] = $keyword;
            $keyword = '';
        }
    } else {
        $pageTplIds = $items;
    }
    $templatesDatas = array();
 public static function getObjectName()
 {
     $page = CMS_tree::getPageByID(CURRENT_PAGE);
     $oembedDefinition = CMS_polymod_oembed_definition_catalog::getByCodename($page->getCodename());
     $parameterName = $oembedDefinition->getParameter();
     if (io::get($parameterName) && ($embededObject = CMS_poly_object_catalog::getObjectByID(io::get($parameterName), false, true))) {
         return $embededObject->getLabel();
     }
     return '';
 }
Example #12
0
     $q = new CMS_query($sql);
     //change default user language
     if ($install_language == 'en') {
         $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tprofilesUsers\n\t\t\t\t\tset\n\t\t\t\t\t\tlanguage_pru = 'en'\n\t\t\t\t\twhere\n\t\t\t\t\t\tlogin_pru = 'root'\n\t\t\t\t";
     } else {
         $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tprofilesUsers\n\t\t\t\t\tset\n\t\t\t\t\t\tlanguage_pru = 'fr'\n\t\t\t\t\twhere\n\t\t\t\t\t\tlogin_pru = 'root'\n\t\t\t\t";
     }
     $q = new CMS_query($sql);
     //CHMOD index.php and config.php with new values
     @chmod(dirname(__FILE__) . '/index.php', octdec(FILES_CHMOD));
     @chmod(dirname(__FILE__) . '/config.php', octdec(FILES_CHMOD));
     //deploy htaccess files
     $automnePatch = new CMS_patch();
     $automnePatch->automneGeneralScript();
     //force regeneration of first page to avoid any error
     $rootPage = CMS_tree::getPageByID(1);
     if ($rootPage && is_object($rootPage) && !$rootPage->hasError()) {
         $rootPage->regenerate(true);
     }
 }
 //Check sessions creation
 $session = true;
 if (function_exists("session_start")) {
     @error_reporting(0);
     if (ini_get("session.save_path") && !@is_dir(ini_get("session.save_path"))) {
         @mkdir(ini_get("session.save_path"));
     }
     @error_reporting(E_ALL ^ E_NOTICE);
 } else {
     $session = false;
 }
Example #13
0
    $roots = $editable ? $cms_user->getEditablePageClearanceRoots() : $cms_user->getViewablePageClearanceRoots();
    foreach ($roots as $pageRootID) {
        if ($pageRootID != APPLICATION_ROOT_PAGE_ID) {
            //get lineage for this clearance root
            $rootLineage = CMS_tree::getLineage(APPLICATION_ROOT_PAGE_ID, $pageRootID, false);
            //go through lineage to check for a break in pages rights
            if (is_array($rootLineage)) {
                $ancestor = array_pop($rootLineage);
                $lastAncestor = '';
                while ($rootLineage && $cms_user->hasPageClearance($ancestor, $editable ? CLEARANCE_PAGE_EDIT : CLEARANCE_PAGE_VIEW)) {
                    $lastAncestor = $ancestor;
                    $ancestor = array_pop($rootLineage);
                }
                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();
}
 /**
  * Get all templates replacement for a given template
  *
  * @param CMS_pageTemplate $tplFrom : the template to get replacements
  * @param CMS_profile_user $cms_user : user to get template replacements (to check rights)
  * @param integer $pageId : user to get template replacements (to check websites)
  * @return array : templates replacements array('match' => array(CMS_pageTemplate), 'nomatch' => array(CMS_pageTemplate));
  * @access public
  */
 static function getTemplatesReplacement($tplFrom, $user, $pageId = false)
 {
     if (!is_a($tplFrom, "CMS_pageTemplate")) {
         CMS_grandFather::raiseError('Template must be a valid CMS_pageTemplate object');
         return array('match' => array(), 'nomatch' => array());
     }
     //get website id if page id is provided
     $websiteId = '';
     if (sensitiveIO::isPositiveInteger($pageId)) {
         $page = CMS_tree::getPageByID($pageId);
         if ($page) {
             $website = $page->getWebsite();
             if ($website) {
                 $websiteId = $website->getID();
             }
         }
     }
     //All templates avalaibles for this user and page website
     $templatesReplacements = CMS_pageTemplatesCatalog::getAll(false, '', array(), $websiteId, array(), $user);
     $matchTpl = array();
     $notMatchTpl = array();
     //modules called in tplFrom
     $tplFromModules = $tplFrom->getModules();
     //clientSpaces in tplFrom
     $csFrom = $tplFrom->getClientSpacesTags();
     $oldClientSpaces = array();
     foreach ($csFrom as $tag) {
         $id = $tag->getAttribute("id") ? $tag->getAttribute("id") : 'NO ID';
         $oldClientSpaces[$tag->getAttribute("module")][] = $id;
     }
     //then check each templates
     foreach ($templatesReplacements as $tplTo) {
         $match = true;
         //remove templates wich not use same modules
         $tplToModules = $tplTo->getModules();
         if ($tplToModules != $tplFromModules) {
             $match = false;
         }
         //check for template number (must be greater or egual)
         if ($match) {
             $csTo = $tplTo->getClientSpacesTags();
             if (sizeof($csTo) < sizeof($csFrom)) {
                 $match = false;
             }
         }
         //search all tpl from in tpl to
         if ($match) {
             $newClientSpaces = array();
             foreach ($csTo as $tag) {
                 $id = $tag->getAttribute("id") ? $tag->getAttribute("id") : 'NO ID';
                 $newClientSpaces[$tag->getAttribute("module")][] = $id;
             }
             foreach ($oldClientSpaces as $module => $moduleCs) {
                 foreach ($moduleCs as $csId) {
                     //search id in from tpl
                     if (!isset($newClientSpaces[$module]) || !in_array($csId, $newClientSpaces[$module])) {
                         $match = false;
                     }
                 }
             }
         }
         if ($match) {
             //here templates match so add it to the array
             $matchTpl[] = $tplTo;
         } else {
             $notMatchTpl[] = $tplTo;
         }
     }
     //sort tables by template labels
     $sortfunc = create_function('$a,$b', 'return strnatcasecmp($a->getLabel(), $b->getLabel());');
     if ($sortfunc) {
         if ($matchTpl) {
             usort($matchTpl, $sortfunc);
         }
         if ($notMatchTpl) {
             usort($notMatchTpl, $sortfunc);
         }
     }
     //then return array of templates
     return array('match' => $matchTpl, 'nomatch' => $notMatchTpl);
 }
Example #15
0
 /**
  * Displays Admin frameset
  *
  * @return void
  * @access public
  */
 function showFrames()
 {
     if (!$this->_context->getSessionVar('largeur')) {
         $this->_context->setSessionVar('largeur', '200');
     }
     if (!$this->_context->getSessionVar('hauteurArbo') && $this->_context->getSessionVar('hauteurArbo') != '0') {
         $this->_context->setSessionVar('hauteurArbo', '*');
     }
     if (!$this->_context->getSessionVar('treeHref') && $this->_context->getSessionVar('hauteurArbo') != '0') {
         $user = $this->_context->getUser();
         //THE USER SECTIONS, Check if user has module administration, else hide Modules Frame
         $sections_roots = array();
         $sections_roots = $user->getEditablePageClearanceRoots();
         if (is_array($sections_roots) && $sections_roots) {
             $this->_context->setSessionVar('sectionsRoots', $sections_roots);
             $root = '9999999';
             $count = '0';
             foreach ($sections_roots as $rootID) {
                 $pg = CMS_tree::getPageByID($rootID);
                 if ($pg && !$pg->hasError()) {
                     $root = $rootID < $root ? $rootID : $root;
                 }
             }
             //build tree link
             $treeHref = PATH_ADMIN_SPECIAL_TREE_WR;
             $treeHref .= '?root=' . $root;
             $treeHref .= '&frame=1';
             $treeHref .= '&encodedPageLink=' . base64_encode(PATH_ADMIN_SPECIAL_PAGE_SUMMARY_WR . chr(167) . chr(167) . 'page=%s');
             $this->_context->setSessionVar('treeHref', $treeHref);
         } else {
             $treeHref = '';
             $this->_context->setSessionVar('hauteurArbo', '0');
         }
     }
     if (!$this->_context->getSessionVar('hauteurModules') && $this->_context->getSessionVar('hauteurModules') != '0') {
         $this->_context->setSessionVar('hauteurModules', '200');
         $user = $this->_context->getUser();
         //THE MODULES ADMINISTRATIONS, Check if user has module administration, else hide Modules Frame
         $modules = CMS_modulesCatalog::getALL();
         $modules_good = array();
         foreach ($modules as $module) {
             if ($module->getCodename() != MOD_STANDARD_CODENAME && $user->hasModuleClearance($module->getCodename(), CLEARANCE_MODULE_EDIT)) {
                 $modules_good[] = $module;
             }
         }
         if (!$modules_good) {
             $this->_context->setSessionVar('hauteurModules', '0');
         }
     }
     if ($this->_context->getSessionVar('hauteurArbo') == '0' && $this->_context->getSessionVar('hauteurModules') == '0') {
         //current user have not any admin rights so logout !
         header("Location: " . PATH_ADMIN_SPECIAL_LOGIN_WR . "?cms_message_id=65&cms_action=logout&" . session_name() . "=" . session_id());
         exit;
     }
     $main = $this->_mainFrame ? $this->_mainFrame : PATH_ADMIN_SPECIAL_ENTRY_WR;
     if (VIEW_SQL && STATS_DEBUG && SYSTEM_DEBUG) {
         $this->_context->setSessionVar('hauteurFrameChecker', '50');
     } else {
         $this->_context->setSessionVar('hauteurFrameChecker', '0');
     }
     $frameset = "\n\t\t\t<SCRIPT type=text/javascript>\n\t\t\t<!--\n\t\t\t    document.writeln('<frameset cols=\"" . $this->_context->getSessionVar('largeur') . ",*\" rows=\"*\" border=\"1\" frameborder=\"1\" framespacing=\"0\">');\n\t\t\t    document.writeln('    <frameset rows=\"" . $this->_context->getSessionVar('hauteurArbo') . ", " . $this->_context->getSessionVar('hauteurModules') . "," . $this->_context->getSessionVar('hauteurFrameChecker') . "\" framespacing=\"0\" frameborder=\"0\" border=\"0\">');\n\t\t\t    document.writeln('        <frame src=\"" . $this->_context->getSessionVar('treeHref') . "\" name=\"arbo\" border=\"1\" frameborder=\"1\" />');\n\t\t\t    document.writeln('        <frame src=\"modules.php\" name=\"modules\" border=\"1\" frameborder=\"1\" />');\n\t\t\t\tdocument.writeln('        <frame src=\"frameChecker.php\" name=\"frameChecker\" frameborder=\"0\" scrolling=\"no\" />');\n\t\t\t    document.writeln('    </frameset>');\n\t\t\t\tdocument.writeln('    <frameset rows=\"72, *\" framespacing=\"0\" frameborder=\"0\" border=\"0\">');\n\t\t\t    document.writeln('        <frame src=\"menu.php\" name=\"menu\" frameborder=\"0\" scrolling=\"no\" />');\n\t\t\t    document.writeln('        <frame src=\"" . $main . "\" name=\"main\" border=\"0\" frameborder=\"0\" />');\n\t\t\t    document.writeln('    </frameset>');\n\t\t\t    document.writeln('    <noframes>');\n\t\t\t    document.writeln('        <body bgcolor=\"#FFFFFF\">');\n\t\t\t    document.writeln('            <p>L\\'utilisation d\\'Automne nécéssite un navigateur <b>supportant les \"frames\"</b>.</p>');\n\t\t\t    document.writeln('            <p>The use of Automne requires a navigator <b>supporting frames</b>.</p>');\n\t\t\t    document.writeln('        </body>');\n\t\t\t    document.writeln('    </noframes>');\n\t\t\t    document.writeln('</frameset>');\n\t\t\t//-->\n\t\t\t</SCRIPT>";
     return $frameset;
 }
Example #16
0
 /**
  * Returns The URL of the current website, according to parameter or constant CURRENT_PAGE or the main domain URL if constant does not exists
  * Static function.
  *
  * @param mixed $currentPage : The current page id or CMS_page
  * @return string The current website URL
  * @access public
  */
 static function getCurrentDomain($currentPage = '')
 {
     static $domain;
     if (!isset($domain)) {
         $domain = '';
         if (io::isPositiveInteger($currentPage)) {
             $page = CMS_tree::getPageByID($currentPage);
         } elseif (is_object($currentPage)) {
             $page = $currentPage;
         } elseif (defined('CURRENT_PAGE') && io::isPositiveInteger(CURRENT_PAGE)) {
             $page = CMS_tree::getPageByID(CURRENT_PAGE);
         }
         if (isset($page) && is_object($page) && !$page->hasError()) {
             $domain = $page->getWebsite()->getURL();
             //check for HTTPS
             if ($page->isHTTPS() || defined('PAGE_SSL_MODE') && PAGE_SSL_MODE) {
                 $domain = str_ireplace('http://', 'https://', $domain);
             }
         }
         if (!$domain) {
             $domain = CMS_websitesCatalog::getMainURL();
         }
     }
     return $domain;
 }
Example #17
0
 /**
  * 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];
 }
Example #18
0
$heading = checkNotFalse($heading) ? $heading : '';
$hideMenu = sensitiveIO::request('hideMenu', 'checkNotFalse') ? true : false;
$window = sensitiveIO::request('window', '', true);
//$window = (sensitiveIO::request('window', 'checkNotFalse', 'true')) ? 'true' : 'false';
$winId = sensitiveIO::request('winId', '', 'treeWindow');
$el = sensitiveIO::request('el');
$currentPage = sensitiveIO::request('currentPage', 'sensitiveIO::isPositiveInteger');
$enableDD = sensitiveIO::request('enableDD', 'checkNotFalse') ? 'true' : 'false';
//THE USER SECTIONS, Check if user has module administration, else hide Modules Frame
$hasSectionsRoots = $editable ? $cms_user->hasEditablePages() : $cms_user->hasViewvablePages();
if (!$hasSectionsRoots) {
    CMS_grandFather::raiseError('No sections root found ...');
    $view->show();
}
//load root page
$root = CMS_tree::getPageByID($rootId);
if (!is_object($root) || $root->hasError()) {
    CMS_grandFather::raiseError('Root page has error ...');
    $view->show();
}
//pageProperty : must be inside the page_properties array
$pageProperties = array("last_creation_date", "template");
if ($pageProperty && !SensitiveIO::isInSet($pageProperty, $pageProperties)) {
    CMS_grandFather::raiseError('Unknown page property : ' . $pageProperty);
    $view->show();
}
//set onclick property
if ($enableDD === 'false') {
    if ($el) {
        //replace value of element by clicked page Id
        $onClick = sensitiveIO::sanitizeJSString('
Example #19
0
 public static function getNewsletterContent($pageId)
 {
     $page = CMS_tree::getPageByID($pageId);
     if ($page->hasError()) {
         return;
     }
     $website = $page->getWebsite();
     $websiteUrl = $website->getURL();
     $language = CMS_languagesCatalog::getByCode($page->getLanguage());
     $content = $page->getContent($language, PAGE_VISUALMODE_HTML_PUBLIC);
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $page);
     $modulesTreatment->setDefinition($content);
     $content = $modulesTreatment->treatContent(true);
     //eval all php code in page
     $php_evalued_content = io::evalPHPCode($content);
     //change all relative URL in page
     $parsed_content = self::prepareHTML($php_evalued_content, $websiteUrl);
     return $parsed_content;
 }
Example #20
0
define("MESSAGE_PAGE_STANDARD_MODULE_LABEL", 213);
define("MESSAGE_PAGE_MODULES", 264);
define("MESSAGE_PAGE_MODULES_PARAMETERS", 807);
define("MESSAGE_PAGE_ARCHIVES", 859);
define("MESSAGE_PAGE_ERROR_PAGE_NEVER_VALIDATED", 867);
define("MESSAGE_PAGE_ERROR_MOVE_ROOT", 868);
define("MESSAGE_PAGE_ERROR_FATHER_IS_DESCENDANT", 869);
define("MESSAGE_PAGE_ERROR_FATHER_SIBLINGS_NEVER_VALIDATED", 870);
define("MESSAGE_PAGE_TASK_PENDING", 1090);
define("MESSAGE_PAGE_NO_VALIDATIONS_PENDING", 1113);
define("MESSAGE_PAGE_ERROR_FATHER_IS_IDENTICAL", 1319);
//Action management
if (isset($_GET["cms_action"]) && $_GET["cms_action"] == "displace") {
    if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES)) {
        $cms_page = CMS_session::getPage();
        $father = CMS_tree::getPageByID($_GET["new_father"]);
        //augment the execution time, because things here can be quite lengthy
        @set_time_limit(9000);
        //ignore user abort to avoid interuption of process
        @ignore_user_abort(true);
        if ($error = CMS_tree::movePage($cms_page, $father)) {
            switch ($error) {
                case "PAGE_NEVER_VALIDATED":
                    $errmsg = $cms_language->getMessage(MESSAGE_PAGE_ERROR_PAGE_NEVER_VALIDATED);
                    break;
                case "MOVE_ROOT":
                    $errmsg = $cms_language->getMessage(MESSAGE_PAGE_ERROR_MOVE_ROOT);
                    break;
                case "FATHER_IS_DESCENDANT":
                    $errmsg = $cms_language->getMessage(MESSAGE_PAGE_ERROR_FATHER_IS_DESCENDANT);
                    break;
Example #21
0
     if (isset($varAttributes['root'])) {
         if (!io::isPositiveInteger($varAttributes['root'])) {
             // Assuming the structure {websitecodename:pagecodename}
             $page = trim($varAttributes['root'], "{}");
             if (strpos($page, ":") !== false) {
                 list($websiteCodename, $pageCodename) = explode(':', $page);
                 $website = CMS_websitesCatalog::getByCodename($websiteCodename);
                 if ($website) {
                     $pageID = CMS_tree::getPageByCodename($pageCodename, $website, false, false);
                     if ($pageID) {
                         $item['root'] = $pageID;
                     }
                 }
             }
         } else {
             if (CMS_tree::getPageByID($tag['attributes'][$name])) {
                 $item['root'] = $varAttributes['root'];
             }
         }
     }
     break;
 default:
     if (strpos($varAttributes['vartype'], 'fields') !== false) {
         // Assume it's a polymod object field
         $fieldId = io::substr($varAttributes['vartype'], strrpos($varAttributes['vartype'], 'fields') + 9, -2);
         $objectId = CMS_poly_object_catalog::getObjectIDForField($fieldId);
         if (io::isPositiveInteger($objectId)) {
             $objectFields = CMS_poly_object_catalog::getFieldsDefinition($objectId);
             if (sensitiveIO::isPositiveInteger($fieldId)) {
                 //subobjects
                 $field = $objectFields[$fieldId];
Example #22
0
 $pageFromId = sensitiveIO::request('pageFrom', 'sensitiveIO::isPositiveInteger', false);
 $pageToId = sensitiveIO::request('pageTo', 'sensitiveIO::isPositiveInteger', false);
 //CHECKS user has duplication clearance
 if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_DUPLICATE_BRANCH)) {
     CMS_grandFather::raiseError('User has no rights to duplicate branch...');
     $cms_message = $cms_language->getMessage(MESSAGE_PAGE_ACTION_DUPLICATION_ERROR_NO_RIGHTS);
 } else {
     //augment the execution time, because things here can be quite lengthy
     @set_time_limit(9000);
     //ignore user abort to avoid interuption of process
     @ignore_user_abort(true);
     //Proceeds with tree duplication
     //First node page
     $pageFrom = CMS_tree::getPageByID($pageFromId);
     //First destination page
     $pageTo = CMS_tree::getPageByID($pageToId);
     $pageDuplicated = array();
     function duplicatePage($user, $page, $pageToAttachTo)
     {
         global $pageDuplicated, $duplicatedCodenames, $cms_user;
         if (is_a($page, "CMS_page") && is_a($pageToAttachTo, "CMS_page") && $page->getTemplate()) {
             //check codename duplication
             $removeCodename = false;
             if ($page->getCodename()) {
                 //if codename already exists in website destination, then we must remove it
                 if (CMS_tree::getPageByCodename($page->getCodename(), $pageToAttachTo->getWebsite(), false, false)) {
                     $removeCodename = true;
                 }
             }
             //Duplicate page template
             $tpl = $page->getTemplate();
Example #23
0
 /**
  * Get Page
  *
  * @return CMS_page The page currently registered, false if none
  * @access public
  */
 public static function getPage()
 {
     $sessionNS = new Zend_Session_Namespace('atm-page');
     if (isset($sessionNS->pageId) && io::isPositiveInteger($sessionNS->pageId)) {
         return CMS_tree::getPageByID($sessionNS->pageId);
     } else {
         return false;
     }
 }
Example #24
0
}
//sort all tree Root
//in lot of case this sorting is buggy, but I leave it in comment for the day I can see a case who is usefull...
//sort($getRoot);
//remove double
$getRoot = array_unique($getRoot);
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), "&amp;", $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);
Example #25
0
    /**
     * 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 .= '&amp;heading=' . $cms_language->getMessage(self::MESSAGE_PAGE_TREEH1);
                $href .= '&amp;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;
    }
Example #26
0
 /**
  * get object previzualisation URL if set
  *
  * @param boolean $addPrevizParameter : add the previz=previz parameter at end of address (default : true)
  * @return string : the object previzualisation URL or false if none set
  * @access public
  */
 function getPrevizPageURL($addPrevizParameter = true)
 {
     //get Object definition
     $objectDef = $this->getObjectDefinition();
     if (!$objectDef->getValue("previewURL")) {
         //no previz set
         return false;
     }
     $previzInfos = explode('||', $objectDef->getValue("previewURL"));
     if (!sensitiveIO::isPositiveInteger($previzInfos[0])) {
         //no valid previz page set
         return false;
     }
     $page = CMS_tree::getPageByID($previzInfos[0]);
     if (!$page || $page->hasError()) {
         //no valid previz page set
         return false;
     }
     $previewPageURL = $page->getURL(false, false, PATH_RELATIVETO_WEBROOT, false, $addPrevizParameter);
     if (!$previewPageURL) {
         //no valid previz page set
         return false;
     }
     //convert URL parameters
     $parameters['item'] =& $this;
     $parameters['public'] = $this->_public;
     $polymodParsing = new CMS_polymod_definition_parsing($previzInfos[1], false);
     $previewPageParams = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
     //overwrite website host with admin current host (to avoid session lost)
     if ($addPrevizParameter) {
         //check for website host
         $pageHost = @parse_url($previewPageURL, PHP_URL_HOST);
         $httpHost = @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST'];
         if ($pageHost && $_SERVER['HTTP_HOST'] && io::strtolower($httpHost) != io::strtolower($pageHost)) {
             //page host is not the same of current host so change it to avoid JS restriction
             $previewPageURL = str_replace($pageHost, $httpHost, $previewPageURL);
         }
         //check for website protocol
         $pageScheme = @parse_url($previewPageURL, PHP_URL_SCHEME);
         $currentScheme = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] && strtolower($_SERVER["HTTPS"]) != 'off' ? 'https' : 'http';
         if ($pageScheme && $currentScheme != io::strtolower($pageScheme)) {
             $previewPageURL = str_replace($pageScheme . '://', $currentScheme . '://', $panelURL);
         }
     }
     return $previewPageURL . '?' . $previewPageParams . ($addPrevizParameter ? '&atm-previz=previz' : '');
 }
Example #27
0
 /**
  * Get the pages based on this template or templates clones
  *
  * @param boolean $withClones : get also all pages based on the clones (default : false)
  * @return array(CMS_page) The pages
  * @access private
  */
 function getPages($withClones = false)
 {
     if (!$this->_id || !$this->_definitionFile) {
         return array();
     }
     if ($withClones) {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tpageTemplates\n\t\t\t\twhere\n\t\t\t\t\ttemplate_pag=id_pt\n\t\t\t\t\tand definitionFile_pt = '" . $this->_definitionFile . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages\n\t\t\t\twhere\n\t\t\t\t\ttemplate_pag='" . $this->_id . "'\n\t\t\t";
     }
     $q = new CMS_query($sql);
     $pages = array();
     while ($id = $q->getValue("id_pag")) {
         $pg = CMS_tree::getPageByID($id);
         if (!$pg->hasError()) {
             $pages[] = $pg;
         }
     }
     return $pages;
 }
Example #28
0
}
if (!isset($cms_page) || !$cms_page || !is_object($cms_page) || $cms_page->hasError() || $cms_page->getID() != APPLICATION_ROOT_PAGE_ID && !CMS_tree::hasAncestor($cms_page->getID())) {
    if ($pageUrl && !$isAutomne) {
        if ($pageUrl == PATH_REALROOT_WR . '/' && $httpHost != @parse_url(CMS_websitesCatalog::getMainURL(), PHP_URL_HOST)) {
            //Website domain is not properly set
            if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
                $jscontent = "\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\ttitle: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_DOMAIN) . "', \n\t\t\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_WEBSITE_CONFIG, array($httpHost, @parse_url(CMS_websitesCatalog::getMainURL(), PHP_URL_HOST))) . "',\n\t\t\t\t\t\tbuttons:\tExt.MessageBox.OK,\n\t\t\t\t\t\ticon: \t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\tfn: \t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\tvar window = new Automne.frameWindow({\n\t\t\t\t\t\t\t\t\t\t\tid:\t\t\t\t'websitesWindow',\n\t\t\t\t\t\t\t\t\t\t\tframeURL:\t\t'" . PATH_MAIN_WR . "/admin-v3/websites.php',\n\t\t\t\t\t\t\t\t\t\t\tallowFrameNav:\ttrue,\n\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t750,\n\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t580\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\twindow.show();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t";
            } else {
                $jscontent = "\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\ttitle: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_DOMAIN) . "', \n\t\t\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_INCORRECT_WEBSITE_CONFIG_ADMIN, array($httpHost, @parse_url(CMS_websitesCatalog::getMainURL(), PHP_URL_HOST))) . "',\n\t\t\t\t\t\tbuttons:\tExt.MessageBox.OK,\n\t\t\t\t\t\ticon: \t\tExt.MessageBox.ERROR\n\t\t\t\t\t});\n\t\t\t\t";
            }
        } else {
            $jscontent = "\n\t\t\t\tAutomne.message.popup({\n\t\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_FOLLOW_EXTERNAL_LINK) . "',\n\t\t\t\t\tbuttons:\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\ticon: \t\tExt.MessageBox.INFO,\n\t\t\t\t\tfn: \t\tfunction (button) {\n\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\twindow.open('{$pageUrl}');\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t";
        }
        $view->addJavascript($jscontent);
        if ($from) {
            $cms_page = CMS_tree::getPageByID($from);
            $pageId = $cms_page->getID();
        }
    } else {
        $jscontent = "\n\t\t\t//disable all tabs except search and tree\n\t\t\tAutomne.tabPanels.items.each(function(panel) {\n\t\t\t\tif (panel.id != 'search' && panel.id != 'tree') {\n\t\t\t\t\tpanel.disable();\n\t\t\t\t} else {\n\t\t\t\t\tpanel.enable();\n\t\t\t\t}\n\t\t\t});\n\t\t\tAutomne.message.popup({\n\t\t\t\ttitle: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_ERROR) . "', \n\t\t\t\tmsg: \t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_PAGE_NOT_VIEWVABLE, array($pageId)) . "',\n\t\t\t\tbuttons:\tExt.MessageBox.OK,\n\t\t\t\ticon: \t\tExt.MessageBox.ERROR\n\t\t\t});\n\t\t";
        $view->addJavascript($jscontent);
        CMS_grandFather::raiseError('Error on page : ' . $pageId);
        $view->show();
    }
}
if (!isset($cms_page) || !is_object($cms_page)) {
    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) {
//
// $Id: page-previsualization.php,v 1.5 2010/03/08 16:41:19 sebastien Exp $
/**
 * PHP page : page previsualization
 * Used to view the page edited data.
 *
 * @package Automne
 * @subpackage admin
 * @author Antoine Pouch <*****@*****.**> &
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
$currentPage = sensitiveIO::request('currentPage', 'sensitiveIO::isPositiveInteger', CMS_session::getPageID());
$draft = sensitiveIO::request('draft') ? true : false;
//unset request to avoid it to have interaction with page code
sensitiveIO::unsetRequest(array('draft', 'currentPage'));
//CHECKS
if (!SensitiveIO::isPositiveInteger($currentPage)) {
    die("Invalid page");
}
//view edited or edition mode ?
$cms_visual_mode = $draft ? PAGE_VISUALMODE_HTML_EDITION : PAGE_VISUALMODE_HTML_EDITED;
$cms_page = CMS_tree::getPageByID($currentPage);
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_EDIT)) {
    die('No rigths on page ...');
    exit;
}
//unset vars to avoid interraction with page
unset($currentPage);
unset($draft);
echo $cms_page->getContent($cms_language, $cms_visual_mode);
Example #30
0
 /**
  * Gets the internal link (a page or false if no link)
  *
  * @return CMS_page
  * @access public
  */
 function getInternalLinkPage()
 {
     if ($this->_internalLink) {
         return CMS_tree::getPageByID($this->_internalLink);
     } else {
         return false;
     }
 }