getPageInfo() публичный статический Метод

Get more info about a page
public static getPageInfo ( integer $pageId ) : string
$pageId integer The pageID wherefore you want more information.
Результат string
Пример #1
0
 /**
  * Load the data
  */
 private function loadData()
 {
     // get the current page id
     $pageId = $this->getContainer()->get('page')->getId();
     $navigation = FrontendNavigation::getNavigation();
     $pageInfo = FrontendNavigation::getPageInfo($pageId);
     $this->navigation = array();
     if (isset($navigation['page'][$pageInfo['parent_id']])) {
         $pages = $navigation['page'][$pageInfo['parent_id']];
         // store
         $pagesPrev = $pages;
         $pagesNext = $pages;
         // check for current id
         foreach ($pagesNext as $key => $value) {
             if ((int) $key != (int) $pageId) {
                 // go to next pointer in array
                 next($pagesNext);
                 next($pagesPrev);
             } else {
                 break;
             }
         }
         // get previous page
         $this->navigation['previous'] = prev($pagesPrev);
         // get next page
         $this->navigation['next'] = next($pagesNext);
         // get parent page
         $this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']);
     }
 }
Пример #2
0
 /**
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     parent::__construct($kernel);
     // store in reference
     $this->getContainer()->set('breadcrumb', $this);
     // get more information for the homepage
     $homeInfo = Navigation::getPageInfo(1);
     // add homepage as first item (with correct element)
     $this->addElement($homeInfo['navigation_title'], Navigation::getURL(1));
     // get other pages
     $pages = $this->URL->getPages();
     // init vars
     $items = array();
     $errorURL = Navigation::getUrl(404);
     // loop pages
     while (!empty($pages)) {
         // init vars
         $URL = implode('/', $pages);
         $menuId = Navigation::getPageId($URL);
         $pageInfo = Navigation::getPageInfo($menuId);
         // do we know something about the page
         if ($pageInfo !== false && isset($pageInfo['navigation_title'])) {
             // only add pages that aren't direct actions
             if ($pageInfo['tree_type'] != 'direct_action') {
                 // get URL
                 $pageURL = Navigation::getUrl($menuId);
                 // if this is the error-page, so we won't show an URL.
                 if ($pageURL == $errorURL) {
                     $pageURL = null;
                 }
                 // add to the items
                 $items[] = array('title' => $pageInfo['navigation_title'], 'url' => $pageURL);
             }
         }
         // remove element
         array_pop($pages);
     }
     // reverse so everything is in place
     krsort($items);
     // loop and add elements
     foreach ($items as $row) {
         $this->addElement($row['title'], $row['url']);
     }
 }
Пример #3
0
 /**
  * Process the query string
  */
 private function processQueryString()
 {
     // store the query string local, so we don't alter it.
     $queryString = trim($this->request->getPathInfo(), '/');
     // split into chunks
     $chunks = (array) explode('/', $queryString);
     $hasMultiLanguages = $this->getContainer()->getParameter('site.multilanguage');
     // single language
     if (!$hasMultiLanguages) {
         // set language id
         $language = $this->get('fork.settings')->get('Core', 'default_language', SITE_DEFAULT_LANGUAGE);
     } else {
         // multiple languages
         // default value
         $mustRedirect = false;
         // get possible languages
         $possibleLanguages = (array) Language::getActiveLanguages();
         $redirectLanguages = (array) Language::getRedirectLanguages();
         // the language is present in the URL
         if (isset($chunks[0]) && in_array($chunks[0], $possibleLanguages)) {
             // define language
             $language = (string) $chunks[0];
             // try to set a cookie with the language
             try {
                 // set cookie
                 CommonCookie::set('frontend_language', $language);
             } catch (\SpoonCookieException $e) {
                 // settings cookies isn't allowed, because this isn't a real problem we ignore the exception
             }
             // set sessions
             \SpoonSession::set('frontend_language', $language);
             // remove the language part
             array_shift($chunks);
         } elseif (CommonCookie::exists('frontend_language') && in_array(CommonCookie::get('frontend_language'), $redirectLanguages)) {
             // set languageId
             $language = (string) CommonCookie::get('frontend_language');
             // redirect is needed
             $mustRedirect = true;
         } else {
             // default browser language
             // set languageId & abbreviation
             $language = Language::getBrowserLanguage();
             // try to set a cookie with the language
             try {
                 // set cookie
                 CommonCookie::set('frontend_language', $language);
             } catch (\SpoonCookieException $e) {
                 // settings cookies isn't allowed, because this isn't a real problem we ignore the exception
             }
             // redirect is needed
             $mustRedirect = true;
         }
         // redirect is required
         if ($mustRedirect) {
             // build URL
             // trim the first / from the query string to prevent double slashes
             $url = rtrim('/' . $language . '/' . trim($this->getQueryString(), '/'), '/');
             // when we are just adding the language to the domain, it's a temporary redirect because
             // Safari keeps the 301 in cache, so the cookie to switch language doesn't work any more
             $redirectCode = $url == '/' . $language ? 302 : 301;
             // set header & redirect
             throw new RedirectException('Redirect', new RedirectResponse($url, $redirectCode));
         }
     }
     // define the language
     defined('FRONTEND_LANGUAGE') || define('FRONTEND_LANGUAGE', $language);
     defined('LANGUAGE') || define('LANGUAGE', $language);
     // sets the locale file
     Language::setLocale($language);
     // list of pageIds & their full URL
     $keys = Navigation::getKeys();
     // rebuild our URL, but without the language parameter. (it's tripped earlier)
     $url = implode('/', $chunks);
     $startURL = $url;
     // loop until we find the URL in the list of pages
     while (!in_array($url, $keys)) {
         // remove the last chunk
         array_pop($chunks);
         // redefine the URL
         $url = implode('/', $chunks);
     }
     // remove language from query string
     if ($hasMultiLanguages) {
         $queryString = trim(mb_substr($queryString, mb_strlen($language)), '/');
     }
     // if it's the homepage AND parameters were given (not allowed!)
     if ($url == '' && $queryString != '') {
         // get 404 URL
         $url = Navigation::getURL(404);
         // remove language
         if ($hasMultiLanguages) {
             $url = str_replace('/' . $language, '', $url);
         }
     }
     // set pages
     $url = trim($url, '/');
     // currently not in the homepage
     if ($url != '') {
         // explode in pages
         $pages = explode('/', $url);
         // reset pages
         $this->setPages($pages);
         // reset parameters
         $this->setParameters(array());
     }
     // set parameters
     $parameters = trim(mb_substr($startURL, mb_strlen($url)), '/');
     // has at least one parameter
     if ($parameters != '') {
         // parameters will be separated by /
         $parameters = explode('/', $parameters);
         // set parameters
         $this->setParameters($parameters);
     }
     // pageId, parentId & depth
     $pageId = Navigation::getPageId(implode('/', $this->getPages()));
     $pageInfo = Navigation::getPageInfo($pageId);
     // invalid page, or parameters but no extra
     if ($pageInfo === false || !empty($parameters) && !$pageInfo['has_extra']) {
         // get 404 URL
         $url = Navigation::getURL(404);
         // remove language
         if ($hasMultiLanguages) {
             $url = str_replace('/' . $language, '', $url);
         }
         // remove the first slash
         $url = trim($url, '/');
         // currently not in the homepage
         if ($url != '') {
             // explode in pages
             $pages = explode('/', $url);
             // reset pages
             $this->setPages($pages);
             // reset parameters
             $this->setParameters(array());
         }
     }
     // is this an internal redirect?
     if (isset($pageInfo['redirect_page_id']) && $pageInfo['redirect_page_id'] != '') {
         // get url for item
         $newPageURL = Navigation::getURL((int) $pageInfo['redirect_page_id']);
         $errorURL = Navigation::getURL(404);
         // not an error?
         if ($newPageURL != $errorURL) {
             // redirect
             throw new RedirectException('Redirect', new RedirectResponse($newPageURL, $pageInfo['redirect_code']));
         }
     }
     // is this an external redirect?
     if (isset($pageInfo['redirect_url']) && $pageInfo['redirect_url'] != '') {
         // redirect
         throw new RedirectException('Redirect', new RedirectResponse($pageInfo['redirect_url'], $pageInfo['redirect_code']));
     }
 }
Пример #4
0
 /**
  * Get tags for current "page"
  */
 private function getTags()
 {
     // get page id
     $pageId = $this->getContainer()->get('page')->getId();
     // array of excluded records
     $this->exclude[] = array('module' => 'Pages', 'other_id' => $pageId);
     // get tags for page
     $tags = (array) FrontendTagsModel::getForItem('pages', $pageId);
     foreach ($tags as $tag) {
         $this->tags = array_merge((array) $this->tags, (array) $tag['name']);
     }
     // get page record
     $record = (array) FrontendNavigation::getPageInfo($pageId);
     // loop blocks
     foreach ((array) $record['extra_blocks'] as $block) {
         // set module class
         $class = 'Frontend\\Modules\\' . $block['module'] . '\\Engine\\Model';
         if (is_callable(array($class, 'getIdForTags'))) {
             // get record for module
             $record = FrontendTagsModel::callFromInterface($block['module'], $class, 'getIdForTags', $this->URL);
             // check if record exists
             if (!$record) {
                 continue;
             }
             // add to excluded records
             $this->exclude[] = array('module' => $block['module'], 'other_id' => $record['id']);
             // get record's tags
             $tags = (array) FrontendTagsModel::getForItem($block['module'], $record['id']);
             foreach ($tags as $tag) {
                 $this->tags = array_merge((array) $this->tags, (array) $tag['name']);
             }
         }
     }
 }
Пример #5
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'];
             }
         }
     }
 }
Пример #6
0
 /**
  * Get the subnavigation html
  *   syntax: {{ getsubnavigation($type, $parentId, $startdepth, $enddepth, $excludeIds-splitted-by-dash, $template) }}
  *
  *   NOTE: When supplying more than 1 ID to exclude, the single quotes around the dash-separated list are mandatory.
  *
  * @param string $type       The type of navigation, possible values are: page, footer.
  * @param int    $pageId     The parent wherefore the navigation should be build.
  * @param int    $startDepth The depth to start from.
  * @param int    $endDepth   The maximum depth that has to be build.
  * @param string $excludeIds Which pageIds should be excluded (split them by -).
  * @param string $template        The template that will be used.
  *
  * @return string
  */
 public static function getSubNavigation($type = 'page', $pageId = 0, $startDepth = 1, $endDepth = null, $excludeIds = null, $template = '/Core/Layout/Templates/Navigation.html.twig')
 {
     // build excludeIds
     if ($excludeIds !== null) {
         $excludeIds = (array) explode('-', $excludeIds);
     }
     // get info about the given page
     $pageInfo = Navigation::getPageInfo($pageId);
     // validate page info
     if ($pageInfo === false) {
         return '';
     }
     // split URL into chunks
     $chunks = (array) explode('/', $pageInfo['full_url']);
     // remove language chunk
     $hasMultiLanguages = FrontendModel::getContainer()->getParameter('site.multilanguage');
     $chunks = $hasMultiLanguages ? (array) array_slice($chunks, 2) : (array) array_slice($chunks, 1);
     if (count($chunks) == 0) {
         $chunks[0] = '';
     }
     // init var
     $parentURL = '';
     // build url
     for ($i = 0; $i < $startDepth - 1; ++$i) {
         $parentURL .= $chunks[$i] . '/';
     }
     // get parent ID
     $parentID = Navigation::getPageId($parentURL);
     try {
         // get HTML
         $return = (string) Navigation::getNavigationHTML($type, $parentID, $endDepth, $excludeIds, (string) $template);
     } catch (Exception $e) {
         return '';
     }
     // return the var
     if ($return != '') {
         return $return;
     }
     // fallback
     return;
 }