/** * 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: define('CALENDAR_MANDATE', MODULE_INDEX); $objCalendar = new \Cx\Modules\Calendar\Controller\Calendar($page->getContent(), MODULE_INDEX); $page->setContent($objCalendar->getCalendarPage()); if ($objCalendar->pageTitle) { $page->setTitle($objCalendar->pageTitle); $page->setContentTitle($objCalendar->pageTitle); $page->setMetaTitle($objCalendar->pageTitle); } 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(16, 'static'); $subMenuTitle = $_CORELANG['TXT_CALENDAR']; $objCalendarManager = new \Cx\Modules\Calendar\Controller\CalendarManager(); $objCalendarManager->getCalendarPage(); 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()); }
/** * This is called by the default ComponentController and does all the repeating work * * This loads a template named after current $act and calls parsePage($actTemplate) * @todo $this->cx->getTemplate()->setVariable() should not be called here but in Cx class * @global array $_ARRAYLANG Language data * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page */ public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_ARRAYLANG, $subMenuTitle; $subMenuTitle = $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName())]; $cmd = array(''); if (isset($_GET['act'])) { $cmd = explode('/', contrexx_input2raw($_GET['act'])); } $actTemplate = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend'); $filename = $cmd[0] . '.html'; $testFilename = $cmd[0]; if (!\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $filename)) { $filename = 'Default.html'; $testFilename = 'Default'; } foreach ($cmd as $index => $name) { if ($index == 0) { continue; } $testFilename .= $name; if (\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $testFilename . '.html')) { $filename = $testFilename . '.html'; } else { break; } } $actTemplate->loadTemplateFile($filename); // todo: Messages $navigation = $this->parseNavigation($cmd); $this->parsePage($actTemplate, $cmd); $txt = $cmd[0]; if (empty($txt)) { $txt = 'DEFAULT'; } // default css and js if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Backend.css'))) { \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1)); } if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Backend.js'))) { \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Backend.js', 1)); } // finish $actTemplate->setGlobalVariable($_ARRAYLANG); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($actTemplate); $page->setContent($actTemplate->get()); $cachedRoot = $this->cx->getTemplate()->getRoot(); $this->cx->getTemplate()->setRoot(\Env::get('cx')->getCodeBaseCorePath() . '/Core/View/Template/Backend'); $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'ContentMaster.html'); $this->cx->getTemplate()->setRoot($cachedRoot); $this->cx->getTemplate()->setVariable(array('CONTENT_NAVIGATION' => $navigation->get(), 'ADMIN_CONTENT' => $page->getContent(), 'CONTENT_TITLE' => $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt)])); }
/** * Do something before content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $themesPages, $page_template; switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: // Get Headlines $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsHeadlines.class.php'; if (file_exists($modulespath)) { for ($i = 0; $i < 5; $i++) { $visibleI = ''; if ($i > 0) { $visibleI = (string) $i; } $headlinesNewsPlaceholder = '{HEADLINES' . $visibleI . '_FILE}'; if (strpos($page->getContent(), $headlinesNewsPlaceholder) !== false || strpos($themesPages['index'], $headlinesNewsPlaceholder) !== false || strpos($themesPages['sidebar'], $headlinesNewsPlaceholder) !== false || strpos($page_template, $headlinesNewsPlaceholder) !== false) { $category = 0; $matches = array(); if (preg_match('/\\{CATEGORY_([0-9]+)\\}/', trim($themesPages['headlines' . $visibleI]), $matches)) { $category = $matches[1]; } $newsHeadlinesObj = new NewsHeadlines($themesPages['headlines' . $visibleI]); $homeHeadlines = $newsHeadlinesObj->getHomeHeadlines($category); $page->setContent(str_replace($headlinesNewsPlaceholder, $homeHeadlines, $page->getContent())); $themesPages['index'] = str_replace($headlinesNewsPlaceholder, $homeHeadlines, $themesPages['index']); $themesPages['sidebar'] = str_replace($headlinesNewsPlaceholder, $homeHeadlines, $themesPages['sidebar']); $page_template = str_replace($headlinesNewsPlaceholder, $homeHeadlines, $page_template); } } } // Get Top news $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsTop.class.php'; $topNewsPlaceholder = '{TOP_NEWS_FILE}'; if (file_exists($modulespath) && (strpos($page->getContent(), $topNewsPlaceholder) !== false || strpos($themesPages['index'], $topNewsPlaceholder) !== false || strpos($themesPages['sidebar'], $topNewsPlaceholder) !== false || strpos($page_template, $topNewsPlaceholder) !== false)) { $newsTopObj = new NewsTop($themesPages['top_news']); $homeTopNews = $newsTopObj->getHomeTopNews(); $page->setContent(str_replace($topNewsPlaceholder, $homeTopNews, $page->getContent())); $themesPages['index'] = str_replace($topNewsPlaceholder, $homeTopNews, $themesPages['index']); $themesPages['sidebar'] = str_replace($topNewsPlaceholder, $homeTopNews, $themesPages['sidebar']); $page_template = str_replace($topNewsPlaceholder, $homeTopNews, $page_template); } // Get News categories $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsLibrary.class.php'; $newsCategoriesPlaceholder = '{NEWS_CATEGORIES}'; if (file_exists($modulespath) && (strpos($page->getContent(), $newsCategoriesPlaceholder) !== false || strpos($themesPages['index'], $newsCategoriesPlaceholder) !== false || strpos($themesPages['sidebar'], $newsCategoriesPlaceholder) !== false || strpos($page_template, $newsCategoriesPlaceholder) !== false)) { $newsLib = new NewsLibrary(); $newsCategories = $newsLib->getNewsCategories(); $page->setContent(str_replace($newsCategoriesPlaceholder, $newsCategories, $page->getContent())); $themesPages['index'] = str_replace($newsCategoriesPlaceholder, $newsCategories, $themesPages['index']); $themesPages['sidebar'] = str_replace($newsCategoriesPlaceholder, $newsCategories, $themesPages['sidebar']); $page_template = str_replace($newsCategoriesPlaceholder, $newsCategories, $page_template); } // Get News Archives $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsLibrary.class.php'; $newsArchivePlaceholder = '{NEWS_ARCHIVES}'; if (file_exists($modulespath) && (strpos($page->getContent(), $newsArchivePlaceholder) !== false || strpos($themesPages['index'], $newsArchivePlaceholder) !== false || strpos($themesPages['sidebar'], $newsArchivePlaceholder) !== false || strpos($page_template, $newsArchivePlaceholder) !== false)) { $newsLib = new NewsLibrary(); $newsArchive = $newsLib->getNewsArchiveList(); $page->setContent(str_replace($newsArchivePlaceholder, $newsArchive, $page->getContent())); $themesPages['index'] = str_replace($newsArchivePlaceholder, $newsArchive, $themesPages['index']); $themesPages['sidebar'] = str_replace($newsArchivePlaceholder, $newsArchive, $themesPages['sidebar']); $page_template = str_replace($newsArchivePlaceholder, $newsArchive, $page_template); } // Get recent News Comments $modulespath = ASCMS_CORE_MODULE_PATH . '/News/Controller/NewsRecentComments.class.php'; $newsCommentsPlaceholder = '{NEWS_RECENT_COMMENTS_FILE}'; if (file_exists($modulespath) && (strpos($page->getContent(), $newsCommentsPlaceholder) !== false || strpos($themesPages['index'], $newsCommentsPlaceholder) !== false || strpos($themesPages['sidebar'], $newsCommentsPlaceholder) !== false || strpos($page_template, $newsCommentsPlaceholder) !== false)) { $newsLib = new NewsRecentComments($themesPages['news_recent_comments']); $newsComments = $newsLib->getRecentNewsComments(); $page->setContent(str_replace($newsCommentsPlaceholder, $newsComments, $page->getContent())); $themesPages['index'] = str_replace($newsCommentsPlaceholder, $newsComments, $themesPages['index']); $themesPages['sidebar'] = str_replace($newsCommentsPlaceholder, $newsComments, $themesPages['sidebar']); $page_template = str_replace($newsCommentsPlaceholder, $newsComments, $page_template); } //Teasers $arrMatches = array(); // Set news teasers $config = \Env::get('config'); if ($config['newsTeasersStatus'] == '1') { // set news teasers in the content if (preg_match_all('/{TEASERS_([0-9A-Z_-]+)}/', $page->getContent(), $arrMatches)) { /** @ignore */ $objTeasers = new Teasers(); $content = $page->getContent(); $objTeasers->setTeaserFrames($arrMatches[1], $content); $page->setContent($content); } // set news teasers in the page design if (preg_match_all('/{TEASERS_([0-9A-Z_-]+)}/', $page_template, $arrMatches)) { /** @ignore */ $objTeasers = new Teasers(); $objTeasers->setTeaserFrames($arrMatches[1], $page_template); } // set news teasers in the website design if (preg_match_all('/{TEASERS_([0-9A-Z_-]+)}/', $themesPages['index'], $arrMatches)) { /** @ignore */ $objTeasers = new Teasers(); $objTeasers->setTeaserFrames($arrMatches[1], $themesPages['index']); } } break; default: break; } }
protected function loadContentTemplateOfPage() { global $plainSection; try { $contentTemplate = self::getContentTemplateOfPage($this->resolvedPage, $plainSection); // In case $contentTemplate is empty, do not replace placeholder {APPLICATION_DATA}. // In such cases the loaded component does have the opportunity to manulay parse {APPLICATION_DATA} itself. if (empty($contentTemplate)) { return; } $this->resolvedPage->setContent(str_replace('{APPLICATION_DATA}', $contentTemplate, $this->resolvedPage->getContent())); } catch (\Exception $e) { throw new \Exception('Error Loading the content template:' . $e); } }
/** * Add the necessary divs for the inline editing around the content and around the title * * @param \Cx\Core\ContentManager\Model\Entity\Page $page */ public function preContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { // Is frontend editing active? if (!$this->frontendEditingIsActive() || !$this->userHasPermissionToEditPage()) { return; } $componentTemplate = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/' . $this->getName() . '/View/Template/Generic'); $componentTemplate->setErrorHandling(PEAR_ERROR_DIE); // add div around content // not used at the moment, because we have no proper way to "not parse" blocks in content and // it should only print a div around the content without parsing the content at this time // $componentTemplate->loadTemplateFile('ContentDiv.html'); // $componentTemplate->setVariable('CONTENT', $page->getContent()); // $page->setContent($componentTemplate->get()); $page->setContent('<div id="fe_content">' . $page->getContent() . '</div>'); // add div around the title $componentTemplate->loadTemplateFile('TitleDiv.html'); $componentTemplate->setVariable('TITLE', $page->getContentTitle()); $page->setContentTitle($componentTemplate->get()); }
/** * This is called by the default ComponentController and does all the repeating work * * This loads a template named after current $act and calls parsePage($actTemplate) * @todo $this->cx->getTemplate()->setVariable() should not be called here but in Cx class * @global array $_ARRAYLANG Language data * @global $subMenuTitle * @param \Cx\Core\ContentManager\Model\Entity\Page $page Resolved page */ public function getPage(\Cx\Core\ContentManager\Model\Entity\Page $page) { global $_ARRAYLANG, $subMenuTitle; $subMenuTitle = $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName())]; $cmd = array(''); if (isset($_GET['act'])) { $cmd = explode('/', contrexx_input2raw($_GET['act'])); } else { $cmd[0] = 'Wysiwyg'; } $actTemplate = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend'); $filename = $cmd[0] . '.html'; $testFilename = $cmd[0]; if (!\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $filename)) { $filename = 'Default.html'; $testFilename = 'Default'; } foreach ($cmd as $index => $name) { if ($index == 0) { continue; } $testFilename .= $name; if (\Env::get('ClassLoader')->getFilePath($actTemplate->getRoot() . '/' . $testFilename . '.html')) { $filename = $testFilename . '.html'; } else { break; } } $actTemplate->loadTemplateFile($filename); // todo: Messages $this->parsePage($actTemplate, $cmd); // set tabs $navigation = new \Cx\Core\Html\Sigma(\Env::get('cx')->getCodeBaseCorePath() . '/Core/View/Template/Backend'); $navigation->loadTemplateFile('Navigation.html'); $commands = array_merge($this->getCommands()); foreach ($commands as $key => $command) { $subnav = array(); if (is_array($command)) { $subnav = array_merge(array(''), $command); $command = $key; } if ($key !== '') { if ($cmd[0] == $command) { $navigation->touchBlock('tab_active'); } else { $navigation->hideBlock('tab_active'); } $act = '&act=' . $command; $txt = $command; if (empty($command)) { $act = ''; $txt = 'DEFAULT'; } $actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt); $actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey; $navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle)); $navigation->parse('tab_entry'); } // subnav if ($cmd[0] == $command && count($subnav)) { $first = true; foreach ($subnav as $subcommand) { if (!isset($cmd[1]) && $first || (isset($cmd[1]) ? $cmd[1] : '') == $subcommand) { $navigation->touchBlock('subnav_active'); } else { $navigation->hideBlock('subnav_active'); } $act = '&act=' . $cmd[0] . '/' . $subcommand; $txt = (empty($cmd[0]) ? 'DEFAULT' : $cmd[0]) . '_'; if (empty($subcommand)) { $act = '&act=' . $cmd[0] . '/'; $txt .= 'DEFAULT'; } else { $txt .= strtoupper($subcommand); } $actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt); $actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey; $navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle)); $navigation->parse('subnav_entry'); $first = false; } } } $txt = $cmd[0]; if (empty($txt)) { $txt = 'DEFAULT'; } // default css and js if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Style/Backend.css'))) { \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1)); } if (file_exists($this->cx->getClassLoader()->getFilePath($this->getDirectory(false) . '/View/Script/Backend.js'))) { \JS::registerJS(substr($this->getDirectory(false, true) . '/View/Script/Backend.js', 1)); } // finish $actTemplate->setGlobalVariable($_ARRAYLANG); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($actTemplate); $page->setContent($actTemplate->get()); $cachedRoot = $this->cx->getTemplate()->getRoot(); $this->cx->getTemplate()->setRoot(\Env::get('cx')->getCodeBaseCorePath() . '/Core/View/Template/Backend'); $this->cx->getTemplate()->addBlockfile('CONTENT_OUTPUT', 'content_master', 'ContentMaster.html'); $this->cx->getTemplate()->setRoot($cachedRoot); $this->cx->getTemplate()->setVariable(array('CONTENT_NAVIGATION' => $navigation->get(), 'ADMIN_CONTENT' => $page->getContent(), 'CONTENT_TITLE' => $_ARRAYLANG['TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt)])); }
public function setContent($content) { $this->_load(); return parent::setContent($content); }
/** * Do something after content is loaded from DB * * @param \Cx\Core\ContentManager\Model\Entity\Page $page The resolved page */ public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page) { switch ($this->cx->getMode()) { case \Cx\Core\Core\Controller\Cx::MODE_FRONTEND: // Show the Shop navbar in the Shop, or on every page if configured to do so if (!Shop::isInitialized()) { \Cx\Core\Setting\Controller\Setting::init('Shop', 'config'); if (\Cx\Core\Setting\Controller\Setting::getValue('shopnavbar_on_all_pages', 'Shop')) { Shop::init(); Shop::setNavbar(); } // replace global product blocks $page->setContent(preg_replace_callback('/<!--\\s+BEGIN\\s+(block_shop_products_category_(?:\\d+)\\s+-->).*<!--\\s+END\\s+\\1/s', function ($matches) { $blockTemplate = new \Cx\Core\Html\Sigma(); $blockTemplate->setTemplate($matches[0]); Shop::parse_products_blocks($blockTemplate); return $blockTemplate->get(); }, $page->getContent())); } break; } }