Subversion Repositories oidplus

Rev

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