From 199277a2fd7258bb60c37a291d0d62e04e9c31ca Mon Sep 17 00:00:00 2001 From: anuko Date: Thu, 16 Feb 2017 20:56:26 +0000 Subject: [PATCH] A bit more refactoring in forms to make them leaner. --- WEB-INF/lib/form/ActionForm.class.php | 10 -------- WEB-INF/lib/form/Form.class.php | 34 ++++++--------------------- WEB-INF/templates/footer.tpl | 2 +- 3 files changed, 8 insertions(+), 38 deletions(-) diff --git a/WEB-INF/lib/form/ActionForm.class.php b/WEB-INF/lib/form/ActionForm.class.php index 186f968a..fa70e15f 100644 --- a/WEB-INF/lib/form/ActionForm.class.php +++ b/WEB-INF/lib/form/ActionForm.class.php @@ -38,7 +38,6 @@ class ActionForm { function __construct($name, &$form, $request=null) { $this->setName($name); - $form->setRequest($request); $this->setForm($form); //if ($request) $this->initAttributes($request); $this->initAttributes($request); @@ -73,7 +72,6 @@ class ActionForm { * @param object $request */ function initAttributes(&$request) { - //$submit_flag = $this->isSubmit(); $submit_flag = (is_object($request) && ($request->isPost())); if ($submit_flag) { @@ -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(); diff --git a/WEB-INF/lib/form/Form.class.php b/WEB-INF/lib/form/Form.class.php index b357fe5e..b37903cd 100644 --- a/WEB-INF/lib/form/Form.class.php +++ b/WEB-INF/lib/form/Form.class.php @@ -36,18 +36,13 @@ class Form { var $name = ''; - // TODO: refactoring ongoing down from here. + var $elements = array(); - var $elements = array(); - var $mRequest; - - function __construct($formName) { - $this->name = $formName; - } - - function setRequest(&$request) { - $this->mRequest = &$request; - } + function __construct($formName) { + $this->name = $formName; + } + + // TODO: refactoring ongoing down from here. function &getElement($name) { return $this->elements[$name]; @@ -65,22 +60,7 @@ class Form { // onsubmit // onreset 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; - } - + //// INPUT element // type = TEXT | PASSWORD | CHECKBOX | RADIO | SUBMIT | RESET | FILE | HIDDEN | IMAGE | BUTTON // name diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 68066f59..fe95f105 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.10.38.3585 | Copyright © Anuko | +  Anuko Time Tracker 1.10.38.3586 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1