diff --git a/PicoPagesList.php b/PicoPagesList.php index d03679b..2457aec 100644 --- a/PicoPagesList.php +++ b/PicoPagesList.php @@ -1,13 +1,13 @@ items = $this->nestedPages($pages); + } + + + /** + * Store the current url. + * + * Triggered after Pico has found the current page and possible siblings + * + * See {@link DummyPlugin::onSinglePageLoaded()} for details about the + * structure of the page data. + * * @see Pico::getCurrentPage() * @see Pico::getPreviousPage() * @see Pico::getNextPage() - * @param array[] &$pages data of all known pages * @param array|null &$currentPage data of the page being served * @param array|null &$previousPage data of the previous page * @param array|null &$nextPage data of the next page * @return void */ - public function onPagesLoaded( - array &$pages, + protected function onCurrentPageDiscovered( array &$currentPage = null, array &$previousPage = null, array &$nextPage = null ) { $base_url = $this->getConfig('base_url'); $this->currentPagePath = str_replace(array('?', $base_url), '', urldecode($currentPage['url'])); - $this->items = $this->nestedPages($pages); } /** @@ -59,15 +74,15 @@ public function onPagesLoaded( * * @see Pico::getTwig() * @see DummyPlugin::onPageRendered() - * @param Twig_Environment &$twig twig template engine - * @param array &$twigVariables template variables * @param string &$templateName file name of the template + * @param array &$twigVariables template variables * @return void */ - public function onPageRendering(Twig_Environment &$twig, array &$twigVariables, &$templateName) + public function onPageRendering(string &$templateName, array &$twigVariables) { + $twig = $this->getPico()->getTwig(); $twigVariables['nested_pages'] = $this->items; - + $twig->addFilter(new Twig_SimpleFilter('navigation', function($pages) { return $this->output($pages); })); @@ -124,7 +139,7 @@ private function nested_path($page) $parent = $value; break; } - + $parent['_childs'][$part] = $value; $parent = &$parent['_childs'][$part]; } @@ -143,7 +158,7 @@ private static function rtrim($str, $substr) $length = strlen($substr); return (substr($str, -$length) === $substr) ? substr($str, 0, -$length) : $str; } - + /** * Filter the pages array according to given paths, as exclusive or inclusive. * @@ -206,6 +221,8 @@ private function output($pages) $html = '