X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/f7f5a1b8e3f8d12902fa462d7426fb4e0b81ea0d..e320f1d51ffa712689c6cb2877208464395aebb2:/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 50804dd8..8bf3ecab 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -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 .= ""; @@ -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); } } }