diff options
author | Mate Bartus <mate.bartus@gmail.com> | 2015-07-14 23:14:35 +0200 |
---|---|---|
committer | Mate Bartus <mate.bartus@gmail.com> | 2015-07-14 23:14:35 +0200 |
commit | c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9 (patch) | |
tree | 4afa54827826e414ef7617f050d8f512121430a7 /phpBB/phpbb/install | |
parent | 051b7d1867351df293d055b62e0eb051758f90da (diff) | |
download | forums-c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9.tar forums-c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9.tar.gz forums-c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9.tar.bz2 forums-c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9.tar.xz forums-c5c98b7ca2dfb85925bc3ec1d6057ec554f9b4f9.zip |
[ticket/13740] Implement navigation sorting
PHPBB3-13740
Diffstat (limited to 'phpBB/phpbb/install')
-rw-r--r-- | phpBB/phpbb/install/controller/helper.php | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/phpBB/phpbb/install/controller/helper.php b/phpBB/phpbb/install/controller/helper.php index 8445d80a41..5ef98ac2bb 100644 --- a/phpBB/phpbb/install/controller/helper.php +++ b/phpBB/phpbb/install/controller/helper.php @@ -158,8 +158,7 @@ class helper { // Get navigation items $nav_array = $this->navigation_provider->get(); - - // @todo Sort navs by order + $nav_array = $this->sort_navigation_level($nav_array); $active_main_menu = $this->get_active_main_menu($nav_array); @@ -174,7 +173,7 @@ class helper if (is_array($entry[0]) && $active_main_menu === $key) { - // @todo Sort navs by order + $entry[0] = $this->sort_navigation_level($entry[0]); foreach ($entry[0] as $name => $sub_entry) { @@ -220,6 +219,7 @@ class helper protected function render_language_select() { $langs = $this->lang_helper->get_available_languages(); + // @todo } /** @@ -246,7 +246,7 @@ class helper { foreach ($nav_options[0] as $sub_menus) { - if (isset($sub_menus['route']) &&$sub_menus['route'] === $active_route) + if (isset($sub_menus['route']) && $sub_menus['route'] === $active_route) { return $current_menu; } @@ -256,4 +256,31 @@ class helper return false; } + + /** + * Sorts the top level of navigation array + * + * @param array $nav_array Navigation array + * + * @return array + */ + protected function sort_navigation_level($nav_array) + { + $sorted = array(); + foreach ($nav_array as $nav) + { + $order = (isset($nav['order'])) ? $nav['order'] : 0; + $sorted[$order][] = $nav; + } + + // Linearization of navigation array + $nav_array = array(); + ksort($sorted); + foreach ($sorted as $nav) + { + $nav_array = array_merge($nav_array, $nav); + } + + return $nav_array; + } } |