/** * sort function * * @param \Cx\Core\ContentManager\Model\Entity\Page $pageA * @param \Cx\Core\ContentManager\Model\Entity\Page $pageB * @return int */ private function sortPages($pageA, $pageB) { $pageATermOnlyInContent = preg_match('#(' . $this->term . ')#i', $pageA->getContent()) && !preg_match('#(' . $this->term . ')#i', $pageA->getTitle()) && !preg_match('#(' . $this->term . ')#i', $pageA->getContentTitle()) && !preg_match('#(' . $this->term . ')#i', $pageA->getSlug()) && !preg_match('#(' . $this->term . ')#i', $pageA->getModule()) && !preg_match('#(' . $this->term . ')#i', $pageA->getCmd()); $pageBTermOnlyInContent = preg_match('#(' . $this->term . ')#i', $pageB->getContent()) && !preg_match('#(' . $this->term . ')#i', $pageB->getTitle()) && !preg_match('#(' . $this->term . ')#i', $pageB->getContentTitle()) && !preg_match('#(' . $this->term . ')#i', $pageB->getSlug()) && !preg_match('#(' . $this->term . ')#i', $pageB->getModule()) && !preg_match('#(' . $this->term . ')#i', $pageB->getCmd()); if ($pageATermOnlyInContent == $pageBTermOnlyInContent) { return 0; } if ($pageATermOnlyInContent && !$pageBTermOnlyInContent) { return 1; } return -1; }
/** * Parses the main template in order to finish request * @todo Remove usage of globals * @global type $themesPages * @global null $moduleStyleFile * @global array $_CONFIG * @global type $subMenuTitle * @global type $_CORELANG * @global type $plainCmd * @global type $cmd */ protected function finalize() { global $themesPages, $moduleStyleFile, $_CONFIG, $subMenuTitle, $_CORELANG, $plainCmd, $cmd; if ($this->mode == self::MODE_FRONTEND) { // parse system $parsingTime = $this->stopTimer(); $this->template->setVariable('PARSING_TIME', $parsingTime); $this->parseGlobalPlaceholders($themesPages['sidebar']); $this->template->setVariable(array('SIDEBAR_FILE' => $themesPages['sidebar'], 'JAVASCRIPT_FILE' => $themesPages['javascript'], 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'DATE_YEAR' => date('Y'), 'DATE_MONTH' => date('m'), 'DATE_DAY' => date('d'), 'DATE_TIME' => date('H:i'), 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'JAVASCRIPT_LIGHTBOX' => '<script type="text/javascript" src="lib/lightbox/javascript/mootools.js"></script> <script type="text/javascript" src="lib/lightbox/javascript/slimbox.js"></script>', 'JAVASCRIPT_MOBILE_DETECTOR' => '<script type="text/javascript" src="lib/mobiledetector.js"></script>')); if (!empty($moduleStyleFile)) { $this->template->setVariable('STYLE_FILE', "<link rel=\"stylesheet\" href=\"{$moduleStyleFile}\" type=\"text/css\" media=\"screen, projection\" />"); } if (!$this->resolvedPage->getUseSkinForAllChannels() && isset($_GET['pdfview']) && intval($_GET['pdfview']) == 1) { $pageTitle = $this->resolvedPage->getTitle(); $extenstion = empty($pageTitle) ? null : '.pdf'; $objPDF = new \Cx\Core_Modules\Pdf\Model\Entity\PdfDocument(); $objPDF->SetTitle($pageTitle . $extenstion); $objPDF->setContent($this->template->get()); $objPDF->Create(); exit; } // fetch the parsed webpage $this->template->setVariable('JAVASCRIPT', 'javascript_inserting_here'); $endcode = $this->template->get(); /** * Get all javascripts in the code, replace them with nothing, and register the js file * to the javascript lib. This is because we don't want something twice, and there could be * a theme that requires a javascript, which then could be used by a module too and therefore would * be loaded twice. */ /* Finds all uncommented script tags, strips them out of the HTML and * stores them internally so we can put them in the placeholder later * (see JS::getCode() below) */ \JS::findJavascripts($endcode); /* * Proposal: Use this * $endcode = preg_replace_callback('/<script\s.*?src=(["\'])(.*?)(\1).*?\/?>(?:<\/script>)?/i', array('JS', 'registerFromRegex'), $endcode); * and change JS::registerFromRegex to use index 2 */ // i know this is ugly, but is there another way $endcode = str_replace('javascript_inserting_here', \JS::getCode(), $endcode); // do a final replacement of all those node-urls ({NODE_<ID>_<LANG>}- placeholders) that haven't been captured earlier $endcode = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $endcode); \LinkGenerator::parseTemplate($endcode); // remove the meta tag X-UA-Compatible if the user agent ist neighter internet explorer nor chromeframe if (!preg_match('/(msie|chromeframe)/i', $_SERVER['HTTP_USER_AGENT'])) { $endcode = preg_replace('/<meta.*?X-UA-Compatible.*?>/i', '', $endcode); } // replace links from before contrexx 3 $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . \Env::get('virtualLanguageDirectory') . '/', $endcode); $this->endcode = $ls->replace(); } else { // backend meta navigation if ($this->template->blockExists('backend_metanavigation')) { // parse language navigation if ($this->template->blockExists('backend_language_navigation') && $this->template->blockExists('backend_language_navigation_item')) { $backendLanguage = \FWLanguage::getActiveBackendLanguages(); if (count($backendLanguage) > 1) { $this->template->setVariable('TXT_LANGUAGE', $_CORELANG['TXT_LANGUAGE']); foreach ($backendLanguage as $language) { $languageUrl = \Env::get('init')->getUriBy('setLang', $language['id']); $this->template->setVariable(array('LANGUAGE_URL' => contrexx_raw2xhtml($languageUrl), 'LANGUAGE_NAME' => $language['name'], 'LANGUAGE_CSS' => \Env::get('init')->getBackendLangId() == $language['id'] ? 'active' : '')); $this->template->parse('backend_language_navigation_item'); } $this->template->parse('backend_language_navigation'); } else { $this->template->hideBlock('backend_language_navigation'); } } $this->template->touchBlock('backend_metanavigation'); } // page parsing $parsingTime = $this->stopTimer(); // var_dump($parsingTime); /*echo ($finishTime[0] - $startTime[0]) . '<br />'; if (!isset($_SESSION['asdf1']) || isset($_GET['reset'])) { $_SESSION['asdf1'] = 0; $_SESSION['asdf2'] = 0; } echo $_SESSION['asdf1'] . '<br />'; if ($_SESSION['asdf1'] > 0) { echo $_SESSION['asdf2'] / $_SESSION['asdf1']; } $_SESSION['asdf1']++; $_SESSION['asdf2'] += ($finishTime[0] - $startTime[0]);//*/ $objAdminNav = new \adminMenu($plainCmd); $objAdminNav->getAdminNavbar(); $this->template->setVariable(array('SUB_MENU_TITLE' => $subMenuTitle, 'FRONTEND_LANG_MENU' => \Env::get('init')->getUserFrontendLangMenu(), 'TXT_GENERATED_IN' => $_CORELANG['TXT_GENERATED_IN'], 'TXT_SECONDS' => $_CORELANG['TXT_SECONDS'], 'TXT_LOGOUT_WARNING' => $_CORELANG['TXT_LOGOUT_WARNING'], 'PARSING_TIME' => $parsingTime, 'LOGGED_NAME' => htmlentities($this->getUser()->objUser->getProfileAttribute('firstname') . ' ' . $this->getUser()->objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_LOGGED_IN_AS' => $_CORELANG['TXT_LOGGED_IN_AS'], 'TXT_LOG_OUT' => $_CORELANG['TXT_LOG_OUT'], 'MODULE_INDEX' => MODULE_INDEX, 'JAVASCRIPT' => \JS::getCode(), 'CX_EDITION' => $_CONFIG['coreCmsEdition'], 'CX_VERSION' => $_CONFIG['coreCmsVersion'], 'CX_CODE_NAME' => $_CONFIG['coreCmsCodeName'], 'CX_STATUS' => $_CONFIG['coreCmsStatus'], 'CX_RELEASE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $_CONFIG['coreCmsReleaseDate']), 'CX_NAME' => $_CONFIG['coreCmsName'])); // Style parsing if (file_exists($this->codeBaseAdminTemplatePath . '/css/' . $cmd . '.css')) { // check if there's a css file in the core section $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseAdminTemplateWebPath . '/css/' . $cmd . '.css'); $this->template->parse('additional_style'); } elseif (file_exists($this->codeBaseModulePath . '/' . $cmd . '/template/backend.css')) { // of maybe in the current module directory $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseModuleWebPath . '/' . $cmd . '/template/backend.css'); $this->template->parse('additional_style'); } elseif (file_exists($this->codeBaseCoreModulePath . '/' . $cmd . '/template/backend.css')) { // or in the core module directory $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseCoreModuleWebPath . '/' . $cmd . '/template/backend.css'); $this->template->parse('additional_style'); } else { $this->template->hideBlock('additional_style'); } /*echo '<pre>'; print_r($_SESSION); /*echo '<b>Overall time: ' . (microtime(true) - $timeAtStart) . 's<br />'; echo 'Max RAM usage: ' . formatBytes(memory_get_peak_usage()) . '<br />'; echo 'End RAM usage: ' . formatBytes(memory_get_usage()) . '<br /></b>';*/ $endcode = $this->template->get(); // replace links from before contrexx 3 $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . $this->getBackendFolderName() . '/', $endcode); $this->endcode = $ls->replace(); } \DBG::log("(Cx: {$this->id}) Request parsing completed after {$parsingTime}"); }
/** * Load your component. * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function load(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_CORELANG, $objTemplate, $subMenuTitle; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: $newsObj = new News($page->getContent()); $page->setContent($newsObj->getNewsPage()); $newsObj->getPageTitle($page->getTitle()); if (substr($page->getCmd(), 0, 7) == 'details') { $page->setTitle($newsObj->newsTitle); $page->setContentTitle($newsObj->newsTitle); $page->setMetaTitle($newsObj->newsTitle); // Set the meta page description to the teaser text if displaying news details $teaser = $newsObj->getTeaser(); if ($teaser !== null) { $page->setMetadesc(contrexx_raw2xhtml(contrexx_strip_tags(html_entity_decode($teaser, ENT_QUOTES, CONTREXX_CHARSET)))); } } break; case \Cx\Core\Core\Controller\Cx::MODE_BACKEND: $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html'); $objTemplate = $this->cx->getTemplate(); \Permission::checkAccess(10, 'static'); $subMenuTitle = $_CORELANG['TXT_NEWS_MANAGER']; $objNews = new NewsManager(); $objNews->getPage(); break; default: break; } }
public function getTitle() { $this->_load(); return parent::getTitle(); }