function get_tree_navigation($data, $id_parent, $startDepth = 0, $maxDepth = -1, $articles = FALSE) { // Pages array $arr = array(); // Return array $select_data = array(); Structure::get_nested_structure($data, $arr, $id_parent, $startDepth, $maxDepth, $articles); return $arr; }
/** * Returns pages from one given parent page * * @TODO Check and finish writing * Planned for 1.0 * * @param FTL_Binding * * @return mixed */ public static function tag_pages(FTL_Binding $tag) { $cache = $tag->getAttribute('cache', TRUE); // Tag cache // if ($cache == TRUE && ($str = self::get_cache(FTL_Binding $tag)) !== FALSE) // return $str; // Returned string $str = ''; $parent = $tag->getAttribute('parent'); $mode = $tag->getAttribute('mode', 'flat'); $levels = $tag->getAttribute('levels'); $menu_name = $tag->getAttribute('menu'); $parent_page = NULL; // Display hidden navigation elements ? $display_hidden = $tag->getAttribute('display_hidden', FALSE); $limit = $tag->getAttribute('limit'); if (!is_null($parent)) { if (strval(abs((int) $parent)) == (string) $parent) { $parent_page = self::get_page_by_id($parent); } else { if (substr($parent, 0, 1) == '-') { $parent_page = self::get_relative_parent_page(self::registry('page'), $parent, $display_hidden); } else { if ($parent == 'this') { $parent_page = self::registry('page'); } else { $parent_page = self::get_page_by_code($parent); } } } } $data = self::registry('pages'); if (!empty($parent_page)) { if ($mode == 'tree') { $pages = Structure::get_tree_navigation($data, $parent_page['id_page']); } else { $pages = array(); Structure::get_nested_structure($data, $pages, $parent_page['id_page']); } } else { $pages = self::registry('pages'); } // Limit pages to a certain level if (!is_null($levels)) { $levels = (int) $levels; for ($i = count($pages) - 1; $i >= 0; $i--) { if ($pages[$i]['level'] > $levels) { unset($pages[$i]); } } $pages = array_values($pages); } // Limit pages to a certain menu if (!is_null($menu_name)) { // By default main menu $id_menu = 1; foreach (self::registry('menus') as $menu) { if ($menu_name == $menu['name']) { $id_menu = $menu['id_menu']; } } for ($i = count($pages) - 1; $i >= 0; $i--) { if ($pages[$i]['id_menu'] != $id_menu) { unset($pages[$i]); } } $pages = array_values($pages); } if ($display_hidden == FALSE) { $pages = array_values(array_filter($pages, array('TagManager_Page', '_filter_appearing_pages'))); } if (!is_null($limit)) { $pages = array_slice($pages, 0, $limit); } $count = count($pages); foreach ($pages as $key => $page) { // Render the article $tag->set('page', $page); $tag->set('index', $key); $tag->set('count', $count); $str .= $tag->expand(); } $output = self::wrap($tag, $str); // Tag cache self::set_cache($tag, $output); return $output; }
/** * @param $data * @param $id_parent * @param int $startDepth * @param $maxDepth * @param bool $articles * * @return array */ function get_tree_navigation($data, $id_parent, $startDepth = 0, $maxDepth = -1, $articles = FALSE) { // Pages array $arr = array(); Structure::get_nested_structure($data, $arr, $id_parent, $startDepth, $maxDepth, $articles); if ($articles) { foreach ($articles as $article) { if ($article['id_page'] == $id_parent) { $arr['articles'][] = $article; } } } return $arr; }