From 60d2288b7fca6caf0f5d9d3eee972f040eb24fb0 Mon Sep 17 00:00:00 2001 From: anuko Date: Wed, 1 Mar 2017 21:42:08 +0000 Subject: [PATCH] Introduced PasswordField.class.php to keep things simple. --- WEB-INF/lib/form/Form.class.php | 6 +++ WEB-INF/lib/form/PasswordField.class.php | 63 ++++++++++++++++++++++++ WEB-INF/lib/form/TextField.class.php | 3 +- WEB-INF/templates/footer.tpl | 2 +- login.php | 2 +- 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 WEB-INF/lib/form/PasswordField.class.php diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index f8a32ec5..868a3b3c 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -62,6 +62,12 @@ class Form { if (isset($arguments['aspassword'])) $el->setAsPassword($arguments['aspassword']); break; + case 'password': + import('form.PasswordField'); + $el = new PasswordField($arguments['name']); + $el->setMaxLength(@$arguments['maxlength']); + break; + // TODO: refactoring ongoing down from here. // aspassword - change this name to something better? Perhaps. // Change $arguments to something better too (maybe). $args or $params? diff --git a/WEB-INF/lib/form/PasswordField.class.php b/WEB-INF/lib/form/PasswordField.class.php new file mode 100644 index 00000000..7fd6624e --- /dev/null +++ b/WEB-INF/lib/form/PasswordField.class.php @@ -0,0 +1,63 @@ +class = 'PasswordField'; + $this->name = $name; + $this->value = $value; + } + + function getHtml() { + if ($this->id == '') $this->id = $this->name; + + $html = "\n\tid.'"'; + $html.= ' name="'.$this->name.'"'; + + if ($this->size != '') + $html.= ' size="'.$this->size.'"'; + + if ($this->style != '') + $html.= ' style="'.$this->style.'"'; + + if ($this->max_length != '') + $html.= ' maxlength="'.$this->max_length.'"'; + + if ($this->on_change != '') + $html.= ' onchange="'.$this->on_change.'"'; + + $html.= ' value="'.htmlspecialchars($this->getValue()).'"'; + $html.= '>'; + return $html; + } +} diff --git a/WEB-INF/lib/form/TextField.class.php b/WEB-INF/lib/form/TextField.class.php index c9ffaaed..b4b1c5d6 100644 --- a/WEB-INF/lib/form/TextField.class.php +++ b/WEB-INF/lib/form/TextField.class.php @@ -30,10 +30,11 @@ import('form.FormElement'); class TextField extends FormElement { var $mPassword = false; - var $class = 'TextField'; + //var $class = 'TextField'; function __construct($name,$value="") { + $this->class = 'TextField'; $this->name = $name; $this->value = $value; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 635abc3a..69c06a38 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.10.38.3613 | Copyright © Anuko | +  Anuko Time Tracker 1.10.38.3614 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/login.php b/login.php index d578ae94..b0c583fa 100644 --- a/login.php +++ b/login.php @@ -38,7 +38,7 @@ if ($cl_login == null && $request->getMethod() == 'GET') $form = new Form('loginForm'); $form->addInput(array('type'=>'text','size'=>'25','maxlength'=>'100','name'=>'login','style'=>'width: 220px;','value'=>$cl_login)); -$form->addInput(array('type'=>'text','size'=>'25','maxlength'=>'50','name'=>'password','style'=>'width: 220px;','aspassword'=>true,'value'=>$cl_password)); +$form->addInput(array('type'=>'password','size'=>'25','maxlength'=>'50','name'=>'password','style'=>'width: 220px;','value'=>$cl_password)); $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_login click. $form->addInput(array('type'=>'submit','name'=>'btn_login','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.login'))); -- 2.20.1