X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/33399ff6a8bdfe9b989810dafe9c4dbf3cf3b685..aad5111d2e9f3329dc1002e897dd910a60946d6c:/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 6fb6ce12..250f5313 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -34,29 +34,24 @@ // +----------------------------------------------------------------------+ class Form { - var $formName = ""; - var $mAction = ""; - var $mMethod = "post"; - var $mEnctype = ""; + + var $name = ''; + // TODO: refactoring ongoing down from here. + var $mId = ""; var $error; var $debugFunction; var $mElements = array(); var $mRequest; -// var $mFormBean; - function Form($formid) { - $this->formName = $formid; + function __construct($formid) { + $this->name = $formid; } function setRequest(&$request) { $this->mRequest = &$request; } - -/* function setFormBean(&$bean) { - $this->mFormBean = &$bean; - } -*/ + function &getElement($name) { return $this->mElements[$name]; } @@ -72,21 +67,12 @@ class Form { // name // onsubmit // onreset - function setName($value) { $this->formName = $value; } - function getName() { return $this->formName; } + function setName($value) { $this->name = $value; } + function getName() { return $this->name; } function setId($value) { $this->mId = $value; } function getId() { return $this->mId; } - function setAction($value) { $this->mAction = $value; } - function getAction() { return $this->mAction; } - - function setMethod($value) { $this->mMethod = $value; } - function getMethod() { return $this->mMethod; } - - function setEnctype($value) { $this->mEnctype = $value; } - function getEnctype() { return $this->mEnctype; } - function isSubmit() { if (!isset($this->mRequest)) return false; $result = false; @@ -225,7 +211,7 @@ class Form { return($this->OutputError("Type not found for input element","AddInput")); } if ($el!=null) { - $el->setFormName($this->formName); + $el->setFormName($this->name); if (isset($arguments["id"])) $el->setId($arguments["id"]); if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]); if (isset($arguments["render"])) $el->setRenderable($arguments["render"]); @@ -251,34 +237,28 @@ class Form { if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]); - $el->setFormName($this->formName); + $el->setFormName($this->name); $this->mElements[$el->getName()] = &$el; } } function toStringOpenTag() { - $html = "
formName\""; + $html = "name\""; if ($this->mId!="") $html .= " id=\"$this->mId\""; - if ($this->mAction!="") - $html .= " action=\"$this->mAction\""; - - if ($this->mMethod!="") - $html .= " method=\"$this->mMethod\""; + $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; }