1 | <?php |
||
15 | class Admin extends Ui { |
||
16 | |||
17 | protected $forAdmins = array('usermanager', 'acl', 'extension', 'config', 'logviewer', 'styling'); |
||
18 | protected $forManagers = array('revert', 'popularity'); |
||
19 | /** @var array[] */ |
||
20 | protected $menu; |
||
21 | |||
22 | /** |
||
23 | * Display the UI element |
||
24 | * |
||
25 | * @return void |
||
26 | */ |
||
27 | public function show() { |
||
28 | $this->menu = $this->getPluginList(); |
||
|
|||
29 | echo '<div class="ui-admin">'; |
||
30 | echo p_locale_xhtml('admin'); |
||
31 | |||
32 | $this->showMenu('admin'); |
||
33 | $this->showMenu('manager'); |
||
34 | $this->showSecurityCheck(); |
||
35 | $this->showVersion(); |
||
36 | $this->showMenu('other'); |
||
37 | echo '</div>'; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Show the given menu of available plugins |
||
42 | * |
||
43 | * @param string $type admin|manager|other |
||
44 | */ |
||
45 | protected function showMenu($type) { |
||
46 | if (!$this->menu[$type]) return; |
||
47 | |||
48 | if ($type === 'other') { |
||
49 | echo p_locale_xhtml('adminplugins'); |
||
50 | $class = 'admin_plugins'; |
||
51 | } else { |
||
52 | $class = 'admin_tasks'; |
||
53 | } |
||
54 | |||
55 | echo "<ul class=\"$class\">"; |
||
56 | foreach ($this->menu[$type] as $item) { |
||
57 | $this->showMenuItem($item); |
||
58 | } |
||
59 | echo '</ul>'; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Display the DokuWiki version |
||
64 | */ |
||
65 | protected function showVersion() { |
||
66 | echo '<div id="admin__version">'; |
||
67 | echo getVersion(); |
||
68 | echo '</div>'; |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * data security check |
||
73 | * |
||
74 | * simple check if the 'savedir' is relative and accessible when appended to DOKU_URL |
||
75 | * |
||
76 | * it verifies either: |
||
77 | * 'savedir' has been moved elsewhere, or |
||
78 | * has protection to prevent the webserver serving files from it |
||
79 | * |
||
80 | * The actual check is carried out via JavaScript. See behaviour.js |
||
81 | */ |
||
82 | protected function showSecurityCheck() { |
||
83 | global $conf; |
||
84 | if(substr($conf['savedir'], 0, 2) !== './') return; |
||
85 | $img = DOKU_URL . $conf['savedir'] . |
||
86 | '/dont-panic-if-you-see-this-in-your-logs-it-means-your-directory-permissions-are-correct.png'; |
||
87 | echo '<div id="security__check" data-src="' . $img . '"></div>'; |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Display a single Admin menu item |
||
92 | * |
||
93 | * @param array $item |
||
94 | */ |
||
95 | protected function showMenuItem($item) { |
||
109 | |||
110 | /** |
||
111 | * Build list of admin functions from the plugins that handle them |
||
112 | * |
||
113 | * Checks the current permissions to decide on manager or admin plugins |
||
114 | * |
||
115 | * @return array list of plugins with their properties |
||
116 | */ |
||
117 | protected function getPluginList() { |
||
153 | |||
154 | /** |
||
155 | * Custom sorting for admin menu |
||
156 | * |
||
157 | * We sort alphabetically first, then by sort value |
||
158 | * |
||
159 | * @param array $a |
||
160 | * @param array $b |
||
161 | * @return int |
||
162 | */ |
||
163 | protected function menuSort($a, $b) { |
||
169 | } |
||
170 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..