From f677f3f373a696b55be6ce16022f9834a83c8913 Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Mon, 9 May 2016 23:11:35 +0200
Subject: [PATCH] AbstractBuildForm.php: some small code cleanup.

---
 extension/qfq/qfq/AbstractBuildForm.php | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php
index 22874b294..e2c71ba98 100644
--- a/extension/qfq/qfq/AbstractBuildForm.php
+++ b/extension/qfq/qfq/AbstractBuildForm.php
@@ -31,8 +31,6 @@ abstract class AbstractBuildForm {
     protected $formSpec = array();  // copy of the loaded form
     protected $feSpecAction = array(); // copy of all formElement.class='action' of the loaded form
     protected $feSpecNative = array(); // copy of all formElement.class='native' of the loaded form
-    protected $store = null;
-    protected $evaluate = null;
     protected $buildElementFunctionName = array();
     protected $pattern = array();
     protected $wrap = array();
@@ -42,11 +40,18 @@ abstract class AbstractBuildForm {
 
 //    protected $feDivClass = array(); // Wrap FormElements in <div class="$feDivClass[type]">
 
+    /**
+     * @var Store
+     */
+    protected $store = null;
+    /**
+     * @var Evaluate
+     */
+    protected $evaluate = null;
     /**
      * @var string
      */
     private $formId = null;
-
     /**
      * @var Sip
      */
@@ -167,9 +172,9 @@ abstract class AbstractBuildForm {
                 $json[] = $jsonTmp;
             }
         } else {
-            $htmlElements = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse);
+            $recordId = $this->store->getVar(SIP_RECORD_ID, STORE_SIP);
+            $htmlElements = $this->elements($recordId, $filter, 0, $json, $modeCollectFe, $htmlElementNameIdZero, $storeUse);
         }
-
         $htmlSip = $this->buildHiddenSip($json);
 
         // </form>
@@ -353,8 +358,7 @@ abstract class AbstractBuildForm {
             $this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($fe), STORE_SYSTEM);
 
             // evaluate current FormElement
-            $evaluate = new Evaluate($this->store, $this->db);
-            $formElement = $evaluate->parseArray($fe, $debugStack);
+            $formElement = $this->evaluate->parseArray($fe, $debugStack);
 
             // Some Defaults
             $formElement = Support::setFeDefaults($formElement);
@@ -1093,7 +1097,8 @@ abstract class AbstractBuildForm {
         for ($ii = 0, $jj = 1; $ii < count($itemKey); $ii++, $jj++) {
             $jsonValue = false;
             $attribute = $attributeBase;
-            $attribute .= Support::doAttribute('name', HelperFormElement::prependFormElementIdCheckBoxMulti($htmlFormElementId, $ii));
+            $htmlFormElementIdUniq = HelperFormElement::prependFormElementIdCheckBoxMulti($htmlFormElementId, $ii);
+            $attribute .= Support::doAttribute('name', $htmlFormElementIdUniq);
 
             // Do this only the first round.
             if ($flagFirst) {
@@ -1134,7 +1139,7 @@ abstract class AbstractBuildForm {
             }
 
             $html .= $htmlElement . $br;
-            $json[] = $this->getJsonElementUpdate($htmlFormElementId, $jsonValue, $formElement[FE_MODE]);
+            $json[] = $this->getJsonElementUpdate($htmlFormElementIdUniq, $jsonValue, $formElement[FE_MODE]);
 
         }
 
-- 
GitLab