dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxAdminHelp.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxAdmin;
3
5
6 private $texts;
7
8 private function texts() {
9 if ($this->texts) {
10 return $this->texts;
11 }
12 dbx()->use_system_class('dbxForm');
13 $texts = new \dbxForm();
14 // Nur den sprachabhängigen FD-Meldungsvertrag laden. Ein vollständiges
15 // Formular-init() würde während der Formular-Hilfe erneut dbxAdminHelp
16 // aufrufen und damit eine Rekursion erzeugen.
17 $texts->set_form_help_enabled(false);
18 $texts->_fd = 'dbxAdmin|admin-help-ui';
19 $texts->load_fd_messages();
20 $this->texts = $texts;
21 return $this->texts;
22 }
23
24 private function tpl() {
25 return dbx()->get_system_obj('dbxTPL');
26 }
27
28 private function h($value) {
29 return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
30 }
31
32 public function topics() {
33 $topics = array(
34 'dashboard' => array('title' => 'Admin Dashboard', 'tpl' => 'admin-help-dashboard', 'permalink' => 'help-dashboard-admin'),
35 'cache' => array('title' => 'Page-Cache', 'tpl' => 'admin-help-cache', 'permalink' => 'help-cache-content'),
36 'dd_list' => array('title' => 'DataDic Sync', 'tpl' => 'admin-help-dd-list', 'permalink' => 'help-datadic-sync'),
37 'dd_fields' => array('title' => 'DD Feldvergleich', 'tpl' => 'admin-help-dd-fields', 'permalink' => 'help-datadic-felder'),
38 'dd_backup' => array('title' => 'DB Backup & Restore', 'tpl' => 'admin-help-dd-backup', 'permalink' => 'help-datenbank-backup'),
39 'db_list' => array('title' => 'DB Sync', 'tpl' => 'admin-help-db-list', 'permalink' => 'help-datenbank-sync'),
40 'edit_dd' => array('title' => 'DD Editor', 'tpl' => 'admin-help-edit-dd', 'permalink' => 'help-datadic-editor'),
41 'edit_fd' => array('title' => 'FD Editor', 'tpl' => 'admin-help-edit-fd', 'permalink' => 'help-formular-editor'),
42 'server' => array('title' => 'Datenbank-Server', 'tpl' => 'admin-help-server', 'permalink' => 'help-datenbank-server'),
43 'server_tables' => array('title' => 'Server-Tabellen', 'tpl' => 'admin-help-server-tables', 'permalink' => 'help-server-tabellen'),
44 'modules_list' => array('title' => 'Module verwalten', 'tpl' => 'admin-help-modules-list', 'permalink' => 'help-module-verwalten'),
45 'modules_new' => array('title' => 'Neues Modul', 'tpl' => 'admin-help-modules-new', 'permalink' => 'help-modul-erstellen'),
46 'modules_access' => array('title' => 'Modul-Zugriff', 'tpl' => 'admin-help-modules-access', 'permalink' => 'help-modul-zugriff'),
47 'config' => array('title' => 'System-Konfiguration', 'tpl' => 'admin-help-config', 'permalink' => 'help-system-konfiguration'),
48 'session' => array('title' => 'Sessions', 'tpl' => 'admin-help-session', 'permalink' => 'help-sessions-admin'),
49 'trace' => array('title' => 'Trace / Historie', 'tpl' => 'admin-help-trace', 'permalink' => 'help-historie-admin'),
50 'sysmsg' => array('title' => 'System-Meldungen', 'tpl' => 'admin-help-sysmsg', 'permalink' => 'help-systemmeldungen-admin'),
51 'missing' => array('title' => 'Missing Files', 'tpl' => 'admin-help-missing', 'permalink' => 'help-fehlende-ressourcen'),
52 'contact' => array('title' => 'Kontaktanfragen', 'tpl' => 'admin-help-contact', 'permalink' => 'help-kontaktanfragen-admin'),
53 'user' => array('title' => 'Benutzer & Gruppen', 'tpl' => 'admin-help-user', 'permalink' => 'help-benutzer-gruppen'),
54 'export_sql' => array('title' => 'SQL Export', 'tpl' => 'admin-help-export-sql', 'permalink' => 'help-sql-export'),
55 'datadic' => array('title' => 'DataDic Uebersicht', 'tpl' => 'admin-help-datadic', 'permalink' => 'help-datadic-uebersicht'),
56 'workflow_list' => array('title' => 'Workflow Definitionen', 'tpl' => 'admin-help-workflow-list', 'permalink' => 'help-workflow-definitionen'),
57 'workflow_edit' => array('title' => 'Workflow bearbeiten', 'tpl' => 'admin-help-workflow-edit', 'permalink' => 'help-workflow-bearbeiten'),
58 'workflow_binds' => array('title' => 'Modul-Bindings', 'tpl' => 'admin-help-workflow-binds', 'permalink' => 'help-workflow-bindings'),
59 'workflow_bind_edit' => array('title' => 'Binding bearbeiten', 'tpl' => 'admin-help-workflow-bind-edit', 'permalink' => 'help-workflow-binding-bearbeiten'),
60 'workflow_instances' => array('title' => 'Workflow Instanzen', 'tpl' => 'admin-help-workflow-instances', 'permalink' => 'help-workflow-instanzen'),
61 'workflow_install' => array('title' => 'Workflow Install', 'tpl' => 'admin-help-workflow-install', 'permalink' => 'help-workflow-installation'),
62 'workflow_use' => array('title' => 'Workflow starten', 'tpl' => 'admin-help-workflow-use', 'permalink' => 'help-workflow-starten'),
63 'workflow_run' => array('title' => 'Workflow ausführen', 'tpl' => 'admin-help-workflow-run', 'permalink' => 'help-workflow-ausfuehren'),
64 'content' => array('title' => 'Content CMS — Benutzerhandbuch', 'tpl' => 'admin-help-content', 'permalink' => 'help-content-cms'),
65 'content_lng' => array('title' => 'Sprachen & Uebersetzung — Benutzerhandbuch', 'tpl' => 'admin-help-content-lng', 'permalink' => 'help-content-sprachen'),
66 'user_admin' => array('title' => 'Benutzer-Administration', 'tpl' => 'admin-help-user-admin', 'permalink' => 'help-benutzer-administration'),
67 'user_profil' => array('title' => 'Mein Profil', 'tpl' => 'admin-help-user-profil', 'permalink' => 'help-benutzer-profil'),
68 'user_group_form' => array('title' => 'Benutzergruppe', 'tpl' => 'admin-help-user-group', 'permalink' => 'help-benutzergruppe'),
69 'consent_privacy' => array('title' => 'Datenschutz-Einstellungen', 'tpl' => 'admin-help-consent-privacy', 'permalink' => 'help-datenschutz-einstellungen'),
70 'impressum' => array('title' => 'Impressum', 'tpl' => 'admin-help-impressum', 'permalink' => 'help-impressum'),
71 );
72 $texts = $this->texts();
73 foreach ($topics as $topic => &$meta) {
74 $meta['title'] = $texts->get_fd_message('title_' . $topic);
75 }
76 unset($meta);
77 return $topics;
78 }
79
80 public function barMeta($topic = '') {
81 if ($topic === '') {
82 $topic = $this->resolveTopic();
83 }
84 $topic = trim((string)$topic);
85 $topics = $this->topics();
86 if ($topic === '' || !isset($topics[$topic])) {
87 return null;
88 }
89
90 $icons = array(
91 'dashboard' => array('icon' => 'bi-speedometer2', 'subtitle' => 'Systemstatus, Datenbanken und Aktivitaeten'),
92 'cache' => array('icon' => 'bi-lightning-charge', 'subtitle' => 'Statische Content-Seiten beschleunigen'),
93 'dd_list' => array('icon' => 'bi-journal-code', 'subtitle' => 'DD-Dateien mit Datenbankstruktur abgleichen'),
94 'dd_fields' => array('icon' => 'bi-list-columns', 'subtitle' => 'Felddefinitionen vergleichen'),
95 'dd_backup' => array('icon' => 'bi-archive', 'subtitle' => 'Datenbank sichern und wiederherstellen'),
96 'db_list' => array('icon' => 'bi-database', 'subtitle' => 'Tabellen und Datensaetze verwalten'),
97 'edit_dd' => array('icon' => 'bi-journal-code', 'subtitle' => 'Tabellen-Metadaten und Felder pflegen'),
98 'edit_fd' => array('icon' => 'bi-input-cursor-text', 'subtitle' => 'Formularfelddefinitionen bearbeiten'),
99 'server' => array('icon' => 'bi-hdd-network', 'subtitle' => 'Datenbank-Server verwalten'),
100 'server_tables' => array('icon' => 'bi-table', 'subtitle' => 'Tabellen des Servers'),
101 'modules_list' => array('icon' => 'bi-boxes', 'subtitle' => 'Installierte Module verwalten'),
102 'modules_new' => array('icon' => 'bi-plus-square', 'subtitle' => 'Neues Modul anlegen'),
103 'modules_access' => array('icon' => 'bi-shield-lock', 'subtitle' => 'Zugriffsrechte pro Modul'),
104 'config' => array('icon' => 'bi-gear', 'subtitle' => 'System-Konfiguration'),
105 'session' => array('icon' => 'bi-person-badge', 'subtitle' => 'Aktive Benutzer-Sessions'),
106 'trace' => array('icon' => 'bi-clock-history', 'subtitle' => 'Aenderungshistorie'),
107 'sysmsg' => array('icon' => 'bi-bell', 'subtitle' => 'System-Meldungen'),
108 'missing' => array('icon' => 'bi-file-earmark-x', 'subtitle' => 'Fehlende Dateien'),
109 'contact' => array('icon' => 'bi-envelope-check', 'subtitle' => 'Kontaktanfragen verwalten'),
110 'user' => array('icon' => 'bi-people', 'subtitle' => 'Benutzer und Gruppen'),
111 'export_sql' => array('icon' => 'bi-filetype-sql', 'subtitle' => 'SQL-Dump exportieren'),
112 'datadic' => array('icon' => 'bi-journal-code', 'subtitle' => 'DataDic Uebersicht'),
113 'workflow_list' => array('icon' => 'bi-diagram-3', 'subtitle' => 'Workflow-Definitionen'),
114 'workflow_edit' => array('icon' => 'bi-diagram-3', 'subtitle' => 'Workflow bearbeiten'),
115 'workflow_binds' => array('icon' => 'bi-plug', 'subtitle' => 'Modul-Bindings verwalten'),
116 'workflow_bind_edit' => array('icon' => 'bi-plug', 'subtitle' => 'Binding JSON bearbeiten'),
117 'workflow_instances' => array('icon' => 'bi-collection', 'subtitle' => 'Laufende Workflow-Durchlaeufe'),
118 'workflow_install' => array('icon' => 'bi-database-gear', 'subtitle' => 'Workflow-Tabellen installieren'),
119 'workflow_use' => array('icon' => 'bi-play-circle', 'subtitle' => 'Ziel prüfen und neuen Durchlauf starten'),
120 'workflow_run' => array('icon' => 'bi-list-check', 'subtitle' => 'Schritte bearbeiten und kontrolliert abschließen'),
121 'content' => array('icon' => 'bi-file-earmark-richtext', 'subtitle' => 'Seiten, Ordner, Medien und Mehrsprachigkeit'),
122 'content_lng' => array('icon' => 'bi-translate', 'subtitle' => 'Master-Sprache, CMS-Sync, Provider und Startseite'),
123 'user_admin' => array('icon' => 'bi-person-lines-fill', 'subtitle' => 'Benutzer, Rollen und Gruppen'),
124 'user_profil' => array('icon' => 'bi-person-circle', 'subtitle' => 'Eigene Stammdaten und Oberflaeche'),
125 'user_group_form' => array('icon' => 'bi-people', 'subtitle' => 'Rollenname, Beschreibung und Aktivstatus'),
126 'consent_privacy' => array('icon' => 'bi-shield-check', 'subtitle' => 'Cookies und externe Medien'),
127 'impressum' => array('icon' => 'bi-building', 'subtitle' => 'Anbieterkennzeichnung'),
128 );
129
130 $extra = $icons[$topic] ?? array('icon' => 'bi-grid', 'subtitle' => '');
131 return array(
132 'title' => (string)($topics[$topic]['title'] ?? $topic),
133 'icon' => (string)($extra['icon'] ?? 'bi-grid'),
134 'subtitle' => $this->texts()->get_fd_message('subtitle_' . $topic),
135 );
136 }
137
138 public function url($topic) {
139 return '?dbx_modul=dbxContent&dbx_run1=help&topic=' . rawurlencode((string)$topic);
140 }
141
142 public function formUrl(string $modul, string $form, string $title = ''): string {
143 $url = '?dbx_modul=dbxContent&dbx_run1=help&topic=form'
144 . '&help_modul=' . rawurlencode($modul)
145 . '&help_form=' . rawurlencode($form);
146 if (trim($title) !== '') {
147 $url .= '&help_title=' . rawurlencode($title);
148 }
149 return $url;
150 }
151
152 public function topicPermalink(string $topic): string {
153 $topic = trim($topic);
154 $topics = $this->topics();
155 $permalink = trim((string)($topics[$topic]['permalink'] ?? ''));
156 if ($permalink !== '' && preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/', $permalink)) {
157 return $permalink;
158 }
159 $slug = preg_replace('/-+/', '-', preg_replace('/[^a-z0-9-]+/', '-', str_replace('_', '-', strtolower($topic))));
160 return trim('help-' . trim((string)$slug, '-'), '-');
161 }
162
163 public function button($topic) {
164 $topic = trim((string)$topic);
165 $topics = $this->topics();
166 if ($topic === '' || !isset($topics[$topic])) {
167 return '';
168 }
169
170 $meta = $topics[$topic];
171 return $this->tpl()->get_tpl('dbxAdmin|admin-help-button', array(
172 'help_url' => $this->h($this->url($topic)),
173 'help_title' => $this->h($this->texts()->format_fd_message('help_prefix', array('title' => $meta['title'] ?? $topic))),
174 ));
175 }
176
184 public function formButton(string $modul, string $form, string $title = ''): string {
185 $modul = trim($modul);
186 $form = trim($form);
187 $title = trim($title);
188 if (!preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $modul)
189 || $form === ''
190 || !preg_match('/^[a-zA-Z0-9_.:-]+$/', $form)) {
191 return '';
192 }
193
194 if ($title === '') {
195 $title = ucwords(str_replace(array('-', '_', '.'), ' ', $form));
196 }
197
198 $url = $this->formUrl($modul, $form, $title);
199 return $this->tpl()->get_tpl('dbxAdmin|admin-help-button', array(
200 'help_url' => $this->h($url),
201 'help_title' => $this->h($this->texts()->format_fd_message('help_prefix', array('title' => $title))),
202 ));
203 }
204
205 public function renderModuleBar($topic = '', $actionsHtml = '', $title = '', $icon = '', $subtitle = '') {
206 $data = $this->moduleBarTemplateData($topic, $actionsHtml, $title, $icon, $subtitle);
207 if (!$data) {
208 return '';
209 }
210
211 return trim($this->tpl()->get_tpl('dbx|module-bar', $data));
212 }
213
214 public function moduleBarTemplateData($topic = '', $actionsHtml = '', $title = '', $icon = '', $subtitle = '') {
215 if ($topic === '') {
216 $topic = $this->resolveTopic();
217 }
218 $topic = trim((string)$topic);
219 if ($topic === '') {
220 return array();
221 }
222
223 $meta = $this->barMeta($topic);
224 if (!is_array($meta)) {
225 return array();
226 }
227
228 if ($title === '') {
229 $title = (string)($meta['title'] ?? $topic);
230 }
231 if ($icon === '') {
232 $icon = (string)($meta['icon'] ?? 'bi-grid');
233 }
234 if ($subtitle === '') {
235 $subtitle = (string)($meta['subtitle'] ?? '');
236 }
237
238 return array(
239 'bar_class' => 'dbx-module-bar',
240 'bar_title_class' => 'dbx-module-bar-titleblock',
241 'bar_actions_class' => 'dbx-module-bar-actions',
242 'bar_title' => (string)$title,
243 'bar_icon' => (string)$icon,
244 'bar_subtitle' => (string)$subtitle,
245 'bar_title_pre' => '',
246 'bar_title_heading_attrs' => '',
247 'bar_actions' => (string)$actionsHtml,
248 'bar_extra' => $this->button($topic),
249 );
250 }
251
255 public function helpWindowBarTemplateData($topic = '') {
256 $topic = trim((string)$topic);
257 if ($topic === '') {
258 return array();
259 }
260
261 $meta = $this->barMeta($topic);
262 if (!is_array($meta)) {
263 return array();
264 }
265
266 return array(
267 'bar_class' => 'dbx-module-bar dbx-help-context-bar',
268 'bar_title_class' => 'dbx-module-bar-titleblock',
269 'bar_actions_class' => 'dbx-module-bar-actions',
270 'bar_title' => (string)($meta['title'] ?? $topic),
271 'bar_icon' => (string)($meta['icon'] ?? 'bi-question-circle'),
272 'bar_subtitle' => $this->texts()->get_fd_message('context_help'),
273 'bar_title_pre' => '',
274 'bar_title_heading_attrs' => '',
275 'bar_actions' => '',
276 'bar_extra' => '',
277 'bar_middle' => '',
278 );
279 }
280
281 public function formHelpWindowBarTemplateData(string $title = ''): array {
282 $title = trim($title) !== '' ? trim($title) : $this->texts()->get_fd_message('form_help');
283 return array(
284 'bar_class' => 'dbx-module-bar dbx-help-context-bar',
285 'bar_title_class' => 'dbx-module-bar-titleblock',
286 'bar_actions_class' => 'dbx-module-bar-actions',
287 'bar_title' => $this->h($title),
288 'bar_icon' => 'bi-question-circle',
289 'bar_subtitle' => $this->texts()->get_fd_message('form_help_subtitle'),
290 'bar_title_pre' => '',
291 'bar_title_heading_attrs' => '',
292 'bar_actions' => '',
293 'bar_extra' => '',
294 'bar_middle' => '',
295 );
296 }
297
298 public function vars($topic) {
299 $data = $this->moduleBarTemplateData($topic);
300 if (!$data) {
301 return array(
302 'help_button' => '',
303 'bar_title' => '',
304 'bar_icon' => 'bi-grid',
305 'bar_subtitle' => '',
306 'bar_title_pre' => '',
307 'bar_title_heading_attrs' => '',
308 'bar_class' => 'dbx-module-bar',
309 'bar_title_class' => 'dbx-module-bar-titleblock',
310 'bar_actions_class' => 'dbx-module-bar-actions',
311 'bar_actions' => '',
312 'bar_extra' => '',
313 );
314 }
315
316 return array_merge($data, array(
317 'help_button' => (string)($data['bar_extra'] ?? ''),
318 ));
319 }
320
321 public function attachForm($oForm, $topic = '') {
322 if (!is_object($oForm) || !method_exists($oForm, 'add_obj')) {
323 return;
324 }
325 if ($topic === '') {
326 $topic = $this->resolveTopic();
327 }
328 if ($topic === '') {
329 return;
330 }
331 $oForm->add_obj('help_button', $this->button($topic));
332 if (method_exists($oForm, 'add_module_bar')) {
333 $barMeta = $this->barMeta($topic);
334 if (is_array($barMeta) && $barMeta) {
335 $oForm->add_module_bar(
336 (string)($barMeta['title'] ?? ''),
337 (string)($barMeta['icon'] ?? 'bi-grid'),
338 (string)($barMeta['subtitle'] ?? '')
339 );
340 }
341 }
342 }
343
344 public function resolveTopic($modul = '', $run1 = '', $run2 = '') {
345 if ($modul === '') {
346 $modul = (string)dbx()->get_system_var('dbx_modul', '');
347 }
348 if ($run1 === '') {
349 $run1 = (string)dbx()->get_modul_var('dbx_run1', '', 'parameter');
350 }
351 if ($run2 === '') {
352 $run2 = (string)dbx()->get_modul_var('dbx_run2', '', 'parameter');
353 }
354
355 $run1 = strtolower(trim($run1));
356 $run2 = strtolower(trim($run2));
357
358 if ($modul === 'dbxAdmin') {
359 if ($run1 === 'run' || $run1 === 'dashboard' || $run1 === '') {
360 return 'dashboard';
361 }
362 if ($run1 === 'cache') {
363 return 'cache';
364 }
365 if ($run1 === 'dd') {
366 if (strpos($run2, 'field') !== false) {
367 return 'dd_fields';
368 }
369 if ($run2 === 'backup_db' || $run2 === 'restore_db') {
370 return 'dd_backup';
371 }
372 return 'dd_list';
373 }
374 if ($run1 === 'db') {
375 return 'db_list';
376 }
377 if ($run1 === 'edit_dd') {
378 return 'edit_dd';
379 }
380 if ($run1 === 'edit_fd') {
381 return 'edit_fd';
382 }
383 if ($run1 === 'server') {
384 return ($run2 === 'list_tables') ? 'server_tables' : 'server';
385 }
386 if ($run1 === 'modules') {
387 if ($run2 === 'modul_new') {
388 return 'modules_new';
389 }
390 if ($run2 === 'modul_access') {
391 return 'modules_access';
392 }
393 return 'modules_list';
394 }
395 if ($run1 === 'config') {
396 $xmodul = strtolower(trim((string)dbx()->get_modul_var('xmodul', '', 'parameter')));
397 if ($xmodul === 'dbxcontent') {
398 return 'content_lng';
399 }
400 return 'config';
401 }
402 if ($run1 === 'session') {
403 return 'session';
404 }
405 if ($run1 === 'trace') {
406 return 'trace';
407 }
408 if ($run1 === 'sysmsg') {
409 return 'sysmsg';
410 }
411 if ($run1 === 'missing') {
412 return 'missing';
413 }
414 if ($run1 === 'contact') {
415 return 'contact';
416 }
417 if ($run1 === 'user') {
418 return 'user';
419 }
420 if ($run1 === 'export_sql') {
421 return 'export_sql';
422 }
423 if ($run1 === 'datadic') {
424 return 'datadic';
425 }
426 }
427
428 if ($modul === 'dbxWorkflow_admin') {
429 if ($run1 === 'edit') {
430 return 'workflow_edit';
431 }
432 if ($run1 === 'edit_bind') {
433 return 'workflow_bind_edit';
434 }
435 if ($run1 === 'binds') {
436 return 'workflow_binds';
437 }
438 if ($run1 === 'instances') {
439 return 'workflow_instances';
440 }
441 if ($run1 === 'install') {
442 return 'workflow_install';
443 }
444 return 'workflow_list';
445 }
446
447 if ($modul === 'dbxWorkflow') {
448 if ($run1 === 'run') {
449 return 'workflow_run';
450 }
451 return 'workflow_use';
452 }
453
454 if ($modul === 'dbxContent_admin') {
455 if ($run1 === 'content' && $run2 === 'config') {
456 return 'content_lng';
457 }
458 return 'content';
459 }
460
461 if ($modul === 'dbxUser_admin') {
462 if ($run1 === 'user' && ($run2 === 'new_group' || $run2 === 'edit_group')) {
463 return 'user_group_form';
464 }
465 return 'user_admin';
466 }
467
468 if ($modul === 'dbxUser') {
469 if ($run1 === 'user' && ($run2 === 'edit_profil' || $run2 === 'profil')) {
470 return 'user_profil';
471 }
472 }
473
474 return '';
475 }
476
477 public function run() {
478 $obj = dbx()->get_include_obj('dbxContentContextHelp', 'dbxContent');
479 if (is_object($obj) && method_exists($obj, 'run')) {
480 return $obj->run();
481 }
482 return '';
483 }
484}
formUrl(string $modul, string $form, string $title='')
formHelpWindowBarTemplateData(string $title='')
moduleBarTemplateData($topic='', $actionsHtml='', $title='', $icon='', $subtitle='')
helpWindowBarTemplateData($topic='')
Bar-Daten fuer Kontext-Hilfe im Hilfe-Fenster (ohne Help-Button, ohne bar_middle).
renderModuleBar($topic='', $actionsHtml='', $title='', $icon='', $subtitle='')
resolveTopic($modul='', $run1='', $run2='')
formButton(string $modul, string $form, string $title='')
Help-Button fuer ein konkretes dbxForm-Formular.
DBX schema administration.