示例#1
0
 /**
  * Regenerate the page file, either from scratch or from the linx file.
  * If linx file doesn't exists, the file is regenerated from scratch (obviously).
  *
  * @param boolean $fromScratch If false, regenerate from the linx file, otherwise regenerate linx file first.
  * @return boolean true on success, false on failure
  * @access public
  */
 function regenerate($fromScratch = false)
 {
     //regenerate don't work on pages that are not public or which not have website
     if ($this->getPublication() != RESOURCE_PUBLICATION_PUBLIC || !$this->_checkWebsite()) {
         return true;
     }
     //need pageTemplate for regeneration
     $this->_checkTemplate();
     //get linx file path
     $linxFile = new CMS_file($this->getLinxFilePath());
     //should we regenerate the linx file ?
     if ($fromScratch || !$linxFile->exists()) {
         if (!$this->_template) {
             $this->raiseError('Can\'t find page template for page ' . $this->getID());
             return false;
         }
         if (!$this->writeLinxFile()) {
             return false;
         }
         //reload linx file
         $linxFile = new CMS_file($this->getLinxFilePath());
     }
     //unregister all linxes
     CMS_linxesCatalog::deleteLinxes($this);
     //instanciate modules treatments for page linx tags
     $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_HTML_PUBLIC, $this);
     $modulesTreatment->setDefinition($linxFile->getContent());
     if ($content = $modulesTreatment->treatContent(true)) {
         $pageHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getHTMLFilename();
         $pageFile = new CMS_file($pageHTMLPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         $pageFile->setContent($content);
         $pageFile->writeToPersistence();
         $this->_lastFileCreation->setNow();
         $this->writeToPersistence();
         //if the page is a website root, create the index page redirecting to this one
         if ($fromScratch && CMS_websitesCatalog::isWebsiteRoot($this->getID())) {
             CMS_websitesCatalog::writeRootRedirection();
         }
     } else {
         $this->raiseError('Malformed linx file');
         return false;
     }
     //write significant url page
     $pagePath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/" . $this->_getFilename();
     $redirectionFile = new CMS_file($pagePath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
     $redirectionFile->setContent($this->redirectionCode($pageHTMLPath));
     $redirectionFile->writeToPersistence(true, true);
     //write website index
     if (CMS_websitesCatalog::isWebsiteRoot($this->getID())) {
         $ws = $this->getWebsite();
         if ($ws && !$ws->isMain()) {
             $wsPath = $ws->getPagesPath(PATH_RELATIVETO_FILESYSTEM) . '/index.php';
             $redirectionFile = new CMS_file($wsPath, CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
             $redirectionFile->setContent($this->redirectionCode($pageHTMLPath));
             $redirectionFile->writeToPersistence(true, true);
         }
     }
     //write print page if any
     if (USE_PRINT_PAGES && $this->_template->getPrintingClientSpaces()) {
         //reload linx file
         $printLinxFile = new CMS_file($this->getLinxFilePath() . '.print', CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         if ($printLinxFile->exists()) {
             $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_LINXES_TAGS, PAGE_VISUALMODE_PRINT, $this);
             $modulesTreatment->setDefinition($printLinxFile->getContent());
             if ($content = $modulesTreatment->treatContent(true)) {
                 $printHTMLPath = $this->_getHTMLFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getHTMLFilename();
                 $printFile = new CMS_file($printHTMLPath);
                 $printFile->setContent($content);
                 $printFile->writeToPersistence();
             } else {
                 $this->raiseError('Malformed print linx file');
                 return false;
             }
             //write significant url print page
             $printPath = $this->_getFilePath(PATH_RELATIVETO_FILESYSTEM) . "/print-" . $this->_getFilename();
             $redirectionFile = new CMS_file($printPath);
             $redirectionFile->setContent($this->redirectionCode($printHTMLPath));
             $redirectionFile->writeToPersistence();
         } else {
             $this->raiseError('Malformed print linx file');
             return false;
         }
     }
     return true;
 }
示例#2
0
     //move page
     $father = CMS_tree::getAncestor($cms_page, 1);
     $draggable = is_object($father) && $cms_user->hasPageClearance($father->getID(), CLEARANCE_PAGE_EDIT) && (!$hasSiblings || $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) && $cms_page->getID() != APPLICATION_ROOT_PAGE_ID);
     if ($draggable) {
         $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVE_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVE_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-move',\n\t\t\t\t\t\t\t\t\t\thandler: function() {\n\t\t\t\t\t\t\t\t\t\t\t//create window element\n\t\t\t\t\t\t\t\t\t\t\tvar win = new Automne.Window({\n\t\t\t\t\t\t\t\t\t\t\t\tid:\t\t\t\t'pageMoveWindow',\n\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t" . $cms_page->getID() . ",\n\t\t\t\t\t\t\t\t\t\t\t\tautoLoad:\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t'tree.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\tparams:\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twinId:\t\t'pageMoveWindow',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:" . $cms_page->getID() . ",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tenableDD:\ttrue,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\theading:\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVE_PAGE_USING_ICONS) . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\ttitle:\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_MOVING_PAGE) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\tnocache:\ttrue,\n\t\t\t\t\t\t\t\t\t\t\t\t\tscope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\twin.show(this.getEl());\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));";
     }
 }
 //page copy
 $panelContent .= $pageCopy;
 if (!$cms_page->isProtected()) {
     //archiving
     if (!$hasSiblings) {
         $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_ARCHIVING_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_ARCHIVING_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-archiving',\n\t\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_ARCHIVING_PAGE_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'archive'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));";
     }
     //deletion
     if (!$hasSiblings && !CMS_websitesCatalog::isWebsiteRoot($cms_page->getID())) {
         $panelContent .= "\n\t\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETING_PAGE_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETING_PAGE) . "</span>',\n\t\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-deletion',\n\t\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_DELETING_PAGE_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'delete'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}));";
     }
 }
 //page editions cancelling
 $editions = $cms_page->getStatus()->getEditions();
 if ($cms_page->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED && $editions & RESOURCE_EDITION_CONTENT) {
     $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addSeparator();\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_INFO) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-editions-cancelling',\n\t\t\t\t\t\t\t\t\thandler: function(){\n\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJSMessage(MESSAGE_PAGE_UNDO_EDITING_CONFIRM) . "',\n\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\t\t\t\t\tanimEl: \t\t\tthis.getEl(),\n\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.setActiveTab('public');\n\t\t\t\t\t\t\t\t\t\t\t\t\tAutomne.server.call({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\turl:\t\t\t\t'page-controler.php',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tparams: \t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcurrentPage:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'cancel_editions'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tfcnCallback: \t\tfunction() {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t//then reload page infos\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttabs.getPageInfos({\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tpageId:\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnoreload:\ttrue\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcallBackScope:\t\tthis\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));";
 }
 if ($editions & RESOURCE_EDITION_CONTENT && $cms_user->hasValidationClearance(MOD_STANDARD_CODENAME)) {
     //validate
     $panelContent .= "\n\t\t\t\t\t\t\t\tmenu.addItem(new Ext.menu.Item({\n\t\t\t\t\t\t\t\t\ttext: '<span ext:qtip=\"" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION_MODIFICATIONS) . "\">" . $cms_language->getJSMessage(MESSAGE_PAGE_VALIDATION) . "</span>',\n\t\t\t\t\t\t\t\t\ticonCls: 'atm-pic-validate',\n\t\t\t\t\t\t\t\t\thandler: function () {\n\t\t\t\t\t\t\t\t\t\tAutomne.server.call('validations-controler.php', function(response, options, jsonResponse){\n\t\t\t\t\t\t\t\t\t\t\tif (!jsonResponse.success) {\n\t\t\t\t\t\t\t\t\t\t\t\t//get validation message\n\t\t\t\t\t\t\t\t\t\t\t\tif (response.responseXML && response.responseXML.getElementsByTagName('message').length) {\n\t\t\t\t\t\t\t\t\t\t\t\t\tvar message = response.responseXML.getElementsByTagName('message').item(0).firstChild.nodeValue;\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\t\t\t\t\t\t\tmsg: \t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\t\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING\n\t\t\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\t\t\taction:\t\t\t\t'validateById',\n\t\t\t\t\t\t\t\t\t\t\tresource:\t\t\t'" . $cms_page->getID() . "',\n\t\t\t\t\t\t\t\t\t\t\tmodule:\t\t\t\t'" . MOD_STANDARD_CODENAME . "',\n\t\t\t\t\t\t\t\t\t\t\tevalMessage:\t\tfalse\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}));";
 }
 $endPublication = $cms_page->getPublicationDateEnd(false);
 $now = new CMS_date();
 $now->setNow();
示例#3
0
 /**
  * Recursive function to Build the targets tree (recursivelinks) 
  * then apply the selection to the builded targets
  * Uses the websites catalog to exclude (for desclinks and sublinks) pages that are not part of the current website
  *
  * @return multidimensionnal array : array("recursiveTree" => tree of page id, "targets" => cms_page objects);
  * @access private
  */
 protected function _buildRecursiveTargets($pageID, $level = 0)
 {
     $targets = array();
     $recursiveTargets = array();
     $targets_temp = CMS_tree::getSiblings($pageID, $this->_publicTree, false);
     if ($targets_temp && is_array($targets_temp)) {
         foreach ($targets_temp as $aTarget_temp) {
             if ($this->_crosswebsite || !CMS_websitesCatalog::isWebsiteRoot($aTarget_temp)) {
                 //construct targets array
                 $targets[$aTarget_temp] = $aTarget_temp;
                 if ($this->_selectionCondition === false || $this->_selectionCondition->levelPasses($level + 1)) {
                     //construct recursive targets array and array of cms_pages objects
                     $returnedDatas = $this->_buildRecursiveTargets($aTarget_temp, $level + 1);
                     $targets = $targets + $returnedDatas["targets"];
                     //add this page to father watches
                     if (sizeof($returnedDatas["targets"])) {
                         $this->_fatherWatches[] = $aTarget_temp;
                     }
                     $recursiveTargets[$aTarget_temp] = $returnedDatas["recursiveTree"];
                 }
             }
         }
     }
     return array("recursiveTree" => $recursiveTargets, "targets" => $targets);
 }
示例#4
0
 /**
  * Returns the website of a page
  * Static function
  * 
  * @param mixed CMS_page or pageID $page : The page we want the website of
  * @return CMS_website or false on failure
  * @access public
  */
 static function getPageWebsite($page)
 {
     //check argument is a page
     if (is_object($page)) {
         $pageID = $page->getID();
     } elseif (sensitiveIO::isPositiveInteger($page)) {
         $pageID = $page;
     } else {
         CMS_grandFather::raiseError('Page must be instance of CMS_page or valid page ID');
         return false;
     }
     $nearestWebsite = 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);
         return false;
     } else {
         $lineage = array_reverse($lineage);
         foreach ($lineage as $ancestor) {
             if (CMS_websitesCatalog::isWebsiteRoot($ancestor)) {
                 $nearestWebsite = $ancestor;
                 break;
             }
         }
     }
     if (!$nearestWebsite) {
         return false;
     }
     return CMS_websitesCatalog::getWebsiteFromRoot($nearestWebsite);
 }