1 | <?php |
||
2 | |||
3 | $plugin_id = elgg_extract('plugin_id', $vars); |
||
4 | $plugin = elgg_get_plugin_from_id($plugin_id); |
||
5 | |||
6 | $filename = elgg_extract('filename', $vars); |
||
7 | |||
8 | elgg_admin_gatekeeper(); |
||
9 | |||
10 | elgg_unregister_css('elgg'); |
||
11 | elgg_require_js('elgg/admin'); |
||
12 | |||
13 | $error = false; |
||
14 | if (!$plugin) { |
||
15 | $error = elgg_echo('admin:plugins:markdown:unknown_plugin'); |
||
16 | $body = elgg_view_layout('admin', ['content' => $error, 'title' => $error]); |
||
17 | echo elgg_view_page($error, $body, 'admin'); |
||
18 | return true; |
||
19 | } |
||
20 | |||
21 | $text_files = $plugin->getAvailableTextFiles(); |
||
22 | |||
23 | if (!array_key_exists($filename, $text_files)) { |
||
24 | $error = elgg_echo('admin:plugins:markdown:unknown_file'); |
||
25 | } |
||
26 | |||
27 | $file = $text_files[$filename]; |
||
28 | $file_contents = file_get_contents($file); |
||
29 | |||
30 | if (!$file_contents) { |
||
31 | $error = elgg_echo('admin:plugins:markdown:unknown_file'); |
||
32 | } |
||
33 | |||
34 | if ($error) { |
||
0 ignored issues
–
show
|
|||
35 | $title = $error; |
||
36 | $body = elgg_view_layout('admin', ['content' => $error, 'title' => $title]); |
||
37 | echo elgg_view_page($title, $body, 'admin'); |
||
38 | return true; |
||
39 | } |
||
40 | |||
41 | $title = $plugin->getDisplayName() . ": $filename"; |
||
42 | |||
43 | use \Michelf\MarkdownExtra; |
||
44 | $text = MarkdownExtra::defaultTransform($file_contents); |
||
45 | |||
46 | $body = elgg_view_layout('admin', [ |
||
47 | // setting classes here because there's no way to pass classes |
||
48 | // to the layout |
||
49 | 'content' => '<div class="elgg-markdown">' . $text . '</div>', |
||
50 | 'title' => $title |
||
51 | ]); |
||
52 | |||
53 | echo elgg_view_page($title, $body, 'admin'); |
||
54 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: