diff options
author | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-06-09 18:49:15 +0000 |
---|---|---|
committer | cash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-06-09 18:49:15 +0000 |
commit | 92819a1cd4ac44607c35de069a1edf8ef5bc4048 (patch) | |
tree | 0ba7b585a0bd54a2e278d83b58905d82858cecb9 /views | |
parent | a7274e5b6ade1a47e2bda837ddf01b5a2087c198 (diff) | |
download | elgg-92819a1cd4ac44607c35de069a1edf8ef5bc4048.tar.gz elgg-92819a1cd4ac44607c35de069a1edf8ef5bc4048.tar.bz2 |
Refs #2871 adding sorting to advanced plugin page
git-svn-id: http://code.elgg.org/elgg/trunk@9153 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views')
-rw-r--r-- | views/default/admin/plugins/advanced.php | 76 | ||||
-rw-r--r-- | views/default/forms/admin/plugins/filter.php | 24 | ||||
-rw-r--r-- | views/default/forms/admin/plugins/sort.php | 24 |
3 files changed, 108 insertions, 16 deletions
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' +)); |