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