Elgg  Version 3.0
full.php
Go to the documentation of this file.
1 <?php
14 /* @var ElggPlugin $plugin */
15 $plugin = elgg_extract('entity', $vars);
16 $reordering = elgg_extract('display_reordering', $vars, false);
17 $priority = $plugin->getPriority();
18 $active = $plugin->isActive();
19 $plugin_id = $plugin->getID();
20 
21 $actions_base = '/action/admin/plugins/';
22 
23 // build reordering links
24 $links = '';
25 $classes = ['elgg-plugin'];
26 
27 if ($reordering) {
28  $max_priority = _elgg_get_max_plugin_priority();
29 
30  if ($active) {
31  $can_activate = false;
32  $can_deactivate = $plugin->canDeactivate();
33  } else {
34  $can_deactivate = false;
35  $can_activate = $plugin->canActivate();
36  }
37 
38  $classes[] = 'elgg-state-draggable';
39 
40  // top and up link only if not at top
41  if ($priority > 1) {
42  $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', [
43  'plugin_guid' => $plugin->guid,
44  'priority' => 'first',
45  'is_action' => true
46  ]);
47 
48  $links .= "<li>" . elgg_view('output/url', [
49  'href' => $top_url,
50  'text' => elgg_echo('top'),
51  'is_action' => true,
52  'is_trusted' => true,
53  ]) . "</li>";
54 
55  $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', [
56  'plugin_guid' => $plugin->guid,
57  'priority' => '-1',
58  'is_action' => true
59  ]);
60 
61  $links .= "<li>" . elgg_view('output/url', [
62  'href' => $up_url,
63  'text' => elgg_echo('up'),
64  'is_action' => true,
65  'is_trusted' => true,
66  ]) . "</li>";
67  }
68 
69  // down and bottom links only if not at bottom
70  if ($priority < $max_priority) {
71  $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', [
72  'plugin_guid' => $plugin->guid,
73  'priority' => '+1',
74  'is_action' => true
75  ]);
76 
77  $links .= "<li>" . elgg_view('output/url', [
78  'href' => $down_url,
79  'text' => elgg_echo('down'),
80  'is_action' => true,
81  'is_trusted' => true,
82  ]) . "</li>";
83 
84  $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', [
85  'plugin_guid' => $plugin->guid,
86  'priority' => 'last',
87  'is_action' => true
88  ]);
89 
90  $links .= "<li>" . elgg_view('output/url', [
91  'href' => $bottom_url,
92  'text' => elgg_echo('bottom'),
93  'is_action' => true,
94  'is_trusted' => true,
95  ]) . "</li>";
96  }
97 
98  if ($links) {
99  $links = '<ul class="elgg-menu elgg-plugin-list-reordering">' . $links . '</ul>';
100  }
101 } else {
102  $classes[] = 'elgg-state-undraggable';
103 }
104 
105 // activate / deactivate links
106 // always let them deactivate
108  'is_action' => true,
109  'is_trusted' => true,
110 ];
111 $action = false;
112 if ($active) {
113  $classes[] = 'elgg-state-active';
114  $options['title'] = elgg_echo('admin:plugins:deactivate');
115  $options['text'] = elgg_echo('admin:plugins:deactivate');
116  if ($can_deactivate) {
117  $action = 'deactivate';
118  $options['class'] = 'elgg-button elgg-button-cancel elgg-plugin-state-change';
119  } else {
120  $classes[] = 'elgg-state-cannot-deactivate';
121  $options['title'] = elgg_echo('admin:plugins:cannot_deactivate');
122  $options['class'] = 'elgg-button elgg-button-cancel elgg-state-disabled';
123  $options['disabled'] = 'disabled';
124  }
125 } else if ($can_activate) {
126  $classes[] = 'elgg-state-inactive';
127  $action = 'activate';
128  $options['title'] = elgg_echo('admin:plugins:activate');
129  $options['class'] = 'elgg-button elgg-button-submit elgg-plugin-state-change';
130  $options['text'] = elgg_echo('admin:plugins:activate');
131 } else {
132  $classes[] = 'elgg-state-inactive elgg-state-cannot-activate';
133  $options['title'] = elgg_echo('admin:plugins:cannot_activate');
134  $options['class'] = 'elgg-button elgg-button-submit elgg-state-disabled';
135  $options['text'] = elgg_echo('admin:plugins:activate');
136  $options['disabled'] = 'disabled';
137 }
138 
139 if ($action) {
141  'plugin_guids[]' => $plugin->guid
142  ]);
143 }
144 
146 
147 $action_button = elgg_trigger_plugin_hook("action_button", "plugin", ["entity" => $plugin], $action_button);
148 
149 // Display categories and make category classes
150 $categories = $plugin->getManifest()->getCategories();
151 
152 $categories[] = 'all';
153 $categories[] = $active ? 'active' : 'inactive';
154 
155 if (!in_array('bundled', $categories)) {
156  $categories[] = 'nonbundled';
157 }
158 
159 foreach ($categories as $category) {
160  $css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
161  $classes[] = "elgg-plugin-category-$css_class";
162 }
163 
164 $body = elgg_view('output/url', [
165  'href' => "ajax/view/object/plugin/details?guid={$plugin->getGUID()}",
166  'text' => $plugin->getDisplayName(),
167  'class' => 'elgg-lightbox elgg-plugin-title',
168 ]);
169 
170 if (elgg_view_exists("plugins/{$plugin_id}/settings")) {
171  $body .= elgg_view('output/url', [
172  'href' => "admin/plugin_settings/{$plugin_id}",
173  'title' => elgg_echo('settings'),
174  'text' => elgg_view_icon('settings-alt'),
175  'class' => 'elgg-plugin-settings',
176  ]);
177 }
178 
179 $description = elgg_view('output/longtext', ['value' => $plugin->getManifest()->getDescription()]);
180 $body .= elgg_format_element('span', [
181  'class' => 'elgg-plugin-list-description',
182 ], $description);
183 
184 $error = $plugin->getError();
185 if ($error) {
187  'class' => $active ? 'elgg-text-help' : 'elgg-text-help elgg-state-error',
188  ], $error);
189 
190  $body .= "<div>$message</div>";
191 }
192 
194 echo elgg_format_element('div', [
195  'class' => $classes,
196  'id' => preg_replace('/[^a-z0-9-]/i', '-', $plugin_id),
197  'data-guid' => $plugin->guid,
198 ], $result);
if($action) $action_button
Definition: full.php:145
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:942
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
$action
Definition: full.php:111
$priority
Definition: full.php:17
$links
Definition: full.php:24
$categories
Definition: full.php:150
if(!in_array('bundled', $categories)) foreach($categories as $category) $body
Definition: full.php:164
$plugin_id
Definition: full.php:19
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_image_block($image, $body, $vars=[])
Wrapper function for the image block display pattern.
Definition: views.php:1177
$plugin
Definition: full.php:15
$active
Definition: full.php:18
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
$reordering
Definition: full.php:16
$classes
Definition: full.php:25
elgg echo
Translates a string.
Definition: languages.js:43
$error
Definition: full.php:184
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:720
if($error) $result
Definition: full.php:193
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
Definition: plugins.php:54
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:1131
$actions_base
Definition: full.php:21
$options
Definition: full.php:107
elgg_view_icon($name, $vars=[])
View an icon glyph.
Definition: views.php:1552
$vars['type']
Definition: save.php:11
if(elgg_view_exists("plugins/{$plugin_id}/settings")) $description
Definition: full.php:179
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246