Newer
Older
<?php
namespace QUI\Menu\Independent\Items;
use QUI;
* menu item which gets its data from a site
//region type stuff
/**
* @return string
*/
public static function itemTitle(): string
{
return QUI::getLocale()->get('quiqqer/menu', 'item.site.title');
}
public static function itemJsControl(): string
{
return 'package/quiqqer/menu/bin/Controls/Independent/Items/Site';
}
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//endregion
//region frontend item methods
/**
* @return QUI\Projects\Site|null
*/
public function getSite(): ?QUI\Projects\Site
{
$data = $this->getCustomData();
if (!is_array($data) || !isset($data['site'])) {
return null;
}
try {
$siteUrl = $data['site'];
$Site = QUI\Projects\Site\Utils::getSiteByLink($siteUrl);
} catch (QUI\Exception $Exception) {
return null;
}
if ($Site->getAttribute('active')) {
return $Site;
}
return null;
}
public function getName(): string
{
$Site = $this->getSite();
if ($Site) {
return $Site->getAttribute('name');
}
return '';
}
/**
* @param QUI\Locale|null $Locale
* @return string
*/
public function getTitle(QUI\Locale $Locale = null): string
{
$Site = $this->getSite();
if ($Site) {
return $Site->getAttribute('title');
}
return '';
}
/**
* @return string
*/
public function getUrl(): string
{
$Site = $this->getSite();
if ($Site) {
try {
return $Site->getUrlRewritten();
} catch (QUI\Exception $Exception) {
return '';
}
}
return '';
}
//endregion