Elgg  Version 4.x
full.php
Go to the documentation of this file.
1 <?php
11  return;
12 }
13 
14 /* @var ElggPlugin $plugin */
15 $plugin = elgg_extract('entity', $vars);
16 $reordering = elgg_extract('display_reordering', $vars, false);
17 $active = $plugin->isActive();
18 
19 $classes = ['elgg-plugin'];
20 $classes[] = $reordering ? 'elgg-state-draggable' : 'elgg-state-undraggable';
21 
22 $error = '';
23 if ($active) {
24  $can_activate = false;
25  try {
26  $plugin->assertCanDeactivate();
27  $can_deactivate = true;
28  } catch (\Elgg\Exceptions\PluginException $e) {
29  $error = $e->getMessage();
30  $can_deactivate = false;
31  }
32 } else {
33  $can_deactivate = false;
34  try {
35  $plugin->assertCanActivate();
36  $can_activate = true;
37  } catch (\Elgg\Exceptions\PluginException $e) {
38  $error = $e->getMessage();
39  $can_activate = false;
40  }
41 }
42 
43 // activate / deactivate button
45  'is_action' => true,
46 ];
47 
48 if ($active) {
49  $classes[] = 'elgg-state-active';
50 
51  $options['title'] = elgg_echo('admin:plugins:deactivate');
52  $options['text'] = elgg_echo('admin:plugins:deactivate');
53  if ($can_deactivate) {
54  $options['href'] = elgg_generate_action_url('admin/plugins/deactivate', ['plugin_guids[]' => $plugin->guid]);
55  $options['class'] = 'elgg-button elgg-button-cancel elgg-plugin-state-change';
56  } else {
57  $classes[] = 'elgg-state-cannot-deactivate';
58 
59  $options['title'] = elgg_echo('admin:plugins:cannot_deactivate');
60  $options['class'] = 'elgg-button elgg-button-cancel';
61  $options['disabled'] = true;
62  }
63 } else if ($can_activate) {
64  $classes[] = 'elgg-state-inactive';
65 
66  $options['href'] = elgg_generate_action_url('admin/plugins/activate', ['plugin_guids[]' => $plugin->guid]);
67  $options['title'] = elgg_echo('admin:plugins:activate');
68  $options['class'] = 'elgg-button elgg-button-submit elgg-plugin-state-change';
69  $options['text'] = elgg_echo('admin:plugins:activate');
70 } else {
71  $classes[] = 'elgg-state-inactive';
72  $classes[] = 'elgg-state-cannot-activate';
73 
74  $options['title'] = elgg_echo('admin:plugins:cannot_activate');
75  $options['class'] = 'elgg-button elgg-button-submit';
76  $options['text'] = elgg_echo('admin:plugins:activate');
77  $options['disabled'] = true;
78 }
79 
80 $action_button = elgg_trigger_plugin_hook('action_button', 'plugin', ['entity' => $plugin], elgg_view('output/url', $options));
81 
82 // Display categories and make category classes
83 $categories = array_keys($plugin->getCategories());
84 
85 $categories[] = 'all';
86 $categories[] = $active ? 'active' : 'inactive';
87 
88 if (!in_array('bundled', $categories)) {
89  $categories[] = 'nonbundled';
90 }
91 
92 $categories = array_map('strtolower', $categories);
93 
94 $style = null;
95 if (!in_array(elgg_extract('active_filter', $vars), $categories)) {
96  $style = 'display: none;';
97 }
98 
99 foreach ($categories as $category) {
100  $css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
101  $classes[] = "elgg-plugin-category-{$css_class}";
102 }
103 
104 $title = elgg_view('output/url', [
105  'href' => "ajax/view/object/plugin/details?guid={$plugin->guid}",
106  'text' => $plugin->getDisplayName(),
107  'class' => 'elgg-lightbox',
108 ]);
109 
110 $content = '';
111 
112 if ($error) {
113  $type = $active ? 'notice' : 'error';
114 
115  $content .= elgg_view_message($type, $error, ['title' => false, 'class' => 'elgg-subtext']);
116 }
117 
118 echo elgg_view('object/elements/summary', [
119  'entity' => $plugin,
120  'class' => $classes,
121  'image_block_vars' => [
122  'style' => $style,
123  'id' => preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID()),
124  ],
125  'data-guid' => $plugin->guid,
126  'icon' => $action_button,
127  'title' => $title,
128  'subtitle' => elgg_view('output/longtext', [
129  'value' => $plugin->getDescription(),
130  ]),
131  'content' => $content,
132  'display_reordering' => $reordering,
133 ]);
$action_button
Definition: full.php:80
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:54
elgg_generate_action_url($action, array $query=[], $add_csrf_tokens=true)
Generate an action URL.
$categories
Definition: full.php:83
$can_activate
Definition: full.php:36
$type
Definition: delete.php:21
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
if(!elgg_is_admin_logged_in()) $plugin
Displays a plugin.
Definition: full.php:15
$content
Definition: full.php:25
if(!in_array(elgg_extract('active_filter', $vars), $categories)) foreach($categories as $category) $title
Definition: full.php:104
elgg_view_message($type, $body, array $vars=[])
Wrapper function for the message display pattern.
Definition: views.php:991
$active
Definition: full.php:17
$reordering
Definition: full.php:16
$classes
Definition: full.php:19
$error
Definition: full.php:22
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:380
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:686
$style
Definition: full.php:94
elgg echo
Translates a string.
Definition: deprecated.js:530
$vars['head']
Definition: html.php:24
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:205
catch(\Elgg\Exceptions\PluginException $e) $options
Definition: full.php:44