aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--languages/en.php4
-rw-r--r--views/default/admin/plugins/advanced.php76
-rw-r--r--views/default/forms/admin/plugins/filter.php24
-rw-r--r--views/default/forms/admin/plugins/sort.php24
4 files changed, 112 insertions, 16 deletions
diff --git a/languages/en.php b/languages/en.php
index a3ee4e421..923647882 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -609,6 +609,10 @@ $english = array(
'admin:plugins:category:theme' => 'Themes',
'admin:plugins:category:widget' => 'Widgets',
+ 'admin:plugins:sort:priority' => 'Priority',
+ 'admin:plugins:sort:alpha' => 'Alphabetical',
+ 'admin:plugins:sort:date' => 'Newest',
+
'admin:plugins:markdown:unknown_plugin' => 'Unknown plugin.',
'admin:plugins:markdown:unknown_file' => 'Unknown file.',
diff --git a/views/default/admin/plugins/advanced.php b/views/default/admin/plugins/advanced.php
index dad1b778d..deae9dcdd 100644
--- a/views/default/admin/plugins/advanced.php
+++ b/views/default/admin/plugins/advanced.php
@@ -11,6 +11,7 @@
elgg_generate_plugin_entities();
$installed_plugins = elgg_get_plugins('any');
$show_category = get_input('category', 'all');
+$sort = get_input('sort', 'priority');
// Get a list of the all categories
// and trim down the plugin list if we're not viewing all categories.
@@ -45,9 +46,6 @@ foreach ($installed_plugins as $id => $plugin) {
}
break;
}
- //if ($show_category && !in_array($show_category, $plugin_categories)) {
- // unset($installed_plugins[$id]);
- //}
if (isset($plugin_categories)) {
foreach ($plugin_categories as $category) {
@@ -58,6 +56,34 @@ foreach ($installed_plugins as $id => $plugin) {
}
}
+// 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(
@@ -67,25 +93,43 @@ $common_categories = array(
);
$categories = array_merge($common_categories, $categories);
+// security - only want a defined option
+if (!array_key_exists($show_category, $categories)) {
+ $show_category = reset($categories);
+}
-$category_dropdown = elgg_view('input/dropdown', array(
- 'name' => 'category',
- 'options_values' => $categories,
- 'value' => $show_category
+$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,
));
-$category_button = elgg_view('input/submit', array(
- 'value' => elgg_echo('filter'),
- 'class' => 'elgg-button elgg-button-action'
-));
-$category_form = elgg_view('input/form', array(
- 'body' => $category_dropdown . $category_button,
- 'method' => 'get',
+$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";
@@ -101,7 +145,7 @@ if ($show_category == 'all') {
$buttons = '';
}
-$buttons .= $category_form;
+$buttons .= $category_form . $sort_form;
// construct page header
?>
@@ -112,7 +156,7 @@ $buttons .= $category_form;
<div id="elgg-plugin-list">
<?php
-echo elgg_view_entity_list($installed_plugins, 0, 0, 0, true, false, false);
+echo elgg_view_entity_list($plugin_list, 0, 0, 0, true, false, false);
?>
</div> \ No newline at end of file
diff --git a/views/default/forms/admin/plugins/filter.php b/views/default/forms/admin/plugins/filter.php
new file mode 100644
index 000000000..d00906e6a
--- /dev/null
+++ b/views/default/forms/admin/plugins/filter.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Category filter for plugins
+ *
+ * @uses $vars['category']
+ * @uses $vars['category_options']
+ * @uses $vvars['sort']
+ */
+
+echo elgg_view('input/dropdown', array(
+ 'name' => 'category',
+ 'options_values' => $vars['category_options'],
+ 'value' => $vars['category'],
+));
+
+echo elgg_view('input/hidden', array(
+ 'name' => 'sort',
+ 'value' => $vars['sort'],
+));
+
+echo elgg_view('input/submit', array(
+ 'value' => elgg_echo('filter'),
+ 'class' => 'elgg-button elgg-button-action',
+));
diff --git a/views/default/forms/admin/plugins/sort.php b/views/default/forms/admin/plugins/sort.php
new file mode 100644
index 000000000..284e085e6
--- /dev/null
+++ b/views/default/forms/admin/plugins/sort.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Sort plugins form body
+ *
+ * @uses $vars['sort']
+ * @uses $vars['sort_options']
+ * @uses $vars['category']
+ */
+
+echo elgg_view('input/dropdown', array(
+ 'name' => 'sort',
+ 'options_values' => $vars['sort_options'],
+ 'value' => $vars['sort'],
+));
+
+echo elgg_view('input/hidden', array(
+ 'name' => 'category',
+ 'value' => $vars['category'],
+));
+
+echo elgg_view('input/submit', array(
+ 'value' => elgg_echo('sort'),
+ 'class' => 'elgg-button elgg-button-action'
+));