Subversion Repositories oidplus

Rev

Rev 635 | Rev 704 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
635 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
if (!defined('INSIDE_OIDPLUS')) die();
21
 
22
class OIDplusPageAdminPlugins extends OIDplusPagePluginAdmin {
23
 
24
        public function init($html=true) {
25
        }
26
 
27
        public function gui($id, &$out, &$handled) {
28
                $tmp = explode('$',$id);
29
                $classname = isset($tmp[1]) ? $tmp[1] : null;
30
 
31
                $parts = explode('.',$tmp[0],2);
32
                if (!isset($parts[1])) $parts[1] = '';
33
                if ($parts[0] != 'oidplus:system_plugins') return;
34
                $handled = true;
35
                $out['title'] = _L('Installed plugins');
36
                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
37
 
38
                if (!OIDplus::authUtils()->isAdminLoggedIn()) {
39
                        $out['icon'] = 'img/error_big.png';
40
                        $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login$admin')).'</p>';
41
                        return;
42
                }
43
 
44
                if (!is_null($classname)) {
45
                        $plugin = OIDplus::getPluginByClassName($classname);
46
                        if (is_null($plugin)) {
47
                                $out['icon'] = 'img/error_big.png';
48
                                $out['text'] = '<p>'._L('Plugin %1 not found.',$classname).'</p>';
49
                                return;
50
                        }
51
 
52
                        $out['title'] = empty($plugin->getManifest()->getName()) ? htmlentities($classname) : htmlentities($plugin->getManifest()->getName());
53
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
54
 
55
                        $back_link = 'oidplus:system_plugins';
56
                        if (get_parent_class($classname) == 'OIDplusPagePluginPublic') $back_link = 'oidplus:system_plugins.pages.public';
57
                        if (get_parent_class($classname) == 'OIDplusPagePluginRa') $back_link = 'oidplus:system_plugins.pages.ra';
58
                        if (get_parent_class($classname) == 'OIDplusPagePluginAdmin') $back_link = 'oidplus:system_plugins.pages.admin';
59
                        if (get_parent_class($classname) == 'OIDplusObjectTypePlugin') $back_link = 'oidplus:system_plugins.objects';
60
                        if (get_parent_class($classname) == 'OIDplusDatabasePlugin') $back_link = 'oidplus:system_plugins.database';
61
                        if (get_parent_class($classname) == 'OIDplusSqlSlangPlugin') $back_link = 'oidplus:system_plugins.sql';
62
                        if (get_parent_class($classname) == 'OIDplusAuthPlugin') $back_link = 'oidplus:system_plugins.auth';
63
                        if (get_parent_class($classname) == 'OIDplusLoggerPlugin') $back_link = 'oidplus:system_plugins.logger';
64
                        if (get_parent_class($classname) == 'OIDplusLanguagePlugin') $back_link = 'oidplus:system_plugins.language';
65
                        if (get_parent_class($classname) == 'OIDplusDesignPlugin') $back_link = 'oidplus:system_plugins.design';
703 daniel-mar 66
                        if (get_parent_class($classname) == 'OIDplusCaptchaPlugin') $back_link = 'oidplus:system_plugins.captcha';
635 daniel-mar 67
                        $out['text'] = '<p><a '.OIDplus::gui()->link($back_link).'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
68
 
69
                        $out['text'] .= '<div><label class="padding_label">'._L('Class name').'</label><b>'.htmlentities($classname).'</b></div>'.
70
                                        '<div><label class="padding_label">'._L('Location').'</label><b>'.htmlentities($plugin->getPluginDirectory()).'</b></div>'.
71
                                        '<div><label class="padding_label">'._L('Plugin type').'</label><b>'.htmlentities(get_parent_class($classname)).'</b></div>'.
72
                                        '<div><label class="padding_label">'._L('Plugin name').'</label><b>'.htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()).'</b></div>'.
73
                                        '<div><label class="padding_label">'._L('Plugin author').'</label><b>'.htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()).'</b></div>'.
74
                                        '<div><label class="padding_label">'._L('Plugin version').'</label><b>'.htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()).'</b></div>'.
75
                                        '<div><label class="padding_label">'._L('Plugin OID').'</label><b>'.htmlentities(empty($plugin->getManifest()->getOid()) ? _L('n/a') : $plugin->getManifest()->getOid()).'</b></div>'.
76
                                        (!empty(trim($plugin->getManifest()->getHtmlDescription())) ? '<br><p><b>'._L('Additional information').':</b></p>' : '').
77
                                        $plugin->getManifest()->getHtmlDescription();
78
                } else {
79
                        $show_pages_public = false;
80
                        $show_pages_ra = false;
81
                        $show_pages_admin = false;
82
                        $show_db_active = false;
83
                        $show_db_inactive = false;
84
                        $show_sql_active = false;
85
                        $show_sql_inactive = false;
86
                        $show_obj_active = false;
87
                        $show_obj_inactive = false;
88
                        $show_auth = false;
89
                        $show_logger = false;
90
                        $show_language = false;
91
                        $show_design_active = false;
92
                        $show_design_inactive = false;
703 daniel-mar 93
                        $show_captcha_active = false;
94
                        $show_captcha_inactive = false;
635 daniel-mar 95
 
96
                        if ($parts[1] == '') {
97
                                $out['title'] = _L('Installed plugins');
98
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
99
                                $show_pages_public = true;
100
                                $show_pages_ra = true;
101
                                $show_pages_admin = true;
102
                                $show_db_active = true;
103
                                $show_db_inactive = true;
104
                                $show_sql_active = true;
105
                                $show_sql_inactive = true;
106
                                $show_obj_active = true;
107
                                $show_obj_inactive = true;
108
                                $show_auth = true;
109
                                $show_logger = true;
110
                                $show_language = true;
111
                                $show_design_active = true;
112
                                $show_design_inactive = true;
703 daniel-mar 113
                                $show_captcha_active = true;
114
                                $show_captcha_inactive = true;
635 daniel-mar 115
                        } else if ($parts[1] == 'pages') {
116
                                $out['title'] = _L('Page plugins');
117
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
118
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
119
                                $show_pages_public = true;
120
                                $show_pages_ra = true;
121
                                $show_pages_admin = true;
122
                        } else if ($parts[1] == 'pages.public') {
123
                                $out['title'] = _L('Public page plugins');
124
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
125
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins.pages').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
126
                                $show_pages_public = true;
127
                        } else if ($parts[1] == 'pages.ra') {
128
                                $out['title'] = _L('RA page plugins');
129
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
130
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins.pages').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
131
                                $show_pages_ra = true;
132
                        } else if ($parts[1] == 'pages.admin') {
133
                                $out['title'] = _L('Admin page plugins');
134
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
135
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins.pages').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
136
                                $show_pages_admin = true;
137
                        } else if ($parts[1] == 'objects') {
138
                                $out['title'] = _L('Object type plugins');
139
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
140
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
141
                                $show_obj_active = true;
142
                                $show_obj_inactive = true;
143
                        } else if ($parts[1] == 'objects.enabled') {
144
                                $out['title'] = _L('Object type plugins (enabled)');
145
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
146
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
147
                                $show_obj_active = true;
148
                        } else if ($parts[1] == 'objects.disabled') {
149
                                $out['title'] = _L('Object type plugins (disabled)');
150
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
152
                                $show_obj_inactive = true;
153
                        } else if ($parts[1] == 'database') {
154
                                $out['title'] = _L('Database provider plugins');
155
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
156
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
157
                                $show_db_active = true;
158
                                $show_db_inactive = true;
159
                        } else if ($parts[1] == 'database.enabled') {
160
                                $out['title'] = _L('Database provider plugins (active)');
161
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
162
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
163
                                $show_db_active = true;
164
                        } else if ($parts[1] == 'database.disabled') {
165
                                $out['title'] = _L('Database provider plugins (inactive)');
166
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
167
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
168
                                $show_db_inactive = true;
169
                        } else if ($parts[1] == 'sql') {
170
                                $out['title'] = _L('SQL slang plugins');
171
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
172
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
173
                                $show_sql_active = true;
174
                                $show_sql_inactive = true;
175
                        } else if ($parts[1] == 'sql.enabled') {
176
                                $out['title'] = _L('SQL slang plugins (active)');
177
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
178
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
179
                                $show_sql_active = true;
180
                        } else if ($parts[1] == 'sql.disabled') {
181
                                $out['title'] = _L('SQL slang plugins (inactive)');
182
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
183
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
184
                                $show_sql_inactive = true;
185
                        } else if ($parts[1] == 'auth') {
186
                                $out['title'] = _L('RA authentication');
187
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
188
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
189
                                $show_auth = true;
190
                        } else if ($parts[1] == 'logger') {
191
                                $out['title'] = _L('Logger');
192
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
193
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
194
                                $show_logger = true;
195
                        } else if ($parts[1] == 'language') {
196
                                $out['title'] = _L('Languages');
197
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
198
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
199
                                $show_language = true;
200
                        } else if ($parts[1] == 'design') {
201
                                $out['title'] = _L('Designs');
202
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
203
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
204
                                $show_design_active = true;
205
                                $show_design_inactive = true;
703 daniel-mar 206
                        } else if ($parts[1] == 'captcha') {
207
                                $out['title'] = _L('CAPTCHA plugins');
208
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
209
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
210
                                $show_captcha_active = true;
211
                                $show_captcha_inactive = true;
212
                        } else if ($parts[1] == 'captcha.enabled') {
213
                                $out['title'] = _L('CAPTCHA plugins (active)');
214
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
215
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
216
                                $show_captcha_active = true;
217
                        } else if ($parts[1] == 'captcha.disabled') {
218
                                $out['title'] = _L('CAPTCHA plugins (inactive)');
219
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
220
                                $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
221
                                $show_captcha_inactive = true;
635 daniel-mar 222
                        } else {
223
                                $out['title'] = _L('Error');
224
                                $out['icon'] = 'img/error_big.png';
225
                                $out['text'] = '<p>'._L('Invalid arguments').'</p>';
226
                                $out['text'] .= '<p><a '.OIDplus::gui()->link('oidplus:system_plugins').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back').'</a></p>';
227
                                return;
228
                        }
229
 
230
                        $pp_public = array();
231
                        $pp_ra = array();
232
                        $pp_admin = array();
233
 
234
                        foreach (OIDplus::getPagePlugins() as $plugin) {
235
                                if (is_subclass_of($plugin, OIDplusPagePluginPublic::class)) {
236
                                        $pp_public[] = $plugin;
237
                                }
238
                                if (is_subclass_of($plugin, OIDplusPagePluginRa::class)) {
239
                                        $pp_ra[] = $plugin;
240
                                }
241
                                if (is_subclass_of($plugin, OIDplusPagePluginAdmin::class)) {
242
                                        $pp_admin[] = $plugin;
243
                                }
244
                        }
245
 
246
                        if ($show_pages_public) {
247
                                if (count($plugins = $pp_public) > 0) {
248
                                        $out['text'] .= '<h2>'._L('Public page plugins').'</h2>';
249
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
250
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
251
                                        $out['text'] .= '       <tr>';
252
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
253
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
254
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
255
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
256
                                        $out['text'] .= '       </tr>';
257
                                        foreach ($plugins as $plugin) {
258
                                                $out['text'] .= '       <tr>';
259
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
260
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
261
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
262
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
263
                                                $out['text'] .= '       </tr>';
264
                                        }
265
                                        $out['text'] .= '</table>';
266
                                        $out['text'] .= '</div></div>';
267
                                }
268
                        }
269
 
270
                        if ($show_pages_ra) {
271
                                if (count($plugins = $pp_ra) > 0) {
272
                                        $out['text'] .= '<h2>'._L('RA page plugins').'</h2>';
273
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
274
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
275
                                        $out['text'] .= '       <tr>';
276
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
277
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
278
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
279
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
280
                                        $out['text'] .= '       </tr>';
281
                                        foreach ($plugins as $plugin) {
282
                                                $out['text'] .= '       <tr>';
283
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
284
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
285
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
286
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
287
                                                $out['text'] .= '       </tr>';
288
                                        }
289
                                        $out['text'] .= '</table>';
290
                                        $out['text'] .= '</div></div>';
291
                                }
292
                        }
293
 
294
                        if ($show_pages_admin) {
295
                                if (count($plugins = $pp_admin) > 0) {
296
                                        $out['text'] .= '<h2>'._L('Admin page plugins').'</h2>';
297
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
298
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
299
                                        $out['text'] .= '       <tr>';
300
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
301
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
302
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
303
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
304
                                        $out['text'] .= '       </tr>';
305
                                        foreach ($plugins as $plugin) {
306
                                                $out['text'] .= '       <tr>';
307
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
308
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
309
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
310
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
311
                                                $out['text'] .= '       </tr>';
312
                                        }
313
                                        $out['text'] .= '</table>';
314
                                        $out['text'] .= '</div></div>';
315
                                }
316
                        }
317
 
318
                        if ($show_obj_active || $show_obj_inactive) {
319
                                $enabled = $show_obj_active ? OIDplus::getObjectTypePluginsEnabled() : array();
320
                                $disabled = $show_obj_inactive ? OIDplus::getObjectTypePluginsDisabled() : array();
321
                                if (count($plugins = array_merge($enabled, $disabled)) > 0) {
322
                                        $out['text'] .= '<h2>'._L('Object types').'</h2>';
323
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
324
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
325
                                        $out['text'] .= '       <tr>';
326
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
327
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
328
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
329
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
330
                                        $out['text'] .= '       </tr>';
331
                                        foreach ($plugins as $plugin) {
332
                                                $out['text'] .= '       <tr>';
333
                                                if (in_array($plugin, $enabled)) {
334
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
335
                                                } else {
336
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'><font color="gray">'.htmlentities(get_class($plugin)).' '._L('(disabled)').'</font></a></td>';
337
                                                }
338
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
339
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
340
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
341
                                                $out['text'] .= '       </tr>';
342
                                        }
343
                                        $out['text'] .= '</table>';
344
                                        $out['text'] .= '</div></div>';
345
                                }
346
                        }
347
 
348
                        if ($show_db_active || $show_db_inactive) {
349
                                if (count($plugins = OIDplus::getDatabasePlugins()) > 0) {
350
                                        $out['text'] .= '<h2>'._L('Database providers').'</h2>';
351
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
352
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
353
                                        $out['text'] .= '       <tr>';
354
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
355
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
356
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
357
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
358
                                        $out['text'] .= '       </tr>';
359
                                        foreach ($plugins as $plugin) {
360
                                                $active = $plugin::id() == OIDplus::baseConfig()->getValue('DATABASE_PLUGIN');
361
                                                if ($active && !$show_db_active) continue;
362
                                                if (!$active && !$show_db_inactive) continue;
363
 
364
                                                $out['text'] .= '       <tr>';
365
                                                if ($active) {
366
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> '._L('(active)').'</a></td>';
367
                                                } else {
368
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
369
                                                }
370
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
371
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
372
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
373
                                                $out['text'] .= '       </tr>';
374
                                        }
375
                                        $out['text'] .= '</table>';
376
                                        $out['text'] .= '</div></div>';
377
                                }
378
                        }
379
 
380
                        if ($show_sql_active || $show_sql_inactive) {
381
                                if (count($plugins = OIDplus::getSqlSlangPlugins()) > 0) {
382
                                        $out['text'] .= '<h2>'._L('SQL slang plugins').'</h2>';
383
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
384
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
385
                                        $out['text'] .= '       <tr>';
386
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
387
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
388
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
389
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
390
                                        $out['text'] .= '       </tr>';
391
                                        foreach ($plugins as $plugin) {
392
                                                $active = $plugin::id() == OIDplus::db()->getSlang()->id();
393
                                                if ($active && !$show_sql_active) continue;
394
                                                if (!$active && !$show_sql_inactive) continue;
395
 
396
                                                $out['text'] .= '       <tr>';
397
                                                if ($active) {
398
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> '._L('(active)').'</a></td>';
399
                                                } else {
400
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
401
                                                }
402
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
403
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
404
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
405
                                                $out['text'] .= '       </tr>';
406
                                        }
407
                                        $out['text'] .= '</table>';
408
                                        $out['text'] .= '</div></div>';
409
                                }
410
                        }
411
 
412
                        if ($show_auth) {
413
                                if (count($plugins = OIDplus::getAuthPlugins()) > 0) {
414
                                        $out['text'] .= '<h2>'._L('RA authentication providers').'</h2>';
415
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
416
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
417
                                        $out['text'] .= '       <tr>';
418
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
419
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
420
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
421
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
422
                                        $out['text'] .= '       </tr>';
423
                                        foreach ($plugins as $plugin) {
424
                                                $out['text'] .= '       <tr>';
425
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
426
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
427
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
428
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
429
                                                $out['text'] .= '       </tr>';
430
                                        }
431
                                        $out['text'] .= '</table>';
432
                                        $out['text'] .= '</div></div>';
433
                                }
434
                        }
435
 
436
                        if ($show_logger) {
437
                                if (count($plugins = OIDplus::getLoggerPlugins()) > 0) {
438
                                        $out['text'] .= '<h2>'._L('Logger plugins').'</h2>';
439
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
440
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
441
                                        $out['text'] .= '       <tr>';
442
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
443
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
444
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
445
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
446
                                        $out['text'] .= '       </tr>';
447
                                        foreach ($plugins as $plugin) {
448
                                                $reason = '';
449
                                                $active = $plugin->available($reason);
450
 
451
                                                $out['text'] .= '       <tr>';
452
                                                if ($active) {
453
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
454
                                                } else {
455
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'><font color="gray">'.htmlentities(get_class($plugin)).'</font></a> <font color="gray">('._L('not available: %1',htmlentities($reason)).')</font></td>';
456
                                                }
457
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
458
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
459
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
460
                                                $out['text'] .= '       </tr>';
461
                                        }
462
                                        $out['text'] .= '</table>';
463
                                        $out['text'] .= '</div></div>';
464
                                }
465
                        }
466
 
467
                        if ($show_language) {
468
                                if (count($plugins = OIDplus::getLanguagePlugins()) > 0) {
469
                                        $out['text'] .= '<h2>'._L('Languages').'</h2>';
470
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
471
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
472
                                        $out['text'] .= '       <tr>';
473
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
474
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
475
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
476
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
477
                                        $out['text'] .= '       </tr>';
478
                                        foreach ($plugins as $plugin) {
479
                                                $out['text'] .= '       <tr>';
480
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
481
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
482
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
483
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
484
                                                $out['text'] .= '       </tr>';
485
                                        }
486
                                        $out['text'] .= '</table>';
487
                                        $out['text'] .= '</div></div>';
488
                                }
489
                        }
490
 
491
                        if ($show_design_active || $show_design_inactive) {
492
                                if (count($plugins = OIDplus::getDesignPlugins()) > 0) {
493
                                        $out['text'] .= '<h2>'._L('Designs').'</h2>';
494
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
495
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
496
                                        $out['text'] .= '       <tr>';
497
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
498
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
499
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
500
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
501
                                        $out['text'] .= '       </tr>';
502
                                        foreach ($plugins as $plugin) {
503
                                                $active = OIDplus::config()->getValue('design') === basename($plugin->getPluginDirectory());
504
                                                if ($active && !$show_design_active) continue;
505
                                                if (!$active && !$show_design_inactive) continue;
506
 
507
                                                $out['text'] .= '       <tr>';
508
                                                if ($active) {
509
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> '._L('(active)').'</a></td>';
510
                                                } else {
511
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
512
                                                }
513
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
514
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
515
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
516
                                                $out['text'] .= '       </tr>';
517
                                        }
518
                                        $out['text'] .= '</table>';
519
                                        $out['text'] .= '</div></div>';
520
                                }
521
                        }
703 daniel-mar 522
 
523
                        if ($show_captcha_active || $show_captcha_inactive) {
524
                                if (count($plugins = OIDplus::getCaptchaPlugins()) > 0) {
525
                                        $out['text'] .= '<h2>'._L('CAPTCHA plugins').'</h2>';
526
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
527
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
528
                                        $out['text'] .= '       <tr>';
529
                                        $out['text'] .= '               <th width="25%">'._L('Class name').'</th>';
530
                                        $out['text'] .= '               <th width="25%">'._L('Plugin name').'</th>';
531
                                        $out['text'] .= '               <th width="25%">'._L('Plugin version').'</th>';
532
                                        $out['text'] .= '               <th width="25%">'._L('Plugin author').'</th>';
533
                                        $out['text'] .= '       </tr>';
534
                                        foreach ($plugins as $plugin) {
535
 
536
                                                $captcha_plugin_name = OIDplus::baseConfig()->getValue('CAPTCHA_PLUGIN', '');
537
                                                if (OIDplus::baseConfig()->getValue('RECAPTCHA_ENABLED', false) && ($captcha_plugin_name === '')) {
538
                                                        // Legacy config file support!
539
                                                        $captcha_plugin_name = 'ReCAPTCHA';
540
                                                }
541
 
542
                                                $active = $plugin::id() == $captcha_plugin_name;
543
                                                if ($active && !$show_captcha_active) continue;
544
                                                if (!$active && !$show_captcha_inactive) continue;
545
 
546
                                                $out['text'] .= '       <tr>';
547
                                                if ($active) {
548
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> '._L('(active)').'</a></td>';
549
                                                } else {
550
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
551
                                                }
552
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getName()) ? _L('n/a') : $plugin->getManifest()->getName()) . '</td>';
553
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getVersion()) ? _L('n/a') : $plugin->getManifest()->getVersion()) . '</td>';
554
                                                $out['text'] .= '<td>' . htmlentities(empty($plugin->getManifest()->getAuthor()) ? _L('n/a') : $plugin->getManifest()->getAuthor()) . '</td>';
555
                                                $out['text'] .= '       </tr>';
556
                                        }
557
                                        $out['text'] .= '</table>';
558
                                        $out['text'] .= '</div></div>';
559
                                }
560
                        }
635 daniel-mar 561
                }
562
        }
563
 
564
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
565
                if (!OIDplus::authUtils()->isAdminLoggedIn()) return false;
566
 
567
                if (file_exists(__DIR__.'/treeicon.png')) {
568
                        $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
569
                } else {
570
                        $tree_icon = null; // default icon (folder)
571
                }
572
 
573
                $tree_icon_pages = $tree_icon; // TODO
574
                $tree_icon_pages_public = $tree_icon; // TODO
575
                $tree_icon_pages_ra = $tree_icon; // TODO
576
                $tree_icon_pages_admin = $tree_icon; // TODO
577
                $tree_icon_db_active = $tree_icon; // TODO
578
                $tree_icon_db_inactive = $tree_icon; // TODO
579
                $tree_icon_sql_active = $tree_icon; // TODO
580
                $tree_icon_sql_inactive = $tree_icon; // TODO
581
                $tree_icon_obj_active = $tree_icon; // TODO
582
                $tree_icon_obj_inactive = $tree_icon; // TODO
583
                $tree_icon_auth = $tree_icon; // TODO
584
                $tree_icon_logger = $tree_icon; // TODO
585
                $tree_icon_language = $tree_icon; // TODO
586
                $tree_icon_design_active = $tree_icon; // TODO
587
                $tree_icon_design_inactive = $tree_icon; // TODO
703 daniel-mar 588
                $tree_icon_captcha_active = $tree_icon; // TODO
589
                $tree_icon_captcha_inactive = $tree_icon; // TODO
635 daniel-mar 590
 
591
                $pp_public = array();
592
                $pp_ra = array();
593
                $pp_admin = array();
594
 
595
                foreach (OIDplus::getPagePlugins() as $plugin) {
596
                        if (is_subclass_of($plugin, OIDplusPagePluginPublic::class)) {
597
                                $pp_public[] = $plugin;
598
                        }
599
                        if (is_subclass_of($plugin, OIDplusPagePluginRa::class)) {
600
                                $pp_ra[] = $plugin;
601
                        }
602
                        if (is_subclass_of($plugin, OIDplusPagePluginAdmin::class)) {
603
                                $pp_admin[] = $plugin;
604
                        }
605
                }
606
 
607
 
608
                $public_plugins = array();
609
                foreach ($pp_public as $plugin) {
610
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
611
 
612
                        $public_plugins[] = array(
613
                                'id' => 'oidplus:system_plugins$'.get_class($plugin),
614
                                'icon' => $tree_icon_pages_public,
615
                                'text' => $txt,
616
                        );
617
                }
618
                $ra_plugins = array();
619
                foreach ($pp_ra as $plugin) {
620
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
621
 
622
                        $ra_plugins[] = array(
623
                                'id' => 'oidplus:system_plugins$'.get_class($plugin),
624
                                'icon' => $tree_icon_pages_ra,
625
                                'text' => $txt,
626
                        );
627
                }
628
                $admin_plugins = array();
629
                foreach ($pp_admin as $plugin) {
630
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
631
 
632
                        $admin_plugins[] = array(
633
                                'id' => 'oidplus:system_plugins$'.get_class($plugin),
634
                                'icon' => $tree_icon_pages_admin,
635
                                'text' => $txt,
636
                        );
637
                }
638
                $db_plugins = array();
639
                foreach (OIDplus::getDatabasePlugins() as $plugin) {
640
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
641
 
642
                        if ($plugin::id() == OIDplus::baseConfig()->getValue('DATABASE_PLUGIN')) {
643
                                $db_plugins[] = array(
644
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
645
                                        'icon' => $tree_icon_db_active,
646
                                        'text' => $txt,
647
                                 );
648
                        } else {
649
                                $db_plugins[] = array(
650
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
651
                                        'icon' => $tree_icon_db_inactive,
652
                                        'text' => '<font color="gray">'.$txt.'</font>',
653
                                 );
654
                        }
655
                }
656
                $sql_plugins = array();
657
                foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
658
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
659
 
660
                        if ($plugin::id() == OIDplus::db()->getSlang()->id()) {
661
                                $sql_plugins[] = array(
662
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
703 daniel-mar 663
                                        'icon' => $tree_icon_sql_active,
635 daniel-mar 664
                                        'text' => $txt,
665
                                 );
666
                        } else {
667
                                $sql_plugins[] = array(
668
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
703 daniel-mar 669
                                        'icon' => $tree_icon_sql_inactive,
635 daniel-mar 670
                                        'text' => '<font color="gray">'.$txt.'</font>',
671
                                 );
672
                        }
673
                }
674
                $obj_plugins = array();
675
                $enabled = OIDplus::getObjectTypePluginsEnabled();
676
                $disabled = OIDplus::getObjectTypePluginsDisabled();
677
                foreach (array_merge($enabled, $disabled) as $plugin) {
678
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
679
                        if (in_array($plugin, $enabled)) {
680
                                $obj_plugins[] = array(
681
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
682
                                        'icon' => $tree_icon_obj_active,
683
                                        'text' => $txt,
684
                                 );
685
                        } else {
686
                                $obj_plugins[] = array(
687
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
688
                                        'icon' => $tree_icon_obj_inactive,
689
                                        'text' => '<font color="gray">'.$txt.'</font>',
690
                                 );
691
                        }
692
                }
693
                $auth_plugins = array();
694
                foreach (OIDplus::getAuthPlugins() as $plugin) {
695
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
696
 
697
                        $auth_plugins[] = array(
698
                                'id' => 'oidplus:system_plugins$'.get_class($plugin),
699
                                'icon' => $tree_icon_auth,
700
                                'text' => $txt,
701
                        );
702
                }
703
                $logger_plugins = array();
704
                foreach (OIDplus::getLoggerPlugins() as $plugin) {
705
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
706
 
707
                        $reason = '';
708
                        if (!$plugin->available($reason)) $txt = '<font color="gray">'.$txt.'</font>';
709
 
710
                        $logger_plugins[] = array(
711
                                'id' => 'oidplus:system_plugins$'.get_class($plugin),
712
                                'icon' => $tree_icon_logger,
713
                                'text' => $txt,
714
                        );
715
                }
716
                $language_plugins = array();
717
                foreach (OIDplus::getLanguagePlugins() as $plugin) {
718
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
719
 
720
                        $language_plugins[] = array(
721
                                'id' => 'oidplus:system_plugins$'.get_class($plugin),
722
                                'icon' => $tree_icon_language,
723
                                'text' => $txt,
724
                        );
725
                }
726
                $design_plugins = array();
727
                foreach (OIDplus::getDesignPlugins() as $plugin) {
728
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
729
 
730
                        $active = OIDplus::config()->getValue('design') === basename($plugin->getPluginDirectory());
731
                        if ($active) {
732
                                $design_plugins[] = array(
733
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
734
                                        'icon' => $tree_icon_design_active,
735
                                        'text' => $txt,
736
                                );
737
                        } else {
738
                                $design_plugins[] = array(
739
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
740
                                        'icon' => $tree_icon_design_inactive,
741
                                        'text' => '<font color="gray">'.$txt.'</font>',
742
                                );
743
                        }
744
                }
703 daniel-mar 745
                $captcha_plugins = array();
746
                foreach (OIDplus::getCaptchaPlugins() as $plugin) {
747
                        $txt = (empty($plugin->getManifest()->getName())) ? get_class($plugin) : $plugin->getManifest()->getName();
748
 
749
                        $captcha_plugin_name = OIDplus::baseConfig()->getValue('CAPTCHA_PLUGIN', '');
750
                        if (OIDplus::baseConfig()->getValue('RECAPTCHA_ENABLED', false) && ($captcha_plugin_name === '')) {
751
                                // Legacy config file support!
752
                                $captcha_plugin_name = 'ReCAPTCHA';
753
                        }
754
 
755
                        if ($plugin::id() == $captcha_plugin_name) {
756
                                $captcha_plugins[] = array(
757
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
758
                                        'icon' => $tree_icon_captcha_active,
759
                                        'text' => $txt,
760
                                 );
761
                        } else {
762
                                $captcha_plugins[] = array(
763
                                        'id' => 'oidplus:system_plugins$'.get_class($plugin),
764
                                        'icon' => $tree_icon_captcha_inactive,
765
                                        'text' => '<font color="gray">'.$txt.'</font>',
766
                                 );
767
                        }
768
                }
635 daniel-mar 769
                $json[] = array(
770
                        'id' => 'oidplus:system_plugins',
771
                        'icon' => $tree_icon,
772
                        'text' => _L('Plugins'),
773
                        'children' => array(
774
                        array(
775
                                'id' => 'oidplus:system_plugins.pages',
776
                                'icon' => $tree_icon,
777
                                'text' => _L('Page plugins'),
778
                                'children' => array(
779
                                        array(
780
                                                'id' => 'oidplus:system_plugins.pages.public',
781
                                                'icon' => $tree_icon,
782
                                                'text' => _L('Public'),
783
                                                'children' => $public_plugins
784
                                        ),
785
                                        array(
786
                                                'id' => 'oidplus:system_plugins.pages.ra',
787
                                                'icon' => $tree_icon,
788
                                                'text' => _L('RA'),
789
                                                'children' => $ra_plugins
790
                                        ),
791
                                        array(
792
                                                'id' => 'oidplus:system_plugins.pages.admin',
793
                                                'icon' => $tree_icon,
794
                                                'text' => _L('Admin'),
795
                                                'children' => $admin_plugins
796
                                        )
797
                                )
798
                                ),
799
                                array(
800
                                        'id' => 'oidplus:system_plugins.objects',
801
                                        'icon' => $tree_icon,
802
                                        'text' => _L('Object types'),
803
                                        'children' => $obj_plugins
804
                                ),
805
                                array(
806
                                        'id' => 'oidplus:system_plugins.database',
807
                                        'icon' => $tree_icon,
808
                                        'text' => _L('Database providers'),
809
                                        'children' => $db_plugins
810
                                ),
811
                                array(
812
                                        'id' => 'oidplus:system_plugins.sql',
813
                                        'icon' => $tree_icon,
814
                                        'text' => _L('SQL slangs'),
815
                                        'children' => $sql_plugins
816
                                ),
817
                                array(
818
                                        'id' => 'oidplus:system_plugins.auth',
819
                                        'icon' => $tree_icon,
820
                                        'text' => _L('RA authentication'),
821
                                        'children' => $auth_plugins
822
                                ),
823
                                array(
824
                                        'id' => 'oidplus:system_plugins.logger',
825
                                        'icon' => $tree_icon,
826
                                        'text' => _L('Logger'),
827
                                        'children' => $logger_plugins
828
                                ),
829
                                array(
830
                                        'id' => 'oidplus:system_plugins.language',
831
                                        'icon' => $tree_icon,
832
                                        'text' => _L('Languages'),
833
                                        'children' => $language_plugins
834
                                ),
835
                                array(
836
                                        'id' => 'oidplus:system_plugins.design',
837
                                        'icon' => $tree_icon,
838
                                        'text' => _L('Designs'),
839
                                        'children' => $design_plugins
703 daniel-mar 840
                                ),
841
                                array(
842
                                        'id' => 'oidplus:system_plugins.captcha',
843
                                        'icon' => $tree_icon,
844
                                        'text' => _L('CAPTCHA plugins'),
845
                                        'children' => $captcha_plugins
635 daniel-mar 846
                                )
847
                        )
848
                );
849
 
850
                return true;
851
        }
852
 
853
        public function tree_search($request) {
854
                // Not required, because all sub-nodes are loaded at the same time; no lazy-loading
855
                return false;
856
        }
703 daniel-mar 857
}