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