X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/8c194ac6af2accb4f45e35e93629037a0983cc3f..4f4df95a604a5c11fe7ba793b18f025b13ef1fb6:/WEB-INF/lib/form/Form.class.php diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index 4d6987f6..a45b55a3 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -38,15 +38,11 @@ class Form { var $name = ''; // TODO: refactoring ongoing down from here. - var $mEnctype = ""; - var $mId = ""; - var $error; - var $debugFunction; - var $mElements = array(); + var $mElements = array(); var $mRequest; - function __construct($formid) { - $this->name = $formid; + function __construct($formName) { + $this->name = $formName; } function setRequest(&$request) { @@ -68,12 +64,8 @@ class Form { // name // onsubmit // onreset - function setName($value) { $this->name = $value; } function getName() { return $this->name; } - function setId($value) { $this->mId = $value; } - function getId() { return $this->mId; } - function isSubmit() { if (!isset($this->mRequest)) return false; $result = false; @@ -89,15 +81,6 @@ class Form { return $result; } - function OutputError($error,$scope="") - { - $this->error=(strcmp($scope,"") ? $scope.": ".$error : $error); - if(strcmp($function=$this->debugFunction,"") - && strcmp($this->error,"")) - $function($this->error); - return($this->error); - } - //// INPUT element // type = TEXT | PASSWORD | CHECKBOX | RADIO | SUBMIT | RESET | FILE | HIDDEN | IMAGE | BUTTON // name @@ -113,18 +96,6 @@ class Form { // onselect - INPUT and TEXTAREA // onchange function addInput($arguments) { - if(strcmp(gettype($arguments),"array")) - $this->OutputError("arguments must be array","AddInput"); - - if(!isset($arguments["type"]) || !strcmp($arguments["type"],"")) - return($this->OutputError("Type not defined","AddInput")); - - if(!isset($arguments["name"]) || !strcmp($arguments["name"],"")) - return($this->OutputError("Name of element not defined","AddInput")); - - if (isset($this->mElements[$arguments["name"]])) - return($this->OutputError("it was specified '".$arguments["name"]."' name of an already defined input","AddInput")); - switch($arguments["type"]) { case "textfield": @@ -207,9 +178,6 @@ class Form { $el = new UploadFile($arguments["name"]); if (isset($arguments["maxsize"])) $el->setMaxSize($arguments["maxsize"]); break; - - default: - return($this->OutputError("Type not found for input element","AddInput")); } if ($el!=null) { $el->setFormName($this->name); @@ -233,9 +201,6 @@ class Form { function addInputElement(&$el) { if ($el && is_object($el)) { - if (!$el->getName()) - return($this->OutputError("no name in element","addInputElement")); - if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]); $el->setFormName($this->name); @@ -247,21 +212,16 @@ class Form { function toStringOpenTag() { $html = "
name\""; - if ($this->mId!="") - $html .= " id=\"$this->mId\""; - $html .= ' method="post"'; - // for upload forms + // Add enctype for file upload forms. foreach ($this->mElements as $elname=>$el) { - if (strtolower(get_class($this->mElements[$elname]))=="uploadfile") { - $this->mEnctype = "multipart/form-data"; + if (strtolower(get_class($this->mElements[$elname])) == 'uploadfile') { + $html .= ' enctype="multipart/form-data"'; + break; } } - - if ($this->mEnctype!="") - $html .= " enctype=\"$this->mEnctype\""; - + $html .= ">"; return $html; }