Subversion Repositories oidplus

Rev

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