Example #1
0
 /**
  * Page xml sitemap
  * 
  * @return object Zend\Navigation\Navigation
  */
 public function __invoke()
 {
     $xmlMap = [];
     if (null != ($siteMap = $this->getModel()->getAllPagesMap())) {
         $processedSiteMap = [];
         foreach ($siteMap as $language => $pages) {
             foreach ($pages as $pageOptions) {
                 if ($pageOptions['xml_map'] == PageNestedSet::PAGE_IN_XML_MAP) {
                     // get dynamic pages
                     if (!empty($pageOptions['pages_provider'])) {
                         if (null != ($dynamicPages = PageProviderUtility::getPages($pageOptions['pages_provider'], $language))) {
                             $xmlMap = array_merge($xmlMap, $this->processDynamicPages($pageOptions, $dynamicPages, $language));
                         }
                     } else {
                         // get a page url
                         if (false !== ($pageUrl = $this->getView()->pageUrl($pageOptions['slug'], [], $language))) {
                             $xmlMap[] = ['uri' => $this->getView()->url('page', ['language' => $language, 'page_name' => $pageUrl], ['force_canonical' => true]), 'lastmod' => $pageOptions['date_edited'], 'changefreq' => $pageOptions['xml_map_update'], 'priority' => $pageOptions['xml_map_priority']];
                         }
                     }
                 }
             }
         }
     }
     return new Navigation($xmlMap);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (null != ($currentPage = PageService::getCurrentPage())) {
         $menuType = $this->getWidgetSetting('page_sidebar_menu_type');
         $showDynamicPages = (int) $this->getWidgetSetting('page_sidebar_menu_show_dynamic');
         $currentLanguage = LocalizationService::getCurrentLocalization()['language'];
         $pages = [];
         // collect sidebar menu items
         foreach ($this->getModel()->getPagesMap($currentLanguage) as $page) {
             // check the type of menu
             if ($page['parent'] != ($menuType == 'sidebar_menu_subpages' ? $currentPage['slug'] : $currentPage['parent_slug'])) {
                 continue;
             }
             // get dynamic pages
             if (!empty($page['pages_provider'])) {
                 if ($showDynamicPages) {
                     if (null != ($dynamicPages = PageProviderUtility::getPages($page['pages_provider'], $currentLanguage))) {
                         // process only the first pages level
                         foreach ($dynamicPages as $dynamicPage) {
                             // check received params
                             if (!isset($dynamicPage['url_params'], $dynamicPage['url_title'])) {
                                 continue;
                             }
                             if (false !== ($pageUrl = $this->getView()->pageUrl($page['slug'], [], $currentLanguage, true))) {
                                 $pages[] = ['active' => !empty($dynamicPage['url_active']), 'url' => $pageUrl, 'title' => $dynamicPage['url_title'], 'params' => $dynamicPage['url_params']];
                             }
                         }
                     }
                 }
             } else {
                 // get a page url
                 if (false === ($pageUrl = $this->getView()->pageUrl($page['slug']))) {
                     continue;
                 }
                 $pages[] = ['active' => $currentPage['slug'] == $page['slug'], 'url' => $pageUrl, 'title' => $this->getView()->pageTitle($page)];
             }
         }
         if ($pages) {
             return $this->getView()->partial('page/widget/sidebar-menu', ['pages' => $pages]);
         }
     }
     return false;
 }
Example #3
0
 /**
  * Process sitemap items
  *
  * @param array $pages
  * @return string
  */
 protected function processSitemapItems(array $pages)
 {
     $sitemap = null;
     // process sitemap items
     foreach ($pages as $pageName => $pageOptions) {
         if ($pageOptions['site_map'] == PageNestedSet::PAGE_IN_SITEMAP) {
             // get dynamic pages
             if (!empty($pageOptions['pages_provider'])) {
                 if (null != ($dynamicPages = PageProviderUtility::getPages($pageOptions['pages_provider'], $this->getCurrentLanguage()))) {
                     $sitemap .= $this->processDynamicPages($pageOptions, $dynamicPages);
                 }
             } else {
                 // get a page url
                 if (false !== ($pageUrl = $this->getView()->pageUrl($pageName))) {
                     $sitemap .= $this->getView()->partial('page/widget/sitemap-item-start', ['url' => $pageUrl, 'title' => $this->getView()->pageTitle($pageOptions), 'params' => []]);
                     // check for children
                     if (!empty($pageOptions['children'])) {
                         if (null !== ($children = $this->processSitemapItems($pageOptions['children']))) {
                             $sitemap .= $this->getView()->partial('page/widget/sitemap-item-children', ['children' => $children]);
                         }
                     }
                     $sitemap .= $this->getView()->partial('page/widget/sitemap-item-end');
                 }
             }
         }
     }
     return $sitemap;
 }