Subversion Repositories oidplus

Rev

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