/**
  * This is just a wrapper for \Cx\Core\PageTree\ classes and Shop::getNavbar()
  * @param   string  $templateContent
  * @param   boolean $boolShop         If true, parse the shop navigation
  *                                    into {SHOPNAVBAR_FILE}
  * @param   \Cx\Core\ContentManager\Model\Entity\Page requestedPage
  * @access  private
  * @return mixed parsed navigation
  */
 private function parseNavigation($templateContent, $license, $boolShop = false, $parseSubnavigation = false)
 {
     // only proceed if a navigation template had been set
     if (empty($templateContent)) {
         return;
     }
     $this->_objTpl = new \Cx\Core\Html\Sigma('.');
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
     $this->_objTpl->setErrorHandling(PEAR_ERROR_DIE);
     $this->_objTpl->setTemplate($templateContent);
     if ($boolShop) {
         $this->_objTpl->setVariable('SHOPNAVBAR_FILE', \Cx\Modules\Shop\Controller\Shop::getNavbar());
     }
     $rootNode = null;
     if ($parseSubnavigation) {
         // TODO: add comment to why the subnavigation will need the rootNode
         $rootNode = $this->page->getNode();
         while ($rootNode->getLvl() > 1) {
             $rootNode = $rootNode->getParent();
         }
     }
     if (isset($this->_objTpl->_blocks['navigation_dropdown'])) {
         // set submenu tag
         if ($this->_objTpl->blockExists('sub_menu')) {
             $this->subNavTag = trim($this->_objTpl->_blocks['sub_menu']);
             $templateContent = preg_replace('<!--\\s+BEGIN\\s+sub_menu\\s+-->.*<!--\\s+END\\s+sub_menu\\s+-->/ms', NULL, $templateContent);
         }
         $navi = new \Cx\Core\PageTree\DropdownNavigationPageTree(\Env::get('em'), $license, 0, $rootNode, $this->langId, $this->page);
         $navi->setVirtualLanguageDirectory(Env::get('virtualLanguageDirectory'));
         $navi->setTemplate($this->_objTpl);
         $renderedNavi = $navi->render();
         $templateContent = preg_replace('/<!--\\s+BEGIN\\s+level_\\d+\\s+-->.*<!--\\s+END\\s+level_\\d+\\s+-->/ms', $renderedNavi, $templateContent);
         return preg_replace('/<!--\\s+BEGIN\\s+navigation_dropdown\\s+-->(.*)<!--\\s+END\\s+navigation_dropdown\\s+-->/ms', '\\1', $templateContent);
     }
     if (isset($this->_objTpl->_blocks['navigation'])) {
         $navi = new \Cx\Core\PageTree\NavigationPageTree(\Env::get('em'), $license, 0, $rootNode, $this->langId, $this->page);
         $navi->setVirtualLanguageDirectory(Env::get('virtualLanguageDirectory'));
         $navi->setTemplate($this->_objTpl);
         return $navi->render();
     }
     // Create a nested list, formatted with ul and li-Tags
     if (isset($this->_objTpl->_blocks['nested_navigation'])) {
         $navi = new \Cx\Core\PageTree\NestedNavigationPageTree(\Env::get('em'), $license, 0, $rootNode, $this->langId, $this->page);
         $navi->setVirtualLanguageDirectory(Env::get('virtualLanguageDirectory'));
         $navi->setTemplate($this->_objTpl);
         $renderedNavi = $navi->render();
         return preg_replace('/<!--\\s+BEGIN\\s+nested_navigation\\s+-->.*<!--\\s+END\\s+nested_navigation\\s+-->/ms', $renderedNavi, $templateContent);
     }
 }
Exemple #2
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>'));
        }