Elgg  Version 2.3
details.php
Go to the documentation of this file.
1 <?php
2 
3 $guid = (int) get_input("guid");
4 
5 if (empty($guid)) {
6  return;
7 }
8 
10 if (!$plugin instanceof ElggPlugin) {
11  return;
12 }
13 
14 $active = $plugin->isActive();
15 $can_activate = $plugin->canActivate();
16 
19 $screenshots = $plugin->getManifest()->getScreenshots();
20 if ($screenshots) {
21 
22  foreach ($screenshots as $key => $screenshot) {
23 
24  $state = "";
25  $rel = "elgg-plugin-details-screenshot-" . $key;
26  if ($key == 0) {
27  $state = " elgg-state-selected";
28  }
29 
30  $desc = elgg_echo($screenshot['description']);
31  $alt = htmlentities($desc, ENT_QUOTES, 'UTF-8');
32 
33  $thumbnail = elgg_view('output/img', array(
34  'src' => "mod/{$plugin->getID()}/{$screenshot['path']}",
35  'alt' => $alt
36  ));
37  $attr = array(
38  'rel' => $rel,
39  'class' => "elgg-plugin-screenshot pas $state",
40  'title' => $alt
41  );
42  $screenshots_menu .= elgg_format_element('li', $attr, $thumbnail);
43 
44  $screenshots_body .= elgg_view('output/img', array(
45  'src' => "mod/{$plugin->getID()}/{$screenshot['path']}",
46  'alt' => $alt,
47  'title' => $alt,
48  'class' => "hidden $state",
49  'rel' => $rel
50  ));
51  }
52 
55 }
56 
57 // table contents
58 $info = [];
59 
60 $info[elgg_echo('admin:plugins:label:version')] = htmlspecialchars($plugin->getManifest()->getVersion());
61 
62 $info[elgg_echo('admin:plugins:label:id')] = elgg_view('output/text', array(
63  'value' => $plugin->getID(),
64 ));
65 
66 $info[elgg_echo('admin:plugins:label:author')] = elgg_view('output/text', array(
67  'value' => $plugin->getManifest()->getAuthor(),
68 ));
69 
70 $url = $plugin->getManifest()->getWebsite();
71 if ($url) {
72  $info[elgg_echo('admin:plugins:label:website')] = elgg_view('output/url', array(
73  'href' => $plugin->getManifest()->getWebsite(),
74  'text' => $plugin->getManifest()->getWebsite(),
75  'is_trusted' => true,
76  ));
77 }
78 
79 $info[elgg_echo('admin:plugins:label:copyright')] = elgg_view('output/text', array(
80  'value' => $plugin->getManifest()->getCopyright(),
81 ));
82 
83 $info[elgg_echo('admin:plugins:label:licence')] = elgg_view('output/text', array(
84  'value' => $plugin->getManifest()->getLicense(),
85 ));
86 
88 $path = $plugin->getPath();
89 if (0 === strpos($path, $site_path)) {
90  $path = substr($path, strlen($site_path));
91 }
92 $info[elgg_echo('admin:plugins:label:location')] = htmlspecialchars($path);
93 
94 $categories = (array)$plugin->getManifest()->getCategories();
95 array_walk($categories, function(&$value) {
97 });
98 
99 $info[elgg_echo('admin:plugins:label:categories')] = implode(', ', $categories);
100 
101 // assemble table
102 $rows = '';
103 foreach ($info as $name => $value) {
104  if (trim($value) === '') {
105  continue;
106  }
107  $rows .= "<tr><th>$name</th><td>$value</td></tr>";
108 }
109 
110 $info_html = elgg_format_element('table', ['class' => 'elgg-table'], $rows);
111 
112 $extra_info = elgg_echo("admin:plugins:info:" . $plugin->getID());
113 if ($extra_info !== ("admin:plugins:info:" . $plugin->getID())) {
114  $info_html .= "<div class='mtm'>" . $extra_info . "</div>";
115 }
116 
117 $resources = array(
118  'repository' => $plugin->getManifest()->getRepositoryURL(),
119  'bugtracker' => $plugin->getManifest()->getBugTrackerURL(),
120  'donate' => $plugin->getManifest()->getDonationsPageURL(),
121 );
122 
124 foreach ($resources as $id => $href) {
125  if ($href) {
126  $resources_html .= "<li>";
127  $resources_html .= elgg_view('output/url', array(
128  'href' => $href,
129  'text' => elgg_echo("admin:plugins:label:$id"),
130  'is_trusted' => true,
131  ));
132  $resources_html .= "</li>";
133  }
134 }
135 
136 if (!empty($resources_html)) {
138 }
139 
140 // show links to text files
141 $files = $plugin->getAvailableTextFiles();
142 
144 if ($files) {
145  $files_html = '<ul>';
146  foreach ($files as $file => $path) {
147  $url = 'admin_plugin_text_file/' . $plugin->getID() . "/$file";
148  $link = elgg_view('output/url', array(
149  'text' => $file,
150  'href' => $url,
151  'is_trusted' => true,
152  ));
153  $files_html .= "<li>$link</li>";
154 
155  }
156  $files_html .= '</ul>';
157 }
158 
159 $body = "<div class='elgg-plugin'>";
160 
161 $body .= "<div class='elgg-plugin-details-container pvm'>";
162 
163 $body .= elgg_view('output/longtext', array('value' => $plugin->getManifest()->getDescription()));
164 
165 // tabs
166 $tabs = array();
167 
168 $tabs[] = array(
169  'text' => elgg_echo("admin:plugins:label:info"),
170  'rel' => 'elgg-plugin-details-info',
171  'selected' => ($can_activate) ? true : false
172 );
173 
174 if ($resources_html) {
175  $tabs[] = array(
176  'text' => elgg_echo("admin:plugins:label:resources"),
177  'rel' => 'elgg-plugin-details-resources'
178  );
179 }
180 
181 if ($files_html) {
182  $tabs[] = array(
183  'text' => elgg_echo("admin:plugins:label:files"),
184  'rel' => 'elgg-plugin-details-files'
185  );
186 }
187 
188 if ($screenshots) {
189  $tabs[] = array(
190  'text' => elgg_echo("admin:plugins:label:screenshots"),
191  'rel' => 'elgg-plugin-details-screenshots'
192  );
193 }
194 
195 $tabs[] = array(
196  'text' => elgg_echo("admin:plugins:label:dependencies"),
197  'rel' => 'elgg-plugin-details-dependencies',
198  'selected' => (!$can_activate) ? true : false
199 );
200 
201 $body .= elgg_view('navigation/tabs', array(
202  'tabs' => $tabs,
203  'class' => 'mtl',
204 ));
205 
206 $body .= "<div>";
207 
208 // info
209 if ($can_activate) {
210  $body .= "<div class='elgg-plugin-details-info'>";
211 } else {
212  $body .= "<div class='elgg-plugin-details-info hidden'>";
213 }
214 $body .= $info_html;
215 $body .= "</div>";
216 
217 // resources
218 if ($resources_html) {
219  $body .= "<div class='elgg-plugin-details-resources hidden'>";
221  $body .= "</div>";
222 }
223 
224 // files
225 if ($files_html) {
226  $body .= "<div class='elgg-plugin-details-files hidden'>";
227  $body .= $files_html;
228  $body .= "</div>";
229 }
230 
231 // screenshots
232 if ($screenshots) {
233  $body .= "<div class='elgg-plugin-details-screenshots hidden'>";
236  $body .= "</div>";
237 }
238 
239 // dependencies
240 if ($can_activate) {
241  $body .= "<div class='elgg-plugin-details-dependencies hidden'>";
242 } else {
243  $body .= "<div class='elgg-plugin-details-dependencies'>";
244 }
245 $body .= elgg_view('object/plugin/elements/dependencies', array('plugin' => $plugin));
246 $body .= "</div>";
247 
248 $body .= "</div>";
249 
250 $body .= "</div>";
251 
252 $body .= "</div>";
253 
254 echo elgg_view_module("plugin-details", $plugin->getManifest()->getName(), $body);
$categories
Definition: details.php:94
if(!array_key_exists($filename, $text_files)) $file
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$screenshots_body
Definition: details.php:18
$extra_info
Definition: details.php:112
$path
Definition: details.php:88
$value
Definition: longtext.php:42
$link
Definition: container.php:14
$site_path
Definition: details.php:87
if($screenshots) $info
Definition: details.php:58
if(empty($guid)) $plugin
Definition: details.php:9
$state
Definition: contents.php:4
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
Definition: output.php:208
if(!$plugin instanceof ElggPlugin) $active
Definition: details.php:14
$screenshots_menu
Definition: details.php:17
if($files) $body
Definition: details.php:159
$guid
Definition: details.php:3
foreach($info as $name=> $value) $info_html
Definition: details.php:110
$key
Definition: summary.php:34
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
$rows
Definition: details.php:102
elgg_get_root_path()
Get the root directory path for this installation.
$files_html
Definition: details.php:143
elgg echo
Translates a string.
Definition: languages.js:48
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
static getFriendlyCategory($category)
Returns a category&#39;s friendly name.
$screenshots
Definition: details.php:19
if($extra_info!==("admin:plugins:info:".$plugin->getID())) $resources
Definition: details.php:117
$can_activate
Definition: details.php:15
elgg_view_module($type, $title, $body, array $vars=array())
Wrapper function for the module display pattern.
Definition: views.php:1250
$url
Definition: details.php:70
$resources_html
Definition: details.php:123
$tabs
Definition: details.php:166
foreach($resources as $id=> $href) if(!empty($resources_html)) $files
Definition: details.php:141
if(!$collection_name) $id
Definition: add.php:17
if(!$limit) $attr
Definition: comments.php:22
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204