|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2021 |
|
6
|
|
|
* @package Client |
|
7
|
|
|
* @subpackage Html |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Account\Subscription\Detail; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Default implementation of acount subscription detail HTML client. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Client |
|
18
|
|
|
* @subpackage Html |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Client\Html\Common\Client\Summary\Base |
|
22
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** client/html/account/subscription/detail/subparts |
|
25
|
|
|
* List of HTML sub-clients rendered within the account subscription detail section |
|
26
|
|
|
* |
|
27
|
|
|
* The output of the frontend is composed of the code generated by the HTML |
|
28
|
|
|
* clients. Each HTML client can consist of serveral (or none) sub-clients |
|
29
|
|
|
* that are responsible for rendering certain sub-parts of the output. The |
|
30
|
|
|
* sub-clients can contain HTML clients themselves and therefore a |
|
31
|
|
|
* hierarchical tree of HTML clients is composed. Each HTML client creates |
|
32
|
|
|
* the output that is placed inside the container of its parent. |
|
33
|
|
|
* |
|
34
|
|
|
* At first, always the HTML code generated by the parent is printed, then |
|
35
|
|
|
* the HTML code of its sub-clients. The detail of the HTML sub-clients |
|
36
|
|
|
* determines the detail of the output of these sub-clients inside the parent |
|
37
|
|
|
* container. If the configured list of clients is |
|
38
|
|
|
* |
|
39
|
|
|
* array( "subclient1", "subclient2" ) |
|
40
|
|
|
* |
|
41
|
|
|
* you can easily change the detail of the output by redetailing the subparts: |
|
42
|
|
|
* |
|
43
|
|
|
* client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
44
|
|
|
* |
|
45
|
|
|
* You can also remove one or more parts if they shouldn't be rendered: |
|
46
|
|
|
* |
|
47
|
|
|
* client/html/<clients>/subparts = array( "subclient1" ) |
|
48
|
|
|
* |
|
49
|
|
|
* As the clients only generates structural HTML, the layout defined via CSS |
|
50
|
|
|
* should support adding, removing or redetailing content by a fluid like |
|
51
|
|
|
* design. |
|
52
|
|
|
* |
|
53
|
|
|
* @param array List of sub-client names |
|
54
|
|
|
* @since 2018.04 |
|
55
|
|
|
* @category Developer |
|
56
|
|
|
*/ |
|
57
|
|
|
private $subPartPath = 'client/html/account/subscription/detail/subparts'; |
|
58
|
|
|
private $subPartNames = []; |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Returns the HTML code for insertion into the body. |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
65
|
|
|
* @return string HTML code |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getBody( string $uid = '' ) : string |
|
68
|
|
|
{ |
|
69
|
|
|
$view = $this->getView(); |
|
70
|
|
|
|
|
71
|
|
|
if( $view->param( 'sub_action' ) != 'detail' ) { |
|
72
|
|
|
return ''; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
$html = ''; |
|
76
|
|
|
foreach( $this->getSubClients() as $subclient ) { |
|
77
|
|
|
$html .= $subclient->setView( $view )->getBody( $uid ); |
|
78
|
|
|
} |
|
79
|
|
|
$view->detailBody = $html; |
|
80
|
|
|
|
|
81
|
|
|
/** client/html/account/subscription/detail/template-body |
|
82
|
|
|
* Relative path to the HTML body template of the account subscription detail client. |
|
83
|
|
|
* |
|
84
|
|
|
* The template file contains the HTML code and processing instructions |
|
85
|
|
|
* to generate the result shown in the body of the frontend. The |
|
86
|
|
|
* configuration string is the path to the template file relative |
|
87
|
|
|
* to the templates directory (usually in client/html/templates). |
|
88
|
|
|
* |
|
89
|
|
|
* You can overwrite the template file configuration in extensions and |
|
90
|
|
|
* provide alternative templates. These alternative templates should be |
|
91
|
|
|
* named like the default one but with the string "standard" replaced by |
|
92
|
|
|
* an unique name. You may use the name of your project for this. If |
|
93
|
|
|
* you've implemented an alternative client class as well, "standard" |
|
94
|
|
|
* should be replaced by the name of the new class. |
|
95
|
|
|
* |
|
96
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
|
97
|
|
|
* @since 2018.04 |
|
98
|
|
|
* @category Developer |
|
99
|
|
|
* @see client/html/account/subscription/detail/template-header |
|
100
|
|
|
*/ |
|
101
|
|
|
$tplconf = 'client/html/account/subscription/detail/template-body'; |
|
102
|
|
|
$default = 'account/subscription/detail-body-standard'; |
|
103
|
|
|
|
|
104
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Returns the sub-client given by its name. |
|
110
|
|
|
* |
|
111
|
|
|
* @param string $type Name of the client type |
|
112
|
|
|
* @param string|null $name Name of the sub-client (Default if null) |
|
113
|
|
|
* @return \Aimeos\Client\Html\Iface Sub-client object |
|
114
|
|
|
*/ |
|
115
|
|
|
public function getSubClient( string $type, string $name = null ) : \Aimeos\Client\Html\Iface |
|
116
|
|
|
{ |
|
117
|
|
|
/** client/html/account/subscription/detail/decorators/excludes |
|
118
|
|
|
* Excludes decorators added by the "common" option from the account subscription detail html client |
|
119
|
|
|
* |
|
120
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
121
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
122
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
123
|
|
|
* modify what is returned to the caller. |
|
124
|
|
|
* |
|
125
|
|
|
* This option allows you to remove a decorator added via |
|
126
|
|
|
* "client/html/common/decorators/default" before they are wrapped |
|
127
|
|
|
* around the html client. |
|
128
|
|
|
* |
|
129
|
|
|
* client/html/account/subscription/detail/decorators/excludes = array( 'decorator1' ) |
|
130
|
|
|
* |
|
131
|
|
|
* This would remove the decorator named "decorator1" from the list of |
|
132
|
|
|
* common decorators ("\Aimeos\Client\Html\Common\Decorator\*") added via |
|
133
|
|
|
* "client/html/common/decorators/default" to the html client. |
|
134
|
|
|
* |
|
135
|
|
|
* @param array List of decorator names |
|
136
|
|
|
* @since 2018.04 |
|
137
|
|
|
* @category Developer |
|
138
|
|
|
* @see client/html/common/decorators/default |
|
139
|
|
|
* @see client/html/account/subscription/detail/decorators/global |
|
140
|
|
|
* @see client/html/account/subscription/detail/decorators/local |
|
141
|
|
|
*/ |
|
142
|
|
|
|
|
143
|
|
|
/** client/html/account/subscription/detail/decorators/global |
|
144
|
|
|
* Adds a list of globally available decorators only to the account subscription detail html client |
|
145
|
|
|
* |
|
146
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
147
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
148
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
149
|
|
|
* modify what is returned to the caller. |
|
150
|
|
|
* |
|
151
|
|
|
* This option allows you to wrap global decorators |
|
152
|
|
|
* ("\Aimeos\Client\Html\Common\Decorator\*") around the html client. |
|
153
|
|
|
* |
|
154
|
|
|
* client/html/account/subscription/detail/decorators/global = array( 'decorator1' ) |
|
155
|
|
|
* |
|
156
|
|
|
* This would add the decorator named "decorator1" defined by |
|
157
|
|
|
* "\Aimeos\Client\Html\Common\Decorator\Decorator1" only to the html client. |
|
158
|
|
|
* |
|
159
|
|
|
* @param array List of decorator names |
|
160
|
|
|
* @since 2018.04 |
|
161
|
|
|
* @category Developer |
|
162
|
|
|
* @see client/html/common/decorators/default |
|
163
|
|
|
* @see client/html/account/subscription/detail/decorators/excludes |
|
164
|
|
|
* @see client/html/account/subscription/detail/decorators/local |
|
165
|
|
|
*/ |
|
166
|
|
|
|
|
167
|
|
|
/** client/html/account/subscription/detail/decorators/local |
|
168
|
|
|
* Adds a list of local decorators only to the account subscription detail html client |
|
169
|
|
|
* |
|
170
|
|
|
* Decorators extend the functionality of a class by adding new aspects |
|
171
|
|
|
* (e.g. log what is currently done), executing the methods of the underlying |
|
172
|
|
|
* class only in certain conditions (e.g. only for logged in users) or |
|
173
|
|
|
* modify what is returned to the caller. |
|
174
|
|
|
* |
|
175
|
|
|
* This option allows you to wrap local decorators |
|
176
|
|
|
* ("\Aimeos\Client\Html\Account\Decorator\*") around the html client. |
|
177
|
|
|
* |
|
178
|
|
|
* client/html/account/subscription/detail/decorators/local = array( 'decorator2' ) |
|
179
|
|
|
* |
|
180
|
|
|
* This would add the decorator named "decorator2" defined by |
|
181
|
|
|
* "\Aimeos\Client\Html\Account\Decorator\Decorator2" only to the html client. |
|
182
|
|
|
* |
|
183
|
|
|
* @param array List of decorator names |
|
184
|
|
|
* @since 2018.04 |
|
185
|
|
|
* @category Developer |
|
186
|
|
|
* @see client/html/common/decorators/default |
|
187
|
|
|
* @see client/html/account/subscription/detail/decorators/excludes |
|
188
|
|
|
* @see client/html/account/subscription/detail/decorators/global |
|
189
|
|
|
*/ |
|
190
|
|
|
|
|
191
|
|
|
return $this->createSubClient( 'account/subscription/detail/' . $type, $name ); |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* Returns the list of sub-client names configured for the client. |
|
197
|
|
|
* |
|
198
|
|
|
* @return array List of HTML client names |
|
199
|
|
|
*/ |
|
200
|
|
|
protected function getSubClientNames() : array |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->getContext()->getConfig()->get( $this->subPartPath, $this->subPartNames ); |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Sets the necessary parameter values in the view. |
|
208
|
|
|
* |
|
209
|
|
|
* @param \Aimeos\MW\View\Iface $view The view object which generates the HTML output |
|
210
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
|
211
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
212
|
|
|
* @return \Aimeos\MW\View\Iface Modified view object |
|
213
|
|
|
*/ |
|
214
|
|
|
public function addData( \Aimeos\MW\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\MW\View\Iface |
|
215
|
|
|
{ |
|
216
|
|
|
if( ( $id = $view->param( 'sub_id' ) ) != null ) |
|
217
|
|
|
{ |
|
218
|
|
|
$context = $this->getContext(); |
|
219
|
|
|
$item = \Aimeos\Controller\Frontend::create( $context, 'subscription' )->get( $id ); |
|
220
|
|
|
|
|
221
|
|
|
$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT | \Aimeos\MShop\Order\Item\Base\Base::PARTS_ADDRESS; |
|
222
|
|
|
$basket = \Aimeos\Controller\Frontend::create( $context, 'basket' )->load( $item->getOrderBaseId(), $parts ); |
|
223
|
|
|
|
|
224
|
|
|
foreach( $basket->getProducts() as $pos => $orderProduct ) |
|
225
|
|
|
{ |
|
226
|
|
|
if( $orderProduct->getId() != $item->getOrderProductId() ) { |
|
227
|
|
|
$basket->deleteProduct( $pos ); |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
$view->detailItem = $item; |
|
232
|
|
|
$view->summaryBasket = $basket; |
|
233
|
|
|
$view->summaryTaxRates = $this->getTaxRates( $basket ); |
|
234
|
|
|
$view->summaryNamedTaxes = $this->getNamedTaxes( $basket ); |
|
235
|
|
|
$view->summaryCostsDelivery = $this->getCostsDelivery( $basket ); |
|
236
|
|
|
$view->summaryCostsPayment = $this->getCostsPayment( $basket ); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
return parent::addData( $view, $tags, $expire ); |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|