/**
  * 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)]));
 }
Example #4
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();
 }
Example #5
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;
     }
 }
Example #7
0
        /**
         * Set main template placeholders required after content parsing
         * @todo Remove usage of globals
         * @global array $_CONFIG
         * @global type $themesPages
         * @global type $objBanner
         * @global type $_CORELANG
         * @return type
         */
        protected function setPostContentLoadPlaceholders()
        {
            global $_CONFIG, $themesPages, $objBanner, $_CORELANG;
            if ($this->mode == self::MODE_BACKEND) {
                $formattedVersion = htmlentities($_CONFIG['coreCmsName'], ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities(str_replace(' Service Pack 0', '', preg_replace('#^(\\d+\\.\\d+)\\.(\\d+)$#', '$1 Service Pack $2', $_CONFIG['coreCmsVersion'])), ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities($_CONFIG['coreCmsEdition'], ENT_QUOTES, CONTREXX_CHARSET) . ' ' . htmlentities($_CONFIG['coreCmsStatus'], ENT_QUOTES, CONTREXX_CHARSET);
                $this->template->setGlobalVariable(array('TXT_FRONTEND' => $_CORELANG['TXT_FRONTEND'], 'TXT_UPGRADE' => $_CORELANG['TXT_UPGRADE'], 'TXT_FEEDBACK_AND_HELP' => $_CORELANG['TXT_FEEDBACK_AND_HELP'], 'CONTREXX_VERSION' => $formattedVersion));
                $this->template->setVariable(array('TXT_LOGOUT' => $_CORELANG['TXT_LOGOUT'], 'TXT_PAGE_ID' => $_CORELANG['TXT_PAGE_ID'], 'CONTAINER_BACKEND_CLASS' => 'backend', 'CONTREXX_CHARSET' => CONTREXX_CHARSET));
                //show Feedback and help block
                \Permission::checkAccess(192, 'static', true) ? $this->template->touchBlock('feedback_help') : $this->template->hideBlock('feedback_help');
                return;
            }
            $objCounter = null;
            $componentRepo = $this->getDb()->getEntityManager()->getRepository('Cx\\Core\\Core\\Model\\Entity\\SystemComponent');
            $statsComponentContoller = $componentRepo->findOneBy(array('name' => 'Stats'));
            if ($statsComponentContoller) {
                $objCounter = $statsComponentContoller->getCounterInstance();
            }
            // set global template variables
            $boolShop = \Cx\Modules\Shop\Controller\Shop::isInitialized();
            $objNavbar = new \Navigation($this->resolvedPage->getId(), $this->resolvedPage);
            $objNavbar->setLanguagePlaceholders($this->resolvedPage, $this->request->getUrl(), $this->template);
            $metarobots = $this->resolvedPage->getMetarobots();
            $this->template->setVariable(array('CHARSET' => \Env::get('init')->getFrontendLangCharset(), 'TITLE' => contrexx_raw2xhtml($this->resolvedPage->getTitle()), 'METATITLE' => contrexx_raw2xhtml($this->resolvedPage->getMetatitle()), 'NAVTITLE' => contrexx_raw2xhtml($this->resolvedPage->getTitle()), 'GLOBAL_TITLE' => $_CONFIG['coreGlobalPageTitle'], 'DOMAIN_URL' => $_CONFIG['domainUrl'], 'PATH_OFFSET' => $this->codeBaseOffsetPath, 'BASE_URL' => ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . $this->codeBaseOffsetPath, 'METAKEYS' => $metarobots ? contrexx_raw2xhtml($this->resolvedPage->getMetakeys()) : '', 'METADESC' => $metarobots ? contrexx_raw2xhtml($this->resolvedPage->getMetadesc()) : '', 'METAROBOTS' => $metarobots ? 'all' : 'none', 'METAIMAGE' => $metarobots ? contrexx_raw2xhtml($this->resolvedPage->getMetaimage()) : '', 'CONTENT_TITLE' => $this->resolvedPage->getContentTitle(), 'CONTENT_TEXT' => $this->resolvedPage->getContent(), 'CSS_NAME' => contrexx_raw2xhtml($this->resolvedPage->getCssName()), 'STANDARD_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('smallscreen', 0)), 'MOBILE_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('smallscreen', 1)), 'PRINT_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('printview', 1)), 'PDF_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('pdfview', 1)), 'APP_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('appview', 1)), 'LOGOUT_URL' => contrexx_raw2xhtml(\Env::get('init')->getUriBy('section', 'logout')), 'PAGE_URL' => htmlspecialchars(\Env::get('init')->getPageUri()), 'PAGE_URL_ENCODED' => urlencode(\Env::get('init')->getPageUri()->toString()), 'CURRENT_URL' => contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()), 'DATE' => showFormattedDate(), 'TIME' => date('H:i', time()), 'NAVTREE' => $objNavbar->getTrail(), 'SUBNAVBAR_FILE' => $objNavbar->getSubnavigation($themesPages['subnavbar'], $this->license, $boolShop), 'SUBNAVBAR2_FILE' => $objNavbar->getSubnavigation($themesPages['subnavbar2'], $this->license, $boolShop), 'SUBNAVBAR3_FILE' => $objNavbar->getSubnavigation($themesPages['subnavbar3'], $this->license, $boolShop), 'NAVBAR_FILE' => $objNavbar->getNavigation($themesPages['navbar'], $this->license, $boolShop), 'NAVBAR2_FILE' => $objNavbar->getNavigation($themesPages['navbar2'], $this->license, $boolShop), 'NAVBAR3_FILE' => $objNavbar->getNavigation($themesPages['navbar3'], $this->license, $boolShop), 'ONLINE_USERS' => $objCounter ? $objCounter->getOnlineUsers() : '', 'VISITOR_NUMBER' => $objCounter ? $objCounter->getVisitorNumber() : '', 'COUNTER' => $objCounter ? $objCounter->getCounterTag() : '', 'BANNER' => isset($objBanner) ? $objBanner->getBannerJS() : '', 'VERSION' => contrexx_raw2xhtml($_CONFIG['coreCmsName']), 'LANGUAGE_NAVBAR' => $objNavbar->getFrontendLangNavigation($this->resolvedPage, $this->request->getUrl()), 'LANGUAGE_NAVBAR_SHORT' => $objNavbar->getFrontendLangNavigation($this->resolvedPage, $this->request->getUrl(), true), 'ACTIVE_LANGUAGE_NAME' => \Env::get('init')->getFrontendLangName(), 'RANDOM' => md5(microtime()), 'TXT_SEARCH' => $_CORELANG['TXT_SEARCH'], 'MODULE_INDEX' => MODULE_INDEX, 'LOGIN_URL' => '<a href="' . contrexx_raw2xhtml(\Env::get('init')->getUriBy('section', 'Login')) . '" class="start-frontend-editing">' . $_CORELANG['TXT_FRONTEND_EDITING_LOGIN'] . '</a>', 'TXT_CORE_LAST_MODIFIED_PAGE' => $_CORELANG['TXT_CORE_LAST_MODIFIED_PAGE'], 'LAST_MODIFIED_PAGE' => date(ASCMS_DATE_FORMAT_DATE, $this->resolvedPage->getUpdatedAt()->getTimestamp()), 'CONTACT_EMAIL' => isset($_CONFIG['contactFormEmail']) ? contrexx_raw2xhtml($_CONFIG['contactFormEmail']) : '', 'CONTACT_NAME' => isset($_CONFIG['coreAdminName']) ? contrexx_raw2xhtml($_CONFIG['coreAdminName']) : '', 'CONTACT_COMPANY' => isset($_CONFIG['contactCompany']) ? contrexx_raw2xhtml($_CONFIG['contactCompany']) : '', 'CONTACT_ADDRESS' => isset($_CONFIG['contactAddress']) ? contrexx_raw2xhtml($_CONFIG['contactAddress']) : '', 'CONTACT_ZIP' => isset($_CONFIG['contactZip']) ? contrexx_raw2xhtml($_CONFIG['contactZip']) : '', 'CONTACT_PLACE' => isset($_CONFIG['contactPlace']) ? contrexx_raw2xhtml($_CONFIG['contactPlace']) : '', 'CONTACT_COUNTRY' => isset($_CONFIG['contactCountry']) ? contrexx_raw2xhtml($_CONFIG['contactCountry']) : '', 'CONTACT_PHONE' => isset($_CONFIG['contactPhone']) ? contrexx_raw2xhtml($_CONFIG['contactPhone']) : '', 'CONTACT_FAX' => isset($_CONFIG['contactFax']) ? contrexx_raw2xhtml($_CONFIG['contactFax']) : '', 'GOOGLE_MAPS_API_KEY' => isset($_CONFIG['googleMapsAPIKey']) ? contrexx_raw2xhtml($_CONFIG['googleMapsAPIKey']) : '', 'FACEBOOK_LIKE_IFRAME' => '<div id="fb-root"></div>
                                                    <script type="text/javascript">
                                                        (function(d, s, id) {
                                                            var js, fjs = d.getElementsByTagName(s)[0];
                                                            if (d.getElementById(id)) return;
                                                            js = d.createElement(s); js.id = id;
                                                            js.src = "//connect.facebook.net/' . \FWLanguage::getLanguageCodeById(LANG_ID) . '_' . strtoupper(\FWLanguage::getLanguageCodeById(LANG_ID)) . '/all.js#xfbml=1";
                                                            fjs.parentNode.insertBefore(js, fjs);
                                                        }(document, \'script\', \'facebook-jssdk\'));
                                                    </script>
                                                    <div class="fb-like" data-href="' . ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()) . '" data-send="false" data-layout="button_count" data-show-faces="false" data-font="segoe ui"></div>', 'GOOGLE_PLUSONE' => '<div class="g-plusone" data-href="' . ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()) . '"></div>
                                                    <script type="text/javascript">
                                                        window.___gcfg = {lang: \'' . \FWLanguage::getLanguageCodeById(LANG_ID) . '\'};

                                                        (function() {
                                                            var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true;
                                                            po.src = \'https://apis.google.com/js/plusone.js\';
                                                            var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);
                                                        })();
                                                    </script>', 'TWITTER_SHARE' => '<a href="https://twitter.com/share" class="twitter-share-button"
                                                    data-url="' . ASCMS_PROTOCOL . '://' . $_CONFIG['domainUrl'] . contrexx_raw2xhtml(\Env::get('init')->getCurrentPageUri()) . '" data-lang="' . \FWLanguage::getLanguageCodeById(LANG_ID) . '">Twittern</a>
                                                    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>', 'XING_SHARE' => '<div data-type="XING/Share" data-counter="right" data-lang="' . \FWLanguage::getLanguageCodeById(LANG_ID) . '"></div>
                                                    <script>
                                                        ;(function (d, s) {
                                                            var x = d.createElement(s),
                                                                s = d.getElementsByTagName(s)[0];
                                                            x.src = "https://www.xing-share.com/js/external/share.js";
                                                            s.parentNode.insertBefore(x, s);
                                                        })(document, "script");
                                                    </script>', 'GOOGLE_ANALYTICS' => '<script type="text/javascript">
                                                        var _gaq = _gaq || [];
                                                        _gaq.push([\'_setAccount\', \'' . (isset($_CONFIG['googleAnalyticsTrackingId']) ? contrexx_raw2xhtml($_CONFIG['googleAnalyticsTrackingId']) : '') . '\']);
                                                        _gaq.push([\'_trackPageview\']);

                                                        (function() {
                                                            var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
                                                            ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
                                                            var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
                                                        })();
                                                    </script>'));
        }
 /**
  * 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());
 }
Example #9
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();
 }
 /**
  * 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)]));
 }
 public function getContent()
 {
     $this->_load();
     return parent::getContent();
 }
 /**
  * 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;
     }
 }