X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fform%2FActionForm.class.php;h=edc15708d28a89d63e917bb58fe5b81c6606e793;hb=a4d1c5627c3958245ea7e2e573267e34f5872471;hp=30d5c93da7b4b28594f05981ca240ab0fc34d77d;hpb=9a23a8c0a51b7ec38a96f525484134f3cb85dc7e;p=timetracker.git diff --git a/WEB-INF/lib/form/ActionForm.class.php b/WEB-INF/lib/form/ActionForm.class.php index 30d5c93d..edc15708 100644 --- a/WEB-INF/lib/form/ActionForm.class.php +++ b/WEB-INF/lib/form/ActionForm.class.php @@ -36,9 +36,8 @@ class ActionForm { var $mForm = null; var $mInitForm = false; - function ActionForm($name, &$form, $request=null) { + function __construct($name, &$form, $request=null) { $this->setName($name); - $form->setRequest($request); $this->setForm($form); //if ($request) $this->initAttributes($request); $this->initAttributes($request); @@ -53,7 +52,7 @@ class ActionForm { function &getFormElement($name) { if ($this->mForm!=null) { - return $this->mForm->mElements[$name]; + return $this->mForm->elements[$name]; } return null; } @@ -63,8 +62,8 @@ class ActionForm { } function setName($name) { - $this->mName = $name; - $this->mSessionCell = "formbean_".$this->mName; + $this->name = $name; + $this->mSessionCell = "formbean_".$this->name; } /** @@ -73,16 +72,15 @@ class ActionForm { * @param object $request */ function initAttributes(&$request) { - //$submit_flag = $this->isSubmit(); - $submit_flag = (is_object($request) && ($request->getMethod() == 'POST')); + $submit_flag = (is_object($request) && ($request->isPost())); if ($submit_flag) { // fill ActionForm and Form from Request foreach ($this->mVariables as $name) { - if ($this->mForm->mElements[$name] && $request->getParameter($name)) { - $this->mForm->mElements[$name]->setValue($request->getParameter($name)); - $this->mValues[$name] = $this->mForm->mElements[$name]->getValue(); + if ($this->mForm->elements[$name] && $request->getParameter($name)) { + $this->mForm->elements[$name]->setValue($request->getParameter($name)); + $this->mValues[$name] = $this->mForm->elements[$name]->getValue(); } } } else { @@ -94,8 +92,8 @@ class ActionForm { if ($this->mForm) { $elements = $this->mForm->getElements(); foreach ($elements as $name=>$el) { - if ($this->mForm->mElements[$name] && isset($this->mValues[$name])) { - $this->mForm->mElements[$name]->setValue($this->mValues[$name]); + if ($this->mForm->elements[$name] && isset($this->mValues[$name])) { + $this->mForm->elements[$name]->setValue($this->mValues[$name]); } } $this->mInitForm = true; @@ -121,12 +119,12 @@ class ActionForm { $this->mValues[$name] = $value; if ($this->mForm) { - if (isset($this->mForm->mElements[$name])) { - if ($this->mForm->mElements[$name]->cClassName=="DateField") { + if (isset($this->mForm->elements[$name])) { + if ($this->mForm->elements[$name]->class=="DateField") { $dt = new DateAndTime($user->date_format, $value); $value = $dt->toString(DB_DATEFORMAT); } - $this->mForm->mElements[$name]->setValueSafe($value); + $this->mForm->elements[$name]->setValueSafe($value); } } } @@ -150,12 +148,12 @@ class ActionForm { if (is_array($this->mValues)) foreach ($this->mValues as $name=>$value) { if ($this->mForm) { - if (isset($this->mForm->mElements[$name])) { - if ($this->mForm->mElements[$name]->cClassName=="DateField") { + if (isset($this->mForm->elements[$name])) { + if ($this->mForm->elements[$name]->class=="DateField") { $dt = new DateAndTime($user->date_format, $value); $value = $dt->toString(DB_DATEFORMAT); } - $this->mForm->mElements[$name]->setValueSafe($value); + $this->mForm->elements[$name]->setValueSafe($value); } } } @@ -165,14 +163,6 @@ class ActionForm { print_r($this->mValues); } - function isSubmit() { - $res = false; - if (is_object($this->mForm)) { - $res = $this->mForm->isSubmit(); - } - return $res; - } - function saveBean() { if ($this->mForm) { $elements = $this->mForm->getElements(); @@ -196,11 +186,11 @@ class ActionForm { import('form.'.$ref_el["class"]); $class_name = $ref_el["class"]; $el = new $class_name($ref_el["name"]); - if (isset($GLOBALS["I18N"])) $el->setLocalization($GLOBALS["I18N"]); + if (isset($GLOBALS["I18N"])) $el->localize($GLOBALS["I18N"]); $el->setValueSafe(@$_SESSION[$this->mSessionCell . "_" .$el->getName()]); - if ($this->mForm && !isset($this->mForm->mElements[$ref_el["name"]])) { - $this->mForm->mElements[$ref_el["name"]] = &$el; + if ($this->mForm && !isset($this->mForm->elements[$ref_el["name"]])) { + $this->mForm->elements[$ref_el["name"]] = &$el; } $this->mValues[$el->getName()] = $el->getValue(); } @@ -222,4 +212,3 @@ class ActionForm { return (isset($_SESSION[$this->mSessionCell . "session_store_elements"]) ? true : false); } } -?>