dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxKiHelp.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxKi;
3
4use dbx\dbxContent\dbxContentLng;
5
6require_once dirname(__DIR__, 2) . '/dbxContent/include/dbxContent_bootstrap_sync.php';
7require_once __DIR__ . '/dbxKiCmsHelpProvision.class.php';
8
9class dbxKiHelp {
10
11 private function tpl() {
12 return dbx()->get_system_obj('dbxTPL');
13 }
14
15 private function h($value) {
16 return htmlspecialchars((string) $value, ENT_QUOTES, 'UTF-8');
17 }
18
19 public function screens(): array {
20 return array(
21 'briefing' => array(
22 'title' => 'KI-Auftrag',
23 'help_title' => dbxKiCmsHelpProvision::TITLE,
24 'icon' => 'bi-ui-checks',
25 'subtitle' => 'Formular, Download, Ablauf',
26 ),
27 'briefing_page_create' => array(
28 'title' => 'Neue Seite — Formular',
29 'help_title' => dbxKiCmsHelpProvision::TITLE,
30 'icon' => 'bi-file-earmark-plus',
31 'subtitle' => 'Auftrag fuer neue Content-Seite',
32 ),
33 'briefing_page_update' => array(
34 'title' => 'Seite aendern — Formular',
35 'help_title' => dbxKiCmsHelpProvision::TITLE,
36 'icon' => 'bi-pencil-square',
37 'subtitle' => 'Auftrag fuer Seiten-Update',
38 ),
39 'briefing_page_translate' => array(
40 'title' => 'Uebersetzung — Formular',
41 'help_title' => dbxKiCmsHelpProvision::TITLE,
42 'icon' => 'bi-translate',
43 'subtitle' => 'Auftrag fuer Seiten-Uebersetzung',
44 ),
45 'translation_sync_all' => array(
46 'title' => 'Sprache komplett uebersetzen',
47 'help_title' => dbxKiCmsHelpProvision::TITLE,
48 'icon' => 'bi-translate',
49 'subtitle' => 'CMS-Struktur in Zielsprachen uebertragen',
50 ),
51 'briefing_module' => array(
52 'title' => 'Modul-KI',
53 'help_title' => dbxKiCmsHelpProvision::TITLE,
54 'icon' => 'bi-stars',
55 'subtitle' => 'Auftrag fuer bestehendes Modul',
56 ),
57 'briefing_styles' => array(
58 'title' => 'Schreibstile',
59 'help_title' => dbxKiCmsHelpProvision::TITLE,
60 'icon' => 'bi-type',
61 'subtitle' => 'Ton und Stil fuer KI-Auftraege',
62 ),
63 'module_bundle' => array(
64 'title' => 'Modul-Antwort importieren',
65 'help_title' => dbxKiCmsHelpProvision::TITLE,
66 'icon' => 'bi-upload',
67 'subtitle' => 'Antwort-ZIP fuer Modul-KI',
68 ),
69 'module_bundle_preview' => array(
70 'title' => 'Modul-Import',
71 'help_title' => dbxKiCmsHelpProvision::TITLE,
72 'icon' => 'bi-check2-square',
73 'subtitle' => 'Modul-Antwort ausfuehren',
74 ),
75 'bundle' => array(
76 'title' => 'Bundle importieren',
77 'help_title' => dbxKiCmsHelpProvision::TITLE,
78 'icon' => 'bi-box-arrow-in-down',
79 'subtitle' => 'KI-Antwort ZIP hochladen',
80 ),
81 'bundle_preview' => array(
82 'title' => 'KI-Import',
83 'help_title' => dbxKiCmsHelpProvision::TITLE,
84 'icon' => 'bi-eye',
85 'subtitle' => 'Vorschau und Ausfuehrung',
86 ),
87 'bundle_process' => array(
88 'title' => 'KI-Import',
89 'help_title' => dbxKiCmsHelpProvision::TITLE,
90 'icon' => 'bi-play-circle',
91 'subtitle' => 'Bundle wird ausgefuehrt',
92 ),
93 );
94 }
95
96 public function resolveScreen(string $run1 = ''): string {
97 if ($run1 === '') {
98 $run1 = (string) dbx()->get_modul_var('dbx_run1', 'bundle', 'parameter');
99 }
100 $run1 = strtolower(trim($run1));
101 if ($run1 === 'briefing' || $run1 === 'briefing_page_create' || $run1 === 'briefing_page_update'
102 || $run1 === 'briefing_page_translate' || $run1 === 'briefing_styles' || $run1 === 'briefing_module'
103 || $run1 === 'translation_sync_all') {
104 return $run1;
105 }
106 if ($run1 === 'module_bundle') {
107 return 'module_bundle';
108 }
109 if ($run1 === 'module_bundle_import') {
110 return 'module_bundle_preview';
111 }
112 if ($run1 === 'bundle_import') {
113 return 'bundle_preview';
114 }
115 if ($run1 === 'bundle_process') {
116 return 'bundle_process';
117 }
118 if ($run1 === 'bundle' || $run1 === 'start' || $run1 === '') {
119 return 'bundle';
120 }
121 return 'bundle';
122 }
123
124 public function helpUrl(string $screen = ''): string {
125 $screen = trim($screen);
126 if ($screen === '') {
127 $screen = $this->resolveScreen();
128 }
129 return '?dbx_modul=dbxKi&dbx_run1=help&screen=' . rawurlencode($screen);
130 }
131
132 public function button(string $screen = ''): string {
133 $screen = trim($screen);
134 if ($screen === '') {
135 $screen = $this->resolveScreen();
136 }
137 $screens = $this->screens();
138 if (!isset($screens[$screen])) {
139 $screen = 'bundle';
140 }
141 $meta = $screens[$screen];
142 return $this->tpl()->get_tpl('dbxAdmin|admin-help-button', array(
143 'help_url' => $this->h($this->helpUrl($screen)),
144 'help_title' => $this->h('Hilfe: ' . ($meta['help_title'] ?? $meta['title'] ?? $screen)),
145 ));
146 }
147
148 public function moduleBarTemplateData(string $screen = '', string $actionsHtml = '', string $title = '', string $icon = '', string $subtitle = ''): array {
149 if ($screen === '') {
150 $screen = $this->resolveScreen();
151 }
152 $screens = $this->screens();
153 if (!isset($screens[$screen])) {
154 $screen = 'bundle';
155 }
156 $meta = $screens[$screen];
157
158 if ($title === '') {
159 $title = (string) ($meta['title'] ?? $screen);
160 }
161 if ($icon === '') {
162 $icon = (string) ($meta['icon'] ?? 'bi-grid');
163 }
164 if ($subtitle === '') {
165 $subtitle = (string) ($meta['subtitle'] ?? '');
166 }
167
168 return array(
169 'bar_class' => 'dbx-module-bar',
170 'bar_title_class' => 'dbx-module-bar-titleblock',
171 'bar_actions_class' => 'dbx-module-bar-actions',
172 'bar_title' => $title,
173 'bar_icon' => $icon,
174 'bar_subtitle' => $subtitle,
175 'bar_title_pre' => '',
176 'bar_title_heading_attrs' => '',
177 'bar_actions' => (string) $actionsHtml,
178 'bar_extra' => $this->button($screen),
179 'bar_middle' => '',
180 );
181 }
182
183 public function helpWindowBarTemplateData(string $screen = ''): array {
184 if ($screen === '') {
185 $screen = $this->resolveScreen();
186 }
187 $screens = $this->screens();
188 if (!isset($screens[$screen])) {
189 $screen = 'bundle';
190 }
191 $meta = $screens[$screen];
192
193 return array(
194 'bar_class' => 'dbx-module-bar dbx-help-context-bar',
195 'bar_title_class' => 'dbx-module-bar-titleblock',
196 'bar_actions_class' => 'dbx-module-bar-actions',
197 'bar_title' => (string) ($meta['help_title'] ?? $meta['title'] ?? $screen),
198 'bar_icon' => 'bi-question-circle',
199 'bar_subtitle' => 'Kontext-Hilfe',
200 'bar_title_pre' => '',
201 'bar_title_heading_attrs' => '',
202 'bar_actions' => '',
203 'bar_extra' => '',
204 'bar_middle' => '',
205 );
206 }
207
208 public function renderCmsHelpContent(): string {
210
212 $cid = $this->resolveHelpCid($permalink);
213
214 if ($cid <= 0) {
216 if (empty($result['errors'])) {
218 $cid = (int) ($result['page_id'] ?? 0);
219 if ($cid <= 0) {
220 $cid = $this->resolveHelpCid($permalink);
221 }
222 }
223 }
224
225 if ($cid <= 0) {
226 return $this->tpl()->get_tpl('dbx|alert-info', array(
227 'msg' => 'Hilfe-Seite noch nicht angelegt. Bitte '
228 . '<a href="?dbx_modul=dbxKi&amp;dbx_run1=provision_anleitung">Anleitung provisionieren</a>.',
229 ));
230 }
231
232 $contentObj = dbx()->get_include_obj('dbxContent_content', 'dbxContent');
233 if (!is_object($contentObj) || !method_exists($contentObj, 'renderPage')) {
234 return '';
235 }
236
237 return $contentObj->renderPage($cid, array(
238 'admin_help' => true,
239 'skip_hits' => true,
240 'skip_cache' => true,
241 ));
242 }
243
244 private function resolveHelpCid(string $permalink): int {
245 $permalink = trim($permalink);
246 if ($permalink === '') {
247 return 0;
248 }
249
250 $contextHelp = dbx()->get_include_obj('dbxContentContextHelp', 'dbxContent');
251 if (is_object($contextHelp) && method_exists($contextHelp, 'resolveCidByPermalink')) {
252 $cid = (int) $contextHelp->resolveCidByPermalink($permalink);
253 if ($cid > 0) {
254 return $cid;
255 }
256 }
257
258 $db = dbx()->get_system_obj('dbxDB');
259 if (!is_object($db)) {
260 return 0;
261 }
262
263 $dd = dbxContentLng::ddContent();
264 $rec = $db->select1($dd, array('permalink' => $permalink), 'id', 0);
265 if (is_array($rec) && (int) ($rec['id'] ?? 0) > 0) {
266 return (int) $rec['id'];
267 }
268
269 return 0;
270 }
271
272 public function renderHelpWindow(string $screen = ''): string {
273 dbx()->set_system_var('dbx_page', 'window');
274
275 if ($screen === '') {
276 $screen = trim((string) dbx()->get_modul_var('screen', '', 'parameter'));
277 }
278 if ($screen === '') {
279 $screen = $this->resolveScreen();
280 }
281
282 $content = $this->renderCmsHelpContent();
283 if (trim(strip_tags((string) $content)) === '') {
284 $content = $this->tpl()->get_tpl('dbx|alert-info', array(
285 'msg' => 'Fuer diesen Bereich ist noch keine Hilfe hinterlegt.',
286 ));
287 }
288
289 return $this->tpl()->get_tpl('dbxAdmin|admin-help-shell', array_merge(
290 $this->helpWindowBarTemplateData($screen),
291 array(
292 'frame_id' => 'dbx_ki_help_' . preg_replace('/[^a-z0-9_-]+/i', '_', $screen),
293 'frame_panel_class' => 'dbx-admin-help py-3 dbx-context-help-preview',
294 'frame_form_open' => '',
295 'frame_form_close' => '',
296 'frame_subbar' => '',
297 'frame_body_class' => 'dbx-admin-help-body dbx-context-help-body',
298 'frame_body_head' => '',
299 'frame_body_tail' => '',
300 'frame_panel_attrs' => '',
301 'content' => $content,
302 )
303 ));
304 }
305}
moduleBarTemplateData(string $screen='', string $actionsHtml='', string $title='', string $icon='', string $subtitle='')
resolveScreen(string $run1='')
helpUrl(string $screen='')
renderHelpWindow(string $screen='')
button(string $screen='')
helpWindowBarTemplateData(string $screen='')
if(!defined( 'IMG_WEBP')) define( 'IMG_WEBP'
DBX schema administration.