aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-06-11 14:01:13 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-06-11 14:01:13 +0000
commita3a84cec2f5424a9195c38f299161278a623913a (patch)
tree72d99c576494429032ca8f1f7911e843830b206e /engine/lib
parent27c507aa645114acd38e3b05e31ffd2c27e242e8 (diff)
downloadelgg-a3a84cec2f5424a9195c38f299161278a623913a.tar.gz
elgg-a3a84cec2f5424a9195c38f299161278a623913a.tar.bz2
sorting plugin settings menu items by text
git-svn-id: http://code.elgg.org/elgg/trunk@9169 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/admin.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 6ef626f81..3bfb69102 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -211,7 +211,7 @@ function elgg_register_admin_menu_item($section, $menu_id, $parent_id = NULL, $p
}
/**
- * Initialise the admin backend.
+ * Initialize the admin backend.
*
* @return void
*/
@@ -284,6 +284,11 @@ function admin_init() {
// plugin settings are added in elgg_admin_add_plugin_settings_menu() via the admin page handler
// for performance reasons.
+ // we want plugin settings menu items to be sorted alphabetical
+ if (elgg_in_context('admin')) {
+ elgg_register_plugin_hook_handler('prepare', 'menu:page', 'elgg_admin_sort_page_menu');
+ }
+
if (elgg_is_admin_logged_in()) {
elgg_register_menu_item('topbar', array(
'name' => 'administration',
@@ -321,6 +326,7 @@ function admin_init() {
*
* @return void
* @access private
+ * @since 1.8.0
*/
function elgg_admin_add_plugin_settings_menu() {
@@ -348,6 +354,33 @@ function elgg_admin_add_plugin_settings_menu() {
}
/**
+ * Sort the plugin settings menu items
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return
+ * @param array $params
+ *
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_admin_sort_page_menu($hook, $type, $return, $params) {
+ $configure_items = $return['configure'];
+ foreach ($configure_items as $menu_item) {
+ if ($menu_item->getName() == 'settings') {
+ $settings = $menu_item;
+ }
+ }
+
+ // keep the basic and advanced settings at the top
+ $children = $settings->getChildren();
+ $site_settings = array_splice($children, 0, 2);
+ usort($children, array('ElggMenuBuilder', 'compareByText'));
+ array_splice($children, 0, 0, $site_settings);
+ $settings->setChildren($children);
+}
+
+/**
* Handles any set up required for administration pages
*
* @return void