Elgg  Version master
plugins.php
Go to the documentation of this file.
1 <?php
10 elgg_import_esm('admin/plugins');
11 
12 $list_only = (bool) elgg_extract('list_only', $vars, false);
14 
15 // @todo this should occur in the controller code
16 _elgg_services()->plugins->generateEntities();
17 
19 
20 // needed for expected plugin view rendering, there are usecases where this is not set so forcing it here
21 elgg_push_context('admin');
22 
24  'limit' => false,
25  'full_view' => true,
26  'pagination' => false,
27  'display_reordering' => true,
28  'active_filter' => $active_filter,
29 ]);
30 
31 $plugins_list .= elgg_format_element('div', ['id' => 'elgg-plugin-list-cover']);
32 
34 
35 if ($list_only) {
36  echo $plugins_list;
37  return;
38 }
39 
41 
43  if (!$plugin->isValid()) {
44  if ($plugin->isActive()) {
45  if (elgg_get_config('auto_disable_plugins')) {
46  try {
47  // force disable and warn
48  $plugin->deactivate();
49 
50  elgg_add_admin_notice('invalid_and_deactivated_' . $plugin->getID(), elgg_echo('ElggPlugin:InvalidAndDeactivated', [$plugin->getID()]));
51  } catch (\Elgg\Exceptions\PluginException $e) {
52  // do nothing
53  }
54  }
55  }
56 
57  continue;
58  }
59 
60  $categories = array_merge($categories, $plugin->getCategories());
61 }
62 
63 echo elgg_view('admin/plugins/categories', [
64  'categories' => $categories,
65  'active_filter' => $active_filter,
66 ]);
67 
68 elgg_register_menu_item('title', [
69  'name' => 'activate-all',
70  'href' => elgg_generate_action_url('admin/plugins/activate_all'),
71  'text' => elgg_echo('admin:plugins:activate_all'),
72  'link_class' => 'elgg-button elgg-button-submit elgg-plugins-toggle',
73  'data-desired-state' => 'active',
74 ]);
75 elgg_register_menu_item('title', [
76  'name' => 'deactivate-all',
77  'href' => elgg_generate_action_url('admin/plugins/deactivate_all'),
78  'text' => elgg_echo('admin:plugins:deactivate_all'),
79  'link_class' => 'elgg-button elgg-button-submit elgg-plugins-toggle',
80  'data-desired-state' => 'inactive',
81 ]);
82 
83 echo elgg_format_element('div', ['id' => 'elgg-plugin-list'], $plugins_list);
elgg_get_plugins(string $status= 'active')
Returns an ordered list of plugins.
Definition: plugins.php:39
elgg_generate_action_url(string $action, array $query=[], bool $add_csrf_tokens=true)
Generate an action URL.
$plugin
$installed_plugins
Definition: plugins.php:18
if($list_only) $categories
Definition: plugins.php:40
elgg_get_config(string $name, $default=null)
Get an Elgg configuration value.
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_strtolower()
Wrapper function for mb_strtolower().
Definition: mb_wrapper.php:125
$list_only
Definition: plugins.php:12
get_input(string $variable, $default=null, bool $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:254
elgg_pop_context()
Removes and returns the top context string from the stack.
Definition: context.php:62
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
$plugins_list
Definition: plugins.php:23
elgg_import_esm(string $name)
Helper functions for external files like css/js.
$active_filter
Definition: plugins.php:13
elgg_view_entity_list(array $entities, array $vars=[])
Returns a rendered list of entities with pagination.
Definition: views.php:636
elgg_push_context(string $context)
Push a context onto the top of the stack.
Definition: context.php:52
$vars
Definition: theme.php:5
elgg_add_admin_notice(string $id, string $message)
Write a persistent message to the admin view.
Definition: admin.php:51
_elgg_services()
Get the global service provider.
Definition: elgglib.php:351
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_register_menu_item(string $menu_name, array|\ElggMenuItem $menu_item)
Elgg navigation library Functions for managing menus and other navigational elements.
Definition: navigation.php:83