aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/admin.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/admin.php')
-rw-r--r--engine/lib/admin.php70
1 files changed, 58 insertions, 12 deletions
diff --git a/engine/lib/admin.php b/engine/lib/admin.php
index 06418c44f..3bfb69102 100644
--- a/engine/lib/admin.php
+++ b/engine/lib/admin.php
@@ -183,7 +183,7 @@ function elgg_admin_notice_exists($id) {
function elgg_register_admin_menu_item($section, $menu_id, $parent_id = NULL, $priority = 100) {
// make sure parent is registered
- if ($parent_id && !elgg_is_menu_item_registered($menu_id, $parent_id)) {
+ if ($parent_id && !elgg_is_menu_item_registered('page', $parent_id)) {
elgg_register_admin_menu_item($section, $parent_id);
}
@@ -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
*/
@@ -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);
@@ -277,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',
@@ -314,6 +326,7 @@ function admin_init() {
*
* @return void
* @access private
+ * @since 1.8.0
*/
function elgg_admin_add_plugin_settings_menu() {
@@ -325,11 +338,13 @@ function elgg_admin_add_plugin_settings_menu() {
foreach ($active_plugins as $plugin) {
$plugin_id = $plugin->getID();
- if (elgg_view_exists("settings/$plugin_id/edit")) {
+ $settings_view_old = 'settings/' . $plugin_id . '/edit';
+ $settings_view_new = 'plugins/' . $plugin_id . '/settings';
+ if (elgg_view_exists($settings_view_new) || elgg_view_exists($settings_view_old)) {
elgg_register_menu_item('page', array(
'name' => $plugin_id,
'href' => "admin/plugin_settings/$plugin_id",
- 'text' => $plugin->manifest->getName(),
+ 'text' => $plugin->getManifest()->getName(),
'parent_name' => 'settings',
'context' => 'admin',
'section' => 'configure',
@@ -339,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
@@ -413,8 +455,8 @@ function admin_settings_page_handler($page) {
$vars = array('page' => $page);
// special page for plugin settings since we create the form for them
- if ($page[0] == 'plugin_settings' && isset($page[1])
- && elgg_view_exists("settings/{$page[1]}/edit")) {
+ if ($page[0] == 'plugin_settings' && isset($page[1]) &&
+ (elgg_view_exists("settings/{$page[1]}/edit") || elgg_view_exists("plugins/{$page[1]}/settings"))) {
$view = 'admin/plugin_settings';
$plugin = elgg_get_plugin_from_id($page[1]);
@@ -516,9 +558,11 @@ function admin_markdown_page_handler($pages) {
$filename = elgg_extract(1, $pages);
$error = false;
-
if (!$plugin) {
$error = elgg_echo('admin:plugins:markdown:unknown_plugin');
+ $body = elgg_view_layout('admin', array('content' => $error, 'title' => $error));
+ echo elgg_view_page($title, $body, 'admin');
+ return true;
}
$text_files = $plugin->getAvailableTextFiles();
@@ -541,11 +585,13 @@ function admin_markdown_page_handler($pages) {
return true;
}
- $title = $plugin->manifest->getName() . ": $filename";
+ $title = $plugin->getManifest()->getName() . ": $filename";
$text = Markdown($file_contents);
$body = elgg_view_layout('admin', array(
- 'content' => $text,
+ // setting classes here because there's no way to pass classes
+ // to the layout
+ 'content' => '<div class="elgg-markdown">' . $text . '</div>',
'title' => $title
));