Elgg  Version 3.0
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 
15 $package = $plugin->getPackage();
16 if ($package && !$package->checkDependencies()) {
17  $show_dependencies = true;
18 }
19 
22 $screenshots = $plugin->getManifest()->getScreenshots();
23 if (!empty($screenshots)) {
24  foreach ($screenshots as $key => $screenshot) {
25  $state = "";
26  $rel = "elgg-plugin-details-screenshot-" . $key;
27  if ($key == 0) {
28  $state = " elgg-state-selected";
29  }
30 
31  $desc = elgg_echo($screenshot['description']);
32  $alt = htmlentities($desc, ENT_QUOTES, 'UTF-8');
33 
34  $thumbnail = elgg_view('output/img', [
35  'src' => "mod/{$plugin->getID()}/{$screenshot['path']}",
36  'alt' => $alt
37  ]);
38  $attr = [
39  'rel' => $rel,
40  'class' => "elgg-plugin-screenshot pas $state",
41  'title' => $alt
42  ];
43  $screenshots_menu .= elgg_format_element('li', $attr, $thumbnail);
44 
45  $screenshots_body .= elgg_view('output/img', [
46  'src' => "mod/{$plugin->getID()}/{$screenshot['path']}",
47  'alt' => $alt,
48  'title' => $alt,
49  'class' => "hidden $state",
50  'rel' => $rel
51  ]);
52  }
53 
56 }
57 
58 // table contents
59 $info = [];
60 
61 $info[elgg_echo('admin:plugins:label:version')] = htmlspecialchars($plugin->getManifest()->getVersion());
62 
63 $info[elgg_echo('admin:plugins:label:id')] = elgg_view('output/text', [
64  'value' => $plugin->getID(),
65 ]);
66 
67 $info[elgg_echo('admin:plugins:label:author')] = elgg_view('output/text', [
68  'value' => $plugin->getManifest()->getAuthor(),
69 ]);
70 
71 $url = $plugin->getManifest()->getWebsite();
72 if (!empty($url)) {
73  $info[elgg_echo('admin:plugins:label:website')] = elgg_view('output/url', [
74  'href' => $plugin->getManifest()->getWebsite(),
75  'text' => $plugin->getManifest()->getWebsite(),
76  'is_trusted' => true,
77  ]);
78 }
79 
80 $info[elgg_echo('admin:plugins:label:copyright')] = elgg_view('output/text', [
81  'value' => $plugin->getManifest()->getCopyright(),
82 ]);
83 
84 $info[elgg_echo('admin:plugins:label:licence')] = elgg_view('output/text', [
85  'value' => $plugin->getManifest()->getLicense(),
86 ]);
87 
89 $path = $plugin->getPath();
90 if (0 === strpos($path, $site_path)) {
91  $path = substr($path, strlen($site_path));
92 }
93 $info[elgg_echo('admin:plugins:label:location')] = htmlspecialchars($path);
94 
95 $categories = (array) $plugin->getManifest()->getCategories();
96 array_walk($categories, function(&$value) {
98 });
99 
100 $info[elgg_echo('admin:plugins:label:categories')] = implode(', ', $categories);
101 
102 // assemble table
103 $rows = '';
104 foreach ($info as $name => $value) {
105  if (trim($value) === '') {
106  continue;
107  }
108  $rows .= "<tr><th>$name</th><td>$value</td></tr>";
109 }
110 
111 $info_html = elgg_format_element('table', ['class' => 'elgg-table'], $rows);
112 
113 $extra_info = elgg_echo("admin:plugins:info:" . $plugin->getID());
114 if ($extra_info !== ("admin:plugins:info:" . $plugin->getID())) {
115  $info_html .= "<div class='mtm'>" . $extra_info . "</div>";
116 }
117 
119  'repository' => $plugin->getManifest()->getRepositoryURL(),
120  'bugtracker' => $plugin->getManifest()->getBugTrackerURL(),
121  'donate' => $plugin->getManifest()->getDonationsPageURL(),
122 ];
123 
125 foreach ($resources as $id => $href) {
126  if ($href) {
127  $resources_html .= "<li>";
128  $resources_html .= elgg_view('output/url', [
129  'href' => $href,
130  'text' => elgg_echo("admin:plugins:label:$id"),
131  'is_trusted' => true,
132  ]);
133  $resources_html .= "</li>";
134  }
135 }
136 
137 if (!empty($resources_html)) {
139 }
140 
141 // show links to text files
142 $files = $plugin->getAvailableTextFiles();
143 
145 if (!empty($files)) {
146  $files_html = '<ul>';
147  foreach ($files as $file => $path) {
148  $url = 'admin_plugin_text_file/' . $plugin->getID() . "/$file";
149  $link = elgg_view('output/url', [
150  'text' => $file,
151  'href' => $url,
152  'is_trusted' => true,
153  ]);
154  $files_html .= "<li>$link</li>";
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', ['value' => $plugin->getManifest()->getDescription()]);
164 
165 // tabs
166 $tabs = [
167  'elgg-plugin-details-info' => [
168  'text' => elgg_echo("admin:plugins:label:info"),
169  'selected' => !$show_dependencies,
170  'content' => $info_html,
171  ],
172 ];
173 
174 if (!empty($resources_html)) {
175  $tabs['elgg-plugin-details-resources'] = [
176  'text' => elgg_echo("admin:plugins:label:resources"),
177  'content' => $resources_html,
178  ];
179 }
180 
181 if (!empty($files_html)) {
182  $tabs['elgg-plugin-details-files'] = [
183  'text' => elgg_echo("admin:plugins:label:files"),
184  'content' => $files_html,
185  ];
186 }
187 
188 if (!empty($screenshots)) {
189  $tabs['elgg-plugin-details-screenshots'] = [
190  'text' => elgg_echo("admin:plugins:label:screenshots"),
191  'content' => $screenshots_menu . $screenshots_body,
192  ];
193 }
194 
195 $tabs['elgg-plugin-details-dependencies'] = [
196  'text' => elgg_echo("admin:plugins:label:dependencies"),
197  'selected' => $show_dependencies,
198  'content' => elgg_view('object/plugin/elements/dependencies', ['plugin' => $plugin]),
199 ];
200 
201 $body .= elgg_view('page/components/tabs', [
202  'tabs' => $tabs,
203 ]);
204 
205 $body .= "</div>";
206 $body .= "</div>";
207 
208 echo elgg_view_module("plugin-details", $plugin->getDisplayName(), $body);
$categories
Definition: details.php:95
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
if($extra_info!==("admin:plugins:info:".$plugin->getID())) $resources_html
Definition: details.php:124
if(!array_key_exists($filename, $text_files)) $file
if(!$plugin instanceof ElggPlugin) $show_dependencies
Definition: details.php:14
$screenshots_body
Definition: details.php:21
$extra_info
Definition: details.php:113
$path
Definition: details.php:89
$site_path
Definition: details.php:88
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
if(empty($guid)) $plugin
Definition: details.php:9
if(!$item instanceof ElggEntity) $link
Definition: container.php:16
if(!empty($files)) $body
Definition: details.php:159
$id
River item delete action.
Definition: delete.php:6
$guid
Definition: details.php:3
foreach($info as $name=> $value) $info_html
Definition: details.php:111
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:103
if($package &&!$package->checkDependencies()) $screenshots_menu
Definition: details.php:20
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:1198
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
$files_html
Definition: details.php:144
elgg echo
Translates a string.
Definition: languages.js:43
if(!empty($screenshots)) $info
Definition: details.php:59
static getFriendlyCategory($category)
Returns a category&#39;s friendly name.
$screenshots
Definition: details.php:22
if($extra_info!==("admin:plugins:info:".$plugin->getID())) $resources
Definition: details.php:118
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
$value
Definition: debugging.php:7
$url
Definition: details.php:71
$package
Definition: details.php:15
$tabs
Definition: details.php:166
foreach($resources as $id=> $href) if(!empty($resources_html)) $files
Definition: details.php:142
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
if(empty($value)&&$value!==0 &&$value!== '0') $href
Definition: tag.php:16
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:87