From 977ab26af244f793440301a3bd4f35d45b1dd0b1 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 9 Jun 2011 19:35:05 +0000 Subject: Refs #2871 promoted advanced plugins up to be a primary menu git-svn-id: http://code.elgg.org/elgg/trunk@9156 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 13 ++- views/default/admin/plugins.php | 171 +++++++++++++++++++++++++++++++ views/default/admin/plugins/advanced.php | 171 ------------------------------- 3 files changed, 181 insertions(+), 174 deletions(-) create mode 100644 views/default/admin/plugins.php delete mode 100644 views/default/admin/plugins/advanced.php diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 8016a2fd6..7c41fc24e 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -262,11 +262,18 @@ function admin_init() { // configure // plugins - elgg_register_admin_menu_item('configure', 'plugins', null, 10); - elgg_register_admin_menu_item('configure', 'simple', 'plugins', 10); - elgg_register_admin_menu_item('configure', 'advanced', 'plugins', 20); + elgg_register_menu_item('page', array( + 'name' => 'plugins', + 'href' => 'admin/plugins', + 'text' => elgg_echo('admin:plugins'), + 'context' => 'admin', + 'priority' => 75, + 'section' => 'configure' + )); // settings + elgg_register_admin_menu_item('configure', 'appearance', null, 50); + elgg_register_admin_menu_item('configure', 'settings', null, 100); elgg_register_admin_menu_item('configure', 'basic', 'settings', 10); elgg_register_admin_menu_item('configure', 'advanced', 'settings', 20); elgg_register_admin_menu_item('configure', 'menu_items', 'appearance', 30); diff --git a/views/default/admin/plugins.php b/views/default/admin/plugins.php new file mode 100644 index 000000000..9f426fae2 --- /dev/null +++ b/views/default/admin/plugins.php @@ -0,0 +1,171 @@ + $plugin) { + if (!$plugin->isValid()) { + continue; + } + + $plugin_categories = $plugin->getManifest()->getCategories(); + + // handle plugins that don't declare categories + // unset them here because this is the list we foreach + switch ($show_category) { + case 'all': + break; + case 'active': + if (!$plugin->isActive()) { + unset($installed_plugins[$id]); + } + break; + case 'inactive': + if ($plugin->isActive()) { + unset($installed_plugins[$id]); + } + break; + default: + if (!in_array($show_category, $plugin_categories)) { + unset($installed_plugins[$id]); + } + break; + } + + if (isset($plugin_categories)) { + foreach ($plugin_categories as $category) { + if (!array_key_exists($category, $categories)) { + $categories[$category] = elgg_echo("admin:plugins:category:$category"); + } + } + } +} + +// sort plugins +switch ($sort) { + case 'date': + $plugin_list = array(); + foreach ($installed_plugins as $plugin) { + $create_date = $plugin->getTimeCreated(); + while (isset($plugin_list[$create_date])) { + $create_date++; + } + $plugin_list[$create_date] = $plugin; + } + krsort($plugin_list); + break; + case 'alpha': + $plugin_list = array(); + foreach ($installed_plugins as $plugin) { + $plugin_list[$plugin->getManifest()->getName()] = $plugin; + } + ksort($plugin_list); + break; + case 'priority': + default: + $plugin_list = $installed_plugins; + break; +} + + + +asort($categories); + +$common_categories = array( + 'all' => elgg_echo('admin:plugins:category:all'), + 'active' => elgg_echo('admin:plugins:category:active'), + 'inactive' => elgg_echo('admin:plugins:category:inactive'), +); + +$categories = array_merge($common_categories, $categories); +// security - only want a defined option +if (!array_key_exists($show_category, $categories)) { + $show_category = reset($categories); +} + +$category_form = elgg_view_form('admin/plugins/filter', array( + 'action' => 'admin/plugins/advanced', + 'method' => 'get', + 'disable_security' => true, +), array( + 'category' => $show_category, + 'category_options' => $categories, + 'sort' => $sort, +)); + + +$sort_options = array( + 'priority' => elgg_echo('admin:plugins:sort:priority'), + 'alpha' => elgg_echo('admin:plugins:sort:alpha'), + 'date' => elgg_echo('admin:plugins:sort:date'), +); +// security - only want a defined option +if (!array_key_exists($sort, $sort_options)) { + $sort = reset($sort_options); +} + +$sort_form = elgg_view_form('admin/plugins/sort', array( + 'action' => 'admin/plugins/advanced', + 'method' => 'get', + 'disable_security' => true, +), array( + 'sort' => $sort, + 'sort_options' => $sort_options, + 'category' => $show_category, +)); + + +// @todo Until "en/deactivate all" means "All plugins on this page" hide when not looking at all. +if ($show_category == 'all') { + $activate_url = "action/admin/plugins/activate_all"; + $activate_url = elgg_add_action_tokens_to_url($activate_url); + $deactivate_url = "action/admin/plugins/deactivate_all"; + $deactivate_url = elgg_add_action_tokens_to_url($deactivate_url); + + $buttons = "
"; + $buttons .= "" . elgg_echo('admin:plugins:activate_all') . ' '; + $buttons .= "" . elgg_echo('admin:plugins:deactivate_all') . ' '; + $buttons .= "
"; +} else { + $buttons = ''; +} + +$buttons .= $category_form . $sort_form; + +// construct page header +?> +
+
+
+ +
+ 0, + 'full_view' => true, + 'list_type_toggle' => false, + 'pagination' => false, +); +if ($show_category == 'all' && $sort == 'priority') { + $options['display_reordering'] = true; +} +echo elgg_view_entity_list($plugin_list, $options); + +?> +
\ No newline at end of file diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php deleted file mode 100644 index 9f426fae2..000000000 --- a/views/default/admin/plugins/advanced.php +++ /dev/null @@ -1,171 +0,0 @@ - $plugin) { - if (!$plugin->isValid()) { - continue; - } - - $plugin_categories = $plugin->getManifest()->getCategories(); - - // handle plugins that don't declare categories - // unset them here because this is the list we foreach - switch ($show_category) { - case 'all': - break; - case 'active': - if (!$plugin->isActive()) { - unset($installed_plugins[$id]); - } - break; - case 'inactive': - if ($plugin->isActive()) { - unset($installed_plugins[$id]); - } - break; - default: - if (!in_array($show_category, $plugin_categories)) { - unset($installed_plugins[$id]); - } - break; - } - - if (isset($plugin_categories)) { - foreach ($plugin_categories as $category) { - if (!array_key_exists($category, $categories)) { - $categories[$category] = elgg_echo("admin:plugins:category:$category"); - } - } - } -} - -// sort plugins -switch ($sort) { - case 'date': - $plugin_list = array(); - foreach ($installed_plugins as $plugin) { - $create_date = $plugin->getTimeCreated(); - while (isset($plugin_list[$create_date])) { - $create_date++; - } - $plugin_list[$create_date] = $plugin; - } - krsort($plugin_list); - break; - case 'alpha': - $plugin_list = array(); - foreach ($installed_plugins as $plugin) { - $plugin_list[$plugin->getManifest()->getName()] = $plugin; - } - ksort($plugin_list); - break; - case 'priority': - default: - $plugin_list = $installed_plugins; - break; -} - - - -asort($categories); - -$common_categories = array( - 'all' => elgg_echo('admin:plugins:category:all'), - 'active' => elgg_echo('admin:plugins:category:active'), - 'inactive' => elgg_echo('admin:plugins:category:inactive'), -); - -$categories = array_merge($common_categories, $categories); -// security - only want a defined option -if (!array_key_exists($show_category, $categories)) { - $show_category = reset($categories); -} - -$category_form = elgg_view_form('admin/plugins/filter', array( - 'action' => 'admin/plugins/advanced', - 'method' => 'get', - 'disable_security' => true, -), array( - 'category' => $show_category, - 'category_options' => $categories, - 'sort' => $sort, -)); - - -$sort_options = array( - 'priority' => elgg_echo('admin:plugins:sort:priority'), - 'alpha' => elgg_echo('admin:plugins:sort:alpha'), - 'date' => elgg_echo('admin:plugins:sort:date'), -); -// security - only want a defined option -if (!array_key_exists($sort, $sort_options)) { - $sort = reset($sort_options); -} - -$sort_form = elgg_view_form('admin/plugins/sort', array( - 'action' => 'admin/plugins/advanced', - 'method' => 'get', - 'disable_security' => true, -), array( - 'sort' => $sort, - 'sort_options' => $sort_options, - 'category' => $show_category, -)); - - -// @todo Until "en/deactivate all" means "All plugins on this page" hide when not looking at all. -if ($show_category == 'all') { - $activate_url = "action/admin/plugins/activate_all"; - $activate_url = elgg_add_action_tokens_to_url($activate_url); - $deactivate_url = "action/admin/plugins/deactivate_all"; - $deactivate_url = elgg_add_action_tokens_to_url($deactivate_url); - - $buttons = "
"; - $buttons .= "" . elgg_echo('admin:plugins:activate_all') . ' '; - $buttons .= "" . elgg_echo('admin:plugins:deactivate_all') . ' '; - $buttons .= "
"; -} else { - $buttons = ''; -} - -$buttons .= $category_form . $sort_form; - -// construct page header -?> -
-
-
- -
- 0, - 'full_view' => true, - 'list_type_toggle' => false, - 'pagination' => false, -); -if ($show_category == 'all' && $sort == 'priority') { - $options['display_reordering'] = true; -} -echo elgg_view_entity_list($plugin_list, $options); - -?> -
\ No newline at end of file -- cgit v1.2.3