/** * Return the module CSS files * * @return array : the module css file in /css/modules/codename * @access public */ function getCSSFiles($pageId = '', $allFiles = false) { $files = array(); $medias = array('all', 'aural', 'braille', 'embossed', 'handheld', 'print', 'projection', 'screen', 'tty', 'tv'); //get generic files foreach ($medias as $media) { if ($media == 'all') { if (file_exists(PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename . '.css')) { $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', PATH_CSS_FS . '/modules/' . $this->_codename . '.css')); } } if (file_exists(PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename . '-' . $media . '.css')) { $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', PATH_CSS_FS . '/modules/' . $this->_codename . '-' . $media . '.css')); } } //get subdir files if any $dirname = PATH_CSS_FS . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . $this->_codename; if (@is_dir($dirname)) { try { //all subdirs or only this dir $dir = $allFiles ? new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST) : new DirectoryIterator($dirname); foreach ($dir as $file) { if ($file->isFile() && io::substr($file->getFilename(), -4) == ".css") { $found = false; foreach ($medias as $media) { if (io::substr($file->getFilename(), -5 - strlen($media)) == '-' . $media . '.css') { $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname())); $found = true; } } if (!$found) { $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname())); } } } } catch (Exception $e) { } } //get website files if any if (!$allFiles && io::isPositiveInteger($pageId)) { $page = CMS_tree::getPageById($pageId); if ($page) { $website = $page->getWebsite(); if ($website) { if (@is_dir($dirname . DIRECTORY_SEPARATOR . $website->getCodename())) { try { foreach (new DirectoryIterator($dirname . DIRECTORY_SEPARATOR . $website->getCodename()) as $file) { if ($file->isFile() && io::substr($file->getFilename(), -4) == ".css") { $found = false; foreach ($medias as $media) { if (io::substr($file->getFilename(), -5 - strlen($media)) == '-' . $media . '.css') { $files[$media][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname())); $found = true; } } if (!$found) { $files['all'][] = str_replace(DIRECTORY_SEPARATOR, '/', str_replace(PATH_REALROOT_FS . '/', '', $file->getPathname())); } } } } catch (Exception $e) { } } } } } return $files; }
/** * Create the redirection of an alias * * @return boolean true on success, false on failure * @access public * @static */ function redirect() { //get aliases for current folder $dirname = array_pop(explode(DIRECTORY_SEPARATOR, dirname($_SERVER['SCRIPT_NAME']))); $aliases = CMS_module_cms_aliases::getByName($dirname); if (!$aliases) { //no alias found, go to 404 CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME'])); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } //check each aliases returned to get the one which respond to current alias $matchAlias = false; $domain = @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) ? @parse_url($_SERVER['REQUEST_URI'], PHP_URL_HOST) : (@parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) ? @parse_url($_SERVER['HTTP_HOST'], PHP_URL_HOST) : $_SERVER['HTTP_HOST']); $websites = array(); if ($domain) { $websites = CMS_websitesCatalog::getWebsitesFromDomain($domain); } foreach ($aliases as $alias) { if (!$matchAlias && dirname($_SERVER['SCRIPT_NAME']) == substr($alias->getPath(), 0, -1)) { if ($websites) { foreach ($websites as $website) { //alias match path, check for website if (!$alias->getWebsites() || !$website || in_array($website->getId(), $alias->getWebsites())) { //alias match website, use it $matchAlias = $alias; } } } else { //alias match path, check for website if (!$alias->getWebsites()) { //alias match website, use it $matchAlias = $alias; } } } } if (!$matchAlias) { //no alias found, go to 404 CMS_grandFather::raiseError('No alias found for directory ' . dirname($_SERVER['SCRIPT_NAME']) . ' and domain ' . $domain); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } //if alias is used as a page url, return page if ($matchAlias->urlReplaced()) { if (io::isPositiveInteger($matchAlias->getPageID())) { $page = CMS_tree::getPageById($matchAlias->getPageID()); } else { //no valid page set, go to 404 $matchAlias->raiseError('No page set for alias ' . $matchAlias->getID()); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } if (!$page || $page->hasError()) { //no valid page found, go to 404 $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID()); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } //return page path $pPath = $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM); if ($pPath) { if (file_exists($pPath)) { return $pPath; } elseif ($page->regenerate(true)) { clearstatcache(); if (file_exists($pPath)) { return $pPath; } } } //no valid url page found, go to 404 $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID()); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } else { //this is a redirection $params = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''; if (isset($_SERVER['HTTP_REFERER'])) { header("Referer: " . $_SERVER['HTTP_REFERER']); } if (io::isPositiveInteger($matchAlias->getPageID())) { //it's a redirection to an Automne Page $page = CMS_tree::getPageById($matchAlias->getPageID()); if ($page && !$page->hasError()) { $pageURL = CMS_tree::getPageValue($matchAlias->getPageID(), 'url'); if ($pageURL) { CMS_view::redirect($pageURL . $params, true, $matchAlias->isPermanent() ? 301 : 302); } else { //no valid url page found, go to 404 $matchAlias->raiseError('Invalid url page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID()); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } } else { //no valid page found, go to 404 $matchAlias->raiseError('Invalid page ' . $matchAlias->getPageID() . ' for alias ' . $matchAlias->getID()); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } } elseif ($matchAlias->getURL()) { //it's a redirection to an URL CMS_view::redirect($matchAlias->getURL(), true, $matchAlias->isPermanent() ? 301 : 302); } else { //no valid redirection found, go to 404 $matchAlias->raiseError('Invalid redirection for alias ' . $matchAlias->getID()); CMS_view::redirect(PATH_SPECIAL_PAGE_NOT_FOUND_WR, true, 301); } } }
//This page must be accessible by all users to avoid infinite loop if a website home page is redirected to an external website require_once dirname(__FILE__) . '/../../cms_rc_frontend.php'; define("MESSAGE_PAGE_REDIRECT", 320); define("MESSAGE_PAGE_PAGE", 1303); define("MESSAGE_PAGE_PAGE_REDIRECT_ERROR", 703); //load interface instance $view = CMS_view::getInstance(); $view->addCSSFile('main'); $view->addCSSFile('info'); //force language if none exists if (!isset($cms_language) || !is_object($cms_language)) { $cms_language = new CMS_language(ADMINISTRATION_DEFAULT_LANGUAGE); } //get page if (isset($_GET['pageId']) && sensitiveIO::isPositiveInteger($_GET['pageId'])) { $page = CMS_tree::getPageById($_GET['pageId']); } if (isset($page) && !$page->hasError()) { $redirect = ''; $redirectlink = $page->getRedirectLink(true); if ($redirectlink->hasValidHREF()) { if ($redirectlink->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL) { $redirectPage = new CMS_page($redirectlink->getInternalLink()); if (!$redirectPage->hasError()) { $label = $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' "' . $redirectPage->getTitle() . '" (' . $redirectPage->getID() . ')'; } $redirect = '<a href="' . $redirectPage->getURL(false, false, PATH_RELATIVETO_WEBROOT, true) . '">' . io::htmlspecialchars($label) . '</a>'; } else { $label = $redirectlink->getExternalLink(); $redirectlink->setTarget('_blank'); $redirect = $redirectlink->getHTML(io::ellipsis($label, '80'), MOD_STANDARD_CODENAME, RESOURCE_DATA_LOCATION_EDITED);
/** * Module script task * @param array $parameters the task parameters * task : string task to execute * object : string module codename for the task * field : string module uid * ... : optional field relative parameters * @return Boolean true/false * @access public */ function scriptTask($parameters) { switch ($parameters['task']) { case 'emailNotification': @set_time_limit(300); $module = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); //create a new script for all recipients $allUsers = $this->_getRecipients($parameters['object']); foreach ($allUsers as $userId) { //add script to send email for user if needed CMS_scriptsManager::addScript($module, array('task' => 'emailSend', 'user' => $userId, 'field' => $parameters['field'], 'object' => $parameters['object'])); } //then set sending date to current date $sendingDate = new CMS_date(); $sendingDate->setNow(); $this->_subfieldValues[1]->setValue($sendingDate->getDBValue()); $this->writeToPersistence(); break; case 'emailSend': @set_time_limit(300); $params = $this->getParamsValues(); if (!sensitiveIO::isPositiveInteger($parameters['user'])) { return false; } //instanciate script related item $item = CMS_poly_object_catalog::getObjectByID($parameters['object'], false, true); if (!is_object($item) || $item->hasError()) { return false; } //instanciate user $cms_user = new CMS_profile_user($parameters['user']); //check user if (!$cms_user || $cms_user->hasError() || !$cms_user->isActive() || $cms_user->isDeleted() || !sensitiveIO::isValidEmail($cms_user->getEmail())) { return false; } $cms_language = $cms_user->getLanguage(); //globalise cms_user and cms_language $GLOBALS['cms_language'] = $cms_user->getLanguage(); $GLOBALS['cms_user'] = $cms_user; //check user clearance on object if (!$item->userHasClearance($cms_user, CLEARANCE_MODULE_VIEW)) { return false; } //create email subject $parameters['item'] = $item; $parameters['public'] = true; $polymodParsing = new CMS_polymod_definition_parsing($params['emailSubject'], false); $subject = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters); $body = ''; //create email body if ($params['emailBody']['type'] == 1) { //send body $parameters['module'] = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID()); $polymodParsing = new CMS_polymod_definition_parsing($params['emailBody']['html'], true, CMS_polymod_definition_parsing::PARSE_MODE, $parameters['module']); $body = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters); } elseif ($params['emailBody']['type'] == 2) { //send a page $page = CMS_tree::getPageById($params['emailBody']['pageID']); if (!$page || $page->hasError()) { $this->raiseError('Page ID is not a valid page : ' . $params['emailBody']['pageID']); return false; } $pageHTMLFile = new CMS_file($page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM)); if (!$pageHTMLFile->exists()) { $this->raiseError('Page HTML file does not exists : ' . $page->getHTMLURL(false, false, PATH_RELATIVETO_FILESYSTEM)); return false; } $body = $pageHTMLFile->readContent(); //create page URL call $polymodParsing = new CMS_polymod_definition_parsing($params['emailBody']['pageURL'], false); $pageURL = $polymodParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters); parse_str($pageURL, $GLOBALS['_REQUEST']); //$GLOBALS['_REQUEST'] //parse and eval HTML page $cms_page_included = true; $GLOBALS['cms_page_included'] = $cms_page_included; //eval() the PHP code $body = sensitiveIO::evalPHPCode($body); $website = $page->getWebsite(); $webroot = $website->getURL(); //replace URLs values $replace = array('="/' => '="' . $webroot . '/', "='/" => "='" . $webroot . "/", "url(/" => "url(" . $webroot . "/"); $body = str_replace(array_keys($replace), $replace, $body); } else { $this->raiseError('No valid email type to send : ' . $params['emailBody']['type']); return false; } if (isset($sendmail)) { //$body .= print_r($sendmail,true); } //drop email sending if (isset($sendmail) && $sendmail === false) { return false; } //if no body for email or if sendmail var is set to false, quit if (!$body) { $this->raiseError('No email body to send ... Email parameters : user : '******'user'] . ' - object ' . $parameters['object']); return false; } //This code is for debug purpose only. //$testFile = new CMS_file('/test/test_'.$cms_user->getUserId().'.php', CMS_file::WEBROOT); //$testFile->setContent($body); //$testFile->writeToPersistence(); // Set email $email = new CMS_email(); $email->setSubject($subject); $email->setEmailHTML($body); $email->setEmailTo($cms_user->getEmail()); if ($params['includeFiles']) { //check for file fields attached to object $files = array(); $this->_getFieldsFiles($item, $files); if (sizeof($files)) { foreach ($files as $file) { $email->setFile($file); } } } //set email From if (!$params['emailFrom']) { $email->setFromName(APPLICATION_LABEL); $email->setEmailFrom(APPLICATION_POSTMASTER_EMAIL); } else { $email->setFromName($params['emailFrom']); $email->setEmailFrom($params['emailFrom']); } //Send if ($email->sendEmail()) { //store email sent number $this->_subfieldValues[2]->setValue($this->_subfieldValues[2]->getValue() + 1); $this->writeToPersistence(); return true; } else { return false; } break; default: $this->raiseError('No valid task given : ' . $parameters['task']); return false; break; } }
//then validate this page content $validation = new CMS_resourceValidation(MOD_STANDARD_CODENAME, RESOURCE_EDITION_CONTENT, $cms_page); $mod = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME); $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT); $edited = true; //reload page to force update status $cms_page = CMS_tree::getPageById($cms_page->getID(), true); //check for basedatas edition pending if ($cms_page->getStatus()->getEditions() & RESOURCE_EDITION_BASEDATA) { //then validate this page basedatas content $validation = new CMS_resourceValidation(MOD_STANDARD_CODENAME, RESOURCE_EDITION_BASEDATA, $cms_page); $mod = CMS_modulesCatalog::getByCodename(MOD_STANDARD_CODENAME); $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT); } //reload page to force update status $cms_page = CMS_tree::getPageById($cms_page->getID(), true); //reload current tab $jscontent = ' //goto previz tab Automne.tabPanels.setActiveTab(\'public\', true);'; $view->addJavascript($jscontent); break; case 'cancel_editions': // Copy clientspaces and data from public to edited tables $tpl = $cms_page->getTemplate(); CMS_moduleClientSpace_standard_catalog::moveClientSpaces($tpl->getID(), RESOURCE_DATA_LOCATION_PUBLIC, RESOURCE_DATA_LOCATION_EDITED, true); CMS_blocksCatalog::moveBlocks($cms_page, RESOURCE_DATA_LOCATION_PUBLIC, RESOURCE_DATA_LOCATION_EDITED, true); $cms_page->cancelAllEditions(); $cms_page->writeToPersistence(); $edited = true; $logAction = CMS_log::LOG_ACTION_RESOURCE_CANCEL_EDITIONS;
</select> </td> </tr> <tr> <td class="admin" align="right">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_FAVICON) . '</td> <td class="admin"><input type="text" size="30" maxlength="255" class="admin_input_long_text" name="favicon" value="' . htmlspecialchars($website->getMeta('favicon')) . '" /> <span class="admin_comment">(' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_FAVICON_COMMENT) . ')</span></td> </tr> <tr> <td colspan="2" class="admin"><br /><input type="submit" class="admin_input_submit" value="' . $cms_language->getMessage(MESSAGE_BUTTON_VALIDATE) . '" /></td> </tr> </table> </fieldset> </form> <br /> ' . $cms_language->getMessage(MESSAGE_FORM_MANDATORY_FIELDS) . ' <br /><br />'; $codenames = $website->getAllPagesCodenames(); if ($codenames) { $content .= ' <fieldset class="admin"> <legend class="admin"><strong>' . $cms_language->getMessage(MESSAGE_PAGE_CODENAMES) . '</strong></legend><ul>'; foreach ($codenames as $codename => $pageId) { $page = CMS_tree::getPageById($pageId); $content .= '<li>' . $codename . ' : <a href="#" onclick="Automne.utils.getPageById(' . $page->getID() . ');Ext.WindowMgr.getActive().close();" class="admin">' . $page->getTitle() . ' (' . $page->getID() . ')</a></li>'; } $content .= ' </ul></fieldset> '; } $dialog->setContent($content); $dialog->show();
$pathinfo = pathinfo($_SERVER['REQUEST_URI']); $basename = isset($pathinfo['filename']) ? $pathinfo['filename'] : $pathinfo['basename']; //first try to get redirection rules from CSV file if exists if (file_exists(PATH_MAIN_FS . '/redirect/redirectRules.csv')) { $csvFile = new CMS_file(PATH_MAIN_FS . '/redirect/redirectRules.csv'); $csvDatas = $csvFile->readContent('csv', 'trim', array('delimiter' => ';', 'enclosure' => '"', 'strict' => true)); $rules = array(); foreach ($csvDatas as $line => $csvData) { if (isset($csvData[0]) && $csvData[0] && isset($csvData[1]) && $csvData[1]) { $rules[$csvData[0]] = $csvData[1]; } } if (isset($rules[$_SERVER['REQUEST_URI']]) && io::isPositiveInteger($rules[$_SERVER['REQUEST_URI']])) { $page = CMS_tree::getPageById($rules[$_SERVER['REQUEST_URI']]); } elseif (isset($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)]) && io::isPositiveInteger($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)])) { $page = CMS_tree::getPageById($rules[parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)]); } } if (!isset($page)) { //get page from requested url $page = CMS_tree::analyseURL($_SERVER['REQUEST_URI'], false); } //get redirection URL for page if (isset($page) && is_object($page) && !$page->hasError() && $page->getStatus()->getLocation() != RESOURCE_LOCATION_DELETED) { //get page file $pageURL = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false, false, PATH_RELATIVETO_FILESYSTEM); if (file_exists($pageURL)) { $redirectTo = $page->getURL(substr($basename, 0, 5) == 'print' ? true : false); } else { //try to regenerate page if ($page->regenerate(true)) {
/** * Gets the 403 page * * @param boolean $returnObject Return a public CMS_page. If false, return only page Id (default : true) * @return mixed The 403 CMS_page object if any and public or false if none found * @access public */ function get403($returnObject = true) { if (!io::isPositiveInteger($this->_403)) { return false; } if (!$returnObject) { return $this->_403; } $page = CMS_tree::getPageById($this->_403); if ($page && !$page->hasError() && $page->getPublication() == RESOURCE_PUBLICATION_PUBLIC) { return $page; } return false; }
/** * Get search results objects for module by Id * * @param array : the results score ids * @return array : results elements (cms_page) * @access public */ function getSearchResults($resultsIds, $user) { $results = array(); $cms_language = $user->getLanguage(); foreach ($resultsIds as $id) { $page = CMS_tree::getPageById($id); //Resource related informations $htmlStatus = $pubRange = ''; $status = $page->getStatus(); if (is_object($status)) { $htmlStatus = $status->getHTML(false, $user, $this->getCodename(), $page->getID()); $pubRange = $status->getPublicationRange($cms_language); } $pageTemplateLabel = $page->getTemplate() ? $page->getTemplate()->getLabel() : ''; //page panel tip content $panelTip = ' ' . $cms_language->getMessage(self::MESSAGE_MOD_STANDARD_LINKTITLE) . ' : <strong>' . $page->getLinkTitle() . '</strong><br /> ' . $cms_language->getMessage(self::MESSAGE_MOD_STANDARD_ID) . ' : <strong>' . $page->getID() . '</strong><br /> ' . ($page->getCodename() ? $cms_language->getMessage(self::MESSAGE_MOD_STANDARD_CODENAME) . ' : <strong>' . $page->getCodename() . '</strong><br />' : '') . ' ' . $cms_language->getMessage(self::MESSAGE_MOD_STANDARD_STATUS) . ' : <strong>' . $page->getStatus()->getStatusLabel($cms_language) . '</strong><br /> ' . $cms_language->getMessage(self::MESSAGE_MOD_STANDARD_TEMPLATE) . ' : <strong>' . $pageTemplateLabel . '</strong>'; $edit = false; if ($user->hasPageClearance($page->getID(), CLEARANCE_PAGE_EDIT)) { $edit = array('type' => 'function', 'func' => "(function(button, window) {\n\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\tmsg: \t\t\t\t'Modifier la page \\'" . sensitiveIO::sanitizeJSString($page->getTitle()) . "\\' fermera la recherche en cours. Etes vous sur ?',\n\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\tanimEl: \t\t\tbutton.getEl(),\n\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\tscope:\t\t\t\tthis,\n\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\tif (button == 'cancel') {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t//view page\n\t\t\t\t\t\t\t\tAutomne.utils.getPageById(" . $page->getID() . ", 'edit');\n\t\t\t\t\t\t\t\t//close window\n\t\t\t\t\t\t\t\twindow.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t})"); } $results[$id] = array('id' => $id, 'type' => $cms_language->getMessage(self::MESSAGE_MOD_STANDARD_PAGE), 'status' => $htmlStatus, 'pubrange' => $pubRange, 'label' => $page->getTitle(), 'description' => $panelTip, 'edit' => $edit, 'view' => array('type' => 'function', 'func' => "(function(button, window) {\n\t\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\t\tmsg: \t\t\t\t'Voir la page \\'" . sensitiveIO::sanitizeJSString($page->getTitle()) . "\\' fermera la recherche en cours. Etes vous sur ?',\n\t\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\t\t\tanimEl: \t\t\tbutton.getEl(),\n\t\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.QUESTION,\n\t\t\t\t\t\t\tscope:\t\t\t\tthis,\n\t\t\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\t\t\tif (button == 'cancel') {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t//view page\n\t\t\t\t\t\t\t\tAutomne.utils.getPageById(" . $page->getID() . ", 'public');\n\t\t\t\t\t\t\t\t//close window\n\t\t\t\t\t\t\t\twindow.close();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t})")); } return $results; }
/** * 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; }
$view->setDisplayMode(CMS_view::SHOW_JSON); //This file is an admin file. Interface must be secure $view->setSecure(); $query = sensitiveIO::request('query', '', ''); $start = sensitiveIO::request('start', 'sensitiveIO::isPositiveInteger', 0); $limit = sensitiveIO::request('limit', 'sensitiveIO::isPositiveInteger', 10); if (!$query || io::strlen($query) < 3) { CMS_grandFather::raiseError('Missing query or query is too short : ' . $query); $view->show(); } //lauch search $results = CMS_search::getSearch($query, $cms_user, false, false); //pr($results); $pages = array(); $count = 0; if (isset($results['results']) && is_array($results['results'])) { foreach ($results['results'] as $result) { if ($count >= $start && sizeof($pages) < $limit) { $page = CMS_tree::getPageById($result); if ($page && !$page->hasError()) { $pages[] = array('pageId' => $page->getID(), 'title' => $page->getTitle() . ' (' . $page->getID() . ')', 'status' => $page->getStatus()->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $page->getID()), 'lineage' => CMS_tree::getLineage(APPLICATION_ROOT_PAGE_ID, $page->getID(), false)); } else { $results['nbresult']--; } } $count++; } } $return = array('pages' => $pages, 'totalCount' => $results['nbresult']); $view->setContent($return); $view->show();
/** * Publish the move of a page : page new position pass from edited to public * Static function. * * @param CMS_page $page The page which move * @return boolean true on success, false on failure * @access public */ static function publishPageMove(&$page) { //check arguments are pages if (!is_a($page, "CMS_page")) { CMS_grandFather::raiseError("Page must be an instance of CMS_page"); return false; } //if page was nevervalidated, do nothing if ($page->getPublication() == RESOURCE_PUBLICATION_NEVERVALIDATED) { return false; } //get current old (public) page father $sql = "select \n\t\t\t\tfather_ltr\n\t\t\tfrom\n\t\t\t\tlinx_tree_public\n\t\t\twhere\n\t\t\t\tsibling_ltr='" . sensitiveIO::sanitizeSQLString($page->getID()) . "'\n\t\t\t"; $q = new CMS_query($sql); $oldFather = $q->getValue('father_ltr'); //get new (edited) page position $sql = "select \n\t\t\t\tfather_ltr, order_ltr\n\t\t\tfrom\n\t\t\t\tlinx_tree_edited\n\t\t\twhere\n\t\t\t\tsibling_ltr='" . sensitiveIO::sanitizeSQLString($page->getID()) . "'\n\t\t\t"; $q = new CMS_query($sql); $r = $q->getArray(); $newFather = $r['father_ltr']; $newPosition = $r['order_ltr']; //remove page from current (public) position $sql = "\n\t\t\tdelete from\n\t\t\t\tlinx_tree_public\n\t\t\twhere\n\t\t\t\tsibling_ltr='" . sensitiveIO::sanitizeSQLString($page->getID()) . "'\n\t\t"; $q = new CMS_query($sql); // compact old public siblings order CMS_tree::compactSiblingOrder(CMS_tree::getPageById($oldFather), true); //get current order of siblings for new father $sql = "select \n\t\t\t\tsibling_ltr\n\t\t\tfrom\n\t\t\t\tlinx_tree_public\n\t\t\twhere\n\t\t\t\tfather_ltr='" . sensitiveIO::sanitizeSQLString($newFather) . "'\n\t\t\torder by order_ltr asc\n\t\t\t"; $q = new CMS_query($sql); $siblingsOrder = array(); while ($id = $q->getValue('sibling_ltr')) { $siblingsOrder[] = $id; } //set moved page into siblings at it's old position $newSiblingOrder = array_slice($siblingsOrder, 0, $newPosition - 1); $newSiblingOrder[] = $page->getID(); $newSiblingOrder = array_merge($newSiblingOrder, array_slice($siblingsOrder, $newPosition - 1)); //set new pages order foreach ($newSiblingOrder as $newOrder => $sibling) { $newOrder += 1; //because array keys start to 0 and sibling number to 1 if ($sibling != $page->getID()) { //move the siblings order $sql = "\n\t\t\t\t\tupdate\n\t\t\t\t\t\tlinx_tree_public\n\t\t\t\t\tset\n\t\t\t\t\t\torder_ltr='" . $newOrder . "'\n\t\t\t\t\twhere\n\t\t\t\t\t\tsibling_ltr='" . $sibling . "'\n\t\t\t\t"; } else { //move the siblings order $sql = "\n\t\t\t\t\tinsert into\n\t\t\t\t\t\tlinx_tree_public\n\t\t\t\t\tset\n\t\t\t\t\t\tfather_ltr='" . $newFather . "',\n\t\t\t\t\t\tsibling_ltr='" . $sibling . "',\n\t\t\t\t\t\torder_ltr='" . $newOrder . "'\n\t\t\t\t"; } $q = new CMS_query($sql); } return true; }
foreach ($aliases as $alias) { $hasSiblings = $alias->hasSubAliases(); if ($alias->hasError()) { $label = ($alias->getWebsites() ? '<span style="color:red;">*</span>' : '') . '<span style="color:red;">' . $alias->getAlias() . '</span>'; } elseif ($pageId && $alias->getPageID() == $pageId && $alias->urlReplaced()) { $label = ($alias->getWebsites() ? '<span style="color:red;">*</span>' : '') . '<span style="color:green;">' . $alias->getAlias() . '</span>'; } else { $label = ($alias->getWebsites() ? '<span style="color:red;">*</span>' : '') . $alias->getAlias(); } if ($alias->hasError()) { $qtip = '<span style="color:red;"><strong>' . $cms_language->getMessage(MESSAGE_PAGE_ALIAS_ERROR, false, 'cms_aliases') . '</strong></span><br />'; } else { $qtip = $cms_language->getMessage(MESSAGE_PAGE_ALIAS, false, 'cms_aliases') . ' <strong>' . $alias->getPath() . '</strong><br />'; } if ($alias->getPageID()) { $page = CMS_tree::getPageById($alias->getPageID()); if ($page && !$page->hasError()) { $label .= $alias->urlReplaced() ? ' (' . $alias->getPageID() . ')' : '<small> ⇒ ' . $alias->getPageID() . '</small>'; $qtip .= $cms_language->getMessage($alias->urlReplaced() ? MESSAGE_PAGE_REPLACE_ADDRESS : MESSAGE_PAGE_REDIRECT_TO, false, 'cms_aliases') . ' ' . $cms_language->getMessage(MESSAGE_PAGE_PAGE) . ' ' . $page->getTitle() . ' (' . $alias->getPageID() . ')<br />'; } else { $label .= $alias->urlReplaced() ? ' (<span style="color:red;">' . $alias->getPageID() . '</span>)' : '<small> ⇒ <span style="color:red;">' . $alias->getPageID() . '</span></small>'; $qtip .= $cms_language->getMessage($alias->urlReplaced() ? MESSAGE_PAGE_REPLACE_ADDRESS : MESSAGE_PAGE_REDIRECT_TO, false, 'cms_aliases') . ' <span style="color:red;">' . $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_PAGE) . ' (' . $alias->getPageID() . ')</span><br />'; } } elseif ($alias->getURL()) { $label .= '<small> ⇒ ' . $alias->getURL() . '</small>'; $qtip .= $cms_language->getMessage(MESSAGE_PAGE_REDIRECT_TO, false, 'cms_aliases') . ' ' . $alias->getURL() . '<br />'; } if (!$alias->getWebsites()) { $qtip .= $cms_language->getMessage(MESSAGE_PAGE_ALIAS_FOR_ALL_WEBSITES, false, 'cms_aliases') . '<br />'; } else { $qtip .= '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_ALIAS_RESTRICTED, false, 'cms_aliases') . ' </strong>' . $cms_language->getMessage(MESSAGE_PAGE_ALIAS_FOR_WEBSITES, false, 'cms_aliases') . '<br />';