Elgg  Version 1.9
full.php
Go to the documentation of this file.
1 <?php
15 /* @var ElggPlugin $plugin */
16 $plugin = $vars['entity'];
17 
18 $reordering = elgg_extract('display_reordering', $vars, false);
19 $priority = $plugin->getPriority();
20 $active = $plugin->isActive();
21 
22 $can_activate = $plugin->canActivate();
24 $actions_base = '/action/admin/plugins/';
25 $css_id = preg_replace('/[^a-z0-9-]/i', '-', $plugin->getID());
26 
27 // build reordering links
28 $links = '';
29 $classes = array('elgg-plugin');
30 
31 if ($reordering) {
32  $classes[] = 'elgg-state-draggable';
33 
34  // top and up link only if not at top
35  if ($priority > 1) {
36  $top_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
37  'plugin_guid' => $plugin->guid,
38  'priority' => 'first',
39  'is_action' => true
40  ));
41 
42  $links .= "<li>" . elgg_view('output/url', array(
43  'href' => $top_url,
44  'text' => elgg_echo('top'),
45  'is_action' => true,
46  'is_trusted' => true,
47  )) . "</li>";
48 
49  $up_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
50  'plugin_guid' => $plugin->guid,
51  'priority' => '-1',
52  'is_action' => true
53  ));
54 
55  $links .= "<li>" . elgg_view('output/url', array(
56  'href' => $up_url,
57  'text' => elgg_echo('up'),
58  'is_action' => true,
59  'is_trusted' => true,
60  )) . "</li>";
61  }
62 
63  // down and bottom links only if not at bottom
64  if ($priority < $max_priority) {
65  $down_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
66  'plugin_guid' => $plugin->guid,
67  'priority' => '+1',
68  'is_action' => true
69  ));
70 
71  $links .= "<li>" . elgg_view('output/url', array(
72  'href' => $down_url,
73  'text' => elgg_echo('down'),
74  'is_action' => true,
75  'is_trusted' => true,
76  )) . "</li>";
77 
78  $bottom_url = elgg_http_add_url_query_elements($actions_base . 'set_priority', array(
79  'plugin_guid' => $plugin->guid,
80  'priority' => 'last',
81  'is_action' => true
82  ));
83 
84  $links .= "<li>" . elgg_view('output/url', array(
85  'href' => $bottom_url,
86  'text' => elgg_echo('bottom'),
87  'is_action' => true,
88  'is_trusted' => true,
89  )) . "</li>";
90  }
91 } else {
92  $classes[] = 'elgg-state-undraggable';
93 }
94 
95 
96 // activate / deactivate links
97 
98 // always let them deactivate
99 $options = array(
100  'is_action' => true,
101  'is_trusted' => true,
102 );
103 if ($active) {
104  $classes[] = 'elgg-state-active';
105  $action = 'deactivate';
106  $options['text'] = elgg_echo('admin:plugins:deactivate');
107  $options['class'] = "elgg-button elgg-button-cancel";
108 
109  if (!$can_activate) {
110  $classes[] = 'elgg-state-active';
111  $options['class'] = 'elgg-button elgg-state-warning';
112  }
113 } else if ($can_activate) {
114  $classes[] = 'elgg-state-inactive';
115  $action = 'activate';
116  $options['text'] = elgg_echo('admin:plugins:activate');
117  $options['class'] = "elgg-button elgg-button-submit";
118 } else {
119  $classes[] = 'elgg-state-inactive';
120  $action = '';
121  $options['text'] = elgg_echo('admin:plugins:cannot_activate');
122  $options['class'] = "elgg-button elgg-button-disabled";
123  $options['disabled'] = 'disabled';
124 }
125 
126 if ($action) {
128  'plugin_guids[]' => $plugin->guid
129  ));
130 
131  $options['href'] = $url;
132 }
134 
135 // Display categories and make category classes
136 $categories = $plugin->getManifest()->getCategories();
138 if ($categories) {
139  $base_url = elgg_get_site_url() . "admin/plugins?category=";
140 
141  foreach ($categories as $category) {
142  $css_class = preg_replace('/[^a-z0-9-]/i', '-', $category);
143  $classes[] = "elgg-plugin-category-$css_class";
144 
145  $url = $base_url . urlencode($category);
146  $friendly_category = htmlspecialchars(ElggPluginManifest::getFriendlyCategory($category));
147  $categories_html .= "<li class=\"elgg-plugin-category prm\"><a href=\"$url\">$friendly_category</a></li>";
148  }
149 }
150 
152 $screenshots = $plugin->getManifest()->getScreenshots();
153 if ($screenshots) {
154  $base_url = elgg_get_plugins_path() . $plugin->getID() . '/';
155  foreach ($screenshots as $screenshot) {
156  $desc = elgg_echo($screenshot['description']);
157  $alt = htmlentities($desc, ENT_QUOTES, 'UTF-8');
158  $screenshot_img = elgg_view('output/img', array(
159  'src' => "admin_plugin_screenshot/{$plugin->getID()}/thumbnail/{$screenshot['path']}",
160  'alt' => $alt,
161  ));
162  $screenshot_link = elgg_view('output/url', array(
163  'href' => "admin_plugin_screenshot/{$plugin->getID()}/full/{$screenshot['path']}",
164  'text' => $screenshot_img,
165  'class' => 'elgg-lightbox',
166  ));
167 
168  $screenshots_html .= "<li class=\"elgg-plugin-screenshot prm ptm\">$screenshot_link</li>";
169  }
170 }
171 
172 // metadata
173 $description = elgg_view('output/longtext', array('value' => $plugin->getManifest()->getDescription()));
174 $author = '<span>' . elgg_echo('admin:plugins:label:author') . '</span>: '
175  . elgg_view('output/text', array('value' => $plugin->getManifest()->getAuthor()));
176 $version = htmlspecialchars($plugin->getManifest()->getVersion());
177 $website = elgg_view('output/url', array(
178  'href' => $plugin->getManifest()->getWebsite(),
179  'text' => $plugin->getManifest()->getWebsite(),
180  'is_trusted' => true,
181 ));
182 
183 $resources = array(
184  'repository' => $plugin->getManifest()->getRepositoryURL(),
185  'bugtracker' => $plugin->getManifest()->getBugTrackerURL(),
186  'donate' => $plugin->getManifest()->getDonationsPageURL(),
187 );
188 
189 $resources_html = "<ul class=\"elgg-plugin-resources\">";
190 foreach ($resources as $id => $href) {
191  if ($href) {
192  $resources_html .= "<li class=\"prm\">";
193  $resources_html .= elgg_view('output/url', array(
194  'href' => $href,
195  'text' => elgg_echo("admin:plugins:label:$id"),
196  'is_trusted' => true,
197  ));
198  $resources_html .= "</li>";
199  }
200 }
201 $resources_html .= "</ul>";
202 
203 $copyright = elgg_view('output/text', array('value' => $plugin->getManifest()->getCopyright()));
204 $license = elgg_view('output/text', array('value' => $plugin->getManifest()->getLicense()));
205 
206 // show links to text files
207 $files = $plugin->getAvailableTextFiles();
208 
209 $docs = '';
210 if ($files) {
211  $docs = '<ul class="elgg-menu elgg-menu-hz">';
212  foreach ($files as $file => $path) {
213  $url = 'admin_plugin_text_file/' . $plugin->getID() . "/$file";
214  $link = elgg_view('output/url', array(
215  'text' => $file,
216  'href' => $url,
217  'is_trusted' => true,
218  ));
219  $docs .= "<li>$link</li>";
220 
221  }
222  $docs .= '</ul>';
223 }
224 
225 ?>
226 
227 <div class="<?php echo implode(' ', $classes); ?>" id="<?php echo $css_id; ?>">
228  <div class="elgg-image-block">
229  <div class="elgg-image-alt">
230  <?php if ($links) : ?>
231  <ul class="elgg-menu elgg-menu-metadata">
232  <?php echo $links; ?>
233  </ul>
234  <?php endif; ?>
235  <div class="clearfloat float-alt mtm">
236  <?php echo $action_button; ?>
237  </div>
238  </div>
239  <div class="elgg-body">
240 <?php
241 $settings_view_old = 'settings/' . $plugin->getID() . '/edit';
242 $settings_view_new = 'plugins/' . $plugin->getID() . '/settings';
244  $link = elgg_get_site_url() . "admin/plugin_settings/" . $plugin->getID();
245  $settings_link = "<a class='elgg-plugin-settings' href='$link'>[" . elgg_echo('settings') . "]</a>";
246 } else {
247  $settings_link = '';
248 }
249 ?>
250  <div class="elgg-head">
251  <h3><?php echo $plugin->getManifest()->getName() . " $version $settings_link"; ?></h3>
252  </div>
253  <?php
254  if ($plugin->getManifest()->getApiVersion() < 1.8) {
255  $reqs = $plugin->getManifest()->getRequires();
256  if (!$reqs) {
257  $message = elgg_echo('admin:plugins:warning:elgg_version_unknown');
258  echo "<p class=\"elgg-state-error\">$message</p>";
259  }
260  }
261 
262  if (!$can_activate) {
263  if ($active) {
264  $message = elgg_echo('admin:plugins:warning:unmet_dependencies_active');
265  echo "<p class=\"elgg-state-warning\">$message</p>";
266  } else {
267  $message = elgg_echo('admin:plugins:warning:unmet_dependencies');
268  echo "<p class=\"elgg-state-error\">$message</p>";
269  }
270  }
271  ?>
272 
273  <div><?php echo $description; ?></div>
274  <p><?php echo $author . ' - ' . $website; ?></p>
275 
276  <?php
278  echo $docs;
279  ?>
280 
281  <div class="pts">
282  <?php
283  echo elgg_view('output/url', array(
284  'href' => "#elgg-plugin-manifest-$css_id",
285  'text' => elgg_echo("admin:plugins:label:moreinfo"),
286  'rel' => 'toggle',
287  ));
288  ?>
289  </div>
290  </div>
291  </div>
292  <div class="elgg-plugin-more hidden" id="elgg-plugin-manifest-<?php echo $css_id; ?>">
293 
294  <?php
295  if ($screenshots_html) {
296  ?>
297  <div><ul><?php echo $screenshots_html; ?></ul></div>
298  <?php
299  }
300 
301  if ($categories_html) {
302  ?>
303  <div><?php echo elgg_echo('admin:plugins:label:categories') . ": <ul class=\"elgg-plugin-categories\">$categories_html</ul>"; ?></div>
304  <?php
305  }
306 
307  ?>
308  <div><?php echo elgg_echo('admin:plugins:label:copyright') . ": " . $copyright; ?></div>
309  <div><?php echo elgg_echo('admin:plugins:label:licence') . ": " . $license; ?></div>
310  <div><?php echo elgg_echo('admin:plugins:label:location') . ": " . htmlspecialchars($plugin->getPath()) ?></div>
311  <?php
312  $contributors = elgg_view('object/plugin/elements/contributors', array('plugin' => $plugin));
313  if (!empty($contributors)) {
314  echo '<div>' . elgg_echo('admin:plugins:label:contributors') . ':';
316  echo '</div>';
317  }
318  ?>
319 
320  <div><?php echo elgg_echo('admin:plugins:label:dependencies'); ?>:
321  <?php
322  echo elgg_view('object/plugin/elements/dependencies', array('plugin' => $plugin));
323  ?>
324  </div>
325  </div>
326 </div>
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:1325
$settings_view_new
Definition: full.php:242
$action
Definition: full.php:120
ul
Definition: admin.php:44
$contributors
$categories_html
Definition: full.php:137
$priority
Definition: full.php:19
$max_priority
Definition: full.php:23
$settings_view_old
Definition: full.php:241
$links
Definition: full.php:28
p
Definition: admin.php:118
$categories
Definition: full.php:136
$resources_html
Definition: full.php:189
$website
Definition: full.php:177
if($screenshots) $description
Definition: full.php:173
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:318
$docs
Definition: full.php:209
$can_activate
Definition: full.php:22
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1464
fieldset div
Definition: admin.php:462
$url
Definition: exceptions.php:24
$screenshots
Definition: full.php:152
$plugin
Definition: full.php:16
if($categories) $screenshots_html
Definition: full.php:151
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$active
Definition: full.php:20
$reordering
Definition: full.php:18
$classes
Definition: full.php:29
elgg echo
Translates a string.
Definition: languages.js:43
_elgg_get_max_plugin_priority()
Returns the highest priority of the plugins.
Definition: plugins.php:255
static getFriendlyCategory($category)
Returns a category&#39;s friendly name.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
$author
Definition: full.php:174
if($links) endif
Definition: full.php:230
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
$css_id
Definition: full.php:25
$version
Definition: full.php:176
if($action) $action_button
Definition: full.php:133
$resources
Definition: full.php:183
$actions_base
Definition: full.php:24
$options
Definition: full.php:99
elgg_get_plugins_path()
Get the plugin path for this installation.
$license
Definition: full.php:204
$copyright
Definition: full.php:203
if(!$collection_name) $id
Definition: add.php:17
$path
Definition: invalid.php:17
$base_url
Definition: list.php:24
h3
Definition: admin.php:85
if(file_exists($welcome)) $vars
Definition: upgrade.php:93
$files
Definition: full.php:207