1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
|
<?php
/**
* Displays a plugin on the admin screen.
*
* This file renders a plugin for the admin screen, including active/deactive,
* manifest details & display plugin settings.
*
* @uses $vars['entity']
* @uses $vars['display_reordering'] Do we display the priority reordering links?
*
* @package Elgg.Core
* @subpackage Plugins
*/
$plugin = $vars['entity'];
$reordering = elgg_extract('display_reordering', $vars, false);
$priority = $plugin->getPriority();
$active = $plugin->isActive();
$can_activate = $plugin->canActivate();
$max_priority = elgg_get_max_plugin_priority();
$actions_base = '/action/admin/plugins/';
$css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
// build reordering links
$links = '';
$classes = array('elgg-plugin');
if ($reordering) {
$classes[] = 'elgg-state-draggable';
// top and up link only if not at top
if ($priority > 1) {
$top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
'plugin_guid' => $plugin->guid,
'priority' => 'first',
'is_action' => true
));
$links .= "<li>" . elgg_view('output/url', array(
'href' => $top_url,
'text' => elgg_echo('top'),
'is_action' => true,
'is_trusted' => true,
)) . "</li>";
$up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
'plugin_guid' => $plugin->guid,
'priority' => '-1',
'is_action' => true
));
$links .= "<li>" . elgg_view('output/url', array(
'href' => $up_url,
'text' => elgg_echo('up'),
'is_action' => true,
'is_trusted' => true,
)) . "</li>";
}
// down and bottom links only if not at bottom
if ($priority < $max_priority) {
$down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
'plugin_guid' => $plugin->guid,
'priority' => '+1',
'is_action' => true
));
$links .= "<li>" . elgg_view('output/url', array(
'href' => $down_url,
'text' => elgg_echo('down'),
'is_action' => true,
'is_trusted' => true,
)) . "</li>";
$bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
'plugin_guid' => $plugin->guid,
'priority' => 'last',
'is_action' => true
));
$links .= "<li>" . elgg_view('output/url', array(
'href' => $bottom_url,
'text' => elgg_echo('bottom'),
'is_action' => true,
'is_trusted' => true,
)) . "</li>";
}
} else {
$classes[] = 'elgg-state-undraggable';
}
// activate / deactivate links
// always let them deactivate
$options = array(
'is_action' => true,
'is_trusted' => true,
);
if ($active) {
$classes[] = 'elgg-state-active';
$action = 'deactivate';
$options['text'] = elgg_echo('admin:plugins:deactivate');
$options['class'] = "elgg-button elgg-button-cancel";
if (!$can_activate) {
$classes[] = 'elgg-state-active';
$options['class'] = 'elgg-button elgg-state-warning';
}
} else if ($can_activate) {
$classes[] = 'elgg-state-inactive';
$action = 'activate';
$options['text'] = elgg_echo('admin:plugins:activate');
$options['class'] = "elgg-button elgg-button-submit";
} else {
$classes[] = 'elgg-state-inactive';
$action = '';
$options['text'] = elgg_echo('admin:plugins:cannot_activate');
$options['class'] = "elgg-button elgg-button-disabled";
$options['disabled'] = 'disabled';
}
if ($action) {
$url = elgg_http_add_url_query_elements($actions_base . $action, array(
'plugin_guids[]' => $plugin->guid
));
$options['href'] = $url;
}
$action_button = elgg_view('output/url', $options);
// Display categories and make category classes
$categories = $plugin->getManifest()->getCategories();
$categories_html = '';
if ($categories) {
$base_url = elgg_get_site_url() . "admin/plugins?category=";
foreach ($categories as $category) {
$css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
$classes[] = "elgg-plugin-category-$css_class";
$url = $base_url . urlencode($category);
$friendly_category = htmlspecialchars(ElggPluginManifest::getFriendlyCategory($category));
$categories_html .= "<li class=\"elgg-plugin-category prm\"><a href=\"$url\">$friendly_category</a></li>";
}
}
$screenshots_html = '';
$screenshots = $plugin->getManifest()->getScreenshots();
if ($screenshots) {
$base_url = elgg_get_plugins_path() . $plugin->getID() . '/';
foreach ($screenshots as $screenshot) {
$desc = elgg_echo($screenshot['description']);
$alt = htmlentities($desc, ENT_QUOTES, 'UTF-8');
$screenshot_full = "{$vars['url']}admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}";
$screenshot_src = "{$vars['url']}admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}";
$screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\"><a class=\"elgg-lightbox\" href=\"$screenshot_full\">"
. "<img src=\"$screenshot_src\" alt=\"$alt\"></a></li>";
}
}
// metadata
$description = elgg_view('output/longtext', array('value' => $plugin->getManifest()->getDescription()));
$author = '<span>' . elgg_echo('admin:plugins:label:author') . '</span>: '
. elgg_view('output/text', array('value' => $plugin->getManifest()->getAuthor()));
$version = htmlspecialchars($plugin->getManifest()->getVersion());
$website = elgg_view('output/url', array(
'href' => $plugin->getManifest()->getWebsite(),
'text' => $plugin->getManifest()->getWebsite(),
'is_trusted' => true,
));
$resources = array(
'repository' => $plugin->getManifest()->getRepository(),
'bugtracker' => $plugin->getManifest()->getBugTracker(),
'donate' => $plugin->getManifest()->getDonationsPage(),
);
$resources_html = "<ul class=\"elgg-plugin-resources\">";
foreach ($resources as $id => $href) {
if ($href) {
$resources_html .= "<li class=\"prm\">";
$resources_html .= elgg_view('output/url', array(
'href' => $href,
'text' => elgg_echo("admin:plugins:label:$id"),
'is_trusted' => true,
));
$resources_html .= "</li>";
}
}
$resources_html .= "</ul>";
$copyright = elgg_view('output/text', array('value' => $plugin->getManifest()->getCopyright()));
$license = elgg_view('output/text', array('value' => $plugin->getManifest()->getLicense()));
// show links to text files
$files = $plugin->getAvailableTextFiles();
$docs = '';
if ($files) {
$docs = '<ul>';
foreach ($files as $file => $path) {
$url = 'admin_plugin_text_file/' . $plugin->getID() . "/$file";
$link = elgg_view('output/url', array(
'text' => $file,
'href' => $url,
'is_trusted' => true,
));
$docs .= "<li>$link</li>";
}
$docs .= '</ul>';
}
?>
<div class="<?php echo implode(' ', $classes); ?>" id="<?php echo $css_id; ?>">
<div class="elgg-image-block">
<div class="elgg-image-alt">
<?php if ($links) : ?>
<ul class="elgg-menu elgg-menu-metadata">
<?php echo $links; ?>
</ul>
<?php endif; ?>
<div class="clearfloat float-alt mtm">
<?php echo $action_button; ?>
</div>
</div>
<div class="elgg-body">
<?php
$settings_view_old = 'settings/' . $plugin->getID() . '/edit';
$settings_view_new = 'plugins/' . $plugin->getID() . '/settings';
if (elgg_view_exists($settings_view_old) || elgg_view_exists($settings_view_new)) {
$link = elgg_get_site_url() . "admin/plugin_settings/" . $plugin->getID();
$settings_link = "<a class='elgg-plugin-settings' href='$link'>[" . elgg_echo('settings') . "]</a>";
}
?>
<div class="elgg-head">
<h3><?php echo $plugin->getManifest()->getName() . " $version $settings_link"; ?></h3>
</div>
<?php
if ($plugin->getManifest()->getApiVersion() < 1.8) {
$reqs = $plugin->getManifest()->getRequires();
if (!$reqs) {
$message = elgg_echo('admin:plugins:warning:elgg_version_unknown');
echo "<p class=\"elgg-state-error\">$message</p>";
}
}
if (!$can_activate) {
if ($active) {
$message = elgg_echo('admin:plugins:warning:unmet_dependencies_active');
echo "<p class=\"elgg-state-warning\">$message</p>";
} else {
$message = elgg_echo('admin:plugins:warning:unmet_dependencies');
echo "<p class=\"elgg-state-error\">$message</p>";
}
}
?>
<div><?php echo $description; ?></div>
<p><?php echo $author . ' - ' . $website; ?></p>
<?php
echo $resources_html;
echo $docs;
?>
<div class="pts">
<?php
echo elgg_view('output/url', array(
'href' => "#elgg-plugin-manifest-$css_id",
'text' => elgg_echo("admin:plugins:label:moreinfo"),
'rel' => 'toggle',
));
?>
</div>
</div>
</div>
<div class="elgg-plugin-more hidden" id="elgg-plugin-manifest-<?php echo $css_id; ?>">
<?php
if ($screenshots_html) {
?>
<div><ul><?php echo $screenshots_html; ?></ul></div>
<?php
}
if ($categories_html) {
?>
<div><?php echo elgg_echo('admin:plugins:label:categories') . ": <ul class=\"elgg-plugin-categories\">$categories_html</ul>"; ?></div>
<?php
}
?>
<div><?php echo elgg_echo('admin:plugins:label:copyright') . ": " . $copyright; ?></div>
<div><?php echo elgg_echo('admin:plugins:label:licence') . ": " . $license; ?></div>
<div><?php echo elgg_echo('admin:plugins:label:location') . ": " . htmlspecialchars($plugin->getPath()) ?></div>
<div><?php echo elgg_echo('admin:plugins:label:dependencies'); ?>:
<?php
echo elgg_view('object/plugin/elements/dependencies', array('plugin' => $plugin));
?>
</div>
</div>
</div>
|