break; case '': //launch authentification process (for modules which can use it) CMS_session::authenticate(array('authenticate' => true, 'type' => 'admin')); $cms_user = CMS_session::getUser(); if ($cms_user && $cms_user->hasAdminAccess()) { //launch the daily routine incase it's not in the cron CMS_module_standard::processDailyRoutine(); //then set context and load Automne interface $userSessionsInfos = CMS_session::getSessionInfos(); $cms_language = $cms_user->getLanguage(); //welcome message $welcome = $cms_language->getJsMessage(MESSAGE_PAGE_USER_WELCOME, array($userSessionsInfos['fullname'])); $welcomeMsg = ''; //last login $logs = CMS_log_catalog::search('', 0, $cms_user->getUserId(), array(CMS_log::LOG_ACTION_AUTO_LOGIN, CMS_log::LOG_ACTION_LOGIN), false, false, 0, 2, 'datetime', 'desc', false); if (isset($logs[1])) { $welcomeMsg .= '<br /><br />' . $cms_language->getJsMessage(MESSAGE_PAGE_PREVIOUS_LOGIN) . ' ' . $logs[1]->getDateTime()->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'); } //validations if ($userSessionsInfos['hasValidations']) { $welcomeMsg .= '<br /><br />' . ($userSessionsInfos['awaitingValidation'] ? $cms_language->getJsMessage(MESSAGE_PAGE_USER_VALIDATIONS, array($userSessionsInfos['awaitingValidation'])) : $cms_language->getJsMessage(MESSAGE_PAGE_USER_NOVALIDATION)); } //debug if (SYSTEM_DEBUG && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $welcomeMsg .= '<br /><br /><span class="atm-red">' . $cms_language->getJsMessage(MESSAGE_PAGE_DEBUG) . '</span> ' . $cms_language->getJsMessage(MESSAGE_PAGE_PRESS_F2_FOR_LOG); } $jscontent = ' //show front page in tab Automne.tabPanels.getActiveTab().setFrameURL(\'' . PATH_REALROOT_WR . '/\'); Automne.tabPanels.getActiveTab().reload();
/** * Get All the actions possible * * @return array(integer=>integer) The actions indexed by their messages * @access public */ static function getAllActions($cms_language) { $modulesActions = CMS_log_catalog::getModulesActions($cms_language); $defaultActions = array(CMS_log::MESSAGE_LOG_ACTION_RESOURCE_EDIT_BASEDATA => CMS_log::LOG_ACTION_RESOURCE_EDIT_BASEDATA, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_EDIT_CONTENT => CMS_log::LOG_ACTION_RESOURCE_EDIT_CONTENT, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_EDIT_SIBLINGSORDER => CMS_log::LOG_ACTION_RESOURCE_EDIT_SIBLINGSORDER, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_EDIT_MOVE => CMS_log::LOG_ACTION_RESOURCE_EDIT_MOVE, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_DELETE => CMS_log::LOG_ACTION_RESOURCE_DELETE, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_UNDELETE => CMS_log::LOG_ACTION_RESOURCE_UNDELETE, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_ARCHIVE => CMS_log::LOG_ACTION_RESOURCE_ARCHIVE, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_UNARCHIVE => CMS_log::LOG_ACTION_RESOURCE_UNARCHIVE, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_CANCEL_EDITIONS => CMS_log::LOG_ACTION_RESOURCE_CANCEL_EDITIONS, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_VALIDATE_EDITION => CMS_log::LOG_ACTION_RESOURCE_VALIDATE_EDITION, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_START_DRAFT => CMS_log::LOG_ACTION_RESOURCE_START_DRAFT, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_EDIT_DRAFT => CMS_log::LOG_ACTION_RESOURCE_EDIT_DRAFT, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_DELETE_DRAFT => CMS_log::LOG_ACTION_RESOURCE_DELETE_DRAFT, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_SUBMIT_DRAFT => CMS_log::LOG_ACTION_RESOURCE_SUBMIT_DRAFT, CMS_log::MESSAGE_LOG_ACTION_RESOURCE_DIRECT_VALIDATION => CMS_log::LOG_ACTION_RESOURCE_DIRECT_VALIDATION, CMS_log::MESSAGE_LOG_ACTION_WEBSITE_ADD => CMS_log::LOG_ACTION_WEBSITE_ADD, CMS_log::MESSAGE_LOG_ACTION_WEBSITE_EDIT => CMS_log::LOG_ACTION_WEBSITE_EDIT, CMS_log::MESSAGE_LOG_ACTION_WEBSITE_DELETE => CMS_log::LOG_ACTION_WEBSITE_DELETE, CMS_log::MESSAGE_LOG_ACTION_PROFILE_GROUP_EDIT => CMS_log::LOG_ACTION_PROFILE_GROUP_EDIT, CMS_log::MESSAGE_LOG_ACTION_PROFILE_GROUP_DELETE => CMS_log::LOG_ACTION_PROFILE_GROUP_DELETE, CMS_log::MESSAGE_LOG_ACTION_PROFILE_USER_EDIT => CMS_log::LOG_ACTION_PROFILE_USER_EDIT, CMS_log::MESSAGE_LOG_ACTION_PROFILE_USER_DELETE => CMS_log::LOG_ACTION_PROFILE_USER_DELETE, CMS_log::MESSAGE_LOG_ACTION_TEMPLATE_EDIT => CMS_log::LOG_ACTION_TEMPLATE_EDIT, CMS_log::MESSAGE_LOG_ACTION_TEMPLATE_EDIT_ROW => CMS_log::LOG_ACTION_TEMPLATE_EDIT_ROW, CMS_log::MESSAGE_LOG_ACTION_TEMPLATE_DELETE => CMS_log::LOG_ACTION_TEMPLATE_DELETE, CMS_log::MESSAGE_LOG_ACTION_TEMPLATE_DELETE_ROW => CMS_log::LOG_ACTION_TEMPLATE_DELETE_ROW, CMS_log::MESSAGE_LOG_ACTION_TEMPLATE_EDIT_FILE => CMS_log::LOG_ACTION_TEMPLATE_EDIT_FILE, CMS_log::MESSAGE_LOG_ACTION_TEMPLATE_DELETE_FILE => CMS_log::LOG_ACTION_TEMPLATE_DELETE_FILE, CMS_log::MESSAGE_LOG_ACTION_SEND_EMAIL => CMS_log::LOG_ACTION_SEND_EMAIL, CMS_log::MESSAGE_LOG_ACTION_LOGIN => CMS_log::LOG_ACTION_LOGIN, CMS_log::MESSAGE_LOG_ACTION_AUTO_LOGIN => CMS_log::LOG_ACTION_AUTO_LOGIN, CMS_log::MESSAGE_LOG_ACTION_DISCONNECT => CMS_log::LOG_ACTION_DISCONNECT); return $modulesActions ? $modulesActions + $defaultActions : $defaultActions; }
$pageTemplateLabel = $cms_page->getTemplate() ? $cms_page->getTemplate()->getLabel() : ''; //page panel tip content $panelTipTitle = '<div id="tip-header-img">' . $cms_page->getStatus()->getHTML() . '</div> <div id="tip-header-text"> <strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_TITLE) . ' : </strong>' . $cms_page->getTitle() . '<br /> <strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_LINKTITLE) . ' : </strong>' . $cms_page->getLinkTitle() . '</div>'; $panelTip = '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_ID) . ' : </strong>' . $cms_page->getID() . '<br />'; if ($cms_page->getCodename()) { $panelTip .= '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_CODENAME) . ' : </strong>' . $cms_page->getCodename() . '<br />'; } $panelTip .= ' <strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_STATUS) . ' : </strong>' . $cms_page->getStatus()->getStatusLabel($cms_language) . '<br /> <strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_TEMPLATE) . ' : </strong>' . $pageTemplateLabel . '<br /> <strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_PUBLICATION) . ' : </strong>' . $cms_page->getStatus()->getPublicationRange($cms_language) . '<br />'; $lastupdate = CMS_log_catalog::getByResourceAction(MOD_STANDARD_CODENAME, $cms_page->getID(), CMS_log::LOG_ACTION_RESOURCE_SUBMIT_DRAFT, 1); $lastvalidation = CMS_log_catalog::getByResourceAction(MOD_STANDARD_CODENAME, $cms_page->getID(), CMS_log::LOG_ACTION_RESOURCE_VALIDATE_EDITION, 1); if ($lastupdate && is_object($lastupdate[0]) || $lastvalidation && is_object($lastvalidation[0])) { $panelTip .= '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_LASTCHANGES) . ' :</strong><br />'; $format = $cms_language->getDateFormat() . ' H:i:s'; } if ($lastupdate && is_object($lastupdate[0])) { $user = $lastupdate[0]->getUser(); $date = $lastupdate[0]->getDateTime(); $panelTip .= $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_LASTMODIFICATION, array($user->getFullName(), $date->getLocalizedDate($format))) . '<br />'; } if ($lastvalidation && is_object($lastvalidation[0])) { $user = $lastvalidation[0]->getUser(); $date = $lastvalidation[0]->getDateTime(); $panelTip .= $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_LASTVALIDATION, array($user->getFullName(), $date->getLocalizedDate($format))) . '<br />'; } if ($cms_page->isProtected()) {
} elseif (method_exists($resource, 'getTitle')) { $method = 'getTitle'; } if ($method) { $element = $resource->{$method}(); } if (!$element) { $element = $resource->getID(); } else { $element .= ' (' . $resource->getID() . ')'; } //get resource type label if (method_exists($module, 'getRessourceTypeLabelMethod') && $module->getRessourceTypeLabelMethod()) { $element = $resource->{$module->getRessourceTypeLabelMethod()}($cms_language) . ' : ' . $element; } else { $element .= ' (' . $module->getLabel($cms_language) . ')'; } } } else { $element = $status = ''; } $actionKey = array_search($log->getLogAction(), $actions); $actionLabel = io::isPositiveInteger($actionKey) ? $cms_language->getMessage($actionKey) : $actionKey; $feeds['items'][] = array('id' => $log->getID(), 'datetime' => $dt->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'), 'element' => $element, 'action' => $actionLabel, 'status' => $status, 'comment' => $log->getTextData()); } $feeds['total_count'] = CMS_log_catalog::search('', 0, $userId, array(), false, false, $start, $limit, $order, $direction, true); $feeds['version'] = 1; $view->setContent($feeds); break; } $view->show();
if (method_exists($module, 'getRessourceTypeLabelMethod') && $module->getRessourceTypeLabelMethod()) { $element = $resource->{$module->getRessourceTypeLabelMethod()}($cms_language) . ' : ' . $element; } else { $element .= ' (' . $module->getLabel($cms_language) . ')'; } } } else { $element = $status = ''; } $actionKey = array_search($log->getLogAction(), $actions); $actionLabel = io::isPositiveInteger($actionKey) ? $cms_language->getMessage($actionKey) : $actionKey; $datas = array('id' => $log->getID(), 'datetime' => $dt->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'), 'element' => $element, 'action' => $actionLabel, 'user' => $user->getFullname(), 'userId' => $user->getUserId(), 'status' => $status, 'comment' => $log->getTextData()); $logsDatas['logs'][] = $datas; } //total logs count for search $logsDatas['totalCount'] = CMS_log_catalog::search($codename, $pageId, $userId, $types, $datestart, $dateend, $start, $limit, 'datetime', 'desc', true); } //export datas as CSV if ($export) { $array2csv = new CMS_array2csv('logs-' . date('Y-m-d') . '.csv'); //add header $array2csv->addDatas(array($cms_language->getMessage(MESSAGE_PAGE_FIELD_DATE), $cms_language->getMessage(MESSAGE_PAGE_FIELD_ELEMENT), $cms_language->getMessage(MESSAGE_PAGE_FIELD_ACTION), $cms_language->getMessage(MESSAGE_PAGE_FIELD_USER), $cms_language->getMessage(MESSAGE_PAGE_FIELD_STATUS), $cms_language->getMessage(MESSAGE_PAGE_FIELD_COMMENTS))); //add datas foreach ($logsDatas['logs'] as $datas) { unset($datas['id']); unset($datas['userId']); $array2csv->addDatas($datas); } //get csv file $file = $array2csv->getFile(); //send to download
$modules['modules'][] = array('codename' => MOD_STANDARD_CODENAME, 'label' => $cms_language->getMessage(MESSAGE_PAGE_STANDARD_MODULE_LABEL)); foreach ($allModules as $module) { if ($module->getCodename() != MOD_STANDARD_CODENAME) { $modules['modules'][] = array('codename' => $module->getCodename(), 'label' => $module->getLabel($cms_language)); } } //json encode groups datas $modules = sensitiveIO::jsonEncode($modules); //types $types = array(); $types['types'][] = array('id' => 'all', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_ALL)); $types['types'][] = array('id' => 'admin', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_ADMIN)); $types['types'][] = array('id' => 'resource', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_PUBLICATION)); $types['types'][] = array('id' => 'login', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_IDENTIFICATION)); $types['types'][] = array('id' => 'email', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_EMAILS)); $modulesActions = CMS_log_catalog::getModulesActions($cms_language); if ($modulesActions) { $types['types'][] = array('id' => 'modules', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_MODULES)); } //json encode groups datas $types = sensitiveIO::jsonEncode($types); if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $purgeLogs = ",'->',{\n\t\t\txtype:\t\t'button',\n\t\t\ticonCls:\t'atm-pic-deletion',\n\t\t\ttext:\t\t'{$cms_language->getJsMessage(MESSAGE_ACTION_PURGE)}',\n\t\t\ttooltip:\t'{$cms_language->getJsMessage(MESSAGE_ACTION_PURGE_DESC)}',\n\t\t\thandler:\tfunction(button) {\n\t\t\t\tAutomne.message.popup({\n\t\t\t\t\tmsg: \t\t\t\t'{$cms_language->getJsMessage(MESSAGE_ACTION_PURGE_CONFIRM)}',\n\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\tanimEl: \t\t\tbutton.getEl(),\n\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\tvar formValues = Ext.getCmp('logsSearchPanel').getForm().getValues();\n\t\t\t\t\t\t\tparams = Ext.apply(formValues, {\n\t\t\t\t\t\t\t\tdel:\t\t\ttrue,\n\t\t\t\t\t\t\t\tlimit:\t\t\t0,\n\t\t\t\t\t\t\t\tstart:\t\t\t0\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tAutomne.server.call('logs-datas.php', function() {\n\t\t\t\t\t\t\t\tlogWindow.launchSearch();\n\t\t\t\t\t\t\t}, params);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}"; } else { $purgeLogs = ''; } $dateFormat = $cms_language->getDateFormat(); $jscontent = <<<END \tvar logWindow = Ext.getCmp('{$winId}'); \t \t//set window title
/** * Treat given content tag by this module for the specified treatment mode, visualization mode and object. * * @param string $tag The CMS_XMLTag. * @param string $tagContent previous tag content. * @param integer $treatmentMode The current treatment mode (see constants on top of CMS_modulesTags class for accepted values). * @param integer $visualizationMode The current visualization mode (see constants on top of cms_page class for accepted values). * @param object $treatedObject The reference object to treat. * @param array $treatmentParameters : optionnal parameters used for the treatment. Usually an array of objects. * @return string the tag content treated. * @access public */ function treatWantedTag(&$tag, $tagContent, $treatmentMode, $visualizationMode, &$treatedObject, $treatmentParameters) { switch ($treatmentMode) { case MODULE_TREATMENT_BLOCK_TAGS: if (!$treatedObject instanceof CMS_row) { $this->raiseError('$treatedObject must be a CMS_row object'); return false; } if (!$treatmentParameters["page"] instanceof CMS_page) { $this->raiseError('$treatmentParameters["page"] must be a CMS_page object'); return false; } if (!$treatmentParameters["language"] instanceof CMS_language) { $this->raiseError('$treatmentParameters["language"] must be a CMS_language object'); return false; } if (!$treatmentParameters["clientSpace"] instanceof CMS_moduleClientspace) { $this->raiseError('$treatmentParameters["clientSpace"] must be a CMS_moduleClientspace object'); return false; } if ($tag->getName() == 'row') { //replace {{pageID}} tag in all page content. return str_replace('{{pageID}}', $treatmentParameters["page"]->getID(), $tag->getInnerContent()); } else { //create the block data $block = $tag->getRepresentationInstance(); return $block->getData($treatmentParameters["language"], $treatmentParameters["page"], $treatmentParameters["clientSpace"], $treatedObject, $visualizationMode); } break; case MODULE_TREATMENT_CLIENTSPACE_TAGS: if (!$treatedObject instanceof CMS_pageTemplate) { $this->raiseError('$treatedObject must be a CMS_pageTemplate object'); return false; } if (!$treatmentParameters["page"] instanceof CMS_page) { $this->raiseError('$treatmentParameters["page"] must be a CMS_page object'); return false; } if (!$treatmentParameters["language"] instanceof CMS_language) { $this->raiseError('$treatmentParameters["language"] must be a CMS_language object'); return false; } $args = array("template" => $treatedObject->getID()); if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_HTML_EDITION || $visualizationMode == PAGE_VISUALMODE_FORM) { $args["editedMode"] = true; } //load CS datas switch ($tag->getName()) { case 'atm-clientspace': default: $client_space = $tag->getRepresentationInstance($args); switch ($visualizationMode) { case PAGE_VISUALMODE_PRINT: $data = ""; $clientSpacesData = array(); $csTagID = $tag->getAttribute("id"); $printingCS = $treatedObject->getPrintingClientSpaces(); if (in_array($csTagID, $printingCS)) { $clientSpacesData[$csTagID] = $client_space->getData($treatmentParameters["language"], $treatmentParameters["page"], $visualizationMode, $treatedObject->hasPages()); } foreach ($printingCS as $cs) { if (isset($clientSpacesData[$cs])) { $data .= $clientSpacesData[$cs] . '<br />'; } } return $data; break; default: if (is_object($client_space)) { return $client_space->getData($treatmentParameters["language"], $treatmentParameters["page"], $visualizationMode, false); } else { return ''; } break; } break; } break; case MODULE_TREATMENT_LINXES_TAGS: switch ($tag->getName()) { case "atm-linx": //linx are visible only if target pages are published (public tree) $linx_args = array("page" => $treatedObject, "publicTree" => true); $linx = $tag->getRepresentationInstance($linx_args); return $linx->getOutput(true); break; } return ''; break; case MODULE_TREATMENT_PAGECONTENT_TAGS: if (!$treatedObject instanceof CMS_page) { $this->raiseError('$treatedObject must be a CMS_page object'); return false; } switch ($tag->getName()) { case "atm-main-url": return CMS_websitesCatalog::getMainURL(); break; case "atm-keywords": return '<meta name="keywords" content="' . SensitiveIO::sanitizeHTMLString($treatedObject->getKeywords($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC)) . '" />'; break; case "atm-description": return '<meta name="description" content="' . SensitiveIO::sanitizeHTMLString($treatedObject->getDescription($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC)) . '" />'; break; case "atm-last-update": $lastlog = CMS_log_catalog::getByResourceAction(MOD_STANDARD_CODENAME, $treatedObject->getID(), array(CMS_log::LOG_ACTION_RESOURCE_SUBMIT_DRAFT, CMS_log::LOG_ACTION_RESOURCE_DIRECT_VALIDATION), 1); if (!$lastlog || !is_object($lastlog[0])) { return ''; } $user = $lastlog[0]->getUser(); $date = $lastlog[0]->getDateTime(); $dateformat = $tag->getAttribute("format") ? $tag->getAttribute("format") : 'Y-m-d'; $replace = array('{{date}}' => date($dateformat, $date->getTimestamp()), '{{firstname}}' => $user->getFirstName(), '{{lastname}}' => $user->getLastName()); return str_replace(array_keys($replace), $replace, $tag->getInnerContent()); break; case "atm-print-link": if ($treatedObject->getPrintStatus()) { $template = $tag->getInnerContent(); if ($tag->getAttribute("keeprequest") == 'true') { return '<?php echo \'' . str_replace("{{href}}", $treatedObject->getURL(true) . '\'.($_SERVER["QUERY_STRING"] ? \'?\'.$_SERVER["QUERY_STRING"] : \'\').\'', str_replace("\\\\'", "\\'", str_replace("'", "\\'", $template))) . '\' ?>'; } else { return str_replace("{{href}}", $treatedObject->getURL(true), $template); } } return ''; break; case "atm-constant": $const = SensitiveIO::stripPHPTags(io::strtoupper($tag->getAttribute("name"))); if (defined($const)) { return constant($const); } return ''; break; case "head": $headCode = '<?php' . "\n" . '$atmHost = null;' . "\n" . '$atmPort = null;' . "\n" . 'if(isset($_SERVER["HTTP_HOST"])) {' . "\n" . ' $atmHost = @parse_url($_SERVER["HTTP_HOST"], PHP_URL_HOST) ? @parse_url($_SERVER["HTTP_HOST"], PHP_URL_HOST) : $_SERVER["HTTP_HOST"];' . "\n" . ' $atmPort = @parse_url($_SERVER[\'HTTP_HOST\'], PHP_URL_PORT) ? \':\'.@parse_url($_SERVER[\'HTTP_HOST\'], PHP_URL_PORT) : \'\';' . "\n" . '}' . "\n" . 'echo "\\t".\'<base href="//\'.$atmHost.$atmPort.PATH_REALROOT_WR.\'/" />\'."\\n";' . "\n" . ' ?>'; //Append base code return preg_replace('#<head([^>]*)>#', '<head\\1>' . "\n" . $headCode, $tag->getContent()); break; case "body": $statsCode = '<?php if (SYSTEM_DEBUG && STATS_DEBUG) {echo CMS_stats::view();} ?>'; //Append stats code return preg_replace('#</body>$#', $statsCode . "\n" . '</body>', $tag->getContent()); break; case "html": //Append DTD return '<?php if (defined(\'APPLICATION_XHTML_DTD\')) echo APPLICATION_XHTML_DTD."\\n"; ?>' . "\n" . $tag->getContent(); break; } return ''; break; case MODULE_TREATMENT_PAGEHEADER_TAGS: if (!$treatedObject instanceof CMS_page) { $this->raiseError('$treatedObject must be a CMS_page object'); return false; } switch ($tag->getName()) { case "atm-linx": if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_FORM) { //direct linx are visible even if target pages are not published (edited tree) //all other linx are only visible if they are published (public tree) $linx_args = array("page" => $treatedObject, "publicTree" => !($tag->getAttribute('type') == 'direct' || !$tag->getAttribute('type'))); $linx = $tag->getRepresentationInstance($linx_args); $linx->setDebug(false); $linx->setLog(false); return $linx->getOutput(); } else { //for public and print visualmode, this treatment is done by MODULE_TREATMENT_LINXES_TAGS mode during page file linx treatment if ($visualizationMode != PAGE_VISUALMODE_HTML_PUBLIC && $visualizationMode != PAGE_VISUALMODE_PRINT) { //linx are visible only if target pages are published (public tree) $linx_args = array("page" => $treatedObject, "publicTree" => true); $linx = $tag->getRepresentationInstance($linx_args); return $linx->getOutput(); } } break; case "atm-js-tags": case "atm-css-tags": $usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename); $tagFiles = $tag->getAttribute('files'); $tagFiles = array_map('trim', explode(',', $tagFiles)); //only if current page use a block of this module if ($tagFiles) { //save in global var the page ID who use this tag CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array($tag->getName() => true)); $return = ''; //overwrite previous modules return to append files of this module //save new modules files switch ($tag->getName()) { case "atm-js-tags": //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-js-tags"); $files = is_array($files) ? $files : array(); //append module js files $files = array_merge($files, $tagFiles); //append CMS_function.js file if (!isset($usage['js-files']) && file_exists(PATH_JS_FS . '/CMS_functions.js')) { $file = str_replace(PATH_REALROOT_FS . '/', '', PATH_JS_FS . '/CMS_functions.js'); $files = array_merge($files, array($file)); } //append swfobject for block flash if (is_array($usage) && isset($usage['blockflash']) && $usage['blockflash'] == true) { $files[] = 'swfobject'; } //save files CMS_module::moduleUsage($treatedObject->getID(), $tag->getName(), $files, true); break; case "atm-css-tags": //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags"); $files = is_array($files) ? $files : array(); $media = $tag->getAttribute('media') ? $tag->getAttribute('media') : 'all'; //append module css files if (!isset($files[$media])) { $files[$media] = array(); } $files[$media] = array_merge($files[$media], $tagFiles); //save files CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags", $files, true); break; } //Create return for all saved modules files switch ($tag->getName()) { case "atm-js-tags": //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-js-tags"); //add files from atm-js-add tag $filesAdd = CMS_module::moduleUsage($treatedObject->getID(), "atm-js-tags-add"); $filesAdd = is_array($filesAdd) ? $filesAdd : array(); $files = array_merge($files, $filesAdd); $return .= '<?php echo CMS_view::getJavascript(array(\'' . implode('\',\'', array_unique($files)) . '\')); ?>' . "\n"; break; case "atm-css-tags": $media = $tag->getAttribute('media') ? $tag->getAttribute('media') : 'all'; //get old files for this tag already needed by other modules $files = CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags"); //add files from atm-css-add tag $filesAdd = CMS_module::moduleUsage($treatedObject->getID(), "atm-css-tags-add"); $filesAdd = is_array($filesAdd) ? $filesAdd : array(); if (isset($files[$media])) { if (isset($filesAdd[$media])) { $files[$media] = array_merge($files[$media], $filesAdd[$media]); } $return .= '<?php echo CMS_view::getCSS(array(\'' . implode('\',\'', array_unique($files[$media])) . '\'), \'' . $media . '\'); ?>' . "\n"; } break; } return $return; } break; case "atm-meta-tags": $attributes = array(); //normalize values for attributes if ($tag->getAttributes()) { $attributes = $tag->getAttributes(); foreach ($attributes as $tagName => $value) { if ($attributes == '1' || $value == 'true') { $attributes[$tagName] = true; } elseif ($value == '0' || $value == 'false') { $attributes[$tagName] = false; } if ($attributes[$tagName] !== false && $attributes[$tagName] !== true) { unset($attributes[$tagName]); } } } $metaDatas = $treatedObject->getMetaTags($visualizationMode == PAGE_VISUALMODE_HTML_PUBLIC, $attributes); $usage = CMS_module::moduleUsage($treatedObject->getID(), $this->_codename); //if page template already use atm-js-tags tag, no need to add JS again if (!is_array($usage) || !isset($usage['atm-js-tags'])) { $metaDatas .= ' <script type="text/javascript" src="' . PATH_REALROOT_WR . '/js/CMS_functions.js"></script>' . "\n"; //save JS handled CMS_module::moduleUsage($treatedObject->getID(), $this->_codename, array('js-files' => true)); } if ($visualizationMode == PAGE_VISUALMODE_FORM) { global $cms_user; $isValidator = is_object($cms_user) && $cms_user->hasPageClearance($treatedObject->getID(), CLEARANCE_PAGE_EDIT) && $cms_user->hasValidationClearance(MOD_STANDARD_CODENAME) ? 'true' : 'false'; //add needed javascripts $metaDatas .= '<script type="text/javascript">' . "\n" . 'var atmRowsDatas = {};' . "\n" . 'var atmBlocksDatas = {};' . "\n" . 'var atmCSDatas = {};' . "\n" . 'var atmIsValidator = ' . $isValidator . ';' . "\n" . 'var atmIsValidable = true;' . "\n" . 'var atmHasPreview = true;' . "\n" . 'var atmHasPreview = true;' . "\n" . 'var CKEDITOR_BASEPATH = \'' . PATH_MAIN_WR . '/ckeditor/\';' . "\n" . '</script>'; //append JS from current view instance $view = CMS_view::getInstance(); $metaDatas .= $view->getJavascript(); $metaDatas .= CMS_view::getCSS(array('edit')); } else { if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM) { //add needed javascripts $metaDatas .= '<script type="text/javascript">' . "\n" . 'var atmRowsDatas = {};' . "\n" . 'var atmBlocksDatas = {};' . "\n" . 'var atmCSDatas = {};' . "\n" . 'var atmIsValidator = false;' . "\n" . 'var atmIsValidable = false;' . "\n" . 'var atmHasPreview = false;' . "\n" . 'var CKEDITOR_BASEPATH = \'' . PATH_MAIN_WR . '/ckeditor/\';' . "\n" . '</script>'; //append JS from current view instance $view = CMS_view::getInstance(); $metaDatas .= $view->getJavascript(); $metaDatas .= CMS_view::getCSS(array('edit')); } } //if page template already use atm-js-tags tag, no need to add JS again if (!is_array($usage) || !isset($usage['atm-js-tags'])) { //if this page use a row block of this module then add the header code to the page if (is_array($usage) && isset($usage['blockflash']) && $usage['blockflash'] == true) { $metaDatas .= '<script type="text/javascript" src="' . PATH_MAIN_WR . '/swfobject/swfobject.js"></script>' . "\n"; } } return $metaDatas; break; } return ''; break; case MODULE_TREATMENT_WYSIWYG_INNER_TAGS: if ($tag->getName() == 'atm-linx') { //linx from standard module $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<html>' . $tag->getContent() . '</html>'); } catch (DOMException $e) { $this->raiseError('Parse error for atm-linx : ' . $e->getMessage() . " :\n" . io::htmlspecialchars($tag->getContent())); return ''; } $nodespecs = $domdocument->getElementsByTagName('nodespec'); if ($nodespecs->length == 1) { $nodespec = $nodespecs->item(0); } $htmltemplates = $domdocument->getElementsByTagName('htmltemplate'); if ($htmltemplates->length == 1) { $htmltemplate = $htmltemplates->item(0); } $noselections = $domdocument->getElementsByTagName('noselection'); if ($noselections->length == 1) { $noselection = $noselections->item(0); } if ($nodespec && $htmltemplate) { //if ($paramsTags[0]->getName() == "nodespec" && $paramsTags[1]->getName() == "noselection" && $paramsTags[2]->getName() == "htmltemplate") { if (isset($noselection)) { // case noselection tag $pageID = $nodespec->getAttribute("value"); $link = CMS_DOMDocument::DOMElementToString($htmltemplate, true); $treatedLink = str_replace('href', 'noselection="true" href', str_replace('{{href}}', '{{' . $pageID . '}}', $link)); } else { $pageID = $nodespec->getAttribute("value"); $link = CMS_DOMDocument::DOMElementToString($htmltemplate, true); $treatedLink = str_replace('{{href}}', '{{' . $pageID . '}}', $link); } } } elseif ($tag->getName() == 'span') { //linx from other module $ids = explode('-', $tag->getAttribute('id')); $selectedPageID = (int) $ids[1]; $noselection = $ids[2]; //then create the code to paste for the current selected object if any if (sensitiveIO::isPositiveInteger($selectedPageID) && ($noselection == 'true' || $noselection == 'false')) { $pattern = "/(.*)<a([^>]*)'\\.CMS_tree.*, 'url'\\)\\.'(.*)\\<\\/a>(.*)<\\/span>/U"; if ($noselection == 'true') { $replacement = '<a noselection="true"\\2{{' . $selectedPageID . '}}\\3</a>'; } else { $replacement = '<a\\2{{' . $selectedPageID . '}}\\3</a>'; } $treatedLink = str_replace("\\'", "'", preg_replace($pattern, $replacement, $tag->getContent())); } } return $treatedLink; case MODULE_TREATMENT_WYSIWYG_OUTER_TAGS: //Anchor if (preg_match('/^#([a-zA-Z0-9._{}:-]*)$/i', $tag->getAttribute('href')) > 0) { //instanciate anchor tag $anchor = new CMS_XMLTag_anchor($tag->getName(), $tag->getAttributes(), $tag->getChildren(), $tag->getParameters()); return $anchor->compute(array('mode' => $treatmentMode, 'visualization' => $visualizationMode, 'object' => $treatedObject, 'parameters' => $treatmentParameters)); } elseif (preg_match('/^.*\\{\\{(\\d+)\\}\\}.*$/i', $tag->getAttribute('href')) > 0) { //internal links /* Pattern explanation : * * \<a([^>]*) : start with "<a" and any characters after except a ">". Content found into the "()" (first parameters of the link) is the first variable : "\\1" * {{(\d+)}} : some numbers only into "{{" and "}}". Content found into the "()" (the page number) is the second variable : "\\2" * (.*)\<\/a> : any characters after followed by "</a>". Content found into the "()" (last parameters of the link and link content) is the third variable : "\\3" * /U : PCRE_UNGREEDY stop to the first finded occurence. */ $pattern = "/<a([^>]*){{(\\d+)}}(.*)\\<\\/a>/Us"; if ($tag->getName() == 'a' && $treatmentParameters['module'] == MOD_STANDARD_CODENAME) { if ($tag->getAttribute('noselection') == 'true') { $replacement = "<atm-linx type=\"direct\"><selection><start><nodespec type=\"node\" value=\"\\2\"/></start></selection><noselection>" . $tag->getInnerContent() . "</noselection><display><htmltemplate><a\\1{{href}}\\3</a></htmltemplate></display></atm-linx>"; $treatedLink = preg_replace($pattern, $replacement, str_replace('noselection="true"', '', $tag->getContent())); } else { $replacement = "<atm-linx type=\"direct\"><selection><start><nodespec type=\"node\" value=\"\\2\"/></start></selection><display><htmltemplate><a\\1{{href}}\\3</a></htmltemplate></display></atm-linx>"; $treatedLink = preg_replace($pattern, $replacement, $tag->getContent()); } } elseif ($tag->getName() == 'a' && $treatmentParameters['module'] != MOD_STANDARD_CODENAME) { if ($tag->getAttribute('noselection') == 'true') { $replacement = '<span id="' . MOD_STANDARD_CODENAME . '-\\2-true"><?php if (CMS_tree::pageExistsForUser(\\2)) { echo \'<a\\1\'.CMS_tree::getPageValue(\\2, \'url\').\'\\3</a>\';} else { echo ' . var_export($tag->getInnerContent(), true) . ';} ?><!--{elements:' . base64_encode(serialize(array('module' => array(0 => MOD_STANDARD_CODENAME)))) . '}--></span>'; $treatedLink = preg_replace($pattern, $replacement, str_replace(array('noselection="true"', "'"), array('', "\\'"), $tag->getContent())); } else { $replacement = '<span id="' . MOD_STANDARD_CODENAME . '-\\2-false"><?php if (CMS_tree::pageExistsForUser(\\2)) { echo \'<a\\1\'.CMS_tree::getPageValue(\\2, \'url\').\'\\3</a>\';} ?><!--{elements:' . base64_encode(serialize(array('module' => array(0 => MOD_STANDARD_CODENAME)))) . '}--></span>'; $treatedLink = preg_replace($pattern, $replacement, str_replace("'", "\\'", $tag->getContent())); } } return $treatedLink; } break; } //in case of no tag treatment, simply return it return $tag->getContent(); }
\t\t\t\t\tdisplayMsg: \t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_LOG_X_ON)}', \t\t\t\t\temptyMsg: \t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_NO_LOG)} ...' \t\t\t\t}) \t\t\t}); \t\t\tlogPanel.add(grid); \t\t\t//redo windows layout \t\t\tlogPanel.doLayout(); END; $view->addJavascript($jscontent); break; case 'search': //set default display mode for this page $view->setDisplayMode(CMS_view::SHOW_JSON); //This file is an admin file. Interface must be secure $view->setSecure(); $actionlabels = CMS_log_catalog::getAllActions($cms_language); $actions = CMS_log_catalog::getByResource(MOD_STANDARD_CODENAME, $cms_page->getID(), $start, $limit, $order, $direction); $feeds = array(); $feeds['items'] = array(); foreach ($actions as $action) { $dt = $action->getDatetime(); $usr = $action->getUser(); $status = $action->getResourceStatusAfter(); $feeds['items'][] = array('id' => $action->getID(), 'status' => $status->getHTML(true, false, false, false, false), 'datetime' => $dt->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'), 'action' => $cms_language->getMessage(array_search($action->getLogAction(), $actionlabels)), 'user' => array($usr->getUserId(), $usr->getFullName()), 'text' => $action->getTextData()); } $feeds['total_count'] = CMS_log_catalog::getByResource(MOD_STANDARD_CODENAME, $cms_page->getID(), $start, $limit, $order, $direction, true); $feeds['version'] = 1; $view->setContent($feeds); break; } $view->show();