Exemplo n.º 1
0
 /**
  * Get the page property specified
  *
  * @param CMS_page $page The page we want the property of
  * @param string $property The property we want
  * @param boolean $public Do we want the public or edited property ?
  * @return mixed The property value
  * @access private
  */
 protected function _getPageProperty(&$page, $property, $public)
 {
     if (!is_a($page, "CMS_page")) {
         $this->raiseError("Page parameter must be an object");
         return;
     }
     switch ($property) {
         case "title":
             return $page->getTitle($public);
             break;
         case "father":
             return CMS_tree::getFather($page, false, $public);
             break;
         case "id":
             return $page->getID();
             break;
         case "website":
             return $page->getWebsite()->getCodename();
             break;
         case "codename":
             return $page->getCodename($public);
             break;
     }
 }
Exemplo n.º 2
0
 /**
  * Process the module validations : here, calls the parent function but before :
  * - Pass all the editors to remindedEditors
  * - computes all the pages that got to be regenerated.
  *
  * @param CMS_resourceValidation $resourceValidation The resource validation to process
  * @param integer $result The result of the validation process. See VALIDATION_OPTION constants
  * @param boolean $lastValidation Is this the last validation done in a load of multiple validations (or the only one) ?
  *        if true, launch the regeneration script.
  * @return boolean true on success, false on failure to process
  * @access public
  */
 function processValidation($resourceValidation, $result, $lastValidation = true)
 {
     if (!$resourceValidation instanceof CMS_resourceValidation) {
         $this->raiseError("ResourceValidation is not a valid CMS_resourceValidation object");
         return false;
     }
     $editions = $resourceValidation->getEditions();
     $page = $resourceValidation->getResource();
     $publication_before = $page->getPublication();
     $location_before = $page->getLocation();
     //Clear polymod cache
     //CMS_cache::clearTypeCacheByMetas('polymod', array('module' => MOD_STANDARD_CODENAME));
     CMS_cache::clearTypeCache('polymod');
     //Get the linked pages (it will be too late after parent processing if pages move outside USERSPACE
     //first add the page to regen
     $regen_pages = array();
     if ($result == VALIDATION_OPTION_ACCEPT) {
         //2.1. If editions contains SIBLINGSORDER, all pages monitoring this one for father changes should regen
         if ($editions & RESOURCE_EDITION_SIBLINGSORDER || $editions & RESOURCE_EDITION_MOVE) {
             $temp_regen = CMS_linxesCatalog::getWatchers($page);
             if ($temp_regen) {
                 $regen_pages = array_merge($regen_pages, $temp_regen);
             }
         }
         //2.2. If editions contains BASEDATA, all pages linked with this one should regen, and all monitoring its father
         if ($editions & RESOURCE_EDITION_BASEDATA || $editions & RESOURCE_EDITION_LOCATION) {
             $temp_regen = CMS_linxesCatalog::getLinkers($page);
             if ($temp_regen) {
                 $regen_pages = array_merge($regen_pages, $temp_regen);
             }
             $father = CMS_tree::getFather($page);
             if ($father) {
                 $temp_regen = CMS_linxesCatalog::getWatchers($father);
                 if ($temp_regen) {
                     $regen_pages = array_merge($regen_pages, $temp_regen);
                 }
             }
         }
         //2.3. If editions contains CONTENT, only the page should be regen
         if ($editions & RESOURCE_EDITION_CONTENT) {
             //do nothing, the page is already in the array
         }
         $regen_pages = array_unique($regen_pages);
     }
     //call the parent function, but empty the reminded editors stack before
     if ($result == VALIDATION_OPTION_ACCEPT) {
         $stack = $page->getRemindedEditorsStack();
         $stack->emptyStack();
         $page->setRemindedEditorsStack($stack);
         $page->writeToPersistence();
     }
     if (!parent::processValidation($resourceValidation, $result)) {
         return false;
     }
     if ($result == VALIDATION_OPTION_REFUSE && ($editions & RESOURCE_EDITION_SIBLINGSORDER || $editions & RESOURCE_EDITION_MOVE)) {
         //validation was refused, move the page to it's original position
         if ($editions & RESOURCE_EDITION_SIBLINGSORDER) {
             //revert page order to the old one
             CMS_tree::revertSiblingsOrder($page);
         } elseif ($editions & RESOURCE_EDITION_MOVE) {
             //revert page move to the old position
             CMS_tree::revertPageMove($page);
         }
     }
     //if validation was not accepted, nothing more to do
     if ($result != VALIDATION_OPTION_ACCEPT) {
         return true;
     }
     //re-instanciate the page object that have changed
     $page = CMS_tree::getPageByID($resourceValidation->getResourceID());
     //page was moved out of userspace
     if ($editions & RESOURCE_EDITION_LOCATION) {
         if ($page->getLocation() != RESOURCE_LOCATION_USERSPACE && $location_before == RESOURCE_LOCATION_USERSPACE) {
             $page->deleteFiles();
             CMS_linxesCatalog::deleteLinxes($page, true);
             if ($publication_before != RESOURCE_PUBLICATION_NEVERVALIDATED) {
                 CMS_tree::detachPageFromTree($page, true);
             }
             CMS_tree::detachPageFromTree($page, false);
             //can't regenerate the page now
             if ($key = array_search($page->getID(), $regen_pages)) {
                 unset($regen_pages[$key]);
             }
         }
     } elseif ($editions & RESOURCE_EDITION_BASEDATA && $publication_before != RESOURCE_PUBLICATION_NEVERVALIDATED && $page->getPublication() != RESOURCE_PUBLICATION_PUBLIC && CMS_tree::isInPublicTree($page)) {
         //detach page if publication dates changed and page no longer published
         $page->deleteFiles();
         CMS_linxesCatalog::deleteLinxes($page, true);
         CMS_tree::detachPageFromTree($page, true);
         //can't regenerate the page now
         if ($key = array_search($page->getID(), $regen_pages)) {
             unset($regen_pages[$key]);
         }
     } else {
         //LINX_TREE RECORDS GENERATION
         //1. If the page has never been validated
         if ($publication_before == RESOURCE_PUBLICATION_NEVERVALIDATED) {
             //test the father's editions. If SIBLINGSORDER, only attach the page, else validate all of siblings orders
             $father = CMS_tree::getFather($page, true);
             $father_status = $father->getStatus();
             if ($father_status->getEditions() & RESOURCE_EDITION_SIBLINGSORDER || $editions & RESOURCE_EDITION_MOVE) {
                 CMS_tree::attachPageToTree($page, $father, true);
             } else {
                 CMS_tree::publishSiblingsOrder($father);
             }
         }
         //2. If the page has been validated, attach it to the public tree
         $grand_root = CMS_tree::getRoot();
         if ($page->getPublication() == RESOURCE_PUBLICATION_PUBLIC && $page->getID() != $grand_root->getID()) {
             $father = CMS_tree::getFather($page);
             if ($editions & RESOURCE_EDITION_MOVE) {
                 //publish page move
                 CMS_tree::publishPageMove($page);
                 //regenerate all pages which link moved page
                 $temp_regen = CMS_linxesCatalog::getLinkers($page);
                 if ($temp_regen) {
                     $regen_pages = array_merge($regen_pages, $temp_regen);
                 }
                 //and regenerate all page who watch new father page
                 $temp_regen = CMS_linxesCatalog::getWatchers($father);
                 if ($temp_regen) {
                     $regen_pages = array_merge($regen_pages, $temp_regen);
                 }
             } else {
                 CMS_tree::attachPageToTree($page, $father, true);
             }
         }
         //PAGE REGENERATION
         //3. the page itself (fromscratch needed).
         $launchRegnerator = $lastValidation && !$regen_pages ? true : false;
         CMS_tree::submitToRegenerator($page->getID(), true, $launchRegnerator);
     }
     $regen_pages = array_unique($regen_pages);
     //2. the linked pages
     CMS_tree::submitToRegenerator($regen_pages, false, !$lastValidation);
     return true;
 }
Exemplo n.º 3
0
    header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id());
    exit;
}
switch ($_POST["cms_action"]) {
    case "delete":
        //delete the website and move all of its pages
        $website = CMS_websitesCatalog::getByID($_POST["website"]);
        if ($website instanceof CMS_website && !$website->isMain()) {
            $log = new CMS_log();
            $log->logMiscAction(CMS_log::LOG_ACTION_WEBSITE_DELETE, $cms_user, "Website : " . $website->getLabel());
            //check for codenames duplications
            //get website codenames
            $websiteCodenames = $website->getAllPagesCodenames();
            //get codenames of parent page for website
            $websiteRoot = $website->getRoot();
            $father = CMS_tree::getFather($websiteRoot, true);
            if ($father && is_object($father) && !$father->hasError()) {
                $fatherWebsite = $father->getWebsite();
                $fatherCodenames = $fatherWebsite->getAllPagesCodenames();
                $codenamesToRemove = array();
                //get duplicated codenames
                foreach ($websiteCodenames as $codename => $pageId) {
                    if (isset($fatherCodenames[$codename])) {
                        $codenamesToRemove[$codename] = $pageId;
                    }
                }
                //remove duplicated codenames
                if ($codenamesToRemove) {
                    foreach ($codenamesToRemove as $codename => $pageId) {
                        $page = CMS_tree::getPageById($pageId);
                        $page->setCodename('', $cms_user);
Exemplo n.º 4
0
 /**
  * Returns the ancestors of the given page to root, including root and the page.
  * Static function.
  *
  * @param CMS_page $ancestor The oldest ancestor we want
  * @param CMS_page $page The page we want the lineage of
  * @param boolean $IO_CMS_page if it false, then the Input arguments aren't CMS_page but only page ID and function return an array(pageID). (this is realy fastest)
  * @return array(CMS_page) The ancestors, from root to the page. Minimum is array(rootpage) if lineage of root wanted. Return false if break in lineage or page is archived or deleted.
  * @access public
  */
 static function getLineage($ancestor, $page, $IO_CMS_page = true, $publicTree = false)
 {
     static $fathers;
     if ($IO_CMS_page && (!is_a($ancestor, "CMS_page") || !is_a($page, "CMS_page"))) {
         CMS_grandFather::raiseError("Ancestor and page must be instances of CMS_page");
         return false;
     }
     $lineage = array($page);
     $currentPageID = $IO_CMS_page ? $page->getID() : $page;
     $ancestorPageID = $IO_CMS_page ? $ancestor->getID() : $ancestor;
     $table = $publicTree ? 'linx_tree_public' : 'linx_tree_edited';
     while ($currentPageID != APPLICATION_ROOT_PAGE_ID && $currentPageID != $ancestorPageID) {
         if (!isset($fathers[$currentPageID])) {
             $father = CMS_tree::getFather($currentPageID, false, $publicTree);
             $fathers[$currentPageID] = $father;
             $currentPageID = $father;
             if ($IO_CMS_page) {
                 $pg = CMS_tree::getPageByID($currentPageID);
                 array_unshift($lineage, $pg);
             } else {
                 array_unshift($lineage, $currentPageID);
             }
         } else {
             $currentPageID = $fathers[$currentPageID];
             if ($IO_CMS_page) {
                 $pg = CMS_tree::getPageByID($currentPageID);
                 array_unshift($lineage, $pg);
             } else {
                 array_unshift($lineage, $currentPageID);
             }
         }
     }
     //if while was stopped because of reaching the root first, no lineage found
     if ($currentPageID == APPLICATION_ROOT_PAGE_ID && $currentPageID != $ancestorPageID) {
         return false;
     } else {
         return $lineage;
     }
 }