Elgg  Version master
plugin_text_file.php
Go to the documentation of this file.
1 <?php
2 
5 
6 elgg_set_context('admin');
7 elgg_unregister_external_file('css', 'elgg');
8 
9 $plugin_id = (string) elgg_extract('plugin_id', $vars);
11 if (!$plugin instanceof \ElggPlugin) {
12  throw new EntityNotFoundException(elgg_echo('admin:plugins:markdown:unknown_plugin'));
13 }
14 
16 $filename = elgg_extract('filename', $vars);
18  $file_contents = file_get_contents($plugin->getPath() . $filename);
19 }
20 
21 if (!$file_contents) {
22  throw new PageNotFoundException(elgg_echo('admin:plugins:markdown:unknown_file'));
23 }
24 
25 $title = $plugin->getDisplayName() . ": $filename";
26 
27 $body = elgg_view_layout('admin', [
28  'content' => elgg_view('admin/plugins/markdown', ['value' => $file_contents]),
29  'title' => $title,
30  'filter_id' => 'admin/plugin_text_file',
31  'filter_value' => "{$plugin_id}/{$filename}",
32 ]);
33 
34 echo elgg_view_page($title, $body, 'admin');
$vars
Definition: theme.php:3
Plugin class containing helper functions for plugin activation/deactivation, dependency checking capa...
Definition: ElggPlugin.php:17
const ADDITIONAL_TEXT_FILES
Definition: ElggPlugin.php:30
Thrown when page is not accessible.
elgg_set_context(string $context)
Elgg context library.
Definition: context.php:29
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:246
elgg_get_plugin_from_id(string $plugin_id)
Elgg plugins library Contains functions for managing plugins.
Definition: plugins.php:15
elgg_unregister_external_file(string $type, string $name)
Unregister an external file.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_view_layout(string $layout_name, array $vars=[])
Displays a layout with optional parameters.
Definition: views.php:352
elgg_view_page(string $title, string|array $body, string $page_shell='default', array $vars=[])
Assembles and outputs a full page.
Definition: views.php:235
elgg_view(string $view, array $vars=[], string $viewtype='')
Return a parsed view.
Definition: views.php:156
if(in_array($filename, \ElggPlugin::ADDITIONAL_TEXT_FILES)) if(! $file_contents) $title
if(! $plugin instanceof \ElggPlugin) $file_contents
$plugin_id