1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2014 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2021 |
7
|
|
|
* @package Client |
8
|
|
|
* @subpackage Html |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Aimeos\Client\Html\Common\Decorator; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Provides common methods for html client decorators. |
17
|
|
|
* |
18
|
|
|
* @package Client |
19
|
|
|
* @subpackage Html |
20
|
|
|
*/ |
21
|
|
|
abstract class Base |
22
|
|
|
extends \Aimeos\Client\Html\Base |
23
|
|
|
implements \Aimeos\Client\Html\Common\Decorator\Iface |
24
|
|
|
{ |
25
|
|
|
private $client; |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Initializes a new client decorator object. |
30
|
|
|
* |
31
|
|
|
* @param \Aimeos\Client\Html\Iface $client Client object |
32
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
33
|
|
|
*/ |
34
|
|
|
public function __construct( \Aimeos\Client\Html\Iface $client, \Aimeos\MShop\Context\Item\Iface $context ) |
35
|
|
|
{ |
36
|
|
|
parent::__construct( $context ); |
37
|
|
|
|
38
|
|
|
$this->client = $client; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Passes unknown methods to wrapped objects. |
44
|
|
|
* |
45
|
|
|
* @param string $name Name of the method |
46
|
|
|
* @param array $param List of method parameter |
47
|
|
|
* @return mixed Returns the value of the called method |
48
|
|
|
* @throws \Aimeos\Client\Html\Exception If method call failed |
49
|
|
|
*/ |
50
|
|
|
public function __call( string $name, array $param ) |
51
|
|
|
{ |
52
|
|
|
return @call_user_func_array( array( $this->client, $name ), $param ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Adds the data to the view object required by the templates |
58
|
|
|
* |
59
|
|
|
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
60
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
61
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
62
|
|
|
* @return \Aimeos\MW\View\Iface The view object with the data required by the templates |
63
|
|
|
* @since 2018.01 |
64
|
|
|
*/ |
65
|
|
|
public function data( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
66
|
|
|
{ |
67
|
|
|
return $this->client->data( $view, $tags, $expire ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Returns the sub-client given by its name. |
73
|
|
|
* |
74
|
|
|
* @param string $type Name of the client type |
75
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
76
|
|
|
* @return \Aimeos\Client\Html\Iface Sub-client object |
77
|
|
|
*/ |
78
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface |
79
|
|
|
{ |
80
|
|
|
return $this->client->getSubClient( $type, $name ); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Returns the HTML string for insertion into the header. |
86
|
|
|
* |
87
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
88
|
|
|
* @return string|null String including HTML tags for the header on error |
89
|
|
|
*/ |
90
|
|
|
public function header( string $uid = '' ) : ?string |
91
|
|
|
{ |
92
|
|
|
return $this->client->header( $uid ); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Returns the HTML code for insertion into the body. |
98
|
|
|
* |
99
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
100
|
|
|
* @return string HTML code |
101
|
|
|
*/ |
102
|
|
|
public function body( string $uid = '' ) : string |
103
|
|
|
{ |
104
|
|
|
return $this->client->body( $uid ); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Returns the view object that will generate the HTML output. |
110
|
|
|
* |
111
|
|
|
* @return \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
112
|
|
|
*/ |
113
|
|
|
public function view() : \Aimeos\MW\View\Iface |
114
|
|
|
{ |
115
|
|
|
return $this->client->view(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Sets the view object that will generate the HTML output. |
121
|
|
|
* |
122
|
|
|
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
123
|
|
|
* @return \Aimeos\Client\Html\Iface Reference to this object for fluent calls |
124
|
|
|
*/ |
125
|
|
|
public function setView( \Aimeos\MW\View\Iface $view ) : \Aimeos\Client\Html\Iface |
126
|
|
|
{ |
127
|
|
|
$this->client->setView( $view ); |
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Modifies the cached body content to replace content based on sessions or cookies. |
134
|
|
|
* |
135
|
|
|
* @param string $content Cached content |
136
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
137
|
|
|
* @return string Modified body content |
138
|
|
|
*/ |
139
|
|
|
public function modifyBody( string $content, string $uid ) : string |
140
|
|
|
{ |
141
|
|
|
return $this->client->modifyBody( $content, $uid ); |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Modifies the cached header content to replace content based on sessions or cookies. |
147
|
|
|
* |
148
|
|
|
* @param string $content Cached content |
149
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
150
|
|
|
* @return string Modified header content |
151
|
|
|
*/ |
152
|
|
|
public function modifyHeader( string $content, string $uid ) : string |
153
|
|
|
{ |
154
|
|
|
return $this->client->modifyHeader( $content, $uid ); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* Processes the input, e.g. store given values. |
160
|
|
|
* |
161
|
|
|
* A view must be available and this method doesn't generate any output |
162
|
|
|
* besides setting view variables. |
163
|
|
|
*/ |
164
|
|
|
public function init() |
165
|
|
|
{ |
166
|
|
|
return $this->client->init(); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Injects the reference of the outmost client object or decorator |
172
|
|
|
* |
173
|
|
|
* @param \Aimeos\Client\Html\Iface $object Reference to the outmost client or decorator |
174
|
|
|
* @return \Aimeos\Client\Html\Iface Client object for chaining method calls |
175
|
|
|
*/ |
176
|
|
|
public function setObject( \Aimeos\Client\Html\Iface $object ) : \Aimeos\Client\Html\Iface |
177
|
|
|
{ |
178
|
|
|
parent::setObject( $object ); |
179
|
|
|
|
180
|
|
|
$this->client->setObject( $object ); |
181
|
|
|
|
182
|
|
|
return $this; |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* Returns the inner client object |
188
|
|
|
* |
189
|
|
|
* @return \Aimeos\Client\Html\Iface HTML client |
190
|
|
|
*/ |
191
|
|
|
protected function getClient() |
192
|
|
|
{ |
193
|
|
|
return $this->client; |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Returns the list of sub-client names configured for the client. |
199
|
|
|
* |
200
|
|
|
* @return array List of HTML client names |
201
|
|
|
*/ |
202
|
|
|
protected function getSubClientNames() : array |
203
|
|
|
{ |
204
|
|
|
return []; |
205
|
|
|
} |
206
|
|
|
} |
207
|
|
|
|