diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 13:17:31 +0000 |
commit | f66ab8dae2f3d0418759f81a3a64dc9517a62449 (patch) | |
tree | fbff2135e7013f196b891bbde54618eb050e4aaf /application/views/helpers/FormStoredPassword.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.tar.xz icingaweb2-module-director-f66ab8dae2f3d0418759f81a3a64dc9517a62449.zip |
Adding upstream version 1.10.2.upstream/1.10.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/views/helpers/FormStoredPassword.php')
-rw-r--r-- | application/views/helpers/FormStoredPassword.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/application/views/helpers/FormStoredPassword.php b/application/views/helpers/FormStoredPassword.php new file mode 100644 index 0000000..e25a1dc --- /dev/null +++ b/application/views/helpers/FormStoredPassword.php @@ -0,0 +1,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; + } +} |