|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Aimeos\Client\Html\Account\Profile\Account; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Log; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Default implementation of acount profile address HTML client. |
|
9
|
|
|
* |
|
10
|
|
|
* @package Client |
|
11
|
|
|
* @subpackage Html |
|
12
|
|
|
*/ |
|
13
|
|
|
class Standard |
|
14
|
|
|
extends \Aimeos\Client\Html\Common\Client\Summary\Base |
|
15
|
|
|
implements \Aimeos\Client\Html\Common\Client\Factory\Iface |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** client/html/account/profile/address/subparts |
|
19
|
|
|
* List of HTML sub-clients rendered within the account profile address section |
|
20
|
|
|
* |
|
21
|
|
|
* The output of the frontend is composed of the code generated by the HTML |
|
22
|
|
|
* clients. Each HTML client can consist of serveral (or none) sub-clients |
|
23
|
|
|
* that are responsible for rendering certain sub-parts of the output. The |
|
24
|
|
|
* sub-clients can contain HTML clients themselves and therefore a |
|
25
|
|
|
* hierarchical tree of HTML clients is composed. Each HTML client creates |
|
26
|
|
|
* the output that is placed inside the container of its parent. |
|
27
|
|
|
* |
|
28
|
|
|
* At first, always the HTML code generated by the parent is printed, then |
|
29
|
|
|
* the HTML code of its sub-clients. The address of the HTML sub-clients |
|
30
|
|
|
* determines the address of the output of these sub-clients inside the parent |
|
31
|
|
|
* container. If the configured list of clients is |
|
32
|
|
|
* |
|
33
|
|
|
* array( "subclient1", "subclient2" ) |
|
34
|
|
|
* |
|
35
|
|
|
* you can easily change the address of the output by readdressing the subparts: |
|
36
|
|
|
* |
|
37
|
|
|
* client/html/<clients>/subparts = array( "subclient1", "subclient2" ) |
|
38
|
|
|
* |
|
39
|
|
|
* You can also remove one or more parts if they shouldn't be rendered: |
|
40
|
|
|
* |
|
41
|
|
|
* client/html/<clients>/subparts = array( "subclient1" ) |
|
42
|
|
|
* |
|
43
|
|
|
* As the clients only generates structural HTML, the layout defined via CSS |
|
44
|
|
|
* should support adding, removing or readdressing content by a fluid like |
|
45
|
|
|
* design. |
|
46
|
|
|
* |
|
47
|
|
|
* @param array List of sub-client names |
|
48
|
|
|
* @since 2019.07 |
|
49
|
|
|
* @category Developer |
|
50
|
|
|
*/ |
|
51
|
|
|
private $subPartPath = 'client/html/account/profile/account/subparts'; |
|
|
|
|
|
|
52
|
|
|
private $subPartNames = []; |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
protected function getSubClientNames(): array |
|
55
|
|
|
{ |
|
56
|
|
|
return []; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function getSubClient(string $type, string $name = null): \Aimeos\Client\Html\Iface |
|
60
|
|
|
{ |
|
61
|
|
|
// TODO: Implement getSubClient() method. |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Returns the HTML code for insertion into the body. |
|
66
|
|
|
* |
|
67
|
|
|
* @param string $uid Unique identifier for the output if the content is placed more than once on the same page |
|
68
|
|
|
* @return string HTML code |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getBody(string $uid = ''): string |
|
71
|
|
|
{ |
|
72
|
|
|
$view = $this->getView(); |
|
73
|
|
|
|
|
74
|
|
|
$html = ''; |
|
75
|
|
|
foreach( $this->getSubClients() as $subclient ) { |
|
76
|
|
|
$html .= $subclient->setView( $view )->getBody( $uid ); |
|
77
|
|
|
} |
|
78
|
|
|
$view->addressBody = $html; |
|
79
|
|
|
|
|
80
|
|
|
/** client/html/account/profile/address/template-body |
|
81
|
|
|
* Relative path to the HTML body template of the account profile address client. |
|
82
|
|
|
* |
|
83
|
|
|
* The template file contains the HTML code and processing instructions |
|
84
|
|
|
* to generate the result shown in the body of the frontend. The |
|
85
|
|
|
* configuration string is the path to the template file relative |
|
86
|
|
|
* to the templates directory (usually in client/html/templates). |
|
87
|
|
|
* |
|
88
|
|
|
* You can overwrite the template file configuration in extensions and |
|
89
|
|
|
* provide alternative templates. These alternative templates should be |
|
90
|
|
|
* named like the default one but with the string "standard" replaced by |
|
91
|
|
|
* an unique name. You may use the name of your project for this. If |
|
92
|
|
|
* you've implemented an alternative client class as well, "standard" |
|
93
|
|
|
* should be replaced by the name of the new class. |
|
94
|
|
|
* |
|
95
|
|
|
* @param string Relative path to the template creating code for the HTML page body |
|
96
|
|
|
* @since 2019.07 |
|
97
|
|
|
* @category Developer |
|
98
|
|
|
* @see client/html/account/profile/address/template-header |
|
99
|
|
|
*/ |
|
100
|
|
|
$tplconf = 'client/html/account/profile/account/template-body'; |
|
101
|
|
|
$default = 'account/profile/account-body-standard'; |
|
102
|
|
|
|
|
103
|
|
|
return $view->render( $view->config( $tplconf, $default ) ); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* Processes the input, e.g. store given values. |
|
108
|
|
|
* |
|
109
|
|
|
* A view must be available and this method doesn't generate any output |
|
110
|
|
|
* besides setting view variables if necessary. |
|
111
|
|
|
*/ |
|
112
|
|
|
public function process() |
|
113
|
|
|
{ |
|
114
|
|
|
$view = $this->getView(); |
|
115
|
|
|
|
|
116
|
|
|
if( !$view->param( 'account/save' ) ) { |
|
117
|
|
|
return parent::process(); |
|
|
|
|
|
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
/** @var \Aimeos\Controller\Frontend\Customer\Standard $cntl */ |
|
121
|
|
|
$cntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'customer' ); |
|
122
|
|
|
$oldPassword = $cntl->get()->getPassword(); |
|
123
|
|
|
$values = $view->param('account', []); |
|
124
|
|
|
|
|
125
|
|
|
$isNew = $values['customer.newpassword'] !== $values['customer.oldpassword']; |
|
126
|
|
|
$confirmed = $values['customer.newpassword'] === $values['customer.confirmnewpassword']; |
|
127
|
|
|
|
|
128
|
|
|
$errors = []; |
|
129
|
|
|
|
|
130
|
|
|
if (!$isNew) { |
|
131
|
|
|
$errors['isNew'] = "The given password is not new!"; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
if (!$confirmed) { |
|
135
|
|
|
$errors["confirm"] = "New passwords doesnt match!"; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
$cntl = $cntl->add($values); |
|
139
|
|
|
|
|
140
|
|
|
if ( $oldPassword === $cntl->get()->getPassword() ) { |
|
141
|
|
|
$errors['oldPassword'] = "Wrong password!"; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
$view->passwordChanged = count(array_keys($errors)) === 0; |
|
145
|
|
|
|
|
146
|
|
|
if (count(array_keys($errors)) > 0) { |
|
147
|
|
|
$view->passwordErrors = $errors; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
$cntl->store(); |
|
151
|
|
|
|
|
152
|
|
|
parent::process(); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths