/**
  * 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;
     }
 }
 /**
  * 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;
     }
 }
示例#3
0
    /**
     * Returns the group ids with access to front- or backend of a page
     * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get the group ids of
     * @param boolean $frontend True for frontend access groups, false for backend
     * @return mixed Array of group ids or false on error
     * @throws PageGuardException 
     */
    public function getAssignedGroupIds($page, $frontend)
    {
        if ($frontend && !$page->isFrontendProtected()) {
            return array();
        }
        if (!$frontend && !$page->isBackendProtected()) {
            return array();
        }
        try {
            $accessId = $this->getAccessId($page, $frontend);
        } catch (PageGuardException $e) {
            // the selected page is listed as protected but does not have an access id.
            // this is probably due to a db inconsistency, which we should be able to handle gracefully:
            $accessId = \Permission::createNewDynamicAccessId();
            if ($frontend && $accessId) {
                $page->setFrontendAccessId($accessId);
            } elseif (!$frontend && $accessId) {
                $page->setBackendAccessId($accessId);
            } else {
                // cannot create a new dynamic access id.
                throw new PageGuardException('This protected page doesn\'t have an access id associated with
it. Contrexx encountered an error while generating a new access id.');
            }
            Env::get('em')->persist($page);
            Env::get('em')->flush();
        }
        return \Permission::getGroupIdsForAccessId($accessId);
    }
 /**
  * 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($page));
             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;
     }
 }
 /**
  * Get the page object by url
  * 
  * @param string $url requested url
  *
  * @return boolean|object
  */
 public function getPageByUrl($url)
 {
     $objUrl = new \Cx\Core\Routing\Url($url);
     $result = $this->pageRepo->getPagesAtPath($this->langName . '/' . $objUrl->getSuggestedTargetPath(), null, $this->langId, false);
     if ($result['page']) {
         return $result['page'];
     }
     return false;
 }
 /**
  * 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)]));
 }
 /**
  * Check if the page is module or content page
  * 
  * @param string $url requested url
  * 
  * @return boolean|object
  */
 public function isModulePage($url)
 {
     try {
         $url = new \Cx\Core\Routing\Url($url);
         $path = $url->getSuggestedTargetPath();
     } catch (\Exception $e) {
         $path = '';
     }
     $result = $this->pageRepo->getPagesAtPath($this->langName . '/' . $path, null, $this->langId, false, \Cx\Core\ContentManager\Model\Repository\PageRepository::SEARCH_MODE_PAGES_ONLY);
     if ($result['page']) {
         return $result['page'];
     }
     return false;
 }
 /**
  * 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;
     }
 }
示例#10
0
 /**
  * Generates a list of pages pointing to $page
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get referencing pages for
  * @param array $subPages (optional, by reference) Do not use, internal
  * @return array List of pages (ID as key, page object as value)
  */
 protected function getPagesPointingTo($page, &$subPages = array())
 {
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $em = $cx->getDb()->getEntityManager();
     $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     $fallback_lang_codes = \FWLanguage::getFallbackLanguageArray();
     $active_langs = \FWLanguage::getActiveFrontendLanguages();
     // get all active languages and their fallbacks
     // $fallbacks[<langId>] = <fallsBackToLangId>
     // if <langId> has no fallback <fallsBackToLangId> will be null
     $fallbacks = array();
     foreach ($active_langs as $lang) {
         $fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null;
     }
     // get all symlinks and fallbacks to it
     $query = '
         SELECT
             p
         FROM
             Cx\\Core\\ContentManager\\Model\\Entity\\Page p
         WHERE
             (
                 p.type = ?1 AND
                 (
                     p.target LIKE ?2';
     if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
         $query .= ' OR
                     p.target LIKE ?3';
     }
     $query .= '
                 )
             ) OR
             (
                 p.type = ?4 AND
                 p.node = ' . $page->getNode()->getId() . '
             )
     ';
     $q = $em->createQuery($query);
     $q->setParameter(1, 'symlink');
     $q->setParameter('2', '%NODE_' . $page->getNode()->getId() . '%');
     if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
         $q->setParameter('3', '%NODE_' . strtoupper($page->getModule()) . '%');
     }
     $q->setParameter(4, 'fallback');
     $result = $q->getResult();
     if (!$result) {
         return $subPages;
     }
     foreach ($result as $subPage) {
         if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_SYMLINK) {
             $subPages[$subPage->getId()] = $subPage;
         } else {
             if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) {
                 // check if $subPage is a fallback to $page
                 $targetLang = \FWLanguage::getLanguageCodeById($page->getLang());
                 $currentLang = \FWLanguage::getLanguageCodeById($subPage->getLang());
                 while ($currentLang && $currentLang != $targetLang) {
                     $currentLang = $fallbacks[$currentLang];
                 }
                 if ($currentLang && !isset($subPages[$subPage->getId()])) {
                     $subPages[$subPage->getId()] = $subPage;
                     // recurse!
                     $this->getPagesPointingTo($subPage, $subPages);
                 }
             }
         }
     }
     return $subPages;
 }
示例#11
0
 /**
  * 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();
 }
示例#12
0
 /**
  * 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;
 }
 /**
  * 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;
     }
 }
 public function __toString()
 {
     $this->_load();
     return parent::__toString();
 }
 /**
  * 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());
 }
示例#16
0
 /**
  * Returns the URL object for a page
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get the URL to
  * @param array $parameters (optional) HTTP GET parameters to append
  * @param string $protocol (optional) The protocol to use
  * @return \Cx\Core\Routing\Url Url object for the supplied page
  */
 public static function fromPage($page, $parameters = array(), $protocol = '')
 {
     if ($protocol == '') {
         $protocol = ASCMS_PROTOCOL;
     }
     $host = \Env::get('config')['domainUrl'];
     $offset = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath();
     $path = $page->getPath();
     $langDir = \FWLanguage::getLanguageCodeById($page->getLang());
     $getParams = '';
     if (count($parameters)) {
         $paramArray = array();
         foreach ($parameters as $key => $value) {
             $paramArray[] = $key . '=' . $value;
         }
         $getParams = '?' . implode('&', $paramArray);
     }
     return new Url($protocol . '://' . $host . $offset . '/' . $langDir . $path . $getParams, true);
 }
 /**
  * Returns the target page for a page with internal target
  * @todo use this everywhere (resolver!)
  * @param   \Cx\Core\ContentManager\Model\Entity\Page  $page
  */
 public function getTargetPage($page)
 {
     if (!$page->isTargetInternal()) {
         throw new PageRepositoryException('Tried to get target node, but page has no internal target');
     }
     // TODO: basically the method \Cx\Core\ContentManager\Model\Entity\Page::cutTarget() would provide us a ready to use $crit array
     //       Check if we could directly use the array from cutTarget() and implement a public method to cutTarget()
     $nodeId = $page->getTargetNodeId();
     $module = $page->getTargetModule();
     $cmd = $page->getTargetCmd();
     $langId = $page->getTargetLangId();
     if ($langId == 0) {
         $langId = FRONTEND_LANG_ID;
     }
     $page = $this->findOneByModuleCmdLang($module, $cmd, $langId);
     if (!$page) {
         $page = $this->findOneByModuleCmdLang($module, $cmd . '_' . $langId, FRONTEND_LANG_ID);
     }
     if (!$page) {
         $page = $this->findOneByModuleCmdLang($module, $langId, FRONTEND_LANG_ID);
     }
     if (!$page) {
         $page = $this->findOneBy(array('nodeIdShadowed' => $nodeId, 'lang' => $langId));
     }
     return $page;
 }
 /**
  * Returns the latest logs of all pages.
  * The log entries are filtered by the page object.
  *
  * @return  array  $result
  */
 public function getLatestLog(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     $result = array();
     $qb = $this->em->createQueryBuilder();
     $objectId = $page->getId();
     $qb->select('l')->setMaxResults(1)->from('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry', 'l')->where('l.objectClass = :objectClass')->andWhere('l.objectId LIKE :objectId')->orderBy('l.version', 'DESC')->setParameter('objectClass', 'Cx\\Core\\ContentManager\\Model\\Entity\\Page')->setParameter('objectId', $objectId);
     $logs = $qb->getQuery()->getResult();
     if (is_array($logs)) {
         foreach ($logs as $log) {
             if (!is_array($log)) {
                 $result[$log->getObjectId()] = $log;
             } else {
                 $result[$log['objectId']] = $log['username'];
             }
         }
     }
     return current($result);
 }
示例#19
0
 /**
  * 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}");
 }
示例#20
0
 /**
  * Create a placeholder for a page object
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get placeholder for
  * @param array $arguments (optional) Query arguments in the form array($key=>$value)
  * @return \Cx\Core\Routing\NodePlaceholder
  */
 public static function fromPage(\Cx\Core\ContentManager\Model\Entity\Page $page, array $arguments = array())
 {
     return new static($page->getNode(), $page->getLang(), $arguments);
 }
 public function postContentLoad(\Cx\Core\ContentManager\Model\Entity\Page $page)
 {
     // Set meta image to default if it's not defined
     if (empty($page->getMetaimage())) {
         $page->setMetaimage(\Env::get('config')['defaultMetaimage']);
     }
 }
示例#22
0
 /**
  * Creates the page array representation of a page
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to "arrayify"
  * @return Array Array representing a page
  */
 private function getPageArray($page)
 {
     // Scheduled Publishing
     $n = new \DateTime(null, $this->tz);
     if ($page->getStart() && $page->getEnd()) {
         $scheduled_publishing = true;
         $start = $page->getStart()->format('d.m.Y H:i');
         $end = $page->getEnd()->format('d.m.Y H:i');
     } else {
         $scheduled_publishing = false;
         $start = $n->format('d.m.Y H:i');
         $end = $n->format('d.m.Y H:i');
     }
     // Access Permissions
     $pg = \Env::get('pageguard');
     $accessData = array();
     $accessData['frontend'] = array('groups' => $pg->getGroups(true), 'assignedGroups' => $pg->getAssignedGroupIds($page, true));
     $accessData['backend'] = array('groups' => $pg->getGroups(false), 'assignedGroups' => $pg->getAssignedGroupIds($page, false));
     try {
         $parentPath = substr($page->getParent()->getPath(), 1) . '/';
     } catch (\Cx\Core\ContentManager\Model\Entity\PageException $e) {
         $parentPath = '';
     }
     $pageArray = array('id' => $page->getId(), 'lang' => \FWLanguage::getLanguageCodeById($page->getLang()), 'node' => $page->getNode()->getId(), 'name' => $page->getTitle(), 'title' => $page->getContentTitle(), 'type' => $page->getType(), 'target' => $page->getTarget(), 'target_path' => $this->getPathByTarget(array('get' => array('target' => $page->getTarget()))), 'module' => $page->getModule(), 'area' => $page->getCmd(), 'scheduled_publishing' => $scheduled_publishing, 'start' => $start, 'end' => $end, 'content' => preg_replace('/{([A-Z0-9_-]+)}/', '[[\\1]]', $page->getContent()), 'sourceMode' => $page->getSourceMode(), 'metatitle' => $page->getMetatitle(), 'metadesc' => $page->getMetadesc(), 'metakeys' => $page->getMetakeys(), 'metarobots' => $page->getMetarobots(), 'frontend_protection' => $page->isFrontendProtected(), 'backend_protection' => $page->isBackendProtected(), 'accessData' => $accessData, 'skin' => $page->getSkin(), 'useSkinForAllChannels' => $page->getUseSkinForAllChannels(), 'customContent' => $page->getCustomContent(), 'useCustomContentForAllChannels' => $page->getUseCustomContentForAllChannels(), 'applicationTemplate' => $page->getApplicationTemplate(), 'useCustomApplicationTemplateForAllChannels' => $page->getUseCustomApplicationTemplateForAllChannels(), 'cssName' => $page->getCssName(), 'cssNavName' => $page->getCssNavName(), 'caching' => $page->getCaching(), 'linkTarget' => $page->getLinkTarget(), 'slug' => $page->getSlug(), 'aliases' => $this->getAliasArray($page), 'editingStatus' => $page->getEditingStatus(), 'parentPath' => $parentPath, 'assignedBlocks' => $this->getBlocks($page), 'historyId' => $page->getVersion()->getVersion());
     return $pageArray;
 }
示例#23
0
 /**
  * Checks if this page can be displayed in frontend, redirects to login of not
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to check
  * @param int $history (optional) Revision of page to use, 0 means current, default 0
  */
 public function checkPageFrontendProtection($page, $history = 0)
 {
     global $sessionObj;
     $page_protected = $page->isFrontendProtected();
     $pageAccessId = $page->getFrontendAccessId();
     if ($history) {
         $pageAccessId = $page->getBackendAccessId();
     }
     // login pages are unprotected by design
     $checkLogin = array($page);
     while (count($checkLogin)) {
         $currentPage = array_pop($checkLogin);
         if ($currentPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) {
             try {
                 array_push($checkLogin, $this->getFallbackPage($currentPage));
             } catch (ResolverException $e) {
             }
         }
         if ($currentPage->getModule() == 'Login') {
             return;
         }
     }
     // Authentification for protected pages
     if (($page_protected || $history || !empty($_COOKIE['PHPSESSID'])) && (!isset($_REQUEST['section']) || $_REQUEST['section'] != 'Login')) {
         if (empty($sessionObj)) {
             $sessionObj = \cmsSession::getInstance();
         }
         $_SESSION->cmsSessionStatusUpdate('frontend');
         if (\FWUser::getFWUserObject()->objUser->login()) {
             if ($page_protected) {
                 if (!\Permission::checkAccess($pageAccessId, 'dynamic', true)) {
                     $link = base64_encode(\Env::get('cx')->getRequest()->getUrl()->toString());
                     \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Login', 'noaccess', '', array('redirect' => $link)));
                     exit;
                 }
             }
             if ($history && !\Permission::checkAccess(78, 'static', true)) {
                 $link = base64_encode(\Env::get('cx')->getRequest()->getUrl()->toString());
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Login', 'noaccess', '', array('redirect' => $link)));
                 exit;
             }
         } elseif (!empty($_COOKIE['PHPSESSID']) && !$page_protected) {
             unset($_COOKIE['PHPSESSID']);
         } else {
             if (isset($_GET['redirect'])) {
                 $link = $_GET['redirect'];
             } else {
                 $link = base64_encode(\Env::get('cx')->getRequest()->getUrl()->toString());
             }
             \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Login', '', '', array('redirect' => $link)));
             exit;
         }
     }
 }
示例#24
0
 /**
  * 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();
 }
示例#25
0
 /**
  * Writes the cache file for the current request
  * @param \Cx\Core\ContentManager\Model\Entity\Page $page Current page (might be null for redirects before postResolve)
  * @param array $headers List of headers set for the current response
  * @param string $endcode Current response
  */
 public function writeCacheFileForRequest($page, $headers, $endcode)
 {
     $pageId = '';
     if ($page) {
         $pageId = $page->getId();
     }
     if (count($headers)) {
         $handleFile = $this->strCachePath . $this->strCacheFilename . '_h' . $pageId;
         $File = new \Cx\Lib\FileSystem\File($handleFile);
         $File->write(serialize($headers));
     }
     // write page cache file
     $handleFile = $this->strCachePath . $this->strCacheFilename . '_' . $pageId;
     $File = new \Cx\Lib\FileSystem\File($handleFile);
     $File->write($endcode);
 }
 /**
  * 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 = '&amp;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 = '&amp;act=' . $cmd[0] . '/' . $subcommand;
                 $txt = (empty($cmd[0]) ? 'DEFAULT' : $cmd[0]) . '_';
                 if (empty($subcommand)) {
                     $act = '&amp;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)]));
 }