Subversion Repositories oidplus

Rev

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

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