dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
dbxModules.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxAdmin;
3
4require_once __DIR__ . '/dbxModuleRegistry.class.php';
5require_once __DIR__ . '/dbxModuleImages.class.php';
6require_once __DIR__ . '/dbxReport_Modules.class.php';
7
8Class dbxModules {
9
10 private function registry(): dbxModuleRegistry {
11 static $registry = null;
12 if (!$registry instanceof dbxModuleRegistry) {
13 $registry = new dbxModuleRegistry();
14 }
15 return $registry;
16 }
17
18 private function adminHelp(): dbxAdminHelp {
19 return dbx()->get_include_obj('dbxAdminHelp');
20 }
21
22 private function tpl() {
23 return dbx()->get_system_obj('dbxTPL');
24 }
25
26 private function save_config_modul($modul, $data) {
27 return dbx()->set_config($modul, $data);
28 }
29
30 private function modul_access() {
31 $xmodul = (string)dbx()->get_modul_var('xmodul');
32 if ($xmodul === '') {
33 return $this->tpl()->get_tpl('dbx', 'alert-warning', array('msg' => 'Kein Modul gewaehlt.'));
34 }
35
36 $data = dbx()->get_config($xmodul);
37 if (!is_array($data)) {
38 $data = array();
39 }
40
41 $oForm = dbx()->get_system_obj('dbxForm');
42 $oForm->init('form-modul-access');
43 $oForm->add_rep('bar_title', 'Zugriff: ' . $xmodul);
44 $oForm->add_obj('bar_actions', 'obj-value', '<button class="btn btn-primary btn-sm" type="submit"><i class="bi bi-save"></i> Speichern</button>');
45 $oForm->_data = $data;
46 $oForm->_msg_info = 'Legen Sie fest, welche Gruppen dieses Modul sehen und nutzen duerfen.';
47
48 $oForm->add_obj('xmodul', $xmodul);
49 $oForm->add_fld('groups', 'multi-select', options: $this->registry()->groupOptions(), rules: 'array|parameter', label: 'Gruppen', errormsg: 'Die Eingabe darf keine Sonderzeichen beinhalten.');
50
51 $this->adminHelp()->attachForm($oForm, 'modules_access');
52
53 if ($oForm->submit()) {
54 if (!$oForm->errors()) {
55 $config = dbx()->get_config($xmodul);
56 if (!is_array($config)) {
57 $config = array();
58 }
59 if (isset($oForm->_post['groups'])) {
60 $groups = $oForm->_post['groups'];
61 $config['groups'] = is_array($groups) ? implode(',', $groups) : (string)$groups;
62 }
63 $ok = $this->save_config_modul($xmodul, $config);
64 if ($ok) {
65 $oForm->_msg_success = 'Zugriffsrechte gespeichert';
66 } else {
67 $oForm->_msg_error = 'Daten konnten nicht gespeichert werden';
68 }
69 } else {
70 $oForm->_msg_error = 'Bitte Eingaben pruefen';
71 }
72 }
73
74 $content = $oForm->run();
75 return str_replace('{xmodul}', $xmodul, $content);
76 }
77
78 private function modul_help() {
79 $xmodul = trim((string)dbx()->get_modul_var('xmodul'));
80 if ($xmodul === '') {
81 return $this->tpl()->get_tpl('dbx', 'alert-warning', array('msg' => 'Kein Modul gewaehlt.'));
82 }
83
84 $raw = $this->registry()->inspect($xmodul);
85 $title = (string)($raw['title'] ?? $xmodul);
86 $moduleHelpHtml = $this->registry()->renderModuleHelp($xmodul, array(
87 'title' => $title,
88 'xmodul' => $xmodul,
89 ));
90
91 return $this->tpl()->get_tpl('dbxAdmin|module-help-detail', array(
92 'title' => $title,
93 'module_help_html' => $moduleHelpHtml,
94 ));
95 }
96
97 private function buildInstallHelpHtml(array $record): string {
98 if (empty($record['install_url'])) {
99 return '';
100 }
101
102 $modul = dbx()->esc((string)($record['install_modul'] ?? ''));
103 $url = dbx()->esc((string)$record['install_url']);
104 $title = dbx()->esc((string)($record['title'] ?? ''));
105
106 return '<h4>Installation</h4>'
107 . '<p>Dieses Modul stellt einen Installationsdialog bereit (<code>' . $modul . '</code>).</p>'
108 . '<p><a class="btn btn-sm btn-outline-secondary dbx-win" href="' . $url . '" data-url="' . $url . '" data-title="Installation: ' . $title . '">'
109 . '<i class="bi bi-database-gear"></i> Installation starten</a></p>';
110 }
111
112 private function formatRunCases(array $runCases): string {
113 if (!$runCases) {
114 return 'Keine Run-Aktionen erkannt';
115 }
116 return implode(', ', array_map('strval', $runCases));
117 }
118
119 private function prepareModuleRecord(array $record): array {
120 return $record;
121 }
122
123 private function images(): dbxModuleImages {
124 static $obj = null;
125 if (!$obj instanceof dbxModuleImages) {
126 $obj = new dbxModuleImages();
127 }
128 return $obj;
129 }
130
131 private function modul_images() {
132 $xmodul = (string)dbx()->get_modul_var('xmodul');
133 if ($xmodul === '') {
134 return $this->tpl()->get_tpl('dbx', 'alert-warning', array('msg' => 'Kein Modul gewaehlt.'));
135 }
136
137 $images = $this->images();
138 $items = $images->imageItems($xmodul);
139 $info = $this->registry()->inspect($xmodul);
140 $report = new dbxReport_Modules();
141 $galleryHtml = $report->moduleImagesGalleryHtml(array(
142 'xmodul' => $xmodul,
143 'image_items' => $items,
144 'default_run1' => (string)($info['default_run1'] ?? 'run'),
145 'default_run2' => (string)($info['default_run2'] ?? ''),
146 'placeholder_url' => (string)($info['placeholder_url'] ?? ''),
147 ));
148 $previewHtml = $report->moduleImagesPreviewHtml(array(
149 'xmodul' => $xmodul,
150 'image_items' => $items,
151 'default_run1' => (string)($info['default_run1'] ?? 'run'),
152 'default_run2' => (string)($info['default_run2'] ?? ''),
153 'placeholder_url' => (string)($info['placeholder_url'] ?? ''),
154 ));
155 $targetHtml = $report->moduleImagesTargetHtml($info);
156
157 $data = array(
158 'xmodul' => dbx()->esc($xmodul),
159 'gallery_html' => $galleryHtml,
160 'images_preview_html' => $previewHtml,
161 'images_target_html' => $targetHtml,
162 'uses_run2' => (string)($info['uses_run2'] ?? '0'),
163 'placeholder_url' => dbx()->esc((string)($info['placeholder_url'] ?? '')),
164 'placeholder_alt' => dbx()->esc((string)($info['placeholder_alt'] ?? '')),
165 'image_count' => count($items),
166 'media_api_url' => dbx()->esc($this->images()->mediaApiUrl() . '&images=1&media_type=image'),
167 'images_add_url' => dbx()->esc('?dbx_modul=dbxAdmin&dbx_run1=modules&dbx_run2=modul_images_add'),
168 'images_upload_url' => dbx()->esc('?dbx_modul=dbxAdmin&dbx_run1=modules&dbx_run2=modul_images_upload'),
169 'images_remove_url' => dbx()->esc('?dbx_modul=dbxAdmin&dbx_run1=modules&dbx_run2=modul_images_remove'),
170 'media_folders_url' => dbx()->esc($this->images()->mediaFoldersApiUrl()),
171 );
172
173 return $this->tpl()->get_tpl('dbxAdmin|form-modul-images', $data);
174 }
175
176 private function modul_image_serve() {
177 $file = trim((string)dbx()->get_modul_var('file', '', '*'));
178 $this->images()->serveFile($file);
179 }
180
181 private function modul_images_media_json() {
182 $xmodul = trim((string)dbx()->get_modul_var('xmodul', ''));
183 dbx()->json_response(array(
184 'ok' => 1,
185 'rows' => $this->images()->mediaBrowserRows($xmodul),
186 ));
187 }
188
189 private function modul_images_media_folders_json() {
190 $folders = array();
191 $dir = $this->images()->absDir();
192 if (is_dir($dir) && is_readable($dir)) {
193 $folders[] = 'mod';
194 }
195 dbx()->json_response(array(
196 'ok' => 1,
197 'success' => true,
198 'folders' => $folders,
199 'root' => 'files/mod/',
200 ));
201 }
202
203 private function modul_images_list_json() {
204 $xmodul = (string)dbx()->get_modul_var('xmodul');
205 if ($xmodul === '') {
206 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul', 'items' => array()));
207 }
208 dbx()->json_response(array(
209 'ok' => 1,
210 'modul' => $xmodul,
211 'items' => $this->images()->imageItems($xmodul),
212 ));
213 }
214
215 private function modul_images_save_json() {
216 $payload = $this->readJsonBody();
217 $xmodul = (string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul'));
218 $files = $payload['files'] ?? array();
219 if ($xmodul === '' || !is_array($files)) {
220 dbx()->json_response(array('ok' => 0, 'msg' => 'Ungueltige Daten'));
221 }
222 $ok = $this->images()->saveList($xmodul, $files);
223 dbx()->json_response(array(
224 'ok' => $ok ? 1 : 0,
225 'modul' => $xmodul,
226 'items' => $this->images()->imageItems($xmodul),
227 ));
228 }
229
230 private function modul_images_add_json() {
231 $payload = $this->readJsonBody();
232 $xmodul = (string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul'));
233 if ($xmodul === '') {
234 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul'));
235 }
236
237 $run1 = trim((string)($payload['dbx_run1'] ?? $payload['run1'] ?? ''));
238 $run2 = trim((string)($payload['dbx_run2'] ?? $payload['run2'] ?? ''));
239 if ($run1 === '') {
240 dbx()->json_response(array('ok' => 0, 'msg' => 'dbx_run1 ist erforderlich'));
241 }
242
243 $filename = null;
244 $mediaId = (int)($payload['media_id'] ?? 0);
245 $filePath = trim((string)($payload['file_path'] ?? ''));
246
247 if ($mediaId > 0 || $filePath !== '') {
248 $filename = $this->images()->importForModul($xmodul, $mediaId, $filePath, $run1, $run2);
249 }
250
251 if ($filename === null || $filename === '') {
252 dbx()->json_response(array('ok' => 0, 'msg' => 'Bild konnte nicht uebernommen werden'));
253 }
254
255 dbx()->json_response(array(
256 'ok' => 1,
257 'modul' => $xmodul,
258 'filename' => $filename,
259 'items' => $this->images()->imageItems($xmodul),
260 ));
261 }
262
263 private function modul_symbol_add_json() {
264 $payload = $this->readJsonBody();
265 $xmodul = (string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul'));
266 if ($xmodul === '') {
267 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul'));
268 }
269
270 $mediaId = (int)($payload['media_id'] ?? 0);
271 $filePath = trim((string)($payload['file_path'] ?? ''));
272 if ($mediaId <= 0 && $filePath === '') {
273 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Bild gewaehlt'));
274 }
275
276 $symbol = $this->images()->importSymbolForModul($xmodul, $mediaId, $filePath);
277 if (!is_array($symbol) || empty($symbol['url'])) {
278 dbx()->json_response(array('ok' => 0, 'msg' => 'Symbolbild konnte nicht uebernommen werden'));
279 }
280
281 dbx()->json_response(array(
282 'ok' => 1,
283 'modul' => $xmodul,
284 'symbol' => $symbol,
285 ));
286 }
287
288 private function modul_images_upload_json() {
289 $xmodul = trim((string)($_POST['xmodul'] ?? dbx()->get_modul_var('xmodul')));
290 $run1 = trim((string)($_POST['dbx_run1'] ?? $_POST['run1'] ?? ''));
291 $run2 = trim((string)($_POST['dbx_run2'] ?? $_POST['run2'] ?? ''));
292 if ($xmodul === '') {
293 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul'));
294 }
295 if ($run1 === '') {
296 dbx()->json_response(array('ok' => 0, 'msg' => 'dbx_run1 ist erforderlich'));
297 }
298
299 $file = $_FILES['file'] ?? null;
300 if (!is_array($file)) {
301 dbx()->json_response(array('ok' => 0, 'msg' => 'Keine Datei erhalten'));
302 }
303
304 $filename = $this->images()->saveFromUpload($xmodul, $run1, $run2, $file);
305 if ($filename === null || $filename === '') {
306 dbx()->json_response(array('ok' => 0, 'msg' => 'Upload konnte nicht gespeichert werden'));
307 }
308
309 dbx()->json_response(array(
310 'ok' => 1,
311 'modul' => $xmodul,
312 'filename' => $filename,
313 'items' => $this->images()->imageItems($xmodul),
314 ));
315 }
316
317 private function modul_images_remove_json() {
318 $payload = $this->readJsonBody();
319 $xmodul = (string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul'));
320 $file = (string)($payload['file'] ?? '');
321 $deleteFile = !array_key_exists('delete_file', $payload) || !empty($payload['delete_file']);
322 if ($xmodul === '' || $file === '') {
323 dbx()->json_response(array('ok' => 0, 'msg' => 'Ungueltige Daten'));
324 }
325
326 $ok = $this->images()->removeFromList($xmodul, $file, $deleteFile);
327 dbx()->json_response(array(
328 'ok' => $ok ? 1 : 0,
329 'modul' => $xmodul,
330 'items' => $this->images()->imageItems($xmodul),
331 ));
332 }
333
334 private function modul_access_save_json() {
335 $payload = $this->readJsonBody();
336 $xmodul = trim((string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul')));
337 if ($xmodul === '') {
338 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul'));
339 }
340
341 $groups = $payload['groups'] ?? array();
342 if (!is_array($groups)) {
343 $groups = preg_split('/\s*,\s*/', trim((string)$groups), -1, PREG_SPLIT_NO_EMPTY);
344 }
345 if (!is_array($groups)) {
346 $groups = array();
347 }
348
349 $allowed = array_keys($this->registry()->groupOptions());
350 $clean = array();
351 foreach ($groups as $group) {
352 $group = trim((string)$group);
353 if ($group !== '' && in_array($group, $allowed, true)) {
354 $clean[] = $group;
355 }
356 }
357 $clean = array_values(array_unique($clean));
358
359 $config = dbx()->get_config($xmodul);
360 if (!is_array($config)) {
361 $config = array();
362 }
363 $config['groups'] = implode(',', $clean);
364
365 $ok = dbx()->set_config($xmodul, $config);
366 dbx()->json_response(array(
367 'ok' => $ok ? 1 : 0,
368 'modul' => $xmodul,
369 'groups' => $clean,
370 'msg' => $ok ? 'Zugriffsrechte gespeichert' : 'Speichern fehlgeschlagen',
371 ));
372 }
373
374 private function modul_active_toggle_json() {
375 $payload = $this->readJsonBody();
376 $xmodul = trim((string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul')));
377 if ($xmodul === '' || !preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $xmodul)) {
378 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul'));
379 }
380
381 $config = dbx()->get_config($xmodul);
382 if (!is_array($config)) {
383 $config = array();
384 }
385
386 $active = null;
387 if (array_key_exists('active', $payload)) {
388 $active = !empty($payload['active']) ? '1' : '0';
389 } else {
390 $current = '1';
391 if (isset($config['activ'])) {
392 $current = (string)$config['activ'] === '1' ? '1' : '0';
393 } elseif (isset($config['active'])) {
394 $current = (string)$config['active'] === '1' ? '1' : '0';
395 }
396 $active = $current === '1' ? '0' : '1';
397 }
398
399 $config['activ'] = $active;
400 $config['active'] = $active;
401 $ok = dbx()->set_config($xmodul, $config);
402 dbx()->json_response(array(
403 'ok' => $ok ? 1 : 0,
404 'modul' => $xmodul,
405 'active' => $active,
406 'active_label' => $active === '1' ? 'Aktiv' : 'Inaktiv',
407 'msg' => $ok ? 'Status gespeichert' : 'Status konnte nicht gespeichert werden',
408 ));
409 }
410
411 private function modul_delete_json() {
412 $payload = $this->readJsonBody();
413 $xmodul = trim((string)($payload['xmodul'] ?? dbx()->get_modul_var('xmodul')));
414 if ($xmodul === '' || !preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $xmodul)) {
415 dbx()->json_response(array('ok' => 0, 'msg' => 'Kein Modul'));
416 }
417 if (!$this->registry()->canDeleteModule($xmodul)) {
418 dbx()->json_response(array('ok' => 0, 'msg' => 'Modul darf nicht geloescht werden'));
419 }
420
421 $dir = dbx_os_path_file(dbx_get_base_dir() . 'dbx/modules/' . $xmodul);
422 $ok = $this->deleteModuleDirectory($dir);
423 if ($ok) {
424 if (isset($_SESSION['dbx']['config'][$xmodul])) {
425 unset($_SESSION['dbx']['config'][$xmodul]);
426 }
427 if (isset($_SESSION['dbx']['config_file'][$xmodul])) {
428 unset($_SESSION['dbx']['config_file'][$xmodul]);
429 }
430 }
431
432 dbx()->json_response(array(
433 'ok' => $ok ? 1 : 0,
434 'modul' => $xmodul,
435 'msg' => $ok ? 'Modul geloescht' : 'Modul konnte nicht geloescht werden',
436 ));
437 }
438
439 private function deleteModuleDirectory(string $dir): bool {
440 $dir = rtrim(dbx_os_path_file($dir), '/\\');
441 if ($dir === '' || !is_dir($dir)) {
442 return false;
443 }
444
445 $items = new \RecursiveIteratorIterator(
446 new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS),
447 \RecursiveIteratorIterator::CHILD_FIRST
448 );
449
450 foreach ($items as $item) {
451 $path = $item->getPathname();
452 if ($item->isDir()) {
453 if (!@rmdir($path)) {
454 return false;
455 }
456 } elseif (!@unlink($path)) {
457 return false;
458 }
459 }
460
461 return @rmdir($dir);
462 }
463
464 private function readJsonBody(): array {
465 $raw = file_get_contents('php://input');
466 if (!is_string($raw) || $raw === '') {
467 return array();
468 }
469 $data = json_decode($raw, true);
470 return is_array($data) ? $data : array();
471 }
472
473 private function modul_avatar() {
474 $xmodul = (string)dbx()->get_modul_var('xmodul');
475
476 if ($xmodul === '') {
477 return 'kein Modul gewaehlt';
478 }
479
480 $path = dbx()->os_path(dbx()->get_base_dir() . "dbx/modules/$xmodul/tpl/img/");
481 $url = dbx()->get_base_url() . "dbx/modules/$xmodul/tpl/img/";
482 $modul_img = 'modul.gif';
483 $path_img_ext = $path . $modul_img;
484 $url_img_ext = $url . $modul_img;
485
486 $data = array(
487 'xmodul' => $xmodul,
488 'avatar_upload' => $url_img_ext,
489 );
490
491 $oForm = dbx()->get_system_obj('dbxForm');
492 $oForm->_msg_info = 'Sie koennen ein Modulbild auswaehlen';
493 $oForm->init('dbxModules_avatar', 'form-avatar');
494 $oForm->_data = $data;
495 $oForm->add_js_call('uploader_img', 'upload');
496
497 if (!empty($_FILES)) {
498 $oUpload = dbx()->get_system_obj('dbxUpload');
499 $oUpload->upload($_FILES['upload_file']);
500 $oUpload->allowed = array('image/*');
501 $oUpload->file_new_name_body = 'modul';
502 $oUpload->image_convert = 'gif';
503 $oUpload->file_overwrite = true;
504 $oUpload->image_resize = true;
505 $oUpload->image_x = 200;
506 $oUpload->image_y = 200;
507 $oUpload->process($path);
508 if ($oUpload->processed) {
509 $oUpload->clean();
510 $oForm->_data['avatar_upload'] = $url . $oUpload->file_dst_name;
511 $oForm->_msg_success = 'Bild erfolgreich hochgeladen.';
512 } else {
513 $oForm->set_msg_error('Bild Datei nicht hochgeladen.');
514 }
515 }
516
517 $oForm->add_fld('avatar_upload', 'avatar_upload', rules: 'alphanum', label: 'Modul-Bild', data: 'msg=Sie koennen ein Bild hochladen.');
518 $content = $oForm->run();
519 return str_replace('{xmodul}', $xmodul, $content);
520 }
521
522 Private function report_modules() {
523 $allModules = $this->registry()->inspectAll();
524 $moduleOptions = array('0' => 'Alle Module');
525 foreach ($allModules as $module) {
526 $name = (string)($module['xmodul'] ?? '');
527 if ($name !== '') {
528 $moduleOptions[$name] = $name;
529 }
530 }
531
532 $activeCount = 0;
533 foreach ($allModules as $module) {
534 if ((string)($module['active'] ?? '1') === '1') {
535 $activeCount++;
536 }
537 }
538
539 $oReport = new dbxReport_Modules();
540 $oReport->init('dbxModules', 'report-modules');
541 $oReport->_action = '?dbx_modul=dbxAdmin&dbx_run1=modules&dbx_run2=modul_list';
542 $oReport->_pages = true;
543 $oReport->_rrows = 20;
544 $oReport->_but_pagination = 7;
545 $oReport->_fld_id = 'rid';
546 $oReport->_create_row_select = true;
547 $oReport->_create_sel_flds = false;
548 $oReport->_data = array(
549 'dbx_rmodul' => '0',
550 'dbx_rwhere' => '',
551 'dbx_rrows' => 20,
552 'dbx_rpos' => 0,
553 );
554
555 $oReport->add_fld('dbx_rmodul', 'select-single-label', label: 'Modul', rules: 'parameter', options: $moduleOptions);
556 $oReport->add_fld('dbx_rwhere', 'dbx|search', label: 'Suche', rules: 'sqlsearch|max=80');
557 $oReport->add_fld('dbx_rrows', 'integer-label', label: 'Zeilen', rules: 'int');
558
559 $modulFilter = $oReport->get_fld_val('dbx_rmodul', '0', 'parameter');
560 $search = $oReport->get_fld_val('dbx_rwhere', '', 'sqlsearch|max=80');
561 $rrows = (int)$oReport->get_fld_val('dbx_rrows', 20, 'int');
562 $rpos = (int)$oReport->get_fld_val('dbx_rpos', 0, 'int');
563 if ($rrows <= 0) {
564 $rrows = 20;
565 }
566
567 $filtered = $this->filterModuleRows($allModules, $modulFilter, $search);
568 $filteredCount = count($filtered);
569 if ($rpos < 0 || ($filteredCount > 0 && $rpos >= $filteredCount)) {
570 $rpos = 0;
571 }
572
573 $oReport->_rrows = $rrows;
574 $oReport->_rpos = $rpos;
575 $oReport->_rcount = $filteredCount;
576 $oReport->_rdata = $this->pageModuleRows($filtered, $rpos, $rrows);
577
578 $oReport->add_rep('module_count', count($allModules));
579 $oReport->add_rep('module_active_count', $activeCount);
580 $oReport->add_rep('module_filtered_count', $filteredCount);
581 $oReport->add_rep('modimg_media_url', dbx()->esc($this->images()->mediaApiUrl() . '&images=1&media_type=image'));
582 $oReport->add_rep('modimg_upload_url', dbx()->esc('?dbx_modul=dbxAdmin&dbx_run1=modules&dbx_run2=modul_images_upload'));
583 $oReport->add_rep('modimg_mediafolders_url', dbx()->esc($this->images()->mediaFoldersApiUrl()));
584 $oReport->add_rep('modimg_mediafoldercreate_url', '');
585 $oReport->add_rep('modimg_mediafolderdelete_url', '');
586 $oReport->add_rep('modimg_deletemedia_url', '');
587 $oReport->add_rep('modimg_uploadmax', (string)(16 * 1024 * 1024));
588
589 return $oReport->run();
590 }
591
592 private function filterModuleRows(array $modules, string $modulFilter, string $search): array {
593 $modulFilter = trim($modulFilter);
594 $search = strtolower(trim($search));
595 $rows = array();
596
597 foreach ($modules as $module) {
598 if (!is_array($module)) {
599 continue;
600 }
601
602 $name = (string)($module['xmodul'] ?? '');
603 if ($name === '') {
604 continue;
605 }
606
607 if ($modulFilter !== '' && $modulFilter !== '0' && $name !== $modulFilter) {
608 continue;
609 }
610
611 if ($search !== '') {
612 $ddList = $module['dd_list'] ?? array();
613 if (!is_array($ddList)) {
614 $ddList = array();
615 }
616
617 $haystack = strtolower(implode(' ', array(
618 $name,
619 (string)($module['description'] ?? ''),
620 (string)($module['default_call'] ?? ''),
621 (string)($module['groups_text'] ?? ''),
622 (string)($module['version'] ?? ''),
623 implode(' ', $ddList),
624 )));
625
626 if (strpos($haystack, $search) === false) {
627 continue;
628 }
629 }
630
631 $module['rid'] = $name;
632 $rows[] = $module;
633 }
634
635 return $rows;
636 }
637
638 private function pageModuleRows(array $modules, int $rpos, int $rrows): array {
639 if ($rpos < 0) {
640 $rpos = 0;
641 }
642 if ($rrows <= 0) {
643 $rrows = 20;
644 }
645
646 $slice = array_slice($modules, $rpos, $rrows);
647 $rows = array();
648 foreach ($slice as $module) {
649 $rows[] = $this->prepareModuleRecord($module);
650 }
651
652 return $rows;
653 }
654
655 public function modul_new() {
656 $obj = dbx()->get_include_obj('dbxWizard');
657 $run = dbx()->get_modul_var('run');
658 return $obj->run($run);
659 }
660
661 public function modul_edit() {
662 $obj = dbx()->get_include_obj('dbxWizard');
663 $run = dbx()->get_modul_var('run');
664 return $obj->run($run);
665 }
666
667 public function run() {
668 $modul = dbx()->get_modul_var('dbx_modul');
669 $action = dbx()->get_modul_var('dbx_run1');
670 $work = dbx()->get_modul_var('dbx_run2');
671 $content = "dbxAdmin->dbxModules ($work) X<br>";
672
673 switch ($work) {
674 case 'modul_list':
675 $content = $this->report_modules();
676 break;
677
678 case 'modul_avatar':
679 $content = $this->modul_avatar();
680 break;
681
682 case 'avatar_upload':
683 $content = $this->modul_avatar();
684 break;
685
686 case 'modul_new':
687 $content = $this->modul_new();
688 break;
689
690 case 'modul_edit':
691 $content = $this->modul_edit();
692 break;
693
694 case 'modul_access':
695 $content = $this->modul_access();
696 break;
697
698 case 'modul_access_save':
699 $this->modul_access_save_json();
700 break;
701
702 case 'modul_active_toggle':
703 $this->modul_active_toggle_json();
704 break;
705
706 case 'modul_delete':
707 $this->modul_delete_json();
708 break;
709
710 case 'modul_help':
711 $content = $this->modul_help();
712 break;
713
714 case 'modul_images':
715 $content = $this->modul_images();
716 break;
717
718 case 'modul_image':
719 $this->modul_image_serve();
720 break;
721
722 case 'modul_images_list':
723 $this->modul_images_list_json();
724 break;
725
726 case 'modul_images_save':
727 $this->modul_images_save_json();
728 break;
729
730 case 'modul_images_add':
731 $this->modul_images_add_json();
732 break;
733
734 case 'modul_symbol_add':
735 $this->modul_symbol_add_json();
736 break;
737
738 case 'modul_images_upload':
739 $this->modul_images_upload_json();
740 break;
741
742 case 'modul_images_remove':
743 $this->modul_images_remove_json();
744 break;
745
746 case 'modul_images_media':
747 $this->modul_images_media_json();
748 break;
749
750 case 'modul_images_media_folders':
751 $this->modul_images_media_folders_json();
752 break;
753
754 default:
755 $msg['msg'] = "Modul=($modul) Action=($action) Work=($work) is undef!";
756 $content = $this->tpl()->get_tpl('dbx', 'alert-warning', $msg);
757 }
758
759 return $content;
760 }
761}
762
763?>
Erkennt Modul-Metadaten aus Dateisystem und PHP-Quellen (ohne manuelle Registry).
$config['version']
Definition config.php:2
dbx_os_path_file($path_file)
Definition index.php:164
if( $syncRequest)
Definition index.php:520
dbx_get_base_dir($cut_Data=0)
Definition index.php:157
DBX schema administration.