dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
dbxContactContentProvision.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxContact;
3
4require_once dirname(__DIR__, 2) . '/dbxContent/include/dbxContent_bootstrap_sync.php';
5
6use dbx\dbxContent\dbxContentLng;
7use dbx\dbxContent\dbxContentLngSync;
8use dbx\dbxContent\dbxContentPageCache;
9use dbx\dbxContent\dbxContentPermalinkIndex;
10
12
13 public static function run($db): int {
14 if (!is_object($db)) {
15 return 0;
16 }
17
18 $dd = dbxContentLng::ddContent('de');
19 $existing = $db->select1($dd, array('permalink' => 'meine-anfragen'), 'id,content', 0);
20 if (is_array($existing) && (int) ($existing['id'] ?? 0) > 0) {
21 $id = (int) $existing['id'];
22 $content = (string) ($existing['content'] ?? '');
23 if (str_starts_with($content, '<h1>Meine Anfragen</h1>') && str_contains($content, '[modul=dbxContact]dbx_run1=tickets[/modul]')) {
24 $db->update($dd, array('content' => self::pageContent()), $id, 0, 1, 0, 1);
26 }
27 return $id;
28 }
29
30 $folderId = self::folderId($db);
31 $data = array(
32 'activ' => 1,
33 'folder' => $folderId,
34 'title' => 'Meine Anfragen',
35 'permalink' => 'meine-anfragen',
36 'description' => 'Eigene Kontaktanfragen, Antworten und aktuellen Bearbeitungsstatus anzeigen.',
37 'keywords' => 'Kontakt, Anfragen, Tickets, Antworten',
38 'group_read' => '*',
39 'sorter' => self::nextSorter($db, $dd, $folderId),
40 'template' => 'parent',
41 'hero_template' => 'parent',
42 'hero_image_id' => 'parent',
43 'hero_margin_top' => 'parent',
44 'hero_height' => 'parent',
45 'hero_variant' => 'parent',
46 'hero_sticky' => 'parent',
47 'hero_scroll_layer' => 'parent',
48 'gallery_template' => 'image-gallery',
49 'gallery_visible_count' => '3',
50 'gallery_image_size' => 'original',
51 'gallery_lightbox_width' => '100vw',
52 'gallery_overflow' => 'grid',
53 'gallery_click_behavior' => 'lightbox',
54 'content' => self::pageContent(),
55 );
56
57 if ($db->insert($dd, $data, 0, 1, 0, 1) <= 0) {
58 return 0;
59 }
60
61 $id = (int) $db->get_insert_id();
62 if ($id <= 0) {
63 return 0;
64 }
65
67 dbxContentPermalinkIndex::upsertPage($id, 'meine-anfragen', '*', 1, 'de');
69 return $id;
70 }
71
72 private static function pageContent(): string {
73 return '<p class="lead">Hier sehen Sie Ihre Kontaktanfragen, Antworten und den aktuellen Bearbeitungsstatus.</p>'
74 . '[modul=dbxContact]dbx_run1=tickets[/modul]';
75 }
76
77 private static function folderId($db): int {
78 $dd = dbxContentLng::ddFolder('de');
79 $rows = $db->select($dd, array('name' => 'Fuer Kunden'), 'id', 'id', 'ASC', '', 1, 0, 0);
80 if (is_array($rows) && isset($rows[0]['id'])) {
81 return (int) $rows[0]['id'];
82 }
83 return 0;
84 }
85
86 private static function nextSorter($db, string $dd, int $folderId): string {
87 $rows = $db->select($dd, array('folder' => $folderId), 'sorter', 'sorter,id', 'DESC', '', 1, 0, 0);
88 $max = 0;
89 if (is_array($rows) && isset($rows[0]['sorter'])) {
90 $max = (int) $rows[0]['sorter'];
91 }
92 return sprintf('%04d', $max + 10);
93 }
94}
static ddContent(string $lng='')
static afterPageSave($db, int $id, bool $isNew=false)
if( $syncRequest)
Definition index.php:520