Subversion Repositories oidplus

Rev

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