From 82593cd2bc056da73caa1b1e981c5a9ead0f1bf2 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 02:37:16 +0000 Subject: Refs #3362. Plugins don't check deps upon boot. Made package and manifest private properties of ElggPlugin and added ->getPackage() and ->getManifest(). git-svn-id: http://code.elgg.org/elgg/trunk@9030 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/lib/admin.php') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 06418c44f..61f64c8b3 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -329,7 +329,7 @@ function elgg_admin_add_plugin_settings_menu() { 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', @@ -541,7 +541,7 @@ 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( -- cgit v1.2.3 From 51ac43e54bd9430602e9e754a9d615a8947f4df5 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 27 Apr 2011 21:21:36 +0000 Subject: Fixed possible WSOD for plugin text file page handler. git-svn-id: http://code.elgg.org/elgg/trunk@9037 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engine/lib/admin.php') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 61f64c8b3..5528a29cc 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -516,9 +516,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(); @@ -545,7 +547,9 @@ function admin_markdown_page_handler($pages) { $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' => '
' . $text . '
', 'title' => $title )); -- cgit v1.2.3 From 7ee9c7cacbe5da9ecc8c5bb8d3ba51be3ce1d30a Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 19 May 2011 23:42:41 +0000 Subject: Fixes #3163 plugin//settings.php is now the preferred way to add settings plugins git-svn-id: http://code.elgg.org/elgg/trunk@9101 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 8 +++++--- views/default/object/plugin/advanced.php | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'engine/lib/admin.php') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 5528a29cc..8016a2fd6 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -325,7 +325,9 @@ 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", @@ -413,8 +415,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]); diff --git a/views/default/object/plugin/advanced.php b/views/default/object/plugin/advanced.php index 4c8bc8c17..9aed4163c 100644 --- a/views/default/object/plugin/advanced.php +++ b/views/default/object/plugin/advanced.php @@ -182,8 +182,9 @@ if ($files) {
getID() . '/edit'; -if (elgg_view_exists($settings_view)) { +$settings_view_old = 'settings/' . $plugin->getID() . '/edit'; +$settings_view_new = 'plugins/' . $plugin->getID() . '/settings'; +if (elgg_view_exists($settings_view_old) || elgg_view_exists($settings_view_new)) { $link = elgg_get_site_url() . "admin/plugin_settings/" . $plugin->getID(); $settings_link = "[" . elgg_echo('settings') . "]"; } -- cgit v1.2.3 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 (limited to 'engine/lib/admin.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 = ""; +} 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 = ""; -} 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 From 8cd4d7f312dbf68636d10a34121d781628c2ead2 Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 9 Jun 2011 20:42:58 +0000 Subject: Fixes #3548 the check for an admin menu's parent wasn't working git-svn-id: http://code.elgg.org/elgg/trunk@9159 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engine/lib/admin.php') diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 7c41fc24e..6ef626f81 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); } -- cgit v1.2.3 From a3a84cec2f5424a9195c38f299161278a623913a Mon Sep 17 00:00:00 2001 From: cash Date: Sat, 11 Jun 2011 14:01:13 +0000 Subject: sorting plugin settings menu items by text git-svn-id: http://code.elgg.org/elgg/trunk@9169 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/classes/ElggMenuItem.php | 11 +++++++++++ engine/lib/admin.php | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) (limited to 'engine/lib/admin.php') diff --git a/engine/classes/ElggMenuItem.php b/engine/classes/ElggMenuItem.php index 61dbf539e..caaba49a1 100644 --- a/engine/classes/ElggMenuItem.php +++ b/engine/classes/ElggMenuItem.php @@ -419,6 +419,17 @@ class ElggMenuItem { $this->children[] = $item; } + /** + * Set the menu item's children + * + * @param array $children Array of ElggMenuItems + * + * @return void + */ + public function setChildren($children) { + $this->children = $children; + } + /** * Get the children menu items * 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() { @@ -347,6 +353,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 * -- cgit v1.2.3