..)
상속: extends Frontend\Core\Engine\Base\Object
예제 #1
0
 /**
  * Processes the page
  */
 protected function processPage()
 {
     // set pageTitle
     $this->header->setPageTitle($this->record['meta_title'], (bool) ($this->record['meta_title_overwrite'] == 'Y'));
     // set meta-data
     $this->header->addMetaDescription($this->record['meta_description'], (bool) ($this->record['meta_description_overwrite'] == 'Y'));
     $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y');
     $this->header->setMetaCustom($this->record['meta_custom']);
     // advanced SEO-attributes
     if (isset($this->record['meta_data']['seo_index'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index']));
     }
     if (isset($this->record['meta_data']['seo_follow'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow']));
     }
     // create navigation instance
     new Navigation($this->getKernel());
     // assign content
     $pageInfo = Navigation::getPageInfo($this->record['id']);
     $this->record['has_children'] = $pageInfo['has_children'];
     $this->tpl->assign('page', $this->record);
     // set template path
     $this->templatePath = FRONTEND_PATH . '/' . $this->record['template_path'];
     // loop blocks
     foreach ($this->record['positions'] as $position => &$blocks) {
         // position not known in template = skip it
         if (!in_array($position, $this->record['template_data']['names'])) {
             continue;
         }
         // loop blocks in position
         foreach ($blocks as $index => &$block) {
             // an extra
             if ($block['extra_id'] !== null) {
                 // block
                 if ($block['extra_type'] == 'block') {
                     // create new instance
                     $extra = new FrontendBlockExtra($this->getKernel(), $block['extra_module'], $block['extra_action'], $block['extra_data']);
                     if (extension_loaded('newrelic')) {
                         newrelic_name_transaction($block['extra_module'] . '::' . $block['extra_action']);
                     }
                 } else {
                     // widget
                     $extra = new FrontendBlockWidget($this->getKernel(), $block['extra_module'], $block['extra_action'], $block['extra_data']);
                 }
                 // add to list of extras
                 $block = array('extra' => $extra);
                 // add to list of extras to parse
                 $this->extras[] = $extra;
             } else {
                 // the block only contains HTML
                 $block = array('blockIsEditor' => true, 'blockContent' => $block['html']);
                 // Maintain backwards compatibility
                 $block['blockIsHTML'] = $block['blockIsEditor'];
             }
         }
     }
 }
예제 #2
0
파일: Block.php 프로젝트: forkcms/forkcms
 /**
  * @param Meta $meta
  */
 protected function setMeta(Meta $meta)
 {
     $this->header->setPageTitle($meta->getTitle(), $meta->isTitleOverwrite());
     $this->header->addMetaDescription($meta->getDescription(), $meta->isDescriptionOverwrite());
     $this->header->addMetaKeywords($meta->getKeywords(), $meta->isKeywordsOverwrite());
     if ($meta->hasSEOFollow()) {
         $this->header->addMetaData(['name' => 'robots', 'content' => $meta->getSEOFollow()]);
     }
     if ($meta->hasSEOIndex()) {
         $this->header->addMetaData(['name' => 'robots', 'content' => $meta->getSEOIndex()]);
     }
 }
예제 #3
0
 /**
  * Execute the action
  * If a javascript file with the name of the module or action exists it will be loaded.
  */
 public function execute()
 {
     // build path to the module
     $frontendModulePath = FRONTEND_MODULES_PATH . '/' . $this->getModule();
     // build URL to the module
     $frontendModuleURL = '/src/Frontend/Modules/' . $this->getModule() . '/Js';
     // add javascript file with same name as module (if the file exists)
     if (is_file($frontendModulePath . '/Js/' . $this->getModule() . '.js')) {
         $this->header->addJS($frontendModuleURL . '/' . $this->getModule() . '.js', false, null, Header::PRIORITY_GROUP_WIDGET);
     }
     // add javascript file with same name as the action (if the file exists)
     if (is_file($frontendModulePath . '/Js/' . $this->getAction() . '.js')) {
         $this->header->addJS($frontendModuleURL . '/' . $this->getAction() . '.js', false, null, Header::PRIORITY_GROUP_WIDGET);
     }
 }
예제 #4
0
 /**
  * Parse pagination
  */
 protected function parsePagination()
 {
     $pagination = null;
     $showFirstPages = false;
     $showLastPages = false;
     $useQuestionMark = true;
     // validate pagination array
     if (!isset($this->pagination['limit'])) {
         throw new Exception('no limit in the pagination-property.');
     }
     if (!isset($this->pagination['offset'])) {
         throw new Exception('no offset in the pagination-property.');
     }
     if (!isset($this->pagination['requested_page'])) {
         throw new Exception('no requested_page available in the pagination-property.');
     }
     if (!isset($this->pagination['num_items'])) {
         throw new Exception('no num_items available in the pagination-property.');
     }
     if (!isset($this->pagination['num_pages'])) {
         throw new Exception('no num_pages available in the pagination-property.');
     }
     if (!isset($this->pagination['url'])) {
         throw new Exception('no URL available in the pagination-property.');
     }
     // should we use a questionmark or an ampersand
     if (mb_strpos($this->pagination['url'], '?') !== false) {
         $useQuestionMark = false;
     }
     // no pagination needed
     if ($this->pagination['num_pages'] < 1) {
         return;
     }
     // populate count fields
     $pagination['num_pages'] = $this->pagination['num_pages'];
     $pagination['current_page'] = $this->pagination['requested_page'];
     // define anchor
     $anchor = isset($this->pagination['anchor']) ? '#' . $this->pagination['anchor'] : '';
     // as long as we have more then 5 pages and are 5 pages from the end we should show all pages till the end
     if ($this->pagination['requested_page'] > 5 && $this->pagination['requested_page'] >= $this->pagination['num_pages'] - 4) {
         // init vars
         $pagesStart = $this->pagination['num_pages'] > 7 ? $this->pagination['num_pages'] - 5 : $this->pagination['num_pages'] - 6;
         $pagesEnd = $this->pagination['num_pages'];
         // fix for page 6
         if ($this->pagination['num_pages'] == 6) {
             $pagesStart = 1;
         }
         // show first pages
         if ($this->pagination['num_pages'] > 7) {
             $showFirstPages = true;
         }
     } elseif ($this->pagination['requested_page'] <= 5) {
         // as long as we are below page 5 and below 5 from the end we should show all pages starting from 1
         // init vars
         $pagesStart = 1;
         $pagesEnd = 6;
         // when we have 7 pages, show 7 as end
         if ($this->pagination['num_pages'] == 7) {
             $pagesEnd = 7;
         } elseif ($this->pagination['num_pages'] <= 6) {
             // when we have less then 6 pages, show the maximum page
             $pagesEnd = $this->pagination['num_pages'];
         }
         // show last pages
         if ($this->pagination['num_pages'] > 7) {
             $showLastPages = true;
         }
     } else {
         // page 6
         // init vars
         $pagesStart = $this->pagination['requested_page'] - 2;
         $pagesEnd = $this->pagination['requested_page'] + 2;
         $showFirstPages = true;
         $showLastPages = true;
     }
     // show previous
     if ($this->pagination['requested_page'] > 1) {
         // build URL
         if ($useQuestionMark) {
             $URL = $this->pagination['url'] . '?page=' . ($this->pagination['requested_page'] - 1);
         } else {
             $URL = $this->pagination['url'] . '&amp;page=' . ($this->pagination['requested_page'] - 1);
         }
         // set
         $pagination['show_previous'] = true;
         $pagination['previous_url'] = $URL . $anchor;
         // flip ahead
         $this->header->addLink(array('rel' => 'prev', 'href' => SITE_URL . $URL . $anchor));
     }
     // show first pages?
     if ($showFirstPages) {
         // init var
         $pagesFirstStart = 1;
         $pagesFirstEnd = 1;
         // loop pages
         for ($i = $pagesFirstStart; $i <= $pagesFirstEnd; $i++) {
             // build URL
             if ($useQuestionMark) {
                 $URL = $this->pagination['url'] . '?page=' . $i;
             } else {
                 $URL = $this->pagination['url'] . '&amp;page=' . $i;
             }
             // add
             $pagination['first'][] = array('url' => $URL . $anchor, 'label' => $i);
         }
     }
     // build array
     for ($i = $pagesStart; $i <= $pagesEnd; $i++) {
         // init var
         $current = $i == $this->pagination['requested_page'];
         // build URL
         if ($useQuestionMark) {
             $URL = $this->pagination['url'] . '?page=' . $i;
         } else {
             $URL = $this->pagination['url'] . '&amp;page=' . $i;
         }
         // add
         $pagination['pages'][] = array('url' => $URL . $anchor, 'label' => $i, 'current' => $current);
     }
     // show last pages?
     if ($showLastPages) {
         // init var
         $pagesLastStart = $this->pagination['num_pages'];
         $pagesLastEnd = $this->pagination['num_pages'];
         // loop pages
         for ($i = $pagesLastStart; $i <= $pagesLastEnd; $i++) {
             // build URL
             if ($useQuestionMark) {
                 $URL = $this->pagination['url'] . '?page=' . $i;
             } else {
                 $URL = $this->pagination['url'] . '&amp;page=' . $i;
             }
             // add
             $pagination['last'][] = array('url' => $URL . $anchor, 'label' => $i);
         }
     }
     // show next
     if ($this->pagination['requested_page'] < $this->pagination['num_pages']) {
         // build URL
         if ($useQuestionMark) {
             $URL = $this->pagination['url'] . '?page=' . ($this->pagination['requested_page'] + 1);
         } else {
             $URL = $this->pagination['url'] . '&amp;page=' . ($this->pagination['requested_page'] + 1);
         }
         // set
         $pagination['show_next'] = true;
         $pagination['next_url'] = $URL . $anchor;
         // flip ahead
         $this->header->addLink(array('rel' => 'next', 'href' => SITE_URL . $URL . $anchor));
     }
     // multiple pages
     $pagination['multiple_pages'] = $pagination['num_pages'] == 1 ? false : true;
     // assign pagination
     $this->tpl->assign('pagination', $pagination);
 }