Skip to content

Commit

Permalink
Improve the solution for #1545 by sorting the settings menu properly
Browse files Browse the repository at this point in the history
to be naturally ordered and case insensitive.
  • Loading branch information
bharat committed Dec 30, 2010
1 parent dd6da5e commit a8b0254
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/gallery/helpers/gallery_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static function site_menu($menu, $theme, $item_css_selector) {
module::event("admin_menu", $admin_menu, $theme);

$settings_menu = $admin_menu->get("settings_menu");
sort($settings_menu->elements);
uasort($settings_menu->elements, array("Menu", "title_comparator"));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/gallery/libraries/Admin_View.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function admin_menu() {
module::event("admin_menu", $menu, $this);

$settings_menu = $menu->get("settings_menu");
sort($settings_menu->elements);
uasort($settings_menu->elements, array("Menu", "title_comparator"));

return $menu->render();
}
Expand Down
4 changes: 4 additions & 0 deletions modules/gallery/libraries/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,8 @@ public function render() {
$view->menu = $this;
return $view;
}

static function title_comparator($a, $b) {
return strnatcasecmp((string)$a->label, (string)$b->label);
}
}

0 comments on commit a8b0254

Please sign in to comment.