/** * 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, $subMenuTitle, $objTemplate; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: $objJobs = new Jobs(\Env::get('cx')->getPage()->getContent()); \Env::get('cx')->getPage()->setContent($objJobs->getJobsPage()); if ($page->getCmd() === 'details') { $objJobs->getPageTitle(\Env::get('cx')->getPage()->getTitle()); \Env::get('cx')->getPage()->setTitle($objJobs->jobsTitle); \Env::get('cx')->getPage()->setContentTitle($objJobs->jobsTitle); \Env::get('cx')->getPage()->setMetaTitle($objJobs->jobsTitle); } 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(148, 'static'); $subMenuTitle = $_CORELANG['TXT_JOBS_MANAGER']; $objJobsManager = new JobsManager(); $objJobsManager->getJobsPage(); break; default: break; } }
/** * 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, $page, $objTemplate, $subMenuTitle; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: $newsObj = new News(\Env::get('cx')->getPage()->getContent()); \Env::get('cx')->getPage()->setContent($newsObj->getNewsPage()); $newsObj->getPageTitle(\Env::get('cx')->getPage()->getTitle()); // Set the meta page description to the teaser text if displaying news details $teaser = $newsObj->getTeaser(); if ($teaser !== null) { //news details, else getTeaser would return null $page->setMetadesc(contrexx_raw2xhtml(contrexx_strip_tags(html_entity_decode($teaser, ENT_QUOTES, CONTREXX_CHARSET)))); } if (substr($page->getCmd(), 0, 7) == 'details') { \Env::get('cx')->getPage()->setTitle($newsObj->newsTitle); \Env::get('cx')->getPage()->setContentTitle($newsObj->newsTitle); \Env::get('cx')->getPage()->setMetaTitle($newsObj->newsTitle); } 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; } }
/** * This is called by the default ComponentController and does all the repeating work * * This creates a template of the page content and calls parsePage($template) * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page */ public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_ARRAYLANG; // init component template $componentTemplate = new \Cx\Core\Html\Sigma('.'); $componentTemplate->setErrorHandling(PEAR_ERROR_DIE); $componentTemplate->setTemplate($page->getContent()); // default css and js if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Frontend.css'))) { \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Frontend.css', 1)); } if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Frontend.js'))) { \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Frontend.js', 1)); } // parse page $componentTemplate->setGlobalVariable($_ARRAYLANG); $this->parsePage($componentTemplate, $page->getCmd()); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($componentTemplate); $page->setContent($componentTemplate->get()); }
/** * Copies the content from the other page given. * @param \Cx\Core\ContentManager\Model\Entity\Page $page */ public function getFallbackContentFrom($page) { $this->isVirtual = true; $this->content = $page->getContent(); $this->module = $page->getModule(); $this->cmd = $page->getCmd(); $this->skin = $page->getSkin(); $this->customContent = $page->getCustomContent(); $this->cssName = $page->getCssName(); $this->cssNavName = $page->getCssNavName(); $this->type = $page->getType(); $this->target = $page->getTarget(); }
/** * 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; }
/** * Returns the type of the page as string. * * @param \Cx\Core\ContentManager\Model\Entity\Page $page * @return string $type */ public function getTypeByPage($page) { global $_CORELANG; switch ($page->getType()) { case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT: $criteria = array('nodeIdShadowed' => $page->getTargetNodeId(), 'lang' => $page->getLang()); $targetPage = $this->findOneBy($criteria); $targetTitle = $targetPage ? $targetPage->getTitle() : $page->getTarget(); $type = $_CORELANG['TXT_CORE_CM_TYPE_REDIRECT'] . ': '; $type .= $targetTitle; break; case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION: $type = $_CORELANG['TXT_CORE_CM_TYPE_APPLICATION'] . ': '; $type .= $page->getModule(); $type .= $page->getCmd() != '' ? ' | ' . $page->getCmd() : ''; break; case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK: $fallbackLangId = \FWLanguage::getFallbackLanguageIdById($page->getLang()); if ($fallbackLangId == 0) { $fallbackLangId = \FWLanguage::getDefaultLangId(); } $type = $_CORELANG['TXT_CORE_CM_TYPE_FALLBACK'] . ' '; $type .= \FWLanguage::getLanguageCodeById($fallbackLangId); break; default: $type = $_CORELANG['TXT_CORE_CM_TYPE_CONTENT']; } return $type; }
/** * Fetch the application template of a content page. * @param \Cx\Core\ContentManager\Model\Entity\Page $page The page object of which to fetch the application template from * @param String $component Optional argument to specify the component to load the template from, instead of using the page's module-attribute * @param String $themeType Optional argument to specify the output channel * @return String The content of the application template */ public static function getContentTemplateOfPage($page, $component = null, $themeType = \Cx\Core\View\Model\Entity\Theme::THEME_TYPE_WEB) { try { $component = empty($component) ? $page->getModule() : $component; $cmd = !$page->getCmd() ? 'Default' : ucfirst($page->getCmd()); $customAppTemplate = !$page->getApplicationTemplate() ? $cmd . '.html' : $page->getApplicationTemplate(); $moduleFolderName = contrexx_isCoreModule($page->getModule()) ? 'core_modules' : 'modules'; $themeFolderName = \Env::get('init')->getCurrentThemesPath(); // use application template for all output channels if ($page->getUseCustomApplicationTemplateForAllChannels() && $page->getSkin()) { $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository(); $themeFolderName = $themeRepo->findById($page->getSkin())->getFoldername(); } // use default theme in case a custom set theme is no longer available if (empty($themeFolderName)) { $themeRepo = new \Cx\Core\View\Model\Repository\ThemeRepository(); $themeFolderName = $themeRepo->getDefaultTheme($themeType, $page->getLang())->getFoldername(); } $cx = \Cx\Core\Core\Controller\Cx::instanciate(); // load custom application template from page's theme $themePath = $cx->getClassLoader()->getFilePath($cx->getWebsiteThemesPath() . '/' . $themeFolderName . '/' . $moduleFolderName . '/' . $component . '/Template/Frontend/' . $customAppTemplate); if ($themePath) { return file_get_contents($themePath); } // load default application template from page's theme if ($customAppTemplate != $cmd . '.html') { $themePath = $cx->getClassLoader()->getFilePath($cx->getWebsiteThemesPath() . '/' . $themeFolderName . '/' . $moduleFolderName . '/' . $component . '/Template/Frontend/' . $cmd . '.html'); if ($themePath) { return file_get_contents($themePath); } } // load default application template from component $modulePath = $cx->getClassLoader()->getFilePath($cx->getCodeBaseDocumentRootPath() . '/' . $moduleFolderName . '/' . $component . '/View/Template/Frontend/' . $cmd . '.html'); if ($modulePath) { return file_get_contents($modulePath); } return; } catch (\Exception $e) { throw new \Exception('Error fetching the content template:' . $e); } }
/** * Copies the content from the other page given. * @param \Cx\Core\ContentManager\Model\Entity\Page $page * @param boolean $includeThemeOptions (optional) Wheter to adopt theme options as well (default false) */ public function setContentOf($page, $includeThemeOptions = false) { $this->isVirtual = true; $this->content = $page->getContent(); $this->module = $page->getModule(); $this->cmd = $page->getCmd(); if ($includeThemeOptions) { $this->skin = $page->getSkin(); $this->customContent = $page->getCustomContent(); $this->applicationTemplate = $page->getApplicationTemplate(); $this->cssName = $page->getCssName(); } $this->cssNavName = $page->getCssNavName(); $this->type = $page->getType(); $this->target = $page->getTarget(); }
public function getCmd() { $this->_load(); return parent::getCmd(); }