]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/form/Form.class.php
Refactoring - removed reference return types from a couple of functions to keep thing...
[timetracker.git] / WEB-INF / lib / form / Form.class.php
index 50804dd83135cd10720a055deabf265922031e81..8bf3ecaba9335e9eb165d0f709a52d99d8d7c534 100644 (file)
@@ -37,50 +37,25 @@ class Form {
 
   var $name = '';
   var $elements = array();
-  // TODO: refactoring ongoing down from here.
 
-       var $mRequest;
-    
-    function __construct($formName) {
-        $this->name = $formName;
-    }
-    
-    function setRequest(&$request) {
-        $this->mRequest = &$request;
-    }
+  function __construct($formName) {
+    $this->name = $formName;
+  }
 
-    function &getElement($name) {
-        return $this->elements[$name];
-    }
-    
-    function &getElements() {
-        return $this->elements;
-    }
-    
-       //// FORM element
-       // action
-       // method - GET, POST
-       // enctype - enctype="multipart/form-data"
-       // name
-       // onsubmit
-       // onreset
-    function getName() { return $this->name; }
+  function getElement($name) {
+    return $this->elements[$name];
+  }
+
+  function getElements() {
+    return $this->elements;
+  }
+
+  function getName() { return $this->name; }
     
-    function isSubmit()        {
-       if (!isset($this->mRequest)) return false;
-        $result = false;
-           foreach ($this->elements as $el) {
-               if (strtolower(get_class($el))=="submit") {
-                   $name = $el->getName();
-                   $value = $this->mRequest->getAttribute($name);
-                   if($value) {
-                      $result = true; 
-                   }
-               }
-           }
-        return $result;
-    }
-       
+  // TODO: refactoring ongoing down from here.
+
+
+
        //// INPUT element
        // type = TEXT | PASSWORD | CHECKBOX | RADIO | SUBMIT | RESET | FILE | HIDDEN | IMAGE | BUTTON
        // name
@@ -201,8 +176,8 @@ class Form {
        
        function addInputElement(&$el) {
                if ($el && is_object($el)) {
-                        if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]);
-
+                       if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]);
+               
                        $el->setFormName($this->name);
                        $this->elements[$el->getName()] = &$el;
                }
@@ -228,9 +203,9 @@ class Form {
     
     function toStringCloseTag() {
        $html = "\n";
-        foreach ($this->elements as $elname=>$el) {
+       foreach ($this->elements as $elname=>$el) {
             if (strtolower(get_class($this->elements[$elname]))=="hidden") {
-                $html .= $this->elements[$elname]->toStringControl()."\n";
+               $html .= $this->elements[$elname]->toStringControl()."\n";
             }
         }
         $html .= "</form>";
@@ -243,7 +218,7 @@ class Form {
         $vars['close'] = $this->toStringCloseTag();
         
         foreach ($this->elements as $elname=>$el) {
-            if (is_object($this->elements[$elname]))
+            if (is_object($this->elements[$elname])) 
                 $vars[$elname] = $this->elements[$elname]->toArray();
         }
 //print_r($vars);
@@ -251,12 +226,12 @@ class Form {
     }
     
     function getValueByElement($elname) {
-        return $this->elements[$elname]->getValue();
+       return $this->elements[$elname]->getValue();
     }
     
     function setValueByElement($elname, $value) {
-        if (isset($this->elements[$elname])) {
-            $this->elements[$elname]->setValue($value);
+       if (isset($this->elements[$elname])) {
+               $this->elements[$elname]->setValue($value);
        }
     }
 }