|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2022 |
|
6
|
|
|
* @package Client |
|
7
|
|
|
* @subpackage Html |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\Client\Html\Account\Basket; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Default implementation of account basket HTML client. |
|
16
|
|
|
* |
|
17
|
|
|
* @package Client |
|
18
|
|
|
* @subpackage Html |
|
19
|
|
|
*/ |
|
20
|
|
|
class Standard |
|
21
|
|
|
extends \Aimeos\Client\Html\Base |
|
22
|
|
|
implements \Aimeos\Client\Html\Iface |
|
23
|
|
|
{ |
|
24
|
|
|
/** client/html/account/basket/name |
|
25
|
|
|
* Class name of the used account basket client implementation |
|
26
|
|
|
* |
|
27
|
|
|
* Each default HTML client can be replace by an alternative imlementation. |
|
28
|
|
|
* To use this implementation, you have to set the last part of the class |
|
29
|
|
|
* name as configuration value so the client factory knows which class it |
|
30
|
|
|
* has to instantiate. |
|
31
|
|
|
* |
|
32
|
|
|
* For example, if the name of the default class is |
|
33
|
|
|
* |
|
34
|
|
|
* \Aimeos\Client\Html\Account\Basket\Standard |
|
35
|
|
|
* |
|
36
|
|
|
* and you want to replace it with your own version named |
|
37
|
|
|
* |
|
38
|
|
|
* \Aimeos\Client\Html\Account\Basket\Mybasket |
|
39
|
|
|
* |
|
40
|
|
|
* then you have to set the this configuration option: |
|
41
|
|
|
* |
|
42
|
|
|
* client/html/account/basket/name = Mybasket |
|
43
|
|
|
* |
|
44
|
|
|
* The value is the last part of your own class name and it's case sensitive, |
|
45
|
|
|
* so take care that the configuration value is exactly named like the last |
|
46
|
|
|
* part of the class name. |
|
47
|
|
|
* |
|
48
|
|
|
* The allowed characters of the class name are A-Z, a-z and 0-9. No other |
|
49
|
|
|
* characters are possible! You should always start the last part of the class |
|
50
|
|
|
* name with an upper case character and continue only with lower case characters |
|
51
|
|
|
* or numbers. Avoid chamel case names like "MyBasket"! |
|
52
|
|
|
* |
|
53
|
|
|
* @param string Last part of the class name |
|
54
|
|
|
* @since 2022.10 |
|
55
|
|
|
*/ |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Processes the input, e.g. store given values. |
|
60
|
|
|
* |
|
61
|
|
|
* A view must be available and this method doesn't generate any output |
|
62
|
|
|
* besides setting view variables if necessary. |
|
63
|
|
|
*/ |
|
64
|
|
|
public function init() |
|
65
|
|
|
{ |
|
66
|
|
|
$view = $this->view(); |
|
67
|
|
|
|
|
68
|
|
|
if( ( $id = $view->param( 'bas_id' ) ) != null && $view->param( 'bas_action' ) === 'delete' ) |
|
69
|
|
|
{ |
|
70
|
|
|
$manager = \Aimeos\MShop::create( $this->context(), 'order/basket' ); |
|
71
|
|
|
$filter = $manager->filter( true )->add( 'order.basket.id', '==', $id ); |
|
72
|
|
|
$manager->delete( $manager->search( $filter ) ); |
|
73
|
|
|
|
|
74
|
|
|
$msg = $view->translate( 'client', 'Saved basket removed sucessfully' ); |
|
75
|
|
|
$view->infos = array_merge( $view->get( 'infos', [] ), [$msg] ); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Sets the necessary parameter values in the view. |
|
82
|
|
|
* |
|
83
|
|
|
* @param \Aimeos\Base\View\Iface $view The view object which generates the HTML output |
|
84
|
|
|
* @param array &$tags Result array for the list of tags that are associated to the output |
|
85
|
|
|
* @param string|null &$expire Result variable for the expiration date of the output (null for no expiry) |
|
86
|
|
|
* @return \Aimeos\Base\View\Iface Modified view object |
|
87
|
|
|
*/ |
|
88
|
|
|
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface |
|
89
|
|
|
{ |
|
90
|
|
|
$context = $this->context(); |
|
91
|
|
|
$manager = \Aimeos\MShop::create( $context, 'order/basket' ); |
|
92
|
|
|
$filter = $manager->filter()->order( '-order.basket.mtime' ) |
|
93
|
|
|
->add( 'order.basket.customerid', '==', $context->user() ) |
|
94
|
|
|
->add( 'order.basket.name', '!=', '' ); |
|
95
|
|
|
|
|
96
|
|
|
$view->basketItems = $manager->search( $filter ); |
|
97
|
|
|
|
|
98
|
|
|
return parent::data( $view, $tags, $expire ); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
|
|
102
|
|
|
/** client/html/account/basket/template-body |
|
103
|
|
|
* Relative path to the HTML body template of the account basket client. |
|
104
|
|
|
* |
|
105
|
|
|
* The template file contains the HTML code and processing instructions |
|
106
|
|
|
* to generate the result shown in the body of the frontend. The |
|
107
|
|
|
* configuration string is the path to the template file relative |
|
108
|
|
|
* to the templates directory (usually in client/html/templates). |
|
109
|
|
|
* |
|
110
|
|
|
* You can overwrite the template file configuration in extensions and |
|
111
|
|
|
* provide alternative templates. These alternative templates should be |
|
112
|
|
|
* named like the default one but suffixed by |
|
113
|
|
|
* an unique name. You may use the name of your project for this. If |
|
114
|
|
|
* you've implemented an alternative client class as well, it |
|
115
|
|
|
* should be suffixed by the name of the new class. |
|
116
|
|
|
* |
|
117
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
|
118
|
|
|
* @since 2022.10 |
|
119
|
|
|
* @see client/html/account/basket/template-header |
|
120
|
|
|
*/ |
|
121
|
|
|
|
|
122
|
|
|
/** client/html/account/basket/template-header |
|
123
|
|
|
* Relative path to the HTML header template of the account basket client. |
|
124
|
|
|
* |
|
125
|
|
|
* The template file contains the HTML code and processing instructions |
|
126
|
|
|
* to generate the HTML code that is inserted into the HTML page header |
|
127
|
|
|
* of the rendered page in the frontend. The configuration string is the |
|
128
|
|
|
* path to the template file relative to the templates directory (usually |
|
129
|
|
|
* in client/html/templates). |
|
130
|
|
|
* |
|
131
|
|
|
* You can overwrite the template file configuration in extensions and |
|
132
|
|
|
* provide alternative templates. These alternative templates should be |
|
133
|
|
|
* named like the default one but suffixed by |
|
134
|
|
|
* an unique name. You may use the name of your project for this. If |
|
135
|
|
|
* you've implemented an alternative client class as well, it |
|
136
|
|
|
* should be suffixed by the name of the new class. |
|
137
|
|
|
* |
|
138
|
|
|
* @param string Relative path to the template creating code for the HTML page head |
|
139
|
|
|
* @since 2022.10 |
|
140
|
|
|
* @see client/html/account/basket/template-body |
|
141
|
|
|
*/ |
|
142
|
|
|
} |
|
143
|
|
|
|