diff options
Diffstat (limited to 'views/default/admin/plugins.php')
| -rw-r--r-- | views/default/admin/plugins.php | 236 |
1 files changed, 174 insertions, 62 deletions
diff --git a/views/default/admin/plugins.php b/views/default/admin/plugins.php index 5a5d37f8c..42f153d0f 100644 --- a/views/default/admin/plugins.php +++ b/views/default/admin/plugins.php @@ -1,85 +1,197 @@ <?php /** - * Elgg administration plugin main screen + * Elgg administration plugin screen * - * @package Elgg - * @subpackage Core - * @author Curverider Ltd - * @link http://elgg.org/ + * Shows a list of plugins that can be sorted and filtered. + * + * @package Elgg.Core + * @subpackage Admin.Plugins */ -global $CONFIG; +elgg_load_js('lightbox'); +elgg_load_css('lightbox'); -$ts = time(); -$token = generate_action_token($ts); -$categories = array_merge(array('' => elgg_echo('admin:plugins:categories:all')), $vars['categories']); +elgg_generate_plugin_entities(); +$installed_plugins = elgg_get_plugins('any'); +$show_category = get_input('category', 'all'); +$sort = get_input('sort', 'priority'); -$category_pulldown = elgg_view('input/pulldown', array( - 'internalname' => 'category', - 'options_values' => $categories, - 'value' => $vars['show_category'] -)); +// Get a list of the all categories +// and trim down the plugin list if we're not viewing all categories. +// @todo this could be cached somewhere after have the manifest loaded +$categories = array(); -$category_button = elgg_view('input/button', array( - 'value' => elgg_echo('filter'), - 'class' => 'action_button' -)); +foreach ($installed_plugins as $id => $plugin) { + if (!$plugin->isValid()) { + if ($plugin->isActive()) { + // force disable and warn + elgg_add_admin_notice('invalid_and_deactivated_' . $plugin->getID(), + elgg_echo('ElggPlugin:InvalidAndDeactivated', array($plugin->getId()))); + $plugin->deactivate(); + } + continue; + } -$category_form = elgg_view('input/form', array( - 'body' => $category_pulldown . $category_button -)); + $plugin_categories = $plugin->getManifest()->getCategories(); -// Page Header elements -$title = elgg_view_title(elgg_echo('admin:plugins')); + // 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; + case 'nonbundled': + if (in_array('bundled', $plugin_categories)) { + unset($installed_plugins[$id]); + } + break; + default: + if (!in_array($show_category, $plugin_categories)) { + unset($installed_plugins[$id]); + } + break; + } -// @todo Until "en/disable all" means "All plugins on this page" hide when not looking at all. -if (!isset($vars['show_category']) || empty($vars['show_category'])) { - $buttons = "<a class='action_button' href=\"{$CONFIG->url}action/admin/plugins/enableall?__elgg_token=$token&__elgg_ts=$ts\">".elgg_echo('enableall')."</a> <a class='action_button disabled' href=\"{$CONFIG->url}action/admin/plugins/disableall?__elgg_token=$token&__elgg_ts=$ts\">".elgg_echo('disableall')."</a> "; - $buttons .= "<br /><br />"; -} else { - $buttons = ''; + if (isset($plugin_categories)) { + foreach ($plugin_categories as $category) { + if (!array_key_exists($category, $categories)) { + $categories[$category] = ElggPluginManifest::getFriendlyCategory($category); + } + } + } +} + +$guids = array(); +foreach ($installed_plugins as $plugin) { + $guids[] = $plugin->getGUID(); +} + +// 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->getFriendlyName()] = $plugin; + } + ksort($plugin_list); + break; + case 'priority': + default: + $plugin_list = $installed_plugins; + break; } -$buttons .= $category_form; -// construct page header -?> -<div id="content_header" class="clearfloat"> - <div class="content_header_title"><?php echo $title ?></div> - <div class="content_header_options"><?php echo $buttons ?></div> -</div> -<?php -echo elgg_view('output/longtext', array('value' => elgg_echo("admin:plugins:description"))); -$limit = get_input('limit', 10); -$offset = get_input('offset', 0); +asort($categories); -// Get the installed plugins -$installed_plugins = $vars['installed_plugins']; -$count = count($installed_plugins); +// we want bundled/nonbundled pulled to be at the top of the list +unset($categories['bundled']); +unset($categories['nonbundled']); -$plugin_list = get_plugin_list(); -$max = 0; -foreach($plugin_list as $key => $foo) { - if ($key > $max) $max = $key; +$common_categories = array( + 'all' => elgg_echo('admin:plugins:category:all'), + 'active' => elgg_echo('admin:plugins:category:active'), + 'inactive' => elgg_echo('admin:plugins:category:inactive'), + 'bundled' => elgg_echo('admin:plugins:category:bundled'), + 'nonbundled' => elgg_echo('admin:plugins:category:nonbundled'), +); + +$categories = array_merge($common_categories, $categories); +// security - only want a defined option +if (!array_key_exists($show_category, $categories)) { + $show_category = reset($categories); } -// Display list of plugins -$n = 0; -foreach ($installed_plugins as $plugin => $data) { - echo elgg_view("admin/plugins_opt/plugin", array('plugin' => $plugin, 'details' => $data, 'maxorder' => $max, 'order' => array_search($plugin, $plugin_list))); - $n++; +$category_form = elgg_view_form('admin/plugins/filter', array( + 'action' => 'admin/plugins', + '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', + 'method' => 'get', + 'disable_security' => true, +), array( + 'sort' => $sort, + 'sort_options' => $sort_options, + 'category' => $show_category, +)); + +$buttons = "<div class=\"clearfix mbm\">"; +$buttons .= elgg_view_form('admin/plugins/change_state', array( + 'action' => 'action/admin/plugins/activate_all', + 'class' => 'float', +), array( + 'guids' => $guids, + 'action' => 'activate', +)); +$buttons .= elgg_view_form('admin/plugins/change_state', array( + 'action' => 'action/admin/plugins/deactivate_all', + 'class' => 'float', +), array( + 'guids' => $guids, + 'action' => 'deactivate', +)); +$buttons .= "</div>"; + +$buttons .= $category_form . $sort_form; + +// construct page header ?> +<div id="content_header" class="mbm clearfix"> + <div class="content-header-options"><?php echo $buttons ?></div> +</div> + +<div id="elgg-plugin-list"> +<?php -<script type="text/javascript"> -$(document).ready(function() { - $('a.plugin_settings.link').click(function() { - elgg_slide_toggle($(this), '.plugin_details', '.pluginsettings'); - }); - $('a.manifest_details.link').click(function() { - elgg_slide_toggle($(this), '.plugin_details', '.manifest_file'); - }); -}); -</script> +$options = array( + 'limit' => 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); + +?> +</div>
\ No newline at end of file |
