/** * Submit pages to the regenerator. The first argument can either be a single page ID or an array of those. * * @param mixed $pages If it's a scalar, it's a page ID, else an array of pages IDs * @param integer $fromScratch Is the submission concerning a full from scratch regeneration (true) or a regeneration from linx files (false) ? * @param boolean $dontLaunchRegenerator to avoid multiple launch of the regenerator during multiple validation only the last page validation launch the script * @return void * @access public */ static function submitToRegenerator($pages, $fromScratch, $dontLaunchRegenerator = false) { $fs = $fromScratch ? true : false; if (!is_array($pages)) { $pages = array($pages); } //get all scripts for standard module if (!class_exists('CMS_module_standard')) { CMS_grandFather::raiseError("Can not found standard module"); return false; } $scripts = CMS_scriptsManager::getScripts(MOD_STANDARD_CODENAME); $pagesToRegen = array(); foreach ($scripts as $scriptID => $script) { $pagesToRegen[$script['pageid']] = array('fromscratch' => $script['fromscratch'], 'script' => $scriptID); } foreach ($pages as $page) { if (isset($pagesToRegen[$page])) { //is existant script need to be updated ? $actual_fs = $pagesToRegen[$page]['fromscratch']; if (!$actual_fs && $fs) { $parameters = array('pageid' => $page, 'fromscratch' => $fs); CMS_scriptsManager::addScript(MOD_STANDARD_CODENAME, $parameters, $pagesToRegen[$page]['script']); } } else { //add script $parameters = array('pageid' => $page, 'fromscratch' => $fs); CMS_scriptsManager::addScript(MOD_STANDARD_CODENAME, $parameters); } } if (!$dontLaunchRegenerator) { //then, launch the regenerator script CMS_scriptsManager::startScript(); } }