From: anuko Date: Fri, 3 Mar 2017 15:55:54 +0000 (+0000) Subject: Ongoing refactoring of Checkbox class. X-Git-Tag: timetracker_1.19-1~1533 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=0fa80122e692abac96010f4da8ed55c3aa52b81b;p=timetracker.git Ongoing refactoring of Checkbox class. --- diff --git a/WEB-INF/lib/form/Checkbox.class.php b/WEB-INF/lib/form/Checkbox.class.php index e3d9cf2e..999bff87 100644 --- a/WEB-INF/lib/form/Checkbox.class.php +++ b/WEB-INF/lib/form/Checkbox.class.php @@ -29,7 +29,7 @@ import('form.FormElement'); class Checkbox extends FormElement { - var $mChecked = false; + var $checked = false; var $mOptions = null; function __construct($name, $value = '') { @@ -38,18 +38,20 @@ class Checkbox extends FormElement { $this->value = $value; } - function setChecked($value) { $this->mChecked = $value; } - function isChecked() { return $this->mChecked; } + function setChecked($value) { $this->checked = $value; } + function isChecked() { return $this->checked; } function setData($value) { $this->mOptions = $value; } function getData() { return $this->mOptions; } - - function getHtml() { - if ($this->id=="") $this->id = $this->name; - - $html = "\n\tname\" id=\"$this->id\""; + function getHtml() { + if ($this->id == '') $this->id = $this->name; + + $html = "\n\tid\" name=\"$this->name\""; + + if ($this->checked || (($this->value == $this->mOptions) && ($this->value != null))) + $html.= " checked=\"true\""; if ($this->on_change!="") $html .= " onchange=\"$this->on_change\""; @@ -57,8 +59,7 @@ class Checkbox extends FormElement { if ($this->style!="") $html .= " style=\"$this->style\""; - if ($this->mChecked || (($this->value == $this->mOptions) && ($this->value != null))) - $html .= " checked=\"true\""; + if (!$this->isEnabled()) $html .= " disabled=\"disabled\""; diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index 704ce7e5..be2c901f 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -26,13 +26,9 @@ // | https://www.anuko.com/time_tracker/credits.htm // +----------------------------------------------------------------------+ -// +----------------------------------------------------------------------+ -// | -// | Class generates elements of specification HTML 4.01 -// | http://www.w3.org/TR/1999/REC-html401-19991224 -// | -// +----------------------------------------------------------------------+ - +// Form class is a container for HTML forms we use in the application. +// It contains an array of $elements - which are individual input controls +// belonging to a form. class Form { var $name = ''; // Form name. var $elements = array(); // An array of input controls in form. @@ -89,8 +85,9 @@ class Form { case 'checkbox': import('form.Checkbox'); $el = new Checkbox($params['name']); + if (isset($params['checked'])) $el->setChecked(true); + // TODO: refactoring ongoing down from here. - if (@$params["checked"]) $el->setChecked(true); $el->setData(@$params["data"]); break; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 3945875a..0d8c3065 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.10.38.3618 | Copyright © Anuko | +  Anuko Time Tracker 1.10.38.3619 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve}