From e1703495130c8ed88fe210f50a2a6b453b3c566b Mon Sep 17 00:00:00 2001 From: anuko Date: Thu, 2 Mar 2017 19:34:46 +0000 Subject: [PATCH] Some further refactoring in form classes. --- WEB-INF/lib/form/Form.class.php | 24 ++++++++++++------------ WEB-INF/lib/form/TextField.class.php | 15 ++++++++------- WEB-INF/lib/form/UploadFile.class.php | 17 +++++++++-------- WEB-INF/templates/footer.tpl | 2 +- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index 7814877f..5f825451 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -79,19 +79,19 @@ class Form { if (isset($params['format'])) $el->setFormat($params['format']); break; + case 'textarea': + import('form.TextArea'); + $el = new TextArea($params['name']); + if (isset($params['cols'])) $el->setColumns($params['cols']); + if (isset($params['rows'])) $el->setRows($params['rows']); + if (isset($params['maxlength'])) $el->setMaxLength($params['maxlength']); + break; + + case 'checkbox': + import('form.Checkbox'); + $el = new Checkbox($params['name']); // TODO: refactoring ongoing down from here. - case "textarea": - import('form.TextArea'); - $el = new TextArea($params["name"]); - $el->setColumns(@$params["cols"]); - $el->setRows(@$params["rows"]); - if (isset($params["maxlength"])) $el->setMaxLength($params["maxlength"]); - break; - - case "checkbox": - import('form.Checkbox'); - $el = new Checkbox($params["name"]); - if (@$params["checked"]) $el->setChecked(true); + if (@$params["checked"]) $el->setChecked(true); $el->setData(@$params["data"]); break; diff --git a/WEB-INF/lib/form/TextField.class.php b/WEB-INF/lib/form/TextField.class.php index 45455d0d..044b3d6d 100644 --- a/WEB-INF/lib/form/TextField.class.php +++ b/WEB-INF/lib/form/TextField.class.php @@ -27,16 +27,17 @@ // +----------------------------------------------------------------------+ import('form.FormElement'); - + class TextField extends FormElement { - function __construct($name,$value="") - { - $this->class = 'TextField'; - $this->name = $name; - $this->value = $value; - } + function __construct($name, $value = '') + { + $this->class = 'TextField'; + $this->name = $name; + $this->value = $value; + } + // TODO: refactoring ongoing down from here. function getHtml() { if (!$this->isEnabled()) { $html = "name\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n"; diff --git a/WEB-INF/lib/form/UploadFile.class.php b/WEB-INF/lib/form/UploadFile.class.php index eb24259e..cfb67120 100644 --- a/WEB-INF/lib/form/UploadFile.class.php +++ b/WEB-INF/lib/form/UploadFile.class.php @@ -29,15 +29,16 @@ import('form.FormElement'); class UploadFile extends FormElement { - var $class = 'UploadFile'; - var $mMaxSize = 100000; // 100kb + var $mMaxSize = 100000; // 100kb // TODO: refactor this. - function __construct($name,$value="") - { - $this->name = $name; - $this->value = $value; - } - + function __construct($name, $value = '') + { + $this->class = 'UploadFile'; + $this->name = $name; + $this->value = $value; + } + +// TODO: refactoring ongoing down from here. function setMaxSize($value) { $this->mMaxSize = $value; } function getMaxSize() { return $this->mMaxSize; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 9b146622..9f064307 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.10.38.3616 | Copyright © Anuko | +  Anuko Time Tracker 1.10.38.3617 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1