Elgg  Version 2.3
plugin_text_file.php
Go to the documentation of this file.
1 <?php
2 
3 $plugin_id = elgg_extract('plugin_id', $vars);
5 
6 $filename = elgg_extract('filename', $vars);
7 
10 
11 elgg_unregister_css('elgg');
12 elgg_require_js('elgg/admin');
13 elgg_load_js('jquery.jeditable');
14 
15 $error = false;
16 if (!$plugin) {
17  $error = elgg_echo('admin:plugins:markdown:unknown_plugin');
18  $body = elgg_view_layout('admin', array('content' => $error, 'title' => $error));
19  echo elgg_view_page($error, $body, 'admin');
20  return true;
21 }
22 
23 $text_files = $plugin->getAvailableTextFiles();
24 
25 if (!array_key_exists($filename, $text_files)) {
26  $error = elgg_echo('admin:plugins:markdown:unknown_file');
27 }
28 
30 $file_contents = file_get_contents($file);
31 
32 if (!$file_contents) {
33  $error = elgg_echo('admin:plugins:markdown:unknown_file');
34 }
35 
36 if ($error) {
37  $title = $error;
38  $body = elgg_view_layout('admin', array('content' => $error, 'title' => $title));
39  echo elgg_view_page($title, $body, 'admin');
40  return true;
41 }
42 
43 $title = $plugin->getManifest()->getName() . ": $filename";
44 
45 use \Michelf\MarkdownExtra;
46 $text = MarkdownExtra::defaultTransform($file_contents);
47 
48 $body = elgg_view_layout('admin', array(
49  // setting classes here because there's no way to pass classes
50  // to the layout
51  'content' => '<div class="elgg-markdown">' . $text . '</div>',
52  'title' => $title
53 ));
54 
55 echo elgg_view_page($title, $body, 'admin');
if(!array_key_exists($filename, $text_files)) $file
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_layout($layout_name, $vars=array())
Displays a layout with optional parameters.
Definition: views.php:689
$vars['entity']
if(!$plugin) $text_files
elgg_unregister_css($name)
Unregister a CSS file.
Definition: elgglib.php:283
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:232
elgg echo
Translates a string.
Definition: languages.js:48
$plugin_id
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
if(!$file_contents) if($error) $title
$file_contents
elgg_admin_gatekeeper()
Used at the top of a page to mark it as admin only.
Definition: pagehandler.php:83
elgg_load_js($name)
Load a JavaScript resource on this page.
Definition: elgglib.php:220
$filename
_elgg_admin_add_plugin_settings_menu()
Create the plugin settings page menu.
Definition: admin.php:464
elgg_get_plugin_from_id($plugin_id)
Returns an object with the path $path.
Definition: plugins.php:82
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
Definition: views.php:447