Elgg  Version 4.x
details.php
Go to the documentation of this file.
1 <?php
2 
3 $guid = (int) get_input('guid');
4 
6 if (!$plugin instanceof ElggPlugin || !$plugin->canEdit()) {
7  return;
8 }
9 
10 $show_dependencies_first = !$plugin->meetsDependencies();
11 
12 // table contents
13 $info = [];
14 
15 $info[elgg_echo('admin:plugins:label:version')] = htmlspecialchars($plugin->getVersion());
16 
17 $info[elgg_echo('admin:plugins:label:id')] = elgg_view('output/text', [
18  'value' => $plugin->getID(),
19 ]);
20 
21 $authors = $plugin->getAuthors();
22 if (!empty($authors)) {
23  $authors_text = '';
24  foreach ($authors as $author) {
25  if (empty($author->name())) {
26  continue;
27  }
28 
29  $author_content = $author->name();
30  if ($author->role()) {
31  $author_content .= ' - ' . $author->role();
32  }
33 
34  if ($author->email()) {
35  $author_content .= elgg_view('output/email', [
36  'text' => false,
37  'icon' => 'envelope-regular',
38  'value' => $author->email(),
39  'class' => 'mls',
40  ]);
41  }
42  if ($author->homepage()) {
43  $author_content .= elgg_view('output/url', [
44  'icon' => 'globe-americas',
45  'text' => false,
46  'href' => $author->homepage(),
47  'class' => 'mls',
48  ]);
49  }
50 
51  $authors_text .= elgg_format_element('li', [], $author_content);
52  }
53  $info[elgg_echo('admin:plugins:label:authors')] = elgg_format_element('ul', [], $authors_text);
54 }
55 
56 $url = $plugin->getWebsite();
57 if (!empty($url)) {
58  $info[elgg_echo('admin:plugins:label:website')] = elgg_view('output/url', [
59  'href' => $url,
60  ]);
61 }
62 
63 $info[elgg_echo('admin:plugins:label:licence')] = elgg_view('output/text', [
64  'value' => $plugin->getLicense(),
65 ]);
66 
68 $path = $plugin->getPath();
69 if (0 === strpos($path, $site_path)) {
71 }
72 $info[elgg_echo('admin:plugins:label:location')] = htmlspecialchars($path);
73 
74 $categories = array_values($plugin->getCategories());
75 $info[elgg_echo('admin:plugins:label:categories')] = implode(', ', $categories);
76 
77 // assemble table
78 $rows = '';
79 foreach ($info as $name => $value) {
80  if (trim($value) === '') {
81  continue;
82  }
83  $rows .= "<tr><th>$name</th><td>$value</td></tr>";
84 }
85 
86 $info_html = elgg_format_element('table', ['class' => 'elgg-table'], $rows);
87 
88 if (elgg_language_key_exists("admin:plugins:info:{$plugin->getID()}")) {
89  $info_html .= elgg_format_element('div', ['class' => 'mtm'], elgg_echo("admin:plugins:info:{$plugin->getID()}"));
90 }
91 
93  'repository' => $plugin->getRepositoryURL(),
94  'bugtracker' => $plugin->getBugTrackerURL(),
95 ];
96 
98 foreach ($resources as $id => $href) {
99  if ($href) {
100  $resources_html .= elgg_format_element('li', [], elgg_view('output/url', [
101  'href' => $href,
102  'text' => elgg_echo("admin:plugins:label:{$id}"),
103  'is_trusted' => true,
104  ]));
105  }
106 }
107 
108 if (!empty($resources_html)) {
110 }
111 
112 // show links to text files
114 foreach (\ElggPlugin::ADDITIONAL_TEXT_FILES as $file) {
115  $file_path = $plugin->getPath() . $file;
116  if (!is_file($file_path) || !is_readable($file_path)) {
117  continue;
118  }
119 
120  $link = elgg_view('output/url', [
121  'text' => $file,
122  'href' => elgg_generate_url('admin_plugin_text_file', [
123  'plugin_id' => $plugin->getID(),
124  'filename' => $file,
125  ]),
126  'is_trusted' => true,
127  ]);
128  $files_html .= elgg_format_element('li', [], $link);
129 }
130 
131 if (!empty($files_html)) {
133 }
134 
135 $body = "<div class='elgg-plugin'>";
136 
137 $body .= "<div class='elgg-plugin-details-container pvm'>";
138 
139 $body .= elgg_view('output/longtext', ['value' => $plugin->getDescription()]);
140 
141 // tabs
142 $tabs = [
143  'elgg-plugin-details-info' => [
144  'text' => elgg_echo('admin:plugins:label:info'),
145  'selected' => !$show_dependencies_first,
146  'content' => $info_html,
147  ],
148 ];
149 
150 if (!empty($resources_html)) {
151  $tabs['elgg-plugin-details-resources'] = [
152  'text' => elgg_echo('admin:plugins:label:resources'),
153  'content' => $resources_html,
154  ];
155 }
156 
157 if (!empty($files_html)) {
158  $tabs['elgg-plugin-details-files'] = [
159  'text' => elgg_echo('admin:plugins:label:files'),
160  'content' => $files_html,
161  ];
162 }
163 
164 $dependencies_html = elgg_view('object/plugin/elements/dependencies', ['plugin' => $plugin]);
165 if (!empty($dependencies_html)) {
166  $tabs['elgg-plugin-details-dependencies'] = [
167  'text' => elgg_echo('admin:plugins:label:dependencies'),
168  'selected' => $show_dependencies_first,
169  'content' => $dependencies_html,
170  ];
171 }
172 
173 $body .= elgg_view('page/components/tabs', [
174  'tabs' => $tabs,
175 ]);
176 
177 $body .= '</div>';
178 $body .= '</div>';
179 
180 echo elgg_view_module('plugin-details', $plugin->getDisplayName(), $body);
elgg_language_key_exists($key, $language= 'en')
Check if a given language key exists.
Definition: languages.php:61
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
foreach($info as $name=> $value) $info_html
Definition: details.php:86
$tabs
Definition: details.php:142
if(!empty($resources_html)) if(!empty($files_html)) $dependencies_html
Definition: details.php:164
$info
Definition: details.php:13
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
$guid
Definition: details.php:3
if(!$item instanceof ElggEntity) $link
Definition: container.php:16
$value
Definition: generic.php:51
const ADDITIONAL_TEXT_FILES
Definition: ElggPlugin.php:28
if(!empty($authors)) $url
Definition: details.php:56
$path
Definition: details.php:68
$categories
Definition: details.php:74
get_input($variable, $default=null, $filter_result=true)
Parameter input functions.
Definition: input.php:20
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:134
elgg_view_module($type, $title, $body, array $vars=[])
Wrapper function for the module display pattern.
Definition: views.php:970
elgg_generate_url($name, array $parameters=[])
Generate a URL for named route.
elgg_get_root_path()
Get the project path (where composer is installed), ending with slash.
$rows
Definition: details.php:78
foreach($resources as $id=> $href) if(!empty($resources_html)) $files_html
Definition: details.php:113
foreach(\ElggPlugin::ADDITIONAL_TEXT_FILES as $file) if(!empty($files_html)) $body
Definition: details.php:135
if(elgg_language_key_exists("admin:plugins:info:{$plugin->getID()}")) $resources
Definition: details.php:92
if(elgg_language_key_exists("admin:plugins:info:{$plugin->getID()}")) $resources_html
Definition: details.php:97
elgg echo
Translates a string.
Definition: deprecated.js:530
$site_path
Definition: details.php:67
$authors
Definition: details.php:21
$plugin
Definition: details.php:5
$id
Generic annotation delete action.
Definition: delete.php:6
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:205
if(!$plugin instanceof ElggPlugin||!$plugin->canEdit()) $show_dependencies_first
Definition: details.php:10
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:69