diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-13 18:48:40 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-13 18:48:40 +0000 |
commit | caf76cbe72ca6749962a1feddfd70bdd29483c36 (patch) | |
tree | c25cc57270602691f3cb756f98e6a17001779d89 | |
parent | ac39d8a06f422887cf256d77a096c03783dd349e (diff) | |
download | elgg-caf76cbe72ca6749962a1feddfd70bdd29483c36.tar.gz elgg-caf76cbe72ca6749962a1feddfd70bdd29483c36.tar.bz2 |
admin menu uses weights for ordering
git-svn-id: http://code.elgg.org/elgg/trunk@8201 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/classes/ElggMenuBuilder.php | 19 | ||||
-rw-r--r-- | engine/classes/ElggMenuItem.php | 25 | ||||
-rw-r--r-- | engine/lib/admin.php | 40 | ||||
-rw-r--r-- | languages/en.php | 6 | ||||
-rw-r--r-- | views/default/layout/shells/admin/menu.php | 4 |
5 files changed, 70 insertions, 24 deletions
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php index f51ec8c62..33abc0c6b 100644 --- a/engine/classes/ElggMenuBuilder.php +++ b/engine/classes/ElggMenuBuilder.php @@ -179,9 +179,12 @@ class ElggMenuBuilder { case 'title': $sort_callback = array('ElggMenuBuilder', 'compareByTitle'); break; - case 'name'; + case 'name': $sort_callback = array('ElggMenuBuilder', 'compareByName'); break; + case 'weight': + $sort_callback = array('ElggMenuBuilder', 'compareByWeight'); + break; case 'order': // use registration order return; @@ -244,4 +247,18 @@ class ElggMenuBuilder { return strcmp($a, $b); } + + /** + * Compare two menu items by their weight + * + * @param ElggMenuItem $a + * @param ElggMenuItem $b + * @return bool + */ + public static function compareByWeight($a, $b) { + $a = $a->getWeight(); + $b = $b->getWeight(); + + return $a > $b; + } } diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index a190a89ef..108cb56f2 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -39,6 +39,11 @@ class ElggMenuItem { protected $tooltip = ''; /** + * @var int Menu weight - smaller weights float to the top + */ + protected $weight = 100; + + /** * @var bool Is this the currently selected menu item */ protected $selected = false; @@ -227,6 +232,26 @@ class ElggMenuItem { } /** + * Set the weight of the menu item + * + * @param int $weight The lower weight items float to the top of the menu + * + * @return void + */ + public function setWeight($weight) { + $this->weight = $weight; + } + + /** + * Get the weight of the menu item + * + * @return int + */ + public function getWeight() { + return $this->weight; + } + + /** * Set the section identifier * * @param string $section The identifier of the section diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 77dcb5bd0..ea18d9e3f 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -23,7 +23,7 @@ function elgg_admin_add_plugin_settings_menu() { return FALSE; } - elgg_add_admin_menu_item('plugin_settings', elgg_echo('admin:plugin_settings')); + elgg_add_admin_menu_item('plugin_settings', elgg_echo('admin:plugin_settings'), null, 51); foreach ($active_plugins as $plugin) { $plugin_id = $plugin->getID(); @@ -43,10 +43,12 @@ function elgg_admin_add_plugin_settings_menu() { * @param string $section_id The Unique ID of section * @param string $section_title Human readable section title. * @param string $parent_id If a child section, the parent section id. + * @param int $weight The menu item weight * * @return bool + * @since 1.8.0 */ -function elgg_add_admin_menu_item($section_id, $section_title, $parent_id = NULL) { +function elgg_add_admin_menu_item($section_id, $section_title, $parent_id = NULL, $weight = 100) { // in the admin section parents never have links if ($parent_id) { @@ -66,6 +68,7 @@ function elgg_add_admin_menu_item($section_id, $section_title, $parent_id = NULL 'title' => $section_title, 'context' => 'admin', 'parent_name' => $parent_id, + 'weight' => $weight, )); } @@ -98,32 +101,32 @@ function admin_init() { elgg_view_register_simplecache('js/admin'); // statistics - elgg_add_admin_menu_item('statistics', elgg_echo('admin:statistics')); + elgg_add_admin_menu_item('statistics', elgg_echo('admin:statistics'), null, 60); elgg_add_admin_menu_item('overview', elgg_echo('admin:statistics:overview'), 'statistics'); // site - elgg_add_admin_menu_item('site', elgg_echo('admin:site')); - elgg_add_admin_menu_item('basic', elgg_echo('admin:site:basic'), 'site'); - elgg_add_admin_menu_item('advanced', elgg_echo('admin:site:advanced'), 'site'); + elgg_add_admin_menu_item('site', elgg_echo('admin:site'), null, 20); + elgg_add_admin_menu_item('basic', elgg_echo('admin:site:basic'), 'site', 10); + elgg_add_admin_menu_item('advanced', elgg_echo('admin:site:advanced'), 'site', 20); // appearance - elgg_add_admin_menu_item('appearance', elgg_echo('admin:appearance')); - elgg_add_admin_menu_item('menu_items', elgg_echo('admin:appearance:menu_items'), 'appearance'); - elgg_add_admin_menu_item('profile_fields', elgg_echo('admin:appearance:profile_fields'), 'appearance'); + elgg_add_admin_menu_item('appearance', elgg_echo('admin:appearance'), null, 30); + elgg_add_admin_menu_item('menu_items', elgg_echo('admin:appearance:menu_items'), 'appearance', 10); + elgg_add_admin_menu_item('profile_fields', elgg_echo('admin:appearance:profile_fields'), 'appearance', 20); // users - elgg_add_admin_menu_item('users', elgg_echo('admin:users')); - elgg_add_admin_menu_item('online', elgg_echo('admin:users:online'), 'users'); - elgg_add_admin_menu_item('newest', elgg_echo('admin:users:newest'), 'users'); - elgg_add_admin_menu_item('add', elgg_echo('admin:users:add'), 'users'); + elgg_add_admin_menu_item('users', elgg_echo('admin:users'), null, 40); + elgg_add_admin_menu_item('add', elgg_echo('admin:users:add'), 'users', 10); + elgg_add_admin_menu_item('online', elgg_echo('admin:users:online'), 'users', 20); + elgg_add_admin_menu_item('newest', elgg_echo('admin:users:newest'), 'users', 30); // plugins - elgg_add_admin_menu_item('plugins', elgg_echo('admin:plugins')); - elgg_add_admin_menu_item('simple', elgg_echo('admin:plugins:simple'), 'plugins'); - elgg_add_admin_menu_item('advanced', elgg_echo('admin:plugins:advanced'), 'plugins'); + elgg_add_admin_menu_item('plugins', elgg_echo('admin:plugins'), null, 50); + elgg_add_admin_menu_item('simple', elgg_echo('admin:plugins:simple'), 'plugins', 10); + elgg_add_admin_menu_item('advanced', elgg_echo('admin:plugins:advanced'), 'plugins', 20); - // plugins - elgg_add_admin_menu_item('utilities', elgg_echo('admin:utilities')); + // utilities + elgg_add_admin_menu_item('utilities', elgg_echo('admin:utilities'), null, 70); // dashboard elgg_register_menu_item('page', array( @@ -131,6 +134,7 @@ function admin_init() { 'url' => 'pg/admin/dashboard', 'title' => elgg_echo('admin:dashboard'), 'context' => 'admin', + 'weight' => 10, )); // widgets diff --git a/languages/en.php b/languages/en.php index 5195264bd..99107b464 100644 --- a/languages/en.php +++ b/languages/en.php @@ -537,9 +537,9 @@ $english = array( 'admin:users:opt:description' => "Configure users and account information. ", 'admin:users:find' => 'Find', - 'admin:site' => "Site Settings", - 'admin:site:basic' => 'Basic', - 'admin:site:advanced' => 'Advanced', + 'admin:site' => "Site", + 'admin:site:basic' => 'Basic Settings', + 'admin:site:advanced' => 'Advanced Settings', 'admin:site:description' => "This admin panel allows you to control global settings for your site. Choose an option below to get started.", 'admin:site:opt:linktext' => "Configure site...", 'admin:site:access:warning' => "Changing the access setting only affects the permissions on content created in the future.", diff --git a/views/default/layout/shells/admin/menu.php b/views/default/layout/shells/admin/menu.php index b0e0d0063..c33eeac32 100644 --- a/views/default/layout/shells/admin/menu.php +++ b/views/default/layout/shells/admin/menu.php @@ -3,6 +3,6 @@ * Admin sidebar menu */ -$content = elgg_view_menu('page', array('sort_by' => 'name')); +$content = elgg_view_menu('page', array('sort_by' => 'weight')); -echo elgg_view_module('main', elgg_echo('admin:menu'), $content);
\ No newline at end of file +echo elgg_view_module('main', '', $content);
\ No newline at end of file |