dbXapp
2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Toggle main menu visibility
Loading...
Searching...
No Matches
dbxContentContextHelp.class.php
Go to the documentation of this file.
1
<?php
2
namespace
dbx\dbxContent;
3
4
require_once __DIR__ .
'/dbxContent_bootstrap.php'
;
5
require_once __DIR__ .
'/dbxContentContextHelpProvision.class.php'
;
6
7
class
dbxContentContextHelp
{
8
9
public
const
HELP_ROOT
=
'outside/help'
;
10
11
public
function
topicSlug
(
string
$topic): string {
12
$topic = strtolower(trim($topic));
13
$topic = str_replace(
'_'
,
'-'
, $topic);
14
$topic = preg_replace(
'/[^a-z0-9-]+/'
,
'-'
, $topic);
15
$topic = preg_replace(
'/-+/'
,
'-'
, $topic);
16
return
trim((
string
) $topic,
'-'
);
17
}
18
19
public
function
permalinkForTopic
(
string
$topic): string {
20
$slug = $this->
topicSlug
($topic);
21
if
($slug ===
''
) {
22
return
''
;
23
}
24
return
dbxContentPermalinkIndex::normalizePermalink
(self::HELP_ROOT .
'/'
. $slug);
25
}
26
27
public
function
resolveCidByPermalink
(
string
$permalink,
string
$lng =
''
): int {
28
$permalink =
dbxContentPermalinkIndex
::normalizePermalink($permalink);
29
if
($permalink ===
''
) {
30
return
0;
31
}
32
33
if
($lng ===
''
) {
34
$lng = function_exists(
'dbx_lng_current'
) ? dbx_lng_current() :
'de'
;
35
}
36
$lng = strtolower(trim($lng));
37
38
$hit = dbxContentPermalinkIndex::resolve($permalink, $lng);
39
if
(is_array($hit) && (
int
) ($hit[
'cid'
] ?? 0) > 0) {
40
return
(
int
) $hit[
'cid'
];
41
}
42
43
$db
=
dbx
()->get_system_obj(
'dbxDB'
);
44
if
(!is_object(
$db
)) {
45
return
0;
46
}
47
48
$dd = dbxContentLng::ddContent($lng);
49
$rec =
$db
->select1($dd, array(
'permalink'
=> $permalink),
'id'
, 0);
50
if
(is_array($rec) && (
int
) ($rec[
'id'
] ?? 0) > 0) {
51
return
(
int
) $rec[
'id'
];
52
}
53
54
$masterLng = strtolower(trim((
string
)
dbx
()->get_config(
'dbx'
,
'default_lng'
,
'de'
)));
55
if
($masterLng !==
''
&& $masterLng !== $lng) {
56
$ddMaster = dbxContentLng::ddContent($masterLng);
57
$rec =
$db
->select1($ddMaster, array(
'permalink'
=> $permalink),
'id'
, 0);
58
if
(is_array($rec) && (
int
) ($rec[
'id'
] ?? 0) > 0) {
59
return
(
int
) $rec[
'id'
];
60
}
61
}
62
63
return
0;
64
}
65
66
public
function
renderTopic
(
string
$topic): string {
67
$permalink = $this->
permalinkForTopic
($topic);
68
if
($permalink ===
''
) {
69
return
''
;
70
}
71
72
$cid = $this->resolveCidByPermalink($permalink);
73
if
($cid <= 0) {
74
return
dbx
()->get_system_obj(
'dbxTPL'
)->get_tpl(
'dbx|alert-info'
, array(
75
'msg'
=>
'Hilfe-Seite noch nicht angelegt. Im CMS unter Ordner <code>'
76
. htmlspecialchars(self::HELP_ROOT, ENT_QUOTES,
'UTF-8'
)
77
.
'</code> eine Seite mit Permalink <code>'
78
. htmlspecialchars($permalink, ENT_QUOTES,
'UTF-8'
)
79
.
'</code> anlegen (Thema: <code>'
80
. htmlspecialchars($topic, ENT_QUOTES,
'UTF-8'
)
81
.
'</code>).'
,
82
));
83
}
84
85
$contentObj =
dbx
()->get_include_obj(
'dbxContent_content'
);
86
if
(!is_object($contentObj) || !method_exists($contentObj,
'renderPage'
)) {
87
return
''
;
88
}
89
90
return
$contentObj->renderPage($cid, array(
91
'admin_help'
=>
true
,
92
'skip_hits'
=>
true
,
93
'skip_cache'
=>
true
,
94
));
95
}
96
97
public
function
run
(): string {
98
dbxContentContextHelpProvision
::
run
();
99
100
dbx
()->set_system_var(
'dbx_page'
,
'_window'
);
101
102
$topic = trim((
string
)
dbx
()->get_modul_var(
'topic'
,
''
,
'parameter'
));
103
if
($topic ===
''
) {
104
$topic = trim((
string
)
dbx
()->get_modul_var(
'dbx_run2'
,
''
,
'parameter'
));
105
}
106
107
$help =
dbx
()->get_include_obj(
'dbxAdminHelp'
,
'dbxAdmin'
);
108
$topics
= is_object($help) && method_exists($help,
'topics'
) ? $help->topics() : array();
109
if
($topic ===
''
|| !isset(
$topics
[$topic])) {
110
$topic =
'dashboard'
;
111
}
112
113
$content = $this->renderTopic($topic);
114
if
(trim(strip_tags((
string
) $content)) ===
''
) {
115
$content =
dbx
()->get_system_obj(
'dbxTPL'
)->get_tpl(
'dbx|alert-info'
, array(
116
'msg'
=>
'Fuer diesen Bereich ist noch keine Hilfe hinterlegt.'
,
117
));
118
}
119
120
$bar = array();
121
if
(is_object($help) && method_exists($help,
'helpWindowBarTemplateData'
)) {
122
$bar = $help->helpWindowBarTemplateData($topic);
123
}
124
125
return
dbx
()->get_system_obj(
'dbxTPL'
)->get_tpl(
'dbxAdmin|admin-help-shell'
, array_merge(
126
is_array($bar) ? $bar : array(),
127
array(
128
'frame_id'
=>
'dbx_context_help_'
. preg_replace(
'/[^a-z0-9_-]+/i'
,
'_'
, $topic),
129
'frame_panel_class'
=>
'dbx-admin-help py-3 dbx-context-help-preview'
,
130
'frame_form_open'
=>
''
,
131
'frame_form_close'
=>
''
,
132
'frame_subbar'
=>
''
,
133
'frame_body_class'
=>
'dbx-admin-help-body dbx-context-help-body'
,
134
'frame_body_head'
=>
''
,
135
'frame_body_tail'
=>
''
,
136
'frame_panel_attrs'
=>
''
,
137
'content'
=> $content,
138
)
139
));
140
}
141
}
dbx\dbxContent\dbxContentContextHelp
Definition
dbxContentContextHelp.class.php:7
dbx\dbxContent\dbxContentContextHelp\topicSlug
topicSlug(string $topic)
Definition
dbxContentContextHelp.class.php:11
dbx\dbxContent\dbxContentContextHelp\HELP_ROOT
const HELP_ROOT
Definition
dbxContentContextHelp.class.php:9
dbx\dbxContent\dbxContentContextHelp\renderTopic
renderTopic(string $topic)
Definition
dbxContentContextHelp.class.php:66
dbx\dbxContent\dbxContentContextHelp\run
run()
Definition
dbxContentContextHelp.class.php:97
dbx\dbxContent\dbxContentContextHelp\resolveCidByPermalink
resolveCidByPermalink(string $permalink, string $lng='')
Definition
dbxContentContextHelp.class.php:27
dbx\dbxContent\dbxContentContextHelp\permalinkForTopic
permalinkForTopic(string $topic)
Definition
dbxContentContextHelp.class.php:19
dbx\dbxContent\dbxContentContextHelpProvision
Definition
dbxContentContextHelpProvision.class.php:8
dbx\dbxContent\dbxContentPermalinkIndex
Kompatibilitaets-Fassade fuer Permalinks.
Definition
dbxContentPermalinkIndex.class.php:16
dbx\dbxContent\dbxContentPermalinkIndex\normalizePermalink
static normalizePermalink(string $permalink)
Definition
dbxContentPermalinkIndex.class.php:38
dbx
DBX schema administration.
$db
$db
Definition
run_context_help_provision.php:38
$topics
$topics
Definition
seed_admin_help_tpl.php:3
dbx
modules
dbxContent
include
dbxContentContextHelp.class.php
Generated by
1.17.0