dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxDocs.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxDocs;
3
12{
13 private const REFERENCE_PAGES = array(
14 'overview' => 'index.html',
15 'classes' => 'annotated.html',
16 'namespaces' => 'namespaces.html',
17 'files' => 'files.html',
18 'examples' => 'examples.html',
19 );
20
21 private function language(): string
22 {
23 $language = strtolower(trim((string)dbx()->get_system_var('dbx_lng', 'de')));
24 return in_array($language, array('de', 'en', 'es'), true) ? $language : 'de';
25 }
26
27 private function labels(string $section): array
28 {
29 $labels = array(
30 'de' => array(
31 'overview' => 'Technische Referenz',
32 'classes' => 'Klassen',
33 'namespaces' => 'Namespaces',
34 'files' => 'Dateien',
35 'examples' => 'Beispiele',
36 'page' => 'Technische Referenz',
37 'subtitle' => 'Automatisch aus dem dbxapp-Quellcode erzeugt.',
38 'open' => 'Referenz in einem neuen Fenster öffnen',
39 'fallback' => 'Die Referenz kann nicht eingebettet angezeigt werden.',
40 ),
41 'en' => array(
42 'overview' => 'Technical reference',
43 'classes' => 'Classes',
44 'namespaces' => 'Namespaces',
45 'files' => 'Files',
46 'examples' => 'Examples',
47 'page' => 'Technical reference',
48 'subtitle' => 'Generated automatically from the dbxapp source code.',
49 'open' => 'Open reference in a new window',
50 'fallback' => 'The reference cannot be displayed within this page.',
51 ),
52 'es' => array(
53 'overview' => 'Referencia técnica',
54 'classes' => 'Clases',
55 'namespaces' => 'Espacios de nombres',
56 'files' => 'Archivos',
57 'examples' => 'Ejemplos',
58 'page' => 'Referencia técnica',
59 'subtitle' => 'Generada automáticamente a partir del código fuente de dbxapp.',
60 'open' => 'Abrir la referencia en una ventana nueva',
61 'fallback' => 'La referencia no se puede mostrar dentro de esta página.',
62 ),
63 );
64
65 $languageLabels = $labels[$this->language()];
66 return array(
67 'title' => (string)($languageLabels[$section] ?? $languageLabels['page']),
68 'subtitle' => (string)$languageLabels['subtitle'],
69 'open' => (string)$languageLabels['open'],
70 'fallback' => (string)$languageLabels['fallback'],
71 );
72 }
73
74 private function requestedDocument(string $section): string
75 {
76 if (isset(self::REFERENCE_PAGES[$section])) {
77 return self::REFERENCE_PAGES[$section];
78 }
79
80 if ($section !== 'page') {
81 return self::REFERENCE_PAGES['overview'];
82 }
83
84 $document = trim((string)dbx()->get_modul_var('doc', '', 'parameter'));
85 if (preg_match('/^[A-Za-z0-9_.-]+\.html$/', $document) !== 1) {
86 return self::REFERENCE_PAGES['overview'];
87 }
88
89 $root = realpath(dbx()->os_path(dbx()->get_base_dir() . 'reference/current'));
90 $file = realpath(dbx()->os_path(dbx()->get_base_dir() . 'reference/current/' . $document));
91 if ($root === false || $file === false || !is_file($file)) {
92 return self::REFERENCE_PAGES['overview'];
93 }
94
95 $rootPrefix = rtrim(str_replace('\\', '/', $root), '/') . '/';
96 $normalizedFile = str_replace('\\', '/', $file);
97 return str_starts_with($normalizedFile, $rootPrefix)
98 ? basename($normalizedFile)
99 : self::REFERENCE_PAGES['overview'];
100 }
101
102 public function run($action = ''): string
103 {
104 $action = $action !== ''
105 ? (string)$action
106 : (string)dbx()->get_modul_var('dbx_run1', 'reference', 'parameter');
107 if ($action !== 'reference') {
108 return '';
109 }
110
111 $section = strtolower(trim((string)dbx()->get_modul_var('dbx_run2', 'overview', 'parameter')));
112 if (!isset(self::REFERENCE_PAGES[$section]) && $section !== 'page') {
113 $section = 'overview';
114 }
115
116 $document = $this->requestedDocument($section);
117 $labels = $this->labels($section);
118 $referenceUrl = dbx()->get_base_url() . 'reference/current/' . rawurlencode($document);
119
120 dbx()->set_system_var('dbx_title', $labels['title']);
121 return dbx()->get_system_obj('dbxTPL')->get_tpl('dbxDocs|reference', array(
122 'reference_title' => $labels['title'],
123 'reference_subtitle' => $labels['subtitle'],
124 'reference_url' => dbx()->esc($referenceUrl),
125 'reference_open_label' => $labels['open'],
126 'reference_fallback' => $labels['fallback'],
127 ));
128 }
129}
Bindet die ausschließlich von Doxygen erzeugte technische Referenz in das dbxapp-Dokumentationsportal...
os_path(string $path)
Normalisiert einen Pfad fuer das aktuelle Betriebssystem.
Definition dbxApi.php:1538
get_base_dir(int $cutData=0)
Liefert das Basisverzeichnis der Installation.
Definition dbxApi.php:1507
esc($value)
Escaped einen Wert fuer HTML-Text und HTML-Attribute.
Definition dbxApi.php:2310
DBX schema administration.