dbXapp 2.0
RAD, CMS, Module und Runtime-IDE fuer dbXapp
Loading...
Searching...
No Matches
dbxContentHome.class.php
Go to the documentation of this file.
1<?php
2namespace dbx\dbxContent;
3
4require_once __DIR__ . '/dbxContent_bootstrap_sync.php';
5
7
8 private static function db() {
9 return dbx()->get_system_obj('dbxDB');
10 }
11
12 public static function masterCid(): int {
13 $cid = dbx()->get_config('dbxHome', 'cid');
14 if ($cid === 'undef' || $cid === '' || $cid === null) {
15 return 0;
16 }
17
18 return (int) $cid;
19 }
20
21 public static function currentLng(): string {
22 if (function_exists('dbx_lng_current')) {
23 return dbx_lng_current();
24 }
25
26 $lng = strtolower(trim((string) dbx()->get_system_var('dbx_lng', dbxContentLngSync::masterLng())));
27 return $lng !== '' ? $lng : dbxContentLngSync::masterLng();
28 }
29
34 public static function resolveCid(string $lng = ''): int {
35 $masterCid = self::masterCid();
36 if ($masterCid <= 0) {
37 return 0;
38 }
39
40 if ($lng === '') {
41 $lng = self::currentLng();
42 }
43 $lng = strtolower(trim($lng));
44 $masterLng = dbxContentLngSync::masterLng();
45
46 if ($lng === $masterLng) {
47 return $masterCid;
48 }
49
50 $db = self::db();
51 if (!is_object($db)) {
52 return 0;
53 }
54
55 $masterDd = dbxContentLng::ddContent($masterLng);
56 $masterRow = $db->select1($masterDd, $masterCid, 'lng_uid', 0);
57 if (!is_array($masterRow)) {
58 return 0;
59 }
60
61 $lngUid = trim((string) ($masterRow['lng_uid'] ?? ''));
62 if ($lngUid === '') {
63 $lngUid = dbxContentLngSync::ensureRecordUid($db, $masterDd, $masterCid, 'p');
64 }
65 if ($lngUid === '') {
66 return 0;
67 }
68
69 $slaveId = dbxContentLngSync::resolveIdByUid($db, dbxContentLng::ddContent(), $lngUid, $lng);
70 if ($slaveId <= 0) {
71 return 0;
72 }
73
74 return $slaveId;
75 }
76
80 public static function isHomePage($db, int $cid, string $lng = ''): bool {
81 $cid = (int) $cid;
82 if ($cid <= 0) {
83 return false;
84 }
85
86 if ($lng === '') {
87 $lng = self::currentLng();
88 }
89 $lng = strtolower(trim($lng));
90
91 return self::resolveCid($lng) === $cid;
92 }
93
97 public static function refreshHomeCache($db, int $cid, string $lng = ''): void {
98 return;
99 }
100}
static refreshHomeCache($db, int $cid, string $lng='')
Kompatibilitaetsmethode: Ein separater Home-Cache existiert nicht mehr.
static isHomePage($db, int $cid, string $lng='')
Prueft, ob eine Seite die Startseite der angegebenen Sprache ist.
static resolveCid(string $lng='')
Startseiten-CID fuer die aktive (oder uebergebene) Sprache.
if( $syncRequest)
Definition index.php:520
DBX schema administration.