Ongoing refactoring of form controls.
authoranuko <support@anuko.com>
Sun, 19 Feb 2017 21:33:27 +0000 (21:33 +0000)
committeranuko <support@anuko.com>
Sun, 19 Feb 2017 21:33:27 +0000 (21:33 +0000)
14 files changed:
WEB-INF/lib/form/ActionForm.class.php
WEB-INF/lib/form/Checkbox.class.php
WEB-INF/lib/form/CheckboxGroup.class.php
WEB-INF/lib/form/Combobox.class.php
WEB-INF/lib/form/DateField.class.php
WEB-INF/lib/form/FloatField.class.php
WEB-INF/lib/form/FormElement.class.php
WEB-INF/lib/form/Hidden.class.php
WEB-INF/lib/form/Submit.class.php
WEB-INF/lib/form/Table.class.php
WEB-INF/lib/form/TextArea.class.php
WEB-INF/lib/form/TextField.class.php
WEB-INF/lib/form/UploadFile.class.php
WEB-INF/templates/footer.tpl

index fa70e15..dcd3811 100644 (file)
@@ -62,8 +62,8 @@ class ActionForm {
        }
 
     function setName($name) {
-               $this->mName = $name;
-               $this->mSessionCell = "formbean_".$this->mName;
+               $this->name = $name;
+               $this->mSessionCell = "formbean_".$this->name;
        }
     
     /**
index 5ba7916..8ee4fea 100644 (file)
@@ -35,7 +35,7 @@ class Checkbox extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
 
@@ -48,10 +48,10 @@ class Checkbox extends FormElement {
        function toStringControl()      {
                if (!$this->isRenderable()) return "";
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->name;
            
                $html = "\n\t<input type=\"checkbox\"";
-               $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+               $html .= " name=\"$this->name\" id=\"$this->id\"";
                
                if ($this->mTabindex!="")
                   $html .= " tabindex=\"$this->mTabindex\"";
index f9d850f..759a076 100644 (file)
@@ -41,7 +41,7 @@ class CheckboxGroup extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
 
@@ -69,7 +69,7 @@ class CheckboxGroup extends FormElement {
        function toStringControl()      {
                if (!$this->isRenderable()) return "";
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->name;
            
            $renderArray = array();
            $renderCols = 0;
@@ -86,14 +86,14 @@ class CheckboxGroup extends FormElement {
                                                $optkey = $optval[$this->mDataKeys[0]];
                                                $optval = $optval[$this->mDataKeys[1]];
                                        }
-                               $html = "<input type=\"checkbox\" name=\"$this->mName[]\" id=\"$this->mId"."_".$i."\"";
+                               $html = "<input type=\"checkbox\" name=\"$this->name[]\" id=\"$this->id"."_".$i."\"";
                                if (is_array($this->mValue)) {
                                        foreach ($this->mValue as $value) {
                                                if (($value == $optkey) && ($value != null))
                                                        $html .= " checked=\"true\"";
                                        }
                                }
-                                       $html .= " value=\"".htmlspecialchars($optkey)."\">&nbsp;<label for=\"$this->mId"."_".$i."\">".htmlspecialchars($optval)."</label>";
+                                       $html .= " value=\"".htmlspecialchars($optkey)."\">&nbsp;<label for=\"$this->id"."_".$i."\">".htmlspecialchars($optval)."</label>";
                                        $renderArray[$col][$row] = $html;
                                        
                                $col++;                         
@@ -114,14 +114,14 @@ class CheckboxGroup extends FormElement {
                                                $optkey = $optval[$this->mDataKeys[0]];
                                                $optval = $optval[$this->mDataKeys[1]];
                                        }
-                               $html = "<input type=\"checkbox\" name=\"$this->mName[]\" id=\"$this->mId"."_".$i."\"";
+                               $html = "<input type=\"checkbox\" name=\"$this->name[]\" id=\"$this->id"."_".$i."\"";
                                if (is_array($this->mValue)) {
                                        foreach ($this->mValue as $value) {
                                                if (($value == $optkey) && ($value != null))
                                                        $html .= " checked=\"true\"";
                                        }
                                }
-                                       $html .= " value=\"".htmlspecialchars($optkey)."\">&nbsp;<label for=\"$this->mId"."_".$i."\">".htmlspecialchars($optval)."</label>";
+                                       $html .= " value=\"".htmlspecialchars($optkey)."\">&nbsp;<label for=\"$this->id"."_".$i."\">".htmlspecialchars($optval)."</label>";
                                        $renderArray[$col][$row] = $html;
 
                                        $row++;
index dcb84a2..0e8ec06 100644 (file)
@@ -48,7 +48,7 @@ class Combobox extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
 
@@ -68,10 +68,10 @@ class Combobox extends FormElement {
        function toStringControl()      {
                if (!$this->isRenderable()) return "";
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->name;
            
                $html = "\n\t<select";
-               $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+               $html .= " name=\"$this->name\" id=\"$this->id\"";
                
                if ($this->mSize!="")
                  $html .= " size=\"$this->mSize\"";
index db59a3b..24266a3 100644 (file)
@@ -40,7 +40,7 @@ class DateField extends TextField {
   var $lCalendarButtons = array('today'=>'Today', 'close'=>'Close');
 
   function __construct($name) {
-    $this->mName  = $name;
+    $this->name  = $name;
     $this->mDateObj  = new DateAndTime();
 
     if (isset($GLOBALS["I18N"])) {
@@ -86,10 +86,10 @@ class DateField extends TextField {
 
     if (!$this->isEnable()) {
       $html = htmlspecialchars($this->getValue()).
-        "<input type=\"hidden\" name=\"$this->mName\" value=\"".htmlspecialchars($this->getValue())."\">\n";
+        "<input type=\"hidden\" name=\"$this->name\" value=\"".htmlspecialchars($this->getValue())."\">\n";
     } else {
 
-        if ($this->mId=="") $this->mId = $this->mName;
+        if ($this->id=="") $this->id = $this->name;
 
       $html = "";
 
@@ -393,7 +393,7 @@ class DateField extends TextField {
       $html .= "</script>\n";
 
       $html .= "\n\t<input type=\"text\"";
-      $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+      $html .= " name=\"$this->name\" id=\"$this->id\"";
 
       if ($this->mSize!="")
         $html .= " size=\"$this->mSize\"";
@@ -418,7 +418,7 @@ class DateField extends TextField {
       if (APP_NAME)
        $app_root = '/'.APP_NAME;
 
-      $html .= "&nbsp;<img src=\"".$app_root."/images/calendar.gif\" width=\"16\" height=\"16\" onclick=\"displayDatePicker('".$this->mName."');\">\n";
+      $html .= "&nbsp;<img src=\"".$app_root."/images/calendar.gif\" width=\"16\" height=\"16\" onclick=\"displayDatePicker('".$this->name."');\">\n";
     }
 
     return $html;
index 9cd38bf..298e09b 100644 (file)
@@ -35,7 +35,7 @@ class FloatField extends TextField {
   var $cClassName = 'FloatField';
 
   function __construct($name) {
-    $this->mName = $name;
+    $this->name = $name;
   }
 
   function setLocalization($i18n) {
index e7ea9cc..f46e3bf 100644 (file)
 // | https://www.anuko.com/time_tracker/credits.htm
 // +----------------------------------------------------------------------+
 
+// FromElement is the base class for controls on forms.
 class FormElement {
-       var $mId                        = "";
-       var $mName;
-       var $mFormName          = "";
+  var $id = "";
+  var $name;
+  var $form_name = "";
        var $mValue                     = "";
        var $mSize                      = "";
        var $mMaxLength         = "";
@@ -52,11 +53,11 @@ class FormElement {
 
        function getClass()     { return $this->cClassName; }
        
-       function setName($name) { $this->mName = $name; }
-       function getName()      { return $this->mName; }
+       function setName($name) { $this->name = $name;  }
+       function getName()      { return $this->name; }
        
-       function setFormName($name)     { $this->mFormName = $name;     }
-       function getFormName()  { return $this->mFormName; }
+       function setFormName($name) { $this->form_name = $name; }
+       function getFormName()  { return $this->form_name; }
        
        function setValue($value)       { $this->mValue = $value;}
        function getValue() { return $this->mValue; }
@@ -64,8 +65,8 @@ class FormElement {
        function setValueSafe($value)   { $this->mValue = $value;}
        function getValueSafe() { return $this->mValue; }
 
-       function setId($id)     { $this->mId = $id;     }
-       function getId() { return $this->mId; }
+       function setId($id)     { $this->id = $id;      }
+       function getId() { return $this->id; }
        
        function setSize($value)        { $this->mSize = $value; }
        function getSize() { return $this->mSize; }
@@ -104,7 +105,7 @@ class FormElement {
        }
        
        function toStringLabel() {
-           return "<label for=\"" . $this->mId . "\">" . $this->mLabel . "</label>";
+           return "<label for=\"" . $this->id . "\">" . $this->mLabel . "</label>";
        }
        
        function toArray() {
index 8483746..0105de1 100644 (file)
@@ -34,16 +34,16 @@ class Hidden extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
 
        function toStringControl()      {
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->name;
            
                $html = "\n\t<input";
-               $html .= " type=\"hidden\" name=\"$this->mName\" id=\"$this->mId\"";
+               $html .= " type=\"hidden\" name=\"$this->name\" id=\"$this->id\"";
                
                $html .= " value=\"".$this->getValue()."\"";
                $html .= ">";
index facfffc..bcfe3be 100644 (file)
@@ -33,17 +33,17 @@ class Submit extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
 
        function toStringControl()      {
                if (!$this->isRenderable()) return "";
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->name;
            
                $html = "\n\t<input";
-               $html .= " type=\"submit\" name=\"$this->mName\" id=\"$this->mId\"";
+               $html .= " type=\"submit\" name=\"$this->name\" id=\"$this->id\"";
                
                if (!$this->isEnable()) {
                        $html .= " disabled=\"true\"";
index b41a1f1..833bffa 100644 (file)
@@ -48,7 +48,7 @@ class Table extends FormElement {
   var $mProccessed    = false;
        
   function __construct($name, $value='') {
-    $this->mName = $name;
+    $this->name = $name;
     $this->mValue = $value;
   }
   
index be0c8ca..ecc2010 100644 (file)
@@ -37,7 +37,7 @@ class TextArea extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
        
@@ -50,12 +50,12 @@ class TextArea extends FormElement {
        function toStringControl()      {
                if (!$this->isRenderable()) return "";
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->mName;
            
            $js_maxlen = "";
            
                $html = "\n\t<textarea";
-               $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+               $html .= " name=\"$this->name\" id=\"$this->id\"";
                
                if ($this->mColumns!="")
                  $html .= " cols=\"$this->mColumns\"";
@@ -65,7 +65,7 @@ class TextArea extends FormElement {
                   
                if ($this->mMaxLength!="") {
                        if ($this->mOnKeyPress) $this->mOnKeyPress .= ";";
-                       $this->mOnKeyPress .= "return validateMaxLenght_".$this->mName."(this, event);";
+                       $this->mOnKeyPress .= "return validateMaxLenght_".$this->name."(this, event);";
                        $js_maxlen = $this->getExtraScript();
                        $html .= " maxlength=\"$this->mMaxLength\"";
                }
@@ -86,7 +86,7 @@ class TextArea extends FormElement {
        function getExtraScript() {
                $s = "<script>\n";
                $s .= "var isNS4 = (navigator.appName==\"Netscape\")?1:0;\n";
-               $s .= "function validateMaxLenght_".$this->mName."(element, event) {\n";
+               $s .= "function validateMaxLenght_".$this->name."(element, event) {\n";
                $s .= "\tmaxlength=".$this->mMaxLength.";\n";
                $s .= "\tvar iKey = (!isNS4?event.keyCode:event.which);\n";
                //$s .= "alert(iKey);";
index a409410..e1259d6 100644 (file)
@@ -35,7 +35,7 @@ class TextField extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
        
@@ -46,14 +46,14 @@ class TextField extends FormElement {
                if (!$this->isRenderable()) return "";
            
                if (!$this->isEnable()) {
-                       $html = "<input name=\"$this->mName\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n";  
+                       $html = "<input name=\"$this->name\" value=\"".htmlspecialchars($this->getValue())."\" readonly>\n";
                } else {
                        
-                   if ($this->mId=="") $this->mId = $this->mName;
+                   if ($this->id=="") $this->id = $this->name;
                    
                        $html = "\n\t<input";
                        $html .= ( $this->mPassword ? " type=\"password\"" : " type=\"text\"");
-                       $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+                       $html .= " name=\"$this->name\" id=\"$this->id\"";
                        
                        if ($this->mSize!="")
                          $html .= " size=\"$this->mSize\"";
index 1055125..98fbe0a 100644 (file)
@@ -35,7 +35,7 @@ class UploadFile extends FormElement {
 
        function __construct($name,$value="")
        {
-               $this->mName                    = $name;
+               $this->name                     = $name;
                $this->mValue                   = $value;
        }
        
@@ -45,24 +45,15 @@ class UploadFile extends FormElement {
        function toStringControl()      {
                if (!$this->isRenderable()) return "";
            
-           if ($this->mId=="") $this->mId = $this->mName;
+           if ($this->id=="") $this->id = $this->name;
            
                $html = "\n\t<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".$this->mMaxSize."\"/>";
                $html .= "\n\t<input";
-               $html .= " name=\"$this->mName\" id=\"$this->mId\"";
+               $html .= " name=\"$this->name\" id=\"$this->id\"";
                
                $html .= " type=\"file\"";
                $html .= ">";
-               
-               // only IE
-               /*$html = "<input type=\"file\" name=\"".$this->mName."\" id=\"".$this->mId."\" style=\"display: none;\">\n";
-               $html .= "<input type=\"text\" name=\"".$this->mName."file\">\n";
-               $html .= "<input type=\"button\" 
-                       style=\"text-align:center;\" onClick=\"".$this->mName.".click();".$this->mName."file.value=".$this->mName.".value;".$this->mName.".disabled=true;\"";
-               $html .= " value=\"".$this->getValue()."\">\n";
-               $html .= "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".$this->mMaxSize."\"/>";*/
-               
-               
-               return $html;
+
+                return $html;
        }
 }
index 7fd7363..20116c5 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.3593 | 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.3594 | 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>