1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2022 |
6
|
|
|
* @package MW |
7
|
|
|
* @subpackage View |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Base\View\Helper\Site; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* View helper class for easy access to site information |
16
|
|
|
* |
17
|
|
|
* @package MW |
18
|
|
|
* @subpackage View |
19
|
|
|
*/ |
20
|
|
|
class Standard extends \Aimeos\Base\View\Helper\Base implements Iface |
21
|
|
|
{ |
22
|
|
|
private $siteItem; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Initializes the view helper |
27
|
|
|
* |
28
|
|
|
* @param \Aimeos\Base\View\Iface $view View object |
29
|
|
|
*/ |
30
|
|
|
public function __construct( \Aimeos\Base\View\Iface $view ) |
31
|
|
|
{ |
32
|
|
|
parent::__construct( $view ); |
33
|
|
|
$this->siteItem = $view->pageSiteItem; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Returns the site view helper |
39
|
|
|
* |
40
|
|
|
* @return Aimeos\Base\View\Helper\Site\Iface Site view helper |
|
|
|
|
41
|
|
|
*/ |
42
|
|
|
public function transform() : \Aimeos\Base\View\Helper\Site\Iface |
43
|
|
|
{ |
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns the site label of the current site |
50
|
|
|
* |
51
|
|
|
* @return string|null Label of the site item or null if not available |
52
|
|
|
*/ |
53
|
|
|
public function label() : ?string |
54
|
|
|
{ |
55
|
|
|
return $this->siteItem->getLabel(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Returns the label of the matching site |
61
|
|
|
* |
62
|
|
|
* @param string|null $siteid ID of a site item |
63
|
|
|
* @return string|null Label of the site item or null if not found |
64
|
|
|
*/ |
65
|
|
|
public function match( string $siteid = null ) : ?string |
66
|
|
|
{ |
67
|
|
|
if( $this->siteItem->getSiteId() == $siteid ) { |
68
|
|
|
return $this->siteItem->getLabel(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return null; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns "readonly" if the item is inherited from another site |
77
|
|
|
* |
78
|
|
|
* @param string|null $siteid ID of a site item |
79
|
|
|
* @return string|null "readonly" if item is from a parent site, null if not |
80
|
|
|
*/ |
81
|
|
|
public function readonly( string $siteid = null ) : ?string |
82
|
|
|
{ |
83
|
|
|
if( $this->siteItem->getSiteId() != $siteid ) { |
84
|
|
|
return 'readonly'; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return null; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Returns the site ID of the current site |
93
|
|
|
* |
94
|
|
|
* @return string|null Site ID or null if not available |
95
|
|
|
*/ |
96
|
|
|
public function siteid() : ?string |
97
|
|
|
{ |
98
|
|
|
return $this->siteItem->getSiteId(); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|