From 4b8aef9f2cff7e08bbb595d8b4856ca81f9d234c Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Sat, 25 Mar 2017 00:15:21 +0100
Subject: [PATCH] Fix #3420 / Quicklink 'editform' on form: directs to the
 current T3 page which might be insufficient AbstractBuildForm.php, Store.php:
 Introduce new config.qfq.ini setting 'EDIT_FORM_PAGE'

---
 extension/Documentation/Manual.rst      | 8 ++++++--
 extension/config.qfq.example.ini        | 5 +++++
 extension/qfq/qfq/AbstractBuildForm.php | 2 +-
 extension/qfq/qfq/Constants.php         | 2 ++
 extension/qfq/qfq/store/Store.php       | 2 +-
 5 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst
index 5efb0303a..0bd643174 100644
--- a/extension/Documentation/Manual.rst
+++ b/extension/Documentation/Manual.rst
@@ -126,7 +126,9 @@ Setup
 
 FormEditor
 ----------
-Setup a *report* to manage all *forms*: Create a Typo3 page and insert a content record of type *qfq*. In the bodytext insert the following code:
+
+Setup a *report* to manage all *forms*: Create a Typo3 page, set the 'URL Alias' to `form` and insert a content record of
+type *qfq*. In the bodytext insert the following code:
 
 ::
 
@@ -217,7 +219,8 @@ config.qfq.ini
 +-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
 | WKHTMLTOPDF                 | WKHTMLTOPDF=/usr/bin/wkhtmltopdf        | Binary where to find wkhtmltopdf                                           |
 +-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
-
+| EDIT_FORM_PAGE              | EDIT_FORM_PAGE = form                   | T3 Pagealias to edit a form.                                               |
++-----------------------------+-----------------------------------------+----------------------------------------------------------------------------+
 
 Example: *typo3conf/config.qfq.ini*
 
@@ -248,6 +251,7 @@ Example: *typo3conf/config.qfq.ini*
 	;FORM_BS_NOTE_COLUMNS = 3
 	BASE_URL_PRINT=http://example.com
 	WKHTMLTOPDF=/usr/bin/wkhtmltopdf
+	;EDIT_FORM_PAGE = form
 
 .. _local-documentation:
 
diff --git a/extension/config.qfq.example.ini b/extension/config.qfq.example.ini
index 9d1e9415a..66eaa11a8 100644
--- a/extension/config.qfq.example.ini
+++ b/extension/config.qfq.example.ini
@@ -37,6 +37,9 @@ DATE_FORMAT = yyyy-mm-dd
 ;FORM_DATA_MATCH_ERROR =
 ;FORM_DATA_ERROR =
 
+; Default width of whole form
+;FORM_BS_COLUMNS = 12
+
 ; Default size for Bootstrap Form Elements
 ;FORM_BS_LABEL_COLUMNS = 3
 ;FORM_BS_INPUT_COLUMNS = 6
@@ -45,3 +48,5 @@ DATE_FORMAT = yyyy-mm-dd
 ; Configure URL where `wkhtmltopdf` fetches pages and produces PDFs
 BASE_URL_PRINT = http://example.com/
 WKHTMLTOPDF = /opt/wkhtmltox/bin/wkhtmltopdf
+
+;EDIT_FORM_PAGE = form
\ No newline at end of file
diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php
index 2b82b9d79..ae437fc72 100644
--- a/extension/qfq/qfq/AbstractBuildForm.php
+++ b/extension/qfq/qfq/AbstractBuildForm.php
@@ -229,7 +229,7 @@ abstract class AbstractBuildForm {
         }
 
         $queryStringArray = [
-            'id' => $this->store->getVar(TYPO3_PAGE_ID, STORE_TYPO3),
+            'id' => $this->store->getVar(SYSTEM_EDIT_FORM_PAGE, STORE_SYSTEM),
             'form' => 'form',
             'r' => $this->formSpec['id']
         ];
diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php
index 35c58047a..c3f67c606 100644
--- a/extension/qfq/qfq/Constants.php
+++ b/extension/qfq/qfq/Constants.php
@@ -335,6 +335,8 @@ const SYSTEM_FORM_BUTTON_ON_CHANGE_CLASS = 'FORM_BUTTON_ON_CHANGE_CLASS';
 const SYSTEM_BASE_URL_PRINT = 'BASE_URL_PRINT';
 const SYSTEM_WKHTMLTOPDF = 'WKHTMLTOPDF';
 
+const SYSTEM_EDIT_FORM_PAGE = 'EDIT_FORM_PAGE';
+
 // computed automatically during runtime
 const SYSTEM_PATH_EXT = 'EXT_PATH';
 const SYSTEM_SITE_PATH = 'SITE_PATH';
diff --git a/extension/qfq/qfq/store/Store.php b/extension/qfq/qfq/store/Store.php
index 22c055792..2aa67e648 100644
--- a/extension/qfq/qfq/store/Store.php
+++ b/extension/qfq/qfq/store/Store.php
@@ -197,7 +197,7 @@ class Store {
         Support::setIfNotSet($config, F_CLASS_PILL, 'qfq-color-grey-1');
         Support::setIfNotSet($config, F_CLASS_BODY, 'qfq-color-grey-2');
         Support::setIfNotSet($config, F_BUTTON_ON_CHANGE_CLASS, 'btn-info alert-info');
-
+        Support::setIfNotSet($config, SYSTEM_EDIT_FORM_PAGE, 'form');
 
         $config = self::doSystemPath($config);
         $config = self::adjustConfig($config);
-- 
GitLab