protected function _loadPageLevels()
    {
        $urlSegments = count(Request::segments());

        // check for homepage feed
        if ($urlSegments == 1 && substr(Request::segment(1), 0, 5) == 'root.') {
            if ($this->feedExtension = Feed::getFeedExtensionFromPath(Request::segment(1))) {
                $urlSegments = 0;
            }
        }

        // load homepage
        if (empty($this->pageLevels[0])) {
            $this->pageLevels[0] = self::_loadHomePage();
        }

        // load sub pages
        if ($urlSegments) {
            for ($i = 1; $i <= $urlSegments; $i++) {
                if (empty($this->pageLevels[$i])) {

                    $currentSegment = Request::segment($i);

                    if ($urlSegments == $i && $this->feedExtension = Feed::getFeedExtensionFromPath($currentSegment)) {
                        Feed::removeFeedExtensionFromPath($currentSegment);
                    }

                    $parentPage = $this->pageLevels[$i - 1];
                    if ($i == 1) {
                        $parentPage = isset($parentPage) ? clone $parentPage : new Page;
                        $parentPage->id = 0;
                    }

                    $this->pageLevels[$i] = self::_loadSubPage($currentSegment, $parentPage);

                    if (empty($this->pageLevels[$i])) {
                        if (($searchOffset = self::_isSearchPage($currentSegment, $parentPage)) !== false) {
                            $this->searchRequired = true;
                            $this->searchQuery = implode('/', array_slice(Request::segments(), $i - 1 + $searchOffset));
                            unset($this->pageLevels[$i]);
                            $urlSegments = $i - 1;
                        }
                        break;
                    }

                }
            }
        }

        $this->pageLevels = array_filter($this->pageLevels);

        if (!empty($this->pageLevels[$urlSegments])) {
            $this->is404 = false;
        } else {
            $page404 = new Page;
            $page404Lang = new PageLang;
            $page404Lang->url = '';
            $page404Lang->name = '404';
            $page404->setRelation('pageCurrentLang', $page404Lang);
            $this->pageLevels[] = $page404;
        }

        if ($this->searchQuery === false && $query = Request::input('q')) {
            $this->searchQuery = $query;
        }
        $this->searchQuery = $this->searchQuery !== false ? urldecode($this->searchQuery) : false;
    }
protected function _loadPageLevels()
    {
        $urlSegments = count(Request::segments());

        // check for homepage feed
        if ($urlSegments == 1 && substr(Request::segment(1), 0, 5) == 'root.') {
            if ($this->feedExtension = Feed::getFeedExtensionFromPath(Request::segment(1))) {
                $urlSegments = 0;
            }
        }

        // load homepage
        if (empty($this->pageLevels[0])) {
            $this->pageLevels[0] = self::_loadHomePage();
        }

        // load sub pages
        if ($urlSegments) {
            for ($i = 1; $i <= $urlSegments; $i++) {
                if (empty($this->pageLevels[$i])) {

                    $currentSegment = Request::segment($i);

                    if ($urlSegments == $i && $this->feedExtension = Feed::getFeedExtensionFromPath($currentSegment)) {
                        Feed::removeFeedExtensionFromPath($currentSegment);
                    }

                    $parentPage = $this->pageLevels[$i - 1];
                    if ($i == 1) {
                        $parentPage = isset($parentPage) ? clone $parentPage : new Page;
                        $parentPage->id = 0;
                    }

                    $this->pageLevels[$i] = self::_loadSubPage($currentSegment, $parentPage);

                    if (empty($this->pageLevels[$i])) {
                        if (($searchOffset = self::_isSearchPage($currentSegment, $parentPage)) !== false) {
                            $this->searchRequired = true;
                            $this->searchQuery = implode('/', array_slice(Request::segments(), $i - 1 + $searchOffset));
                            unset($this->pageLevels[$i]);
                            $urlSegments = $i - 1;
                        }
                        break;
                    }

                }
            }
        }

        $this->pageLevels = array_filter($this->pageLevels);

        if (!empty($this->pageLevels[$urlSegments])) {
            $this->is404 = false;
        } else {
            $page404 = new Page;
            $page404Lang = new PageLang;
            $page404Lang->url = '';
            $page404Lang->name = '404';
            $page404->setRelation('pageCurrentLang', $page404Lang);
            $this->pageLevels[] = $page404;
        }

        if ($this->searchQuery === false && $query = Request::input('q')) {
            $this->searchQuery = $query;
        }
        $this->searchQuery = $this->searchQuery !== false ? urldecode($this->searchQuery) : false;
    }
protected function _loadPageLevels ( ) { $ urlSegments = count ( Request :: segments ( ) ) ; // check for homepage feed if ( $ urlSegments == 1 && substr ( Request :: segment ( 1 ) , 0 , 5 ) == 'root.' ) { if ( $ this -> feedExtension = Feed :: getFeedExtensionFromPath ( Request :: segment ( 1 ) ) ) { $ urlSegments = 0 ; } } // load homepage if ( empty ( $ this -> pageLevels [ 0 ] ) ) { $ this -> pageLevels [ 0 ] = self :: _loadHomePage ( ) ; } // load sub pages if ( $ urlSegments ) { for ( $ i = 1 ; $ i <= $ urlSegments ; $ i ++ ) { if ( empty ( $ this -> pageLevels [ $ i ] ) ) { $ currentSegment = Request :: segment ( $ i ) ; if ( $ urlSegments == $ i && $ this -> feedExtension = Feed :: getFeedExtensionFromPath ( $ currentSegment ) ) { Feed :: removeFeedExtensionFromPath ( $ currentSegment ) ; } $ parentPage = $ this -> pageLevels [ $ i - 1 ] ; if ( $ i == 1 ) { $ parentPage = isset ( $ parentPage ) ? clone $ parentPage : new Page ; $ parentPage -> id = 0 ; } $ this -> pageLevels [ $ i ] = self :: _loadSubPage ( $ currentSegment , $ parentPage ) ; if ( empty ( $ this -> pageLevels [ $ i ] ) ) { if ( ( $ searchOffset = self :: _isSearchPage ( $ currentSegment , $ parentPage ) ) !== false ) { $ this -> searchRequired = true ; $ this -> searchQuery = implode ( '/' , array_slice ( Request :: segments ( ) , $ i - 1 + $ searchOffset ) ) ; unset ( $ this -> pageLevels [ $ i ] ) ; $ urlSegments = $ i - 1 ; } break ; } } } } $ this -> pageLevels = array_filter ( $ this -> pageLevels ) ; if ( ! empty ( $ this -> pageLevels [ $ urlSegments ] ) ) { $ this -> is404 = false ; } else { $ page404 = new Page ; $ page404Lang = new PageLang ; $ page404Lang -> url = '' ; $ page404Lang -> name = '404' ; $ page404 -> setRelation ( 'pageCurrentLang' , $ page404Lang ) ; $ this -> pageLevels [ ] = $ page404 ; } if ( $ this -> searchQuery === false && $ query = Request :: input ( 'q' ) ) { $ this -> searchQuery = $ query ; } $ this -> searchQuery = $ this -> searchQuery !== false ? urldecode ( $ this -> searchQuery ) : false ; }
Load all page levels for current request.
Also check if search page or feed page.
Load all page levels for current request . Also check if search page or feed page .