} elseif (preg_match("#[0-9]+\\-[0-9]+#", $p)) { $subPages = explode('-', $p); sort($subPages); for ($idp = $subPages[0]; $idp <= $subPages[1]; $idp++) { $pages[] = $idp; } } } $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++; } } }
$view->setContent($content); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_TEMPLATE); } break; case 'regenerate': //submit all pages of this template to the regenerator $pages = $template->getPages(true); $pagesIds = array(); foreach ($pages as $page) { if ($page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { $pagesIds[] = $page->getID(); } } if ($pagesIds) { CMS_tree::submitToRegenerator($pagesIds, true); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_N_PAGES_REGEN, array(sizeof($pagesIds))); } else { $cms_message = $cms_language->getMessage(MESSAGE_ERROR_NO_PUBLIC_PAGE); } break; case 'copy': if (is_a($template, "CMS_pageTemplate") && !$template->hasError()) { //Dupplicate selected template with given label $label = $cms_language->getMessage(MESSAGE_PAGE_COPY_OF) . ' ' . $template->getLabel(); $template = CMS_pageTemplatesCatalog::getCloneFromID($templateId, $label); $log = new CMS_log(); $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Template : " . $label . " (create template)"); $content = array('success' => array('templateId' => $template->getID())); $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label)); $view->setContent($content);
//$father->addEdition(RESOURCE_EDITION_SIBLINGSORDER, $cms_user); $pg->writeToPersistence(); $father->writeToPersistence(); //move the data if ($pg->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { CMS_module_standard::_changeDataLocation($pg, RESOURCE_DATA_LOCATION_ARCHIVED, RESOURCE_DATA_LOCATION_PUBLIC, true); } CMS_module_standard::_changeDataLocation($pg, RESOURCE_DATA_LOCATION_ARCHIVED, RESOURCE_DATA_LOCATION_EDITED, false); //attach the page to the tree CMS_tree::attachPageToTree($pg, $father); if ($pg->getPublication() != RESOURCE_PUBLICATION_NEVERVALIDATED) { CMS_tree::attachPageToTree($pg, $father, true); } if (!APPLICATION_ENFORCES_WORKFLOW) { //submit the page to the regenerator CMS_tree::submitToRegenerator($pg->getID(), true); //validate the father $pg->regenerate(true); $validation = new CMS_resourceValidation(MOD_STANDARD_CODENAME, RESOURCE_EDITION_SIBLINGSORDER + RESOURCE_EDITION_CONTENT, $father); $mod = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME); $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT); } $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE); $archives = CMS_tree::getArchivedPagesData(); $log = new CMS_log(); $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_UNARCHIVE, $cms_user, MOD_STANDARD_CODENAME, $pg->getStatus(), "", $pg); } } break; } $dialog = new CMS_dialog();
/** * Process the daily routine unpublication part : unpublish page that needs to be * * @return void * @access private */ protected function _dailyRoutineUnpublish() { $today = new CMS_date(); $today->setNow(); //process all pages that are to be unpublished $sql = "\n\t\t\tselect\n\t\t\t\tid_pag\n\t\t\tfrom\n\t\t\t\tpages,\n\t\t\t\tresources,\n\t\t\t\tresourceStatuses\n\t\t\twhere\n\t\t\t\tresource_pag=id_res\n\t\t\t\tand status_res=id_rs\n\t\t\t\tand location_rs='" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\tand publication_rs='" . RESOURCE_PUBLICATION_PUBLIC . "'\n\t\t\t\tand\t(publicationDateStart_rs > '" . $today->getDBValue(true) . "'\n\t\t\t\t\tor (publicationDateEnd_rs < '" . $today->getDBValue(true) . "' and publicationDateEnd_rs!='0000-00-00'))\n\t\t"; $q = new CMS_query($sql); $unpublished = array(); while ($id = $q->getValue("id_pag")) { $unpublished[] = $id; } $regen_pages = array(); foreach ($unpublished as $page_id) { $page = CMS_tree::getPageByID($page_id); //calculate the pages to regenerate $temp_regen = CMS_linxesCatalog::getLinkers($page); if ($temp_regen) { $regen_pages = array_merge($regen_pages, $temp_regen); } $father = CMS_tree::getAncestor($page, 1); if ($father) { $temp_regen = CMS_linxesCatalog::getWatchers($father); if ($temp_regen) { $regen_pages = array_merge($regen_pages, $temp_regen); } } //apply changes on the page $page->deleteFiles(); CMS_linxesCatalog::deleteLinxes($page, true); CMS_tree::detachPageFromTree($page, true); } //regenerate the pages that needs to be, but first pull off the array the ids of the unpublished pages $regen_pages = array_unique(array_diff($regen_pages, $unpublished)); CMS_tree::submitToRegenerator($regen_pages, false); }
/** * Regenerate alias page and all pages related to this alias * * @return string * @access protected */ protected function _regenerate() { if (($this->_replace || $this->_needRegen) && $this->_pageID) { $page = CMS_tree::getPageById($this->_pageID); if ($page && !$page->hasError()) { $regen_pages = array(); $temp_regen = CMS_linxesCatalog::getWatchers($page); if ($temp_regen) { $regen_pages = array_merge($regen_pages, $temp_regen); } $temp_regen = CMS_linxesCatalog::getLinkers($page); if ($temp_regen) { $regen_pages = array_merge($regen_pages, $temp_regen); } $regen_pages = array_unique($regen_pages); //regen page itself CMS_tree::submitToRegenerator($page->getID(), false, false); //regen all pages which link this one and lauch regeneration CMS_tree::submitToRegenerator($regen_pages, false, true); } } return true; }
/** * Regenerates all the pages AND make all re-register their links * Static function. * * @param boolean $fromScratch If set to true, all pages will rebuild their content and not only their linxes * @return void * @access public */ static function regenerateAllPages($fromScratch = false) { //first, clean all the linx files if ($fromScratch === true) { $dir = PATH_PAGES_LINXFILES_FS; if ($opendir = @opendir($dir)) { while (false !== ($readdir = readdir($opendir))) { if ($readdir !== '..' && $readdir !== '.' && $readdir !== '.htaccess') { $readdir = trim($readdir); if (is_file($dir . '/' . $readdir)) { @unlink($dir . '/' . $readdir); } } } closedir($opendir); } } //then regenerate all the pages $sql = "\n\t\t\tselect\n\t\t\t\tid_pag\n\t\t\tfrom\n\t\t\t\tpages,\n\t\t\t\tpagesBaseData_public,\n\t\t\t\tresources,\n\t\t\t\tresourceStatuses\n\t\t\twhere\n\t\t\t\tpage_pbd = id_pag\n\t\t\t\tand resource_pag=id_res\n\t\t\t\tand status_res=id_rs\n\t\t\t\tand location_rs='" . RESOURCE_LOCATION_USERSPACE . "'\n\t\t\t\tand publication_rs='" . RESOURCE_PUBLICATION_PUBLIC . "'\n\t\t"; $q = new CMS_query($sql); while ($id = $q->getValue("id_pag")) { $regen_pages[] = $id; } CMS_tree::submitToRegenerator($regen_pages, $fromScratch); }