These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\View; |
||
3 | |||
4 | use Redaxscript\Html; |
||
5 | use Redaxscript\Model; |
||
6 | use Redaxscript\Module; |
||
7 | use Redaxscript\Validator; |
||
8 | |||
9 | /** |
||
10 | * children class to create the login form |
||
11 | * |
||
12 | * @since 3.0.0 |
||
13 | * |
||
14 | * @package Redaxscript |
||
15 | * @category View |
||
16 | * @author Henry Ruhs |
||
17 | */ |
||
18 | |||
19 | class LoginForm extends ViewAbstract |
||
20 | { |
||
21 | /** |
||
22 | * render the view |
||
23 | * |
||
24 | * @since 3.0.0 |
||
25 | * |
||
26 | * @return string |
||
27 | */ |
||
28 | |||
29 | 1 | public function render() : string |
|
30 | { |
||
31 | 1 | $output = Module\Hook::trigger('loginFormStart'); |
|
32 | 1 | $outputLegend = null; |
|
33 | 1 | $settingModel = new Model\Setting(); |
|
34 | 1 | $userValidator = new Validator\User(); |
|
35 | 1 | $passwordValidator = new Validator\Password(); |
|
36 | 1 | $parameterRoute = $this->_registry->get('parameterRoute'); |
|
37 | |||
38 | /* html element */ |
||
39 | |||
40 | 1 | $element = new Html\Element(); |
|
41 | $titleElement = $element |
||
42 | 1 | ->copy() |
|
43 | 1 | ->init('h2', |
|
44 | [ |
||
45 | 1 | 'class' => 'rs-title-content' |
|
46 | ]) |
||
47 | 1 | ->text($this->_language->get('login')); |
|
48 | 1 | if ($settingModel->get('recovery')) |
|
0 ignored issues
–
show
|
|||
49 | { |
||
50 | $linkElement = $element |
||
51 | 1 | ->copy() |
|
52 | 1 | ->init('a', |
|
53 | [ |
||
54 | 1 | 'href' => $parameterRoute . 'login/recover' |
|
55 | ]); |
||
56 | 1 | $outputLegend = $linkElement->text($this->_language->get('recovery_question') . $this->_language->get('question_mark')); |
|
57 | } |
||
58 | 1 | $formElement = new Html\Form($this->_registry, $this->_language); |
|
59 | 1 | $formElement->init( |
|
60 | [ |
||
61 | 'form' => |
||
62 | [ |
||
63 | 1 | 'class' => 'rs-js-validate rs-form-default rs-form-login' |
|
64 | ], |
||
65 | 'button' => |
||
66 | [ |
||
67 | 'submit' => |
||
68 | [ |
||
69 | 'name' => self::class |
||
70 | ] |
||
71 | ] |
||
72 | ], |
||
73 | [ |
||
74 | 1 | 'captcha' => $settingModel->get('captcha') |
|
75 | ]); |
||
76 | |||
77 | /* create the form */ |
||
78 | |||
79 | $formElement |
||
80 | 1 | ->legend($outputLegend) |
|
81 | 1 | ->append('<ul><li>') |
|
82 | 1 | ->label('* ' . $this->_language->get('user'), |
|
83 | [ |
||
84 | 1 | 'for' => 'user' |
|
85 | ]) |
||
86 | 1 | ->text( |
|
87 | [ |
||
88 | 1 | 'autofocus' => 'autofocus', |
|
89 | 1 | 'id' => 'user', |
|
90 | 1 | 'name' => 'user', |
|
91 | 1 | 'pattern' => $userValidator->getPattern(), |
|
92 | 1 | 'required' => 'required' |
|
93 | ]) |
||
94 | 1 | ->append('</li><li>') |
|
95 | 1 | ->label('* ' . $this->_language->get('password'), |
|
96 | [ |
||
97 | 1 | 'for' => 'password' |
|
98 | ]) |
||
99 | 1 | ->password( |
|
100 | [ |
||
101 | 1 | 'id' => 'password', |
|
102 | 1 | 'name' => 'password', |
|
103 | 1 | 'pattern' => $passwordValidator->getPattern(), |
|
104 | 1 | 'required' => 'required' |
|
105 | ]) |
||
106 | 1 | ->append('</li>'); |
|
107 | 1 | if ($settingModel->get('captcha') > 0) |
|
108 | { |
||
109 | $formElement |
||
110 | 1 | ->append('<li>') |
|
111 | 1 | ->captcha('task') |
|
112 | 1 | ->append('</li>'); |
|
113 | } |
||
114 | 1 | $formElement->append('</ul>'); |
|
115 | 1 | if ($settingModel->get('captcha') > 0) |
|
116 | { |
||
117 | 1 | $formElement->captcha('solution'); |
|
118 | } |
||
119 | $formElement |
||
120 | 1 | ->token() |
|
121 | 1 | ->submit(); |
|
122 | |||
123 | /* collect output */ |
||
124 | |||
125 | 1 | $output .= $titleElement . $formElement; |
|
126 | 1 | $output .= Module\Hook::trigger('loginFormEnd'); |
|
127 | 1 | return $output; |
|
128 | } |
||
129 | } |
||
130 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: