Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
plugins.php
Go to the documentation of this file.
1 <?php
11 // @todo this should occur in the controller code
13 
15 
16 // Get a list of the all categories
17 // and trim down the plugin list if we're not viewing all categories.
18 // @todo this could be cached somewhere after have the manifest loaded
19 $categories = array();
20 
21 foreach ($installed_plugins as $id => $plugin) {
22  if (!$plugin->isValid()) {
23  if ($plugin->isActive()) {
24  $disable_plugins = elgg_get_config('auto_disable_plugins');
25  if ($disable_plugins === null) {
26  $disable_plugins = true;
27  }
28  if ($disable_plugins) {
29  // force disable and warn
30  elgg_add_admin_notice('invalid_and_deactivated_' . $plugin->getID(),
31  elgg_echo('ElggPlugin:InvalidAndDeactivated', array($plugin->getId())));
32  $plugin->deactivate();
33  }
34  }
35  continue;
36  }
37 
38  $plugin_categories = $plugin->getManifest()->getCategories();
39 
40  if (isset($plugin_categories)) {
41  foreach ($plugin_categories as $category) {
42  if (!array_key_exists($category, $categories)) {
44  }
45  }
46  }
47 }
48 
49 
50 asort($categories);
51 
52 // we want bundled/nonbundled pulled to be at the top of the list
53 unset($categories['bundled']);
54 unset($categories['nonbundled']);
55 
57  'all' => elgg_echo('admin:plugins:category:all'),
58  'active' => elgg_echo('admin:plugins:category:active'),
59  'inactive' => elgg_echo('admin:plugins:category:inactive'),
60  'bundled' => elgg_echo('admin:plugins:category:bundled'),
61  'nonbundled' => elgg_echo('admin:plugins:category:nonbundled'),
62 ];
63 
65 
66 $category_form = elgg_view("admin/plugins/filter", [
67  'category' => "all",
68  'category_options' => $categories
69 ]);
70 
71 $activate_all = elgg_view('output/url', [
72  'href' => 'action/admin/plugins/activate_all',
73  'text' => elgg_echo('admin:plugins:activate_all'),
74  'class' => 'elgg-button elgg-button-submit elgg-plugins-toggle',
75  'data-desired-state' => 'active',
76 ]);
77 $deactivate_all = elgg_view('output/url', [
78  'href' => 'action/admin/plugins/deactivate_all',
79  'text' => elgg_echo('admin:plugins:deactivate_all'),
80  'class' => 'elgg-button elgg-button-submit elgg-plugins-toggle',
81  'data-desired-state' => 'inactive',
82 ]);
83 
84 $buttons = elgg_format_element('div', ['class' => 'float-alt'], $activate_all . $deactivate_all);
85 
86 echo elgg_format_element('div', ['class' => 'mbm'], $buttons . $category_form);
87 
88 $options = array(
89  'limit' => 0,
90  'full_view' => true,
91  'list_type_toggle' => false,
92  'pagination' => false,
93  'display_reordering' => true
94 );
95 
96 echo elgg_format_element('div', ['id' => 'elgg-plugin-list'] , elgg_view_entity_list($installed_plugins, $options));
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$plugin
$installed_plugins
Definition: plugins.php:14
$activate_all
Definition: plugins.php:71
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_add_admin_notice($id, $message)
Write a persistent message to the admin view.
Definition: admin.php:75
$deactivate_all
Definition: plugins.php:77
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:218
$options
Definition: plugins.php:88
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:342
static getFriendlyCategory($category)
Returns a category's friendly name.
elgg_view_entity_list($entities, array $vars=array())
Returns a rendered list of entities with pagination.
Definition: views.php:1007
elgg_get_plugins($status= 'active', $site_guid=null)
Returns an ordered list of plugins.
Definition: plugins.php:132
$common_categories
Definition: plugins.php:56
$categories
Definition: plugins.php:19
$buttons
Definition: plugins.php:84
if(!$collection_name) $id
Definition: add.php:17
_elgg_generate_plugin_entities()
Discovers plugins in the plugins_path setting and creates entities for them if they don't exist...
Definition: plugins.php:60
$category_form
Definition: plugins.php:66