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