dbxapp
4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
dbxapp.de
Portal
Start
Anwender
Entwickler
KI-Bereiche
Loading...
Searching...
No Matches
dbxTPL_design_slots_test.php
Go to the documentation of this file.
1
<?php
2
3
class
dbxObj
{}
4
5
class
dbxTPLDesignSlotsTestApi
{
6
public
string
$root
;
7
public
array
$registered
= array();
8
public
array
$system
= array(
'dbx_design'
=>
'demo'
,
'dbx_activ_design'
=>
'demo'
);
9
10
public
function
get_base_dir
(): string { return rtrim($this->root,
'/\\'
) . DIRECTORY_SEPARATOR; }
11
public
function
get_base_url
(): string { return
'https://localhost/dbxapp/'
; }
12
public
function
get_system_var
(
string
$key, $default =
''
, ...$rest) {
return
$this->
system
[$key] ?? $default; }
13
public
function
get_request_var
(
string
$key, $default =
''
, ...$rest) {
return
$default; }
14
public
function
get_skin
(): string { return
'blau'
; }
15
public
function
get_skin_css
(): string { return
'skin-blau.css'
; }
16
public
function
get_skin_class
(): string { return
'skin-blau'
; }
17
public
function
os_path
(
string
$path): string { return str_replace(array(
'/'
,
'\\'
), DIRECTORY_SEPARATOR, $path); }
18
public
function
register_editor_file
(
string
$kind,
string
$file
): void { $this->registered[] = array($kind,
$file
); }
19
}
20
21
function
dbx
():
dbxTPLDesignSlotsTestApi
{
22
static
$api
;
23
if
(!
$api
)
$api
=
new
dbxTPLDesignSlotsTestApi
();
24
return
$api
;
25
}
26
27
$root
= sys_get_temp_dir() . DIRECTORY_SEPARATOR .
'dbx-tpl-slots-'
. bin2hex(random_bytes(5));
28
dbx
()->root =
$root
;
29
$htm
=
$root
. DIRECTORY_SEPARATOR .
'dbx'
. DIRECTORY_SEPARATOR .
'design'
. DIRECTORY_SEPARATOR .
'demo'
. DIRECTORY_SEPARATOR .
'htm'
;
30
mkdir(
$htm
, 0777,
true
);
31
file_put_contents(
$htm
.
'/logo.htm'
,
'<img src="../img/logo.png" data-design="{dbx:design}">'
);
32
file_put_contents(
$htm
.
'/branding.htm'
,
'<strong>Demo</strong>'
);
33
file_put_contents(
$htm
.
'/footer.htm'
,
'<footer>{dbx:color}</footer>'
);
34
35
require_once dirname(__DIR__) .
'/dbxTPL.class.php'
;
36
$tpl
=
new
dbxTPL
();
37
$out
=
$tpl
->replace_design_slots(
'[dbx:logo]|[dbx:branding]|[dbx:footer]'
,
'demo'
);
38
39
$expected
=
'<img src="dbx/design/demo/img/logo.png" data-design="demo">|<strong>Demo</strong>|<footer>blau</footer>'
;
40
if
(
$out
!==
$expected
) {
41
fwrite(STDERR,
"FAIL: Design-Slots wurden nicht richtig eingesetzt.\n$out\n"
);
42
exit
(1);
43
}
44
$missing
=
$tpl
->replace_design_slots(
'A[dbx:logo]B[dbx:footer]C'
,
'missing'
);
45
if
(
$missing
!==
'ABC'
) {
46
fwrite(STDERR,
"FAIL: Fehlende Fragmente wurden nicht leer aufgeloest.\n"
);
47
exit
(2);
48
}
49
file_put_contents(
$htm
.
'/branding.htm'
,
'<strong>Demo</strong>[dbx:content][dbx:footer]'
);
50
$guarded
=
$tpl
->replace_design_slots(
'[dbx:branding]'
,
'demo'
);
51
if
(
$guarded
!==
'<strong>Demo</strong>'
) {
52
fwrite(STDERR,
"FAIL: Verschachtelte Design-/Content-Slots wurden nicht abgefangen.\n"
);
53
exit
(3);
54
}
55
56
foreach
(
new
RecursiveIteratorIterator(
new
RecursiveDirectoryIterator(
$root
, FilesystemIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST) as
$file
) {
57
$file
->isDir() ? rmdir(
$file
->getPathname()) : unlink(
$file
->getPathname());
58
}
59
rmdir(
$root
);
60
echo
"OK dbxTPL design slots\n"
;
dbxObj
Gemeinsame Basisklasse fuer dbXapp-System-, Modul- und Include-Objekte.
Definition
dbxKernel.php:63
dbxTPLDesignSlotsTestApi
Definition
dbxTPL_design_slots_test.php:5
dbxTPLDesignSlotsTestApi\get_base_url
get_base_url()
Definition
dbxTPL_design_slots_test.php:11
dbxTPLDesignSlotsTestApi\$root
string $root
Definition
dbxTPL_design_slots_test.php:6
dbxTPLDesignSlotsTestApi\get_system_var
get_system_var(string $key, $default='',... $rest)
Definition
dbxTPL_design_slots_test.php:12
dbxTPLDesignSlotsTestApi\$registered
array $registered
Definition
dbxTPL_design_slots_test.php:7
dbxTPLDesignSlotsTestApi\get_request_var
get_request_var(string $key, $default='',... $rest)
Definition
dbxTPL_design_slots_test.php:13
dbxTPLDesignSlotsTestApi\get_skin
get_skin()
Definition
dbxTPL_design_slots_test.php:14
dbxTPLDesignSlotsTestApi\register_editor_file
register_editor_file(string $kind, string $file)
Definition
dbxTPL_design_slots_test.php:18
dbxTPLDesignSlotsTestApi\$system
array $system
Definition
dbxTPL_design_slots_test.php:8
dbxTPLDesignSlotsTestApi\get_base_dir
get_base_dir()
Definition
dbxTPL_design_slots_test.php:10
dbxTPLDesignSlotsTestApi\get_skin_class
get_skin_class()
Definition
dbxTPL_design_slots_test.php:16
dbxTPLDesignSlotsTestApi\os_path
os_path(string $path)
Definition
dbxTPL_design_slots_test.php:17
dbxTPLDesignSlotsTestApi\get_skin_css
get_skin_css()
Definition
dbxTPL_design_slots_test.php:15
dbxTPL
Definition
dbxTPL.class.php:279
$root
$root
Definition
db_access_boundary_test.php:3
$api
$api
Definition
dbxApi_head_response_test.php:6
$expected
foreach( $iterator as $file) if(! $groups) $expected
Definition
dbxForm_fd_language_messages_test.php:56
system
$api system['dbx_permalink']
Definition
dbxMissingResources_test.php:59
$tpl
if($web->content_permalink_redirect_target() !=='') $tpl
Definition
dbxSeoCanonicalPolicy_test.php:73
$htm
$htm
Definition
dbxTPL_design_slots_test.php:29
dbx
dbx()
Definition
dbxTPL_design_slots_test.php:21
$missing
if($out !==$expected) $missing
Definition
dbxTPL_design_slots_test.php:44
$out
$out
Definition
dbxTPL_design_slots_test.php:37
$guarded
$guarded
Definition
dbxTPL_design_slots_test.php:50
exit
exit
Definition
index.php:146
$file
$file
Definition
shop_repository_request_cache_test.php:3
dbx
include
tests
dbxTPL_design_slots_test.php
Generated by
1.17.0