From 4598776895d3a08587942f1e75bbd7abcc317e8a Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Fri, 3 Feb 2017 22:27:08 +0100
Subject: [PATCH] AbstractBuildForm.php: accidently a function duplicated -
 removed

---
 extension/qfq/qfq/AbstractBuildForm.php | 147 ++++++++----------------
 1 file changed, 49 insertions(+), 98 deletions(-)

diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php
index a3b50a2a4..1b3116a64 100644
--- a/extension/qfq/qfq/AbstractBuildForm.php
+++ b/extension/qfq/qfq/AbstractBuildForm.php
@@ -322,104 +322,6 @@ abstract class AbstractBuildForm {
 
     abstract public function getProcessFilter();
 
-    /**
-     * Check if there is an explicit 'autofocus' definition in at least one FE.
-     * Found: do nothing, it will be rendered at the correct position.
-     * Not found: set 'autofocus' on the first FE.
-     *
-     * Accepted misbehaviour on forms with pills: if there is at least one editable element on the first pill,
-     *   the other pills are not checked - independent if there was a definition on the first pill or not.
-     *   Reason: checks happens per pill - if there is no explizit definition on the first pill, take the first editable
-     *           element of that pill.
-     */
-    private function checkAutoFocus() {
-        static $found = false;
-        $idx = false;
-
-        if ($found) {
-            return;
-        }
-
-        // Search if there is an explicit autofocus definition.
-        for ($i = 0; $i < count($this->feSpecNative); ++$i) {
-            // Only check native elements which will be shown
-            if ($this->feSpecNative[$i][FE_CLASS] == FE_CLASS_NATIVE &&
-                ($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW || $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED)
-            ) {
-                // Check if there is an explicit definition.
-                if (isset($this->feSpecNative[$i][FE_AUTOFOCUS])) {
-                    if ($this->feSpecNative[$i][FE_AUTOFOCUS] == '' || $this->feSpecNative[$i][FE_AUTOFOCUS] == '1') {
-                        $this->feSpecNative[$i][FE_AUTOFOCUS] = '1'; // fix to '=1'
-                    } else {
-                        unset($this->feSpecNative[$i][FE_AUTOFOCUS]);
-                    }
-                    $found = true;
-                    return;
-                }
-
-                if ($idx === false) {
-                    $idx = $i;
-                }
-            }
-        }
-
-        // No explicit definition found: take the first found editable element.
-        if ($idx !== false) {
-            $found = true;
-            // No explicit definition found: set autofocus.
-            $this->feSpecNative[$idx][FE_AUTOFOCUS] = '1';
-        }
-    }
-
-    /**
-     * Check if there is an explicit 'autofocus' definition in at least one FE.
-     * Found: do nothing, it will be rendered at the correct position.
-     * Not found: set 'autofocus' on the first FE.
-     *
-     * Accepted misbehaviour on forms with pills: if there is at least one editable element on the first pill,
-     *   the other pills are not checked - independent if there was a definition on the first pill or not.
-     *   Reason: checks happens per pill - if there is no explizit definition on the first pill, take the first editable
-     *           element of that pill.
-     */
-    private function checkAutoFocus() {
-        static $found = false;
-        $idx = false;
-
-        if ($found) {
-            return;
-        }
-
-        // Search if there is an explicit autofocus definition.
-        for ($i = 0; $i < count($this->feSpecNative); ++$i) {
-            // Only check native elements which will be shown
-            if ($this->feSpecNative[$i][FE_CLASS] == FE_CLASS_NATIVE &&
-                ($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW || $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED)
-            ) {
-                // Check if there is an explicit definition.
-                if (isset($this->feSpecNative[$i][FE_AUTOFOCUS])) {
-                    if ($this->feSpecNative[$i][FE_AUTOFOCUS] == '' || $this->feSpecNative[$i][FE_AUTOFOCUS] == '1') {
-                        $this->feSpecNative[$i][FE_AUTOFOCUS] = '1'; // fix to '=1'
-                    } else {
-                        unset($this->feSpecNative[$i][FE_AUTOFOCUS]);
-                    }
-                    $found = true;
-                    return;
-                }
-
-                if ($idx === false) {
-                    $idx = $i;
-                }
-            }
-        }
-
-        // No explicit definition found: take the first found editable element.
-        if ($idx !== false) {
-            $found = true;
-            // No explicit definition found: set autofocus.
-            $this->feSpecNative[$idx][FE_AUTOFOCUS] = '1';
-        }
-    }
-
     /**
      * Process all FormElements: build corresponding HTML code. Collect and return all HTML code.
      *
@@ -537,6 +439,55 @@ abstract class AbstractBuildForm {
         return $html;
     }
 
+    /**
+     * Check if there is an explicit 'autofocus' definition in at least one FE.
+     * Found: do nothing, it will be rendered at the correct position.
+     * Not found: set 'autofocus' on the first FE.
+     *
+     * Accepted misbehaviour on forms with pills: if there is at least one editable element on the first pill,
+     *   the other pills are not checked - independent if there was a definition on the first pill or not.
+     *   Reason: checks happens per pill - if there is no explizit definition on the first pill, take the first editable
+     *           element of that pill.
+     */
+    private function checkAutoFocus() {
+        static $found = false;
+        $idx = false;
+
+        if ($found) {
+            return;
+        }
+
+        // Search if there is an explicit autofocus definition.
+        for ($i = 0; $i < count($this->feSpecNative); ++$i) {
+            // Only check native elements which will be shown
+            if ($this->feSpecNative[$i][FE_CLASS] == FE_CLASS_NATIVE &&
+                ($this->feSpecNative[$i][FE_MODE] == FE_MODE_SHOW || $this->feSpecNative[$i][FE_MODE] == FE_MODE_REQUIRED)
+            ) {
+                // Check if there is an explicit definition.
+                if (isset($this->feSpecNative[$i][FE_AUTOFOCUS])) {
+                    if ($this->feSpecNative[$i][FE_AUTOFOCUS] == '' || $this->feSpecNative[$i][FE_AUTOFOCUS] == '1') {
+                        $this->feSpecNative[$i][FE_AUTOFOCUS] = '1'; // fix to '=1'
+                    } else {
+                        unset($this->feSpecNative[$i][FE_AUTOFOCUS]);
+                    }
+                    $found = true;
+                    return;
+                }
+
+                if ($idx === false) {
+                    $idx = $i;
+                }
+            }
+        }
+
+        // No explicit definition found: take the first found editable element.
+        if ($idx !== false) {
+            $found = true;
+            // No explicit definition found: set autofocus.
+            $this->feSpecNative[$idx][FE_AUTOFOCUS] = '1';
+        }
+    }
+
     abstract public function fillWrapLabelInputNote($label, $input, $note);
 
     abstract public function tail();
-- 
GitLab