dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxValidator_permalink_test.php
Go to the documentation of this file.
1<?php
2$root = dirname(__DIR__, 3);
3chdir($root);
4$_SERVER['REQUEST_URI'] = '/dbxapp/';
5$_SERVER['HTTP_HOST'] = 'localhost';
6$_SERVER['HTTPS'] = 'on';
7$_SERVER['SCRIPT_NAME'] = '/dbxapp/index.php';
8
9if (!defined('dbxSystem')) {
10 define('dbxSystem', 'dbxWebApp');
11}
12if (!defined('dbxRunAsAdmin')) {
13 define('dbxRunAsAdmin', 1);
14}
15
16require_once $root . '/dbx/vendor/autoload.php';
17require_once $root . '/dbx/include/dbxKernel.php';
18require_once dirname(__DIR__) . '/dbxValidator.class.php';
19require_once dirname(__DIR__, 2) . '/modules/dbxContent/include/dbxContent_permalink.class.php';
20require_once dirname(__DIR__, 2) . '/modules/dbxAdmin/include/dbxAdminHelp.class.php';
21
23
25
26foreach (array('home', 'help-dashboard-admin', 'seite-51', 'a1-b2') as $value) {
27 if (!$validator->validate($value, 'permalink|min=1|max=254')) {
28 throw new RuntimeException('Gueltiger Permalink abgelehnt: ' . $value);
29 }
30}
31
32foreach (array('home/tutorial', 'zwei woerter', 'mit_unterstrich', 'datei.html', 'Gross', '-start', 'ende-', 'zwei--striche', 'äöü') as $value) {
33 if ($validator->validate($value, 'permalink|min=1|max=254')) {
34 throw new RuntimeException('Ungueltiger Permalink akzeptiert: ' . $value);
35 }
36}
37
38if (dbxContent_permalink::normalize(' Home / Über uns ') !== 'home-ueber-uns') {
39 throw new RuntimeException('Permalink-Normalisierung verwendet nicht ausschliesslich Bindestriche.');
40}
41
42if (dbxContent_permalink::canonicalFromLegacy('home/tutorial/admin-dashboard') !== 'tutorial-admin-dashboard') {
43 throw new RuntimeException('Legacy-Tutorial wird nicht auf den stabilen Permalink abgebildet.');
44}
45
46$db = new class {
47 public array $permalinks = array('neue-seite' => 7);
48
49 public function select($dd, $where, $fields = '*', $order = '', $direction = '', $group = '', $limit = 0, $offset = 0, $debug = 0): array {
50 if (!preg_match("/permalink = '([^']+)'/", (string)$where, $match)) {
51 return array();
52 }
53 $permalink = str_replace("''", "'", $match[1]);
54 return isset($this->permalinks[$permalink]) ? array(array('id' => $this->permalinks[$permalink])) : array();
55 }
56};
57
58if (dbxContent_permalink::build($db, 'content_folder_de', 99, 'Neue Seite') !== 'neue-seite-2') {
59 throw new RuntimeException('Automatische Permalinks sind nicht ordnerunabhaengig oder nicht eindeutig.');
60}
61
62if (dbxContent_permalink::unique($db, 'content_de', 'neue-seite', 7) !== 'neue-seite') {
63 throw new RuntimeException('Eigener Datensatz wird bei der Eindeutigkeitspruefung nicht ausgeschlossen.');
64}
65
67foreach ((new \dbx\dbxAdmin\dbxAdminHelp())->topics() as $topic => $meta) {
68 $permalink = (string)($meta['permalink'] ?? '');
69 if (!$validator->validate($permalink, 'permalink|min=1|max=254')) {
70 throw new RuntimeException('Hilfe-Thema besitzt keinen gueltigen Permalink: ' . $topic);
71 }
72 if (isset($helpPermalinks[$permalink])) {
73 throw new RuntimeException('Doppelter Hilfe-Permalink: ' . $permalink);
74 }
75 $helpPermalinks[$permalink] = $topic;
76}
77
78echo "OK: Permalink-Regel, Normalisierung, Legacy-Alias und Eindeutigkeit geprueft.\n";
Zentrale, strikt pruefende Eingabevalidierung.
$_SERVER['REQUEST_METHOD']
DBX schema administration.