Subversion Repositories oidplus

Rev

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

Rev Author Line No. Line
148 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 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
 
256 daniel-mar 20
class OIDplusPageAdminPlugins extends OIDplusPagePluginAdmin {
21
 
148 daniel-mar 22
        public function action(&$handled) {
23
        }
24
 
25
        public function init($html=true) {
26
        }
27
 
28
        public function gui($id, &$out, &$handled) {
151 daniel-mar 29
                $parts = explode('.',$id,2);
30
                if (!isset($parts[1])) $parts[1] = '';
31
                if ($parts[0] != 'oidplus:system_plugins') return;
32
                $handled = true;
220 daniel-mar 33
                $out['title'] = "Installed plugins";
241 daniel-mar 34
                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
148 daniel-mar 35
 
151 daniel-mar 36
                if (!OIDplus::authUtils()::isAdminLoggedIn()) {
37
                        $out['icon'] = 'img/error_big.png';
250 daniel-mar 38
                        $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>';
281 daniel-mar 39
                        return;
151 daniel-mar 40
                }
41
 
42
                if (substr($parts[1],0,1) == '$') {
43
                        $classname = substr($parts[1],1);
44
                        $out['title'] = htmlentities($classname);
241 daniel-mar 45
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 46
 
47
                        $reflector = new \ReflectionClass($classname);
277 daniel-mar 48
                        $pluginInfo = OIDplus::getPluginInfo($classname);
151 daniel-mar 49
 
222 daniel-mar 50
                        if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
51
                        if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
52
                        if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
53
                        if (!isset($pluginInfo['descriptionHTML']) || empty($pluginInfo['descriptionHTML'])) $pluginInfo['descriptionHTML'] = '';
54
 
152 daniel-mar 55
                        $out['text'] .= '<div><label class="padding_label">Classname</label><b>'.htmlentities($classname).'</b></div>'.
56
                                        '<div><label class="padding_label">Location</label><b>'.htmlentities(dirname($reflector->getFileName())).'</b></div>'.
222 daniel-mar 57
                                        '<div><label class="padding_label">Plugin type</label><b>'.htmlentities(get_parent_class($classname)).'</b></div>'.
58
                                        '<div><label class="padding_label">Plugin name</label><b>'.htmlentities($pluginInfo['name']).'</b></div>'.
59
                                        '<div><label class="padding_label">Plugin author</label><b>'.htmlentities($pluginInfo['author']).'</b></div>'.
60
                                        '<div><label class="padding_label">Plugin version</label><b>'.htmlentities($pluginInfo['version']).'</b></div>'.
61
                                        (!empty($pluginInfo['descriptionHTML']) ? '<br><p><b>Additional information:</b></p>' : '').
62
                                        $pluginInfo['descriptionHTML'];
151 daniel-mar 63
                } else {
64
                        $show_pages_public = false;
65
                        $show_pages_ra = false;
66
                        $show_pages_admin = false;
67
                        $show_db_active = false;
68
                        $show_db_inactive = false;
274 daniel-mar 69
                        $show_sql_active = false;
70
                        $show_sql_inactive = false;
151 daniel-mar 71
                        $show_obj_active = false;
72
                        $show_obj_inactive = false;
221 daniel-mar 73
                        $show_auth = false;
289 daniel-mar 74
                        $show_logger = false;
151 daniel-mar 75
 
76
                        if ($parts[1] == '') {
77
                                $out['title'] = "Installed plugins";
241 daniel-mar 78
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 79
                                $show_pages_public = true;
80
                                $show_pages_ra = true;
81
                                $show_pages_admin = true;
82
                                $show_db_active = true;
83
                                $show_db_inactive = true;
274 daniel-mar 84
                                $show_sql_active = true;
85
                                $show_sql_inactive = true;
151 daniel-mar 86
                                $show_obj_active = true;
87
                                $show_obj_inactive = true;
221 daniel-mar 88
                                $show_auth = true;
289 daniel-mar 89
                                $show_logger = true;
151 daniel-mar 90
                        } else if ($parts[1] == 'pages') {
91
                                $out['title'] = "Page plugins";
241 daniel-mar 92
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 93
                                $show_pages_public = true;
94
                                $show_pages_ra = true;
95
                                $show_pages_admin = true;
96
                        } else if ($parts[1] == 'pages.public') {
97
                                $out['title'] = "Public page plugins";
241 daniel-mar 98
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 99
                                $show_pages_public = true;
100
                        } else if ($parts[1] == 'pages.ra') {
101
                                $out['title'] = "RA page plugins";
241 daniel-mar 102
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 103
                                $show_pages_ra = true;
104
                        } else if ($parts[1] == 'pages.admin') {
105
                                $out['title'] = "Admin page plugins";
241 daniel-mar 106
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 107
                                $show_pages_admin = true;
108
                        } else if ($parts[1] == 'objects') {
109
                                $out['title'] = "Object type plugins";
241 daniel-mar 110
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 111
                                $show_obj_active = true;
112
                                $show_obj_inactive = true;
113
                        } else if ($parts[1] == 'objects.enabled') {
114
                                $out['title'] = "Object type plugins (enabled)";
241 daniel-mar 115
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 116
                                $show_obj_active = true;
117
                        } else if ($parts[1] == 'objects.disabled') {
118
                                $out['title'] = "Object type plugins (disabled)";
241 daniel-mar 119
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 120
                                $show_obj_inactive = true;
121
                        } else if ($parts[1] == 'database') {
122
                                $out['title'] = "Database provider plugins";
241 daniel-mar 123
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 124
                                $show_db_active = true;
125
                                $show_db_inactive = true;
126
                        } else if ($parts[1] == 'database.enabled') {
127
                                $out['title'] = "Database provider plugins (active)";
241 daniel-mar 128
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 129
                                $show_db_active = true;
130
                        } else if ($parts[1] == 'database.disabled') {
131
                                $out['title'] = "Database provider plugins (inactive)";
241 daniel-mar 132
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
151 daniel-mar 133
                                $show_db_inactive = true;
274 daniel-mar 134
                        } else if ($parts[1] == 'sql') {
135
                                $out['title'] = "SQL slang plugins";
136
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
137
                                $show_sql_active = true;
138
                                $show_sql_inactive = true;
139
                        } else if ($parts[1] == 'sql.enabled') {
140
                                $out['title'] = "SQL slang plugins (active)";
141
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
142
                                $show_sql_active = true;
143
                        } else if ($parts[1] == 'sql.disabled') {
144
                                $out['title'] = "SQL slang plugins (inactive)";
145
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
146
                                $show_sql_inactive = true;
221 daniel-mar 147
                        } else if ($parts[1] == 'auth') {
148
                                $out['title'] = "RA authentication";
241 daniel-mar 149
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
221 daniel-mar 150
                                $show_auth = true;
289 daniel-mar 151
                        } else if ($parts[1] == 'logger') {
152
                                $out['title'] = "Logger";
153
                                $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
154
                                $show_logger = true;
151 daniel-mar 155
                        } else {
148 daniel-mar 156
                                $out['icon'] = 'img/error_big.png';
153 daniel-mar 157
                                $out['text'] = '<p>Invalid arguments.</p>';
281 daniel-mar 158
                                return;
148 daniel-mar 159
                        }
160
 
281 daniel-mar 161
                        $pp_public = array();
162
                        $pp_ra = array();
163
                        $pp_admin = array();
289 daniel-mar 164
 
281 daniel-mar 165
                        foreach (OIDplus::getPagePlugins() as $plugin) {
166
                                if (is_subclass_of($plugin, OIDplusPagePluginPublic::class)) {
167
                                        $pp_public[] = $plugin;
168
                                }
169
                                if (is_subclass_of($plugin, OIDplusPagePluginRa::class)) {
170
                                        $pp_ra[] = $plugin;
171
                                }
172
                                if (is_subclass_of($plugin, OIDplusPagePluginAdmin::class)) {
173
                                        $pp_admin[] = $plugin;
174
                                }
175
                        }
176
 
151 daniel-mar 177
                        if ($show_pages_public) {
281 daniel-mar 178
                                if (count($plugins = $pp_public) > 0) {
222 daniel-mar 179
                                        $out['text'] .= '<h2>Public page plugins</h2>';
180
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
181
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
182
                                        $out['text'] .= '       <tr>';
183
                                        $out['text'] .= '               <th width="25%">Class name</th>';
184
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
185
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
186
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
187
                                        $out['text'] .= '       </tr>';
151 daniel-mar 188
                                        foreach ($plugins as $plugin) {
222 daniel-mar 189
                                                $out['text'] .= '       <tr>';
277 daniel-mar 190
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
250 daniel-mar 191
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
222 daniel-mar 192
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
193
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
194
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
195
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
196
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
197
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
198
                                                $out['text'] .= '       </tr>';
151 daniel-mar 199
                                        }
222 daniel-mar 200
                                        $out['text'] .= '</table>';
201
                                        $out['text'] .= '</div></div>';
148 daniel-mar 202
                                }
203
                        }
204
 
151 daniel-mar 205
                        if ($show_pages_ra) {
281 daniel-mar 206
                                if (count($plugins = $pp_ra) > 0) {
222 daniel-mar 207
                                        $out['text'] .= '<h2>RA page plugins</h2>';
208
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
209
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
210
                                        $out['text'] .= '       <tr>';
211
                                        $out['text'] .= '               <th width="25%">Class name</th>';
212
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
213
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
214
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
215
                                        $out['text'] .= '       </tr>';
151 daniel-mar 216
                                        foreach ($plugins as $plugin) {
222 daniel-mar 217
                                                $out['text'] .= '       <tr>';
277 daniel-mar 218
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
250 daniel-mar 219
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
222 daniel-mar 220
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
221
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
222
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
223
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
224
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
225
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
226
                                                $out['text'] .= '       </tr>';
151 daniel-mar 227
                                        }
222 daniel-mar 228
                                        $out['text'] .= '</table>';
229
                                        $out['text'] .= '</div></div>';
148 daniel-mar 230
                                }
231
                        }
232
 
151 daniel-mar 233
                        if ($show_pages_admin) {
281 daniel-mar 234
                                if (count($plugins = $pp_admin) > 0) {
222 daniel-mar 235
                                        $out['text'] .= '<h2>Admin page plugins</h2>';
236
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
237
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
238
                                        $out['text'] .= '       <tr>';
239
                                        $out['text'] .= '               <th width="25%">Class name</th>';
240
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
241
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
242
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
243
                                        $out['text'] .= '       </tr>';
151 daniel-mar 244
                                        foreach ($plugins as $plugin) {
222 daniel-mar 245
                                                $out['text'] .= '       <tr>';
277 daniel-mar 246
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
250 daniel-mar 247
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
222 daniel-mar 248
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
249
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
250
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
251
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
252
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
253
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
254
                                                $out['text'] .= '       </tr>';
151 daniel-mar 255
                                        }
222 daniel-mar 256
                                        $out['text'] .= '</table>';
257
                                        $out['text'] .= '</div></div>';
148 daniel-mar 258
                                }
259
                        }
260
 
222 daniel-mar 261
                        if ($show_obj_active || $show_obj_inactive) {
227 daniel-mar 262
                                $enabled = $show_obj_active ? OIDplus::getObjectTypePluginsEnabled() : array();
263
                                $disabled = $show_obj_inactive ? OIDplus::getObjectTypePluginsDisabled() : array();
222 daniel-mar 264
                                if (count($plugins = array_merge($enabled, $disabled)) > 0) {
265
                                        $out['text'] .= '<h2>Object types</h2>';
266
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
267
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
268
                                        $out['text'] .= '       <tr>';
269
                                        $out['text'] .= '               <th width="25%">Class name</th>';
270
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
271
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
272
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
273
                                        $out['text'] .= '       </tr>';
227 daniel-mar 274
                                        foreach ($plugins as $plugin) {
222 daniel-mar 275
                                                $out['text'] .= '       <tr>';
277 daniel-mar 276
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
227 daniel-mar 277
                                                if (in_array($plugin, $enabled)) {
250 daniel-mar 278
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
222 daniel-mar 279
                                                } else {
250 daniel-mar 280
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'><font color="gray">'.htmlentities(get_class($plugin)).' (disabled)</font></a></td>';
222 daniel-mar 281
                                                }
282
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
283
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
284
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
285
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
286
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
287
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
288
                                                $out['text'] .= '       </tr>';
150 daniel-mar 289
                                        }
222 daniel-mar 290
                                        $out['text'] .= '</table>';
291
                                        $out['text'] .= '</div></div>';
148 daniel-mar 292
                                }
293
                        }
294
 
151 daniel-mar 295
                        if ($show_db_active || $show_db_inactive) {
296
                                if (count($plugins = OIDplus::getDatabasePlugins()) > 0) {
222 daniel-mar 297
                                        $out['text'] .= '<h2>Database providers</h2>';
298
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
299
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
300
                                        $out['text'] .= '       <tr>';
301
                                        $out['text'] .= '               <th width="25%">Class name</th>';
302
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
303
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
304
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
305
                                        $out['text'] .= '       </tr>';
151 daniel-mar 306
                                        foreach ($plugins as $plugin) {
275 daniel-mar 307
                                                $active = $plugin::id() == OIDplus::baseConfig()->getValue('DATABASE_PLUGIN');
222 daniel-mar 308
                                                if ($active && !$show_db_active) continue;
309
                                                if (!$active && !$show_db_inactive) continue;
310
 
311
                                                $out['text'] .= '       <tr>';
277 daniel-mar 312
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
274 daniel-mar 313
                                                if ($active) {
250 daniel-mar 314
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> (active)</a></td>';
151 daniel-mar 315
                                                } else {
250 daniel-mar 316
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
151 daniel-mar 317
                                                }
222 daniel-mar 318
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
319
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
320
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
321
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
322
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
323
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
324
                                                $out['text'] .= '       </tr>';
150 daniel-mar 325
                                        }
222 daniel-mar 326
                                        $out['text'] .= '</table>';
327
                                        $out['text'] .= '</div></div>';
148 daniel-mar 328
                                }
329
                        }
221 daniel-mar 330
 
274 daniel-mar 331
                        if ($show_sql_active || $show_sql_inactive) {
332
                                if (count($plugins = OIDplus::getSqlSlangPlugins()) > 0) {
333
                                        $out['text'] .= '<h2>SQL slang plugins</h2>';
334
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
335
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
336
                                        $out['text'] .= '       <tr>';
337
                                        $out['text'] .= '               <th width="25%">Class name</th>';
338
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
339
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
340
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
341
                                        $out['text'] .= '       </tr>';
342
                                        foreach ($plugins as $plugin) {
343
                                                $active = $plugin::id() == OIDplus::db()->getSlang()::id();
344
                                                if ($active && !$show_sql_active) continue;
345
                                                if (!$active && !$show_sql_inactive) continue;
346
 
347
                                                $out['text'] .= '       <tr>';
277 daniel-mar 348
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
274 daniel-mar 349
                                                if ($active) {
350
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'><b>'.htmlentities(get_class($plugin)).'</b> (active)</a></td>';
351
                                                } else {
352
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
353
                                                }
354
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
355
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
356
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
357
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
358
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
359
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
360
                                                $out['text'] .= '       </tr>';
361
                                        }
362
                                        $out['text'] .= '</table>';
363
                                        $out['text'] .= '</div></div>';
364
                                }
365
                        }
366
 
221 daniel-mar 367
                        if ($show_auth) {
368
                                if (count($plugins = OIDplus::getAuthPlugins()) > 0) {
222 daniel-mar 369
                                        $out['text'] .= '<h2>RA authentication providers</h2>';
370
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
371
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
372
                                        $out['text'] .= '       <tr>';
373
                                        $out['text'] .= '               <th width="25%">Class name</th>';
374
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
375
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
376
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
377
                                        $out['text'] .= '       </tr>';
221 daniel-mar 378
                                        foreach ($plugins as $plugin) {
222 daniel-mar 379
                                                $out['text'] .= '       <tr>';
277 daniel-mar 380
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
250 daniel-mar 381
                                                $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
222 daniel-mar 382
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
383
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
384
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
385
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
386
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
387
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
388
                                                $out['text'] .= '       </tr>';
221 daniel-mar 389
                                        }
222 daniel-mar 390
                                        $out['text'] .= '</table>';
391
                                        $out['text'] .= '</div></div>';
221 daniel-mar 392
                                }
393
                        }
289 daniel-mar 394
 
395
                        if ($show_logger) {
396
                                if (count($plugins = OIDplus::getLoggerPlugins()) > 0) {
397
                                        $out['text'] .= '<h2>Logger plugins</h2>';
398
                                        $out['text'] .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
399
                                        $out['text'] .= '<table class="table table-bordered table-striped">';
400
                                        $out['text'] .= '       <tr>';
401
                                        $out['text'] .= '               <th width="25%">Class name</th>';
402
                                        $out['text'] .= '               <th width="25%">Plugin name</th>';
403
                                        $out['text'] .= '               <th width="25%">Plugin version</th>';
404
                                        $out['text'] .= '               <th width="25%">Plugin author</th>';
405
                                        $out['text'] .= '       </tr>';
406
                                        foreach ($plugins as $plugin) {
407
                                                $reason = '';
408
                                                $active = $plugin->available($reason);
409
 
410
                                                $out['text'] .= '       <tr>';
411
                                                $pluginInfo = OIDplus::getPluginInfo($plugin);
412
                                                if ($active) {
413
                                                        $out['text'] .= '<td><a '.OIDplus::gui()->link('oidplus:system_plugins.$'.get_class($plugin)).'>'.htmlentities(get_class($plugin)).'</a></td>';
414
                                                } else {
415
                                                        $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">(not available: '.htmlentities($reason).')</font></td>';
416
                                                }
417
                                                if (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) $pluginInfo['name'] = 'n/a';
418
                                                if (!isset($pluginInfo['author']) || empty($pluginInfo['author'])) $pluginInfo['author'] = 'n/a';
419
                                                if (!isset($pluginInfo['version']) || empty($pluginInfo['version'])) $pluginInfo['version'] = 'n/a';
420
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['name']) . '</td>';
421
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['version']) . '</td>';
422
                                                $out['text'] .= '<td>' . htmlentities($pluginInfo['author']) . '</td>';
423
                                                $out['text'] .= '       </tr>';
424
                                        }
425
                                        $out['text'] .= '</table>';
426
                                        $out['text'] .= '</div></div>';
427
                                }
428
                        }
148 daniel-mar 429
                }
430
        }
431
 
432
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
281 daniel-mar 433
                if (!OIDplus::authUtils()::isAdminLoggedIn()) return false;
289 daniel-mar 434
 
148 daniel-mar 435
                if (file_exists(__DIR__.'/treeicon.png')) {
241 daniel-mar 436
                        $tree_icon = OIDplus::webpath(__DIR__).'treeicon.png';
148 daniel-mar 437
                } else {
438
                        $tree_icon = null; // default icon (folder)
439
                }
440
 
151 daniel-mar 441
                $tree_icon_pages = $tree_icon; // TODO
442
                $tree_icon_pages_public = $tree_icon; // TODO
443
                $tree_icon_pages_ra = $tree_icon; // TODO
444
                $tree_icon_pages_admin = $tree_icon; // TODO
445
                $tree_icon_db_active = $tree_icon; // TODO
446
                $tree_icon_db_inactive = $tree_icon; // TODO
274 daniel-mar 447
                $tree_icon_sql_active = $tree_icon; // TODO
448
                $tree_icon_sql_inactive = $tree_icon; // TODO
151 daniel-mar 449
                $tree_icon_obj_active = $tree_icon; // TODO
450
                $tree_icon_obj_inactive = $tree_icon; // TODO
221 daniel-mar 451
                $tree_icon_auth = $tree_icon; // TODO
289 daniel-mar 452
                $tree_icon_logger = $tree_icon; // TODO
151 daniel-mar 453
 
281 daniel-mar 454
                $pp_public = array();
455
                $pp_ra = array();
456
                $pp_admin = array();
457
 
458
                foreach (OIDplus::getPagePlugins() as $plugin) {
459
                        if (is_subclass_of($plugin, OIDplusPagePluginPublic::class)) {
460
                                $pp_public[] = $plugin;
461
                        }
462
                        if (is_subclass_of($plugin, OIDplusPagePluginRa::class)) {
463
                                $pp_ra[] = $plugin;
464
                        }
465
                        if (is_subclass_of($plugin, OIDplusPagePluginAdmin::class)) {
466
                                $pp_admin[] = $plugin;
467
                        }
468
                }
469
 
470
 
151 daniel-mar 471
                $public_plugins = array();
281 daniel-mar 472
                foreach ($pp_public as $plugin) {
277 daniel-mar 473
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
222 daniel-mar 474
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
475
 
151 daniel-mar 476
                        $public_plugins[] = array(
477
                                'id' => 'oidplus:system_plugins.$'.get_class($plugin),
478
                                'icon' => $tree_icon_pages_public,
222 daniel-mar 479
                                'text' => $txt,
151 daniel-mar 480
                        );
481
                }
482
                $ra_plugins = array();
281 daniel-mar 483
                foreach ($pp_ra as $plugin) {
277 daniel-mar 484
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
222 daniel-mar 485
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
486
 
151 daniel-mar 487
                        $ra_plugins[] = array(
488
                                'id' => 'oidplus:system_plugins.$'.get_class($plugin),
489
                                'icon' => $tree_icon_pages_ra,
222 daniel-mar 490
                                'text' => $txt,
151 daniel-mar 491
                        );
492
                }
493
                $admin_plugins = array();
281 daniel-mar 494
                foreach ($pp_admin as $plugin) {
277 daniel-mar 495
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
222 daniel-mar 496
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
497
 
151 daniel-mar 498
                        $admin_plugins[] = array(
499
                                'id' => 'oidplus:system_plugins.$'.get_class($plugin),
500
                                'icon' => $tree_icon_pages_admin,
222 daniel-mar 501
                                'text' => $txt,
151 daniel-mar 502
                        );
503
                }
504
                $db_plugins = array();
505
                foreach (OIDplus::getDatabasePlugins() as $plugin) {
277 daniel-mar 506
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
222 daniel-mar 507
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
508
 
275 daniel-mar 509
                        if ($plugin::id() == OIDplus::baseConfig()->getValue('DATABASE_PLUGIN')) {
151 daniel-mar 510
                                $db_plugins[] = array(
511
                                        'id' => 'oidplus:system_plugins.$'.get_class($plugin),
512
                                        'icon' => $tree_icon_db_active,
513
                                        'text' => $txt,
514
                                 );
515
                        } else {
516
                                $db_plugins[] = array(
517
                                        'id' => 'oidplus:system_plugins.$'.get_class($plugin),
518
                                        'icon' => $tree_icon_db_inactive,
519
                                        'text' => '<font color="gray">'.$txt.'</font>',
520
                                 );
521
                        }
522
                }
274 daniel-mar 523
                $sql_plugins = array();
524
                foreach (OIDplus::getSqlSlangPlugins() as $plugin) {
277 daniel-mar 525
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
274 daniel-mar 526
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
527
 
528
                        if ($plugin::id() == OIDplus::db()->getSlang()::id()) {
529
                                $sql_plugins[] = array(
530
                                        'id' => 'oidplus:system_plugins.$'.get_class($plugin),
531
                                        'icon' => $tree_icon_db_active,
532
                                        'text' => $txt,
533
                                 );
534
                        } else {
535
                                $sql_plugins[] = array(
536
                                        'id' => 'oidplus:system_plugins.$'.get_class($plugin),
537
                                        'icon' => $tree_icon_db_inactive,
538
                                        'text' => '<font color="gray">'.$txt.'</font>',
539
                                 );
540
                        }
541
                }
151 daniel-mar 542
                $obj_plugins = array();
227 daniel-mar 543
                $enabled = OIDplus::getObjectTypePluginsEnabled();
544
                $disabled = OIDplus::getObjectTypePluginsDisabled();
222 daniel-mar 545
                foreach (array_merge($enabled, $disabled) as $plugin) {
277 daniel-mar 546
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
547
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
222 daniel-mar 548
                        if (in_array($plugin, $enabled)) {
151 daniel-mar 549
                                $obj_plugins[] = array(
227 daniel-mar 550
                                        'id' => 'oidplus:system_plugins.$'.get_class($plugin),
151 daniel-mar 551
                                        'icon' => $tree_icon_obj_active,
552
                                        'text' => $txt,
553
                                 );
554
                        } else {
555
                                $obj_plugins[] = array(
227 daniel-mar 556
                                        'id' => 'oidplus:system_plugins.$'.get_class($plugin),
151 daniel-mar 557
                                        'icon' => $tree_icon_obj_inactive,
558
                                        'text' => '<font color="gray">'.$txt.'</font>',
559
                                 );
560
                        }
561
                }
221 daniel-mar 562
                $auth_plugins = array();
563
                foreach (OIDplus::getAuthPlugins() as $plugin) {
277 daniel-mar 564
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
222 daniel-mar 565
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
566
 
221 daniel-mar 567
                        $auth_plugins[] = array(
568
                                'id' => 'oidplus:system_plugins.$'.get_class($plugin),
569
                                'icon' => $tree_icon_auth,
222 daniel-mar 570
                                'text' => $txt,
221 daniel-mar 571
                        );
572
                }
289 daniel-mar 573
                $logger_plugins = array();
574
                foreach (OIDplus::getLoggerPlugins() as $plugin) {
575
                        $pluginInfo = OIDplus::getPluginInfo($plugin);
576
                        $txt = (!isset($pluginInfo['name']) || empty($pluginInfo['name'])) ? get_class($plugin) : $pluginInfo['name'];
577
 
578
                        $reason = '';
579
                        if (!$plugin->available($reason)) $txt = '<font color="gray">'.$txt.'</font>';
580
 
581
                        $logger_plugins[] = array(
582
                                'id' => 'oidplus:system_plugins.$'.get_class($plugin),
583
                                'icon' => $tree_icon_logger,
584
                                'text' => $txt,
585
                        );
586
                }
148 daniel-mar 587
                $json[] = array(
588
                        'id' => 'oidplus:system_plugins',
589
                        'icon' => $tree_icon,
151 daniel-mar 590
                        'text' => 'Plugins',
591
                        'children' => array(
592
                        array(
593
                                'id' => 'oidplus:system_plugins.pages',
594
                                'icon' => $tree_icon,
595
                                'text' => 'Page plugins',
596
                                'children' => array(
597
                                        array(
598
                                                'id' => 'oidplus:system_plugins.pages.public',
599
                                                'icon' => $tree_icon,
600
                                                'text' => 'Public',
601
                                                'children' => $public_plugins
602
                                        ),
603
                                        array(
604
                                                'id' => 'oidplus:system_plugins.pages.ra',
605
                                                'icon' => $tree_icon,
606
                                                'text' => 'RA',
607
                                                'children' => $ra_plugins
608
                                        ),
609
                                        array(
610
                                                'id' => 'oidplus:system_plugins.pages.admin',
611
                                                'icon' => $tree_icon,
612
                                                'text' => 'Admin',
613
                                                'children' => $admin_plugins
614
                                        )
615
                                )
616
                                ),
617
                                array(
618
                                        'id' => 'oidplus:system_plugins.objects',
619
                                        'icon' => $tree_icon,
620
                                        'text' => 'Object types',
621
                                        'children' => $obj_plugins
622
                                ),
623
                                array(
624
                                        'id' => 'oidplus:system_plugins.database',
625
                                        'icon' => $tree_icon,
626
                                        'text' => 'Database providers',
627
                                        'children' => $db_plugins
221 daniel-mar 628
                                ),
629
                                array(
274 daniel-mar 630
                                        'id' => 'oidplus:system_plugins.sql',
631
                                        'icon' => $tree_icon,
632
                                        'text' => 'SQL slangs',
633
                                        'children' => $sql_plugins
634
                                ),
635
                                array(
221 daniel-mar 636
                                        'id' => 'oidplus:system_plugins.auth',
637
                                        'icon' => $tree_icon,
638
                                        'text' => 'RA authentication',
639
                                        'children' => $auth_plugins
289 daniel-mar 640
                                ),
641
                                array(
642
                                        'id' => 'oidplus:system_plugins.logger',
643
                                        'icon' => $tree_icon,
644
                                        'text' => 'Logger',
645
                                        'children' => $logger_plugins
151 daniel-mar 646
                                )
647
                        )
148 daniel-mar 648
                );
649
 
650
                return true;
651
        }
652
 
653
        public function tree_search($request) {
654
                return false;
655
        }
656
}