Ejemplo n.º 1
0
 /**
  * Get pages
  *
  * @param string $language
  * @return array
  *      boolean url_active
  *      string url_title
  *      array url_params
  *      array xml_map
  *          string lastmod
  *          string changefreq
  *          string priority
  *     array children
  */
 public function getPages($language)
 {
     if (null === self::$pages) {
         self::$pages = [];
         $users = $this->getModel()->getAllActiveUsers();
         $currentPage = PageService::getCurrentPage();
         if (count($users)) {
             foreach ($users as $user) {
                 self::$pages[] = ['url_active' => !empty($currentPage['slug']) && $currentPage['slug'] == $this->dynamicPageName && RouteParamUtility::getParam('slug') == $user['slug'], 'url_title' => $user['nick_name'], 'url_params' => ['slug' => $user['slug']], 'xml_map' => ['lastmod' => $user['date_edited'], 'changefreq' => null, 'priority' => null], 'children' => []];
             }
         }
     }
     return self::$pages;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * Get page slug
  *
  * @return string|integer
  */
 protected function getPageSlug()
 {
     return !empty(PageService::getCurrentPage()['pages_provider']) ? $this->getSlug() : null;
 }
 /**
  * Is it page of news list
  * 
  * @return boolean
  */
 protected function isNewsListPage()
 {
     return self::NEWS_LIST_PAGE == PageService::getCurrentPage()['slug'];
 }
Ejemplo n.º 5
0
 /**
  * Class constructor
  *
  * @param array $pagesTree
  */
 public function __construct(array $pagesTree = [])
 {
     $this->pagesTree = $pagesTree;
     $this->currentPage = PageService::getCurrentPage();
 }
 /**
  * Is it shopping cart page
  * 
  * @return boolean
  */
 protected function isShoppingCartPage()
 {
     return !empty(PageService::getCurrentPage()['slug']) && self::SHOPPING_CART_PAGE == PageService::getCurrentPage()['slug'];
 }