1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
use ipl\Html\Html;
use ipl\Html\HtmlDocument;
/**
* Please see StoredPassword (the Form Element) for related documentation
*
* We're rendering the following fields:
*
* - ${name}[_value]:
* - ${name}[_sent]:
*
* Avoid complaints about class names:
* @codingStandardsIgnoreStart
*/
class Zend_View_Helper_FormStoredPassword extends Zend_View_Helper_FormElement
{
public function formStoredPassword($name, $value = null, $attribs = null)
{
// @codingStandardsIgnoreEnd
$info = $this->_getInfo($name, $value, $attribs);
\extract($info); // name, value, attribs, options, listsep, disable
$sentValue = $this->stripAttribute($attribs, 'sentValue');
$res = new HtmlDocument();
$el = Html::tag('input', [
'type' => 'password',
'name' => "${name}[_value]",
'id' => $id,
]);
$res->add($el);
$res->add(Html::tag('input', [
'type' => 'hidden',
'name' => "${name}[_sent]",
'value' => 'y'
]));
if ($sentValue !== null && \strlen($sentValue)) {
$el->getAttributes()->set('value', $sentValue);
} elseif ($value !== null && \strlen($value) > 0) {
$el->getAttributes()->set('value', '__UNCHANGED_VALUE__');
}
return $res;
}
protected function stripAttribute(&$attribs, $name, $default = null)
{
if (\array_key_exists($name, $attribs)) {
if (\strlen($attribs[$name])) {
return $attribs[$name];
}
unset($attribs[$name]);
}
return $default;
}
}
|