Ongoing refactoring of Checkbox class.
authoranuko <support@anuko.com>
Fri, 3 Mar 2017 15:55:54 +0000 (15:55 +0000)
committeranuko <support@anuko.com>
Fri, 3 Mar 2017 15:55:54 +0000 (15:55 +0000)
WEB-INF/lib/form/Checkbox.class.php
WEB-INF/lib/form/Form.class.php
WEB-INF/templates/footer.tpl

index e3d9cf2..999bff8 100644 (file)
@@ -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\t<input type=\"checkbox\"";
-               $html .= " name=\"$this->name\" id=\"$this->id\"";
+  function getHtml() {
+    if ($this->id == '') $this->id = $this->name;
+
+    $html = "\n\t<input type=\"checkbox\"";
+    $html.= " id=\"$this->id\" 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\"";
index 704ce7e..be2c901 100644 (file)
 // | 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;
                            
index 3945875..0d8c306 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.10.38.3618 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.10.38.3619 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>