From 741660d57d2e740b472c10a9763d535a74cff09c Mon Sep 17 00:00:00 2001 From: anuko Date: Sun, 7 Jan 2018 19:08:10 +0000 Subject: [PATCH] A bit of refactoring. --- WEB-INF/lib/form/Form.class.php | 22 +++++++++--------- WEB-INF/lib/form/Submit.class.php | 37 ++++++++++++------------------- WEB-INF/templates/footer.tpl | 2 +- 3 files changed, 26 insertions(+), 35 deletions(-) diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index cb2f5203..a67c0c37 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -87,6 +87,16 @@ class Form { $el = new Checkbox($params['name']); break; + case 'hidden': + import('form.Hidden'); + $el = new Hidden($params['name']); + break; + + case 'submit': + import('form.Submit'); + $el = new Submit($params['name']); + break; + // TODO: refactoring ongoing down from here. case "checkboxgroup": import('form.CheckboxGroup'); @@ -104,17 +114,7 @@ class Form { $el->setDataDefault(@$params["empty"]); if (isset($params["datakeys"])) $el->setDataKeys($params["datakeys"]); break; - - case "hidden": - import('form.Hidden'); - $el = new Hidden($params["name"]); - break; - - case "submit": - import('form.Submit'); - $el = new Submit($params["name"]); - break; - + case "calendar": import('form.Calendar'); $el = new Calendar($params["name"]); diff --git a/WEB-INF/lib/form/Submit.class.php b/WEB-INF/lib/form/Submit.class.php index 35eb6df3..5f8da37e 100644 --- a/WEB-INF/lib/form/Submit.class.php +++ b/WEB-INF/lib/form/Submit.class.php @@ -27,34 +27,25 @@ // +----------------------------------------------------------------------+ import('form.FormElement'); - + class Submit extends FormElement { - function __construct($name) - { + function __construct($name) { $this->class = 'Submit'; $this->name = $name; } function getHtml() { - - if ($this->id=="") $this->id = $this->name; - - $html = "\n\tname\" id=\"$this->id\""; - - if (!$this->isEnabled()) { - $html .= " disabled=\"true\""; - } - - $html .= " value=\"$this->value\""; - - if ($this->on_click) { - $html .= " onclick=\"".$this->on_click."\""; - } - - $html .= ">"; - - return $html; - } + if (empty($this->id)) + $this->id = $this->name; + + // Output HTML. + $html = "\n\tname\" id=\"$this->id\""; + $html .= " value=\"$this->value\""; + if ($this->on_click) $html .= " onclick=\"".$this->on_click."\""; + if (!$this->isEnabled()) $html .= " disabled"; + $html .= ">"; + + return $html; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3d14fea2..1772b100 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.13.8.3727 | Copyright © Anuko | +  Anuko Time Tracker 1.13.8.3728 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1