Commit 64a34001 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'master' into twig_new

# Conflicts:
#	extension/Classes/Core/Database/Database.php
parents 4fea624d d7dfe24d
Pipeline #2114 passed with stages
in 2 minutes and 59 seconds
......@@ -30,7 +30,11 @@ nbprojec
qfq.flowchart.dia.autosave
test.json
test.php
test.html
*.autosave
composer.lock
/Documentation-GENERATED-temp
/bower_components
/composer.phar
......
before_script:
- VERSION=`cat ./version`
- RELDATE=`date '+%Y%m%d%H%M'`
- mkdir build || true
variables:
......@@ -28,6 +29,7 @@ snapshot:
script:
- make VERSION=$VERSION phpunit_snapshot
- chmod a+r qfq_$VERSION_*.zip
- mv qfq_$VERSION_*.zip qfq_${VERSION}_${RELDATE}-${CI_BUILD_REF_NAME}.zip
- scp qfq_$VERSION_*.zip w16:qfq/snapshots/
- mv qfq_$VERSION_*.zip build/qfq.zip
......
......@@ -36,6 +36,41 @@ Features
Bug Fixes
^^^^^^^^^
Version 19.7.0
--------------
Date: 02.07.2019
Notes
^^^^^
* Settings for tablesorter can now be saved.
* Selenium docker based is integrated now.
Features
^^^^^^^^
* #7284 tablesorter save sort order
* #8592 Fixed button display, added Alert instead of disabled button.
* #8204 / position required mark
* Excel.php: Delete superficial autoloader require
* Cleanup: hashPassword.php moved from Api to External.
* Cleanup unwanted git tracked files: Documentation-develop/jsdoc|...
* Selenium + Docker
* Update .gitignore - documentation directory moved several days ago.
Bug Fixes
^^^^^^^^^
* #6917 / Fix Monitor does not work.
* #8098 / Fix Language specific retype label or note has not been set correctly.
* Fix undefined index and potential undefined index.
* Fix Autoloader for External/AutoCron.php.
* Small fixes Manual.rst.
* Fix broken Manual: unwanted '<' after '{{!' lead to fully broken Manual.
* Fix path Source/api to Source/Api.
Version 19.6.2
--------------
......
......@@ -53,12 +53,12 @@ Neue Versionsnummer
* Update the version number in this document (topic 6)
* Commit & Push new version changes to master branch:
New version 19.6.2
New version 19.7.0
6) **New Tag**:
git tag v19.6.2
git push -u origin v19.6.2
git tag v19.7.0
git push -u origin v19.7.0
7) Tickets:
* Schliessen und der QFQ Version zuweisen.
......
......@@ -38,7 +38,8 @@ General
* Project homepage: https://qfq.io
* Latest releases: https://qfq.io/download
* Development: https://git.math.uzh.ch/typo3/qfq
* Slack: https://qfq-io.slack.com
* Chat: https://hello.math.uzh.ch > QFQ
.. _installation:
......@@ -1235,7 +1236,7 @@ Only in FormElement:
| **auto** | Form | | Only supported for FormElements. Most suitable checktype is dynamically evaluated based |
| | | | on native column definition, the FormElement type, and other info. See below for details. |
+------------------+------+-------+-------------------------------------------------------------------------------------------+
| **email** | Form | Query | [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,} |
| **email** | Form | Query | [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\\.[a-zA-Z]{2,} |
+------------------+------+-------+-------------------------------------------------------------------------------------------+
| **pattern** | Form | | Compares the value against a regexp. |
+------------------+------+-------+-------------------------------------------------------------------------------------------+
......@@ -1266,15 +1267,15 @@ The following `escape` & `action` types are available:
+=======+==================================================================================================================================+
| c | Config - the escape type configured in `configuration`_. |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
| C | Colon ':' will be escaped against \\:. |
| C | Colon ':' will be escaped against \\: |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
| d | Double ticks " will be escaped against \\". |
| d | Double ticks " will be escaped against \\\". |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
| l | LDAP search filter values: `ldap-escape() <http://php.net/manual/en/function.ldap-escape.php>`_ (LDAP_ESCAPE_FILTER). |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
| L | LDAP DN values. `ldap-escape() <http://php.net/manual/en/function.ldap-escape.php>`_ (LDAP_ESCAPE_DN). |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
| s | Single ticks ' will be escaped against \\'. |
| s | Single ticks ' will be escaped against \\\'. |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
| S | Stop replace. If the replaced value contains nested variables, they won't be replaced. |
+-------+----------------------------------------------------------------------------------------------------------------------------------+
......@@ -1308,12 +1309,13 @@ Escape
To 'escape' a character typically means: a character, which have a special meaning/function, should not treated as a special
character.
E.g. a string is surrounded by single ticks '. If such a string should contain a single tick inside (like 'Miller's'),
the inside single tick has to be escaped. This is typically done by a backlash: 'Millers\\'s'.
E.g. a string is surrounded by single ticks '. If such a string should contain the same single tick inside,
the inside single tick has to be escaped - if not, the string end's at the second tick, not the third. This is typically
done by a backlash: \\
QFQ offers different ways of escaping. Which of them to use, depends on the situation.
Especially variables used in SQL Statements might cause trouble when using: NUL (ASCII 0), \\n, \\r, \\, ', ", or Control-Z.
Especially variables used in SQL statements might cause trouble when using: NUL (ASCII 0), \\n, \\r, \\, ', ", or Control-Z.
Action
^^^^^^
......@@ -1347,7 +1349,7 @@ Default
* Any string can be given to define a default value.
* If a default value is given, it makes no sense to define more than one store: with a default value given, only the
first store is considered.
* If the default value contains a ':', that one needs to be escaped by '\'.
* If the default value contains a ':', that one needs to be escaped by \\
.. _`variable-type-message-violate`:
......@@ -1360,7 +1362,7 @@ If a value violates the sanitize class, the following actions are possible:
* 'e' - Instead of the value an empty string will be set as content.
* '0' - Instead of the value the string '0' will be set as content.
* 'custom text ...' - Instead of the value, the custom text will be set as content. If the text contains a ':', that one
needs to be escaped by '\'. Check `variable-escape`_ qualifier 'C' to let QFQ do the colon escaping.
needs to be escaped by \\ . Check `variable-escape`_ qualifier 'C' to let QFQ do the colon escaping.
.. _`sql-variables`:
......@@ -2197,9 +2199,9 @@ Comment- and space-character
The following applies to the fields `Form.parameter` and `FormElement.parameter`:
* Lines will be trimmed - leading and trailing spaces will be removed.
* If a leading and/or trailing space is needed, escape it: '\\ hello world \\' > ' hello world '.
* If a leading and/or trailing space is needed, escape it: \\ hello world \\ > ' hello world '.
* Lines starting with a '#' are treated as a comment and will not be parsed. Such lines are treated as 'empty lines'.
* The comment sign can be escaped with '\\'.
* The comment sign can be escaped with \\ .
.. _form-main:
......@@ -2522,6 +2524,8 @@ Parameter
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| maxFileSize | int | Overwrite default from configuration_ . |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
| requiredPosition | int | See requiredPosition_ . |
+-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
* Example:
......@@ -2966,9 +2970,9 @@ See also at specific *FormElement* definitions.
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| htmlBefore | string | HTML Code wrapped before the complete *FormElement* |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| extraButtonLock | none | No value. Show a 'lock' on the right side of the input element. See `extraButtonLock`_ |
| extraButtonLock | none | [0|1] Show a 'lock' on the right side of the input element. See `extraButtonLock`_ |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| extraButtonPassword | none | No value. Show an 'eye' on the right side of the input element. See `extraButtonPassword`_ |
| extraButtonPassword | none | [0|1] Show an 'eye' on the right side of the input element. See `extraButtonPassword`_ |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| extraButtonInfo | string | Text. Show an 'i' on the right side of the input element. See `extraButtonInfo`_ |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
......@@ -3033,6 +3037,8 @@ See also at specific *FormElement* definitions.
| messageFail | string | |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| dataReference | string | Optional. See `applicationTest`_ |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
| requiredPosition | int | See requiredPosition_ . |
+------------------------+--------+----------------------------------------------------------------------------------------------------------+
......@@ -3096,6 +3102,21 @@ extraButtonInfo
* For `FormElement` with mode `below`, a `span` element with the given class in `extraButtonInfoClass` (FE, F, configuration_)
will be applied. E.g. this might be `pull-right` to align the `info` button/icon on the right side below the input element.
.. _`requiredPosition`:
Required Position
^^^^^^^^^^^^^^^^^
By default, input elements with `Mode=required` will be displayed with a 'red asterix' right beside the label. The position
of the 'red asterix' can be choosen via the `parameter` field::
requiredPosition = label-left|label-right|input-left|input-right|note-left|note-right
The default is 'label-right'.
The definition can be set per Form (=affects all FormElements) or per FormElement.
.. _`input-checkbox`:
Type: checkbox
......@@ -3134,7 +3155,7 @@ Checkboxes can be rendered in mode:
* ``itemList=red,blue,orange``
* ``itemList=1:red,2:blue,3:orange``
* If ':' or ',' are part of key or value, it needs to escaped by '\\'.
* If ':' or ',' are part of key or value, it needs to escaped by \\ .
E.g.: `itemList=1:red\\: (with colon),2:blue\\, (with comma),3:orange``
* *FormElement.sql1* = ``{{!SELECT id, value FROM someTable}}``
......@@ -3440,7 +3461,7 @@ Type: radio
2. *FormElement.parameter*:
* *itemList* = `<attribute>` E.g.: *itemList=red,blue,orange* or *itemList=1:red,2:blue,3:orange*
* If ':' or ',' are part of key or value, it needs to escaped by '\\'. E.g.: `itemList=1:red\\: (with colon),2:blue\\, (with comma),3:orange`
* If ':' or ',' are part of key or value, it needs to escaped by \\ . E.g.: `itemList=1:red\\: (with colon),2:blue\\, (with comma),3:orange`
3. Definition of the *enum* or *set* field (only labels, ids are not possible).
......@@ -3503,7 +3524,7 @@ Type: select
* *FormElement.parameter*:
* *itemList* = `<attribute>` - E.g.: *itemList=red,blue,orange* or *itemList=1:red,2:blue:3:orange*
* If ':' or ',' are part of key or value, it needs to escaped by '\\'. E.g.: `itemList=1:red\\: (with colon),2:blue\\, (with comma),3:orange`
* If ':' or ',' are part of key or value, it needs to escaped by \\ . E.g.: `itemList=1:red\\: (with colon),2:blue\\, (with comma),3:orange`
* Definition of the *enum* or *set* field (only labels, ids are not possible).
......@@ -5470,7 +5491,7 @@ Notice the space between "...world'" and "FROM ...".
Join mode: strip whitespace
"""""""""""""""""""""""""""
Ending a line with a '\\' strips all leading and trailing whitespaces of that line joins the line directly (no extra
Ending a line with a \\ strips all leading and trailing whitespaces of that line joins the line directly (no extra
space in between). E.g.::
10.sql = SELECT 'hello world', 'd:final.pdf \
......@@ -5479,7 +5500,7 @@ space in between). E.g.::
Results to: ``10.sql = SELECT 'hello world', 'd:final.pdf|p:id=export|t:Download' AS _pdf``
Note: the '\\' does not force the joining, it only removes the whitespaces.
Note: the \\ does not force the joining, it only removes the whitespaces.
To get the same result, the following is also possible::
......@@ -5955,7 +5976,7 @@ Question
If the user click on the negative answer (or waits for timout), the alert is closed and the browser does nothing.
* All parameter are optional.
* Parameter are separated by ':'
* To use ':' inside the text, the colon has to be escaped by '\\'. E.g. 'ok\\: I understand'.
* To use ':' inside the text, the colon has to be escaped by \\. E.g. 'ok\\ : I understand'.
+----------------------+--------------------------------------------------------------------------------------------------------------------------+
| Parameter | Description |
......@@ -6789,7 +6810,7 @@ Parameter and (element) sources
Check `wkhtmltopdf.txt <https://wkhtmltopdf.org/usage/wkhtmltopdf.txt>`_ for possible options. Be aware that
key/value tuple in the documentation is separated by a space, but to respect the QFQ key/value notation of URLs,
the key/value tuple in `p:...`, `u:...` or `U:...` has to be separated by '='. Please see last example below.
* If an option contains an '&' it must be escaped with double '\\'. See example.
* If an option contains an '&' it must be escaped with double \\ . See example.
Most of the other Link-Class attributes can be used to customize the link as well.
......
......@@ -36,6 +36,41 @@ Features
Bug Fixes
^^^^^^^^^
Version 19.7.0
--------------
Date: 02.07.2019
Notes
^^^^^
* Settings for tablesorter can now be saved.
* Selenium docker based is integrated now.
Features
^^^^^^^^
* #7284 tablesorter save sort order
* #8592 Fixed button display, added Alert instead of disabled button.
* #8204 / position required mark
* Excel.php: Delete superficial autoloader require
* Cleanup: hashPassword.php moved from Api to External.
* Cleanup unwanted git tracked files: Documentation-develop/jsdoc|...
* Selenium + Docker
* Update .gitignore - documentation directory moved several days ago.
Bug Fixes
^^^^^^^^^
* #6917 / Fix Monitor does not work.
* #8098 / Fix Language specific retype label or note has not been set correctly.
* Fix undefined index and potential undefined index.
* Fix Autoloader for External/AutoCron.php.
* Small fixes Manual.rst.
* Fix broken Manual: unwanted '<' after '{{!' lead to fully broken Manual.
* Fix path Source/api to Source/Api.
Version 19.6.2
--------------
......
......@@ -21,8 +21,8 @@
; you can use in 'conf.py'
project = QFQ - Quick Form Query
version = 19.6
release = 19.6.2
version = 19.7
release = 19.7.0
t3author = Carsten Rose
copyright = since 2017 by the author
......
......@@ -22,7 +22,7 @@ $data = array();
try {
try {
$form = OnString::splitPathInfoToIdForm($_SERVER['PATH_INFO'], $restId, $restForm);
$form = OnString::splitPathInfoToIdForm($_SERVER['PATH_INFO'] ?? '', $restId, $restForm);
// get latest `ìd`
$id = end($restId);
......@@ -31,7 +31,7 @@ try {
$bodytext = TYPO3_RECORD_ID . '=' . $id . PHP_EOL;
$bodytext .= TYPO3_FORM . '=' . $form . PHP_EOL;
$method = $_SERVER['REQUEST_METHOD'];
$method = $_SERVER['REQUEST_METHOD'] ?? '';
switch ($method) {
case REQUEST_METHOD_GET:
$status = HTTP_200_OK;
......
......@@ -58,7 +58,8 @@ try {
if (isset($data[REPORT_SAVE])) {
// Redirect to previous page
header("Location: {$_SERVER['HTTP_REFERER']}");
$referer = $_SERVER['HTTP_REFERER'] ?? '';
header("Location: {$referer}");
}
$arr = $qfq->getForwardMode();
......
......@@ -8,19 +8,19 @@
namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\Store;
use IMATHUZH\Qfq\Core\Database\Database;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Helper\Ldap;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\KeyValueStringParser;
use IMATHUZH\Qfq\Core\Report\Link;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Sanitize;
use IMATHUZH\Qfq\Core\Helper\HelperFile;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Report\Link;
use IMATHUZH\Qfq\Core\Report\Report;
use IMATHUZH\Qfq\Core\Store\Sip;
use IMATHUZH\Qfq\Core\Store\Store;
/**
* Class AbstractBuildForm
......@@ -958,6 +958,7 @@ abstract class AbstractBuildForm {
* @throws \UserFormException
*/
private function getFormElementForJson($htmlFormElementName, $value, array $formElement) {
$addClassRequired = array();
$json = $this->getJsonFeMode($formElement[FE_MODE]); // disabled, required
......@@ -984,14 +985,20 @@ abstract class AbstractBuildForm {
// }
}
if ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
}
if (isset($formElement[FE_LABEL])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL;
$addClass = ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) ? CSS_REQUIRED : '';
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClass);
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
}
if (isset($formElement[FE_NOTE])) {
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE;
if (!empty($addClassRequired[FE_NOTE])) {
$formElement[FE_NOTE] = Support::wrapTag('<span class="' . $addClassRequired[FE_NOTE] . '">', $formElement[FE_NOTE]);
}
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_CONTENT] = $formElement[FE_NOTE];
}
......@@ -1041,6 +1048,10 @@ abstract class AbstractBuildForm {
$class .= ' hidden';
}
if (!empty($addClassRequired[FE_INPUT])) {
$class .= ' ' . $addClassRequired[FE_INPUT];
}
$key = $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW;
$json[API_ELEMENT_UPDATE][$key][API_ELEMENT_ATTRIBUTE]['class'] = $class;
}
......
......@@ -8,11 +8,11 @@
namespace IMATHUZH\Qfq\Core;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
use IMATHUZH\Qfq\Core\Helper\Logger;
use IMATHUZH\Qfq\Core\Helper\OnArray;
use IMATHUZH\Qfq\Core\Helper\Support;
use IMATHUZH\Qfq\Core\Helper\HelperFormElement;
/**
* Class BuildFormBootstrap
......@@ -728,6 +728,7 @@ EOF;
$htmlLabel = '';
$classHideRow = '';
$classHideElement = '';
$addClassRequired = array();
if ($formElement[FE_MODE] == FE_MODE_HIDDEN) {
if ($formElement[FE_FLAG_ROW_OPEN_TAG] && $formElement[FE_FLAG_ROW_CLOSE_TAG]) {
......@@ -737,23 +738,32 @@ EOF;
}
}
if ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) {
$addClassRequired = HelperFormElement::getRequiredPositionClass($formElement[F_FE_REQUIRED_POSITION]);
}
// Label
if ($formElement[FE_BS_LABEL_COLUMNS] != '0') {
$addClass = ($formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED) ? CSS_REQUIRED : '';
$htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClass);
$htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClassRequired[FE_LABEL] ?? '');
}
$html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS],
[$this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_LABEL][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL);
// Input
if (!empty($addClassRequired[FE_INPUT])) {
$htmlElement = Support::wrapTag('<span class="' . $addClassRequired[FE_INPUT] . '">', $htmlElement);
}
$html .= $this->customWrap($formElement, $htmlElement, FE_WRAP_INPUT, $formElement[FE_BS_INPUT_COLUMNS],
[$this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_INPUT][WRAP_SETUP_END]],
$formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT, $classHideElement);
if (!empty($addClassRequired[FE_NOTE])) {
$formElement[FE_NOTE] = Support::wrapTag('<span class="' . $addClassRequired[FE_NOTE] . '">', $formElement[FE_NOTE]);
}
// Note
$note = $formElement[FE_NOTE];
$html .= $this->customWrap($formElement, $note, FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS],
$html .= $this->customWrap($formElement, $formElement[FE_NOTE], FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS],
[$this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_START], $this->wrap[WRAP_SETUP_NOTE][WRAP_SETUP_END]], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE);
// Row
......
......@@ -675,7 +675,8 @@ const DOWNLOAD_POPUP_REPLACE_TITLE = '#downloadPopupReplaceTitle#';
const SYSTEM_DRAG_AND_DROP_JS = 'hasDragAndDropJS';
const SYSTEM_PARAMETER_LANGUAGE_FIELD_NAME = 'parameterLanguageFieldName';
const CSS_REQUIRED = 'required-field';
const CSS_REQUIRED_RIGHT = 'required-right';
const CSS_REQUIRED_LEFT = 'required-left';
// die folgenden Elemente sind vermutlich nicht noetig, wenn Store Klassen globale Vars benutzt.
//const SYSTEM_FORM_DEF = 'formDefinition'; // Type: SANITIZE_ALNUMX / AssocArray. Final form to process. Useful for error reporting.
......@@ -964,6 +965,13 @@ const F_FE_DATA_MATCH_ERROR_DEFAULT = 'Fields do not match'; // Attention: the d
const F_FE_LABEL_ALIGN = SYSTEM_LABEL_ALIGN;
const F_FE_LABEL_ALIGN_DEFAULT = 'default';
const F_FE_REQUIRED_POSITION = 'requiredPosition';
const F_FE_REQUIRED_POSITION_LABEL_LEFT = 'label-left';
const F_FE_REQUIRED_POSITION_LABEL_RIGHT = 'label-right';
const F_FE_REQUIRED_POSITION_INPUT_LEFT = 'input-left';
const F_FE_REQUIRED_POSITION_INPUT_RIGHT = 'input-right';
const F_FE_REQUIRED_POSITION_NOTE_LEFT = 'note-left';
const F_FE_REQUIRED_POSITION_NOTE_RIGHT = 'note-right';
const F_PARAMETER = 'parameter'; // valid for F_ and FE_
......@@ -1060,6 +1068,7 @@ const FE_VALUE = 'value';
const FE_CLASS = 'class';
const FE_LABEL = 'label';
const FE_NOTE = 'note';
const FE_INPUT = 'input';
const FE_BS_LABEL_COLUMNS = F_BS_LABEL_COLUMNS;
const FE_BS_INPUT_COLUMNS = F_BS_INPUT_COLUMNS;
const FE_BS_NOTE_COLUMNS = F_BS_NOTE_COLUMNS;
......
......@@ -851,7 +851,7 @@ class Database {
$feSpecNative = $this->sql($sql, ROW_REGULAR, $param);
$feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative);
$feSpecNative = HelperFormElement::formElementSetDefault($feSpecNative, $formSpec);
// Explode and Do $FormElement.parameter
HelperFormElement::explodeParameterInArrayElements($feSpecNative, FE_PARAMETER);
......
......@@ -75,7 +75,7 @@ class File {
}
// Throws an exception if content is too big - if content is bigger than 'post_max_size', the POST is lost together with the PHP Upload error message.
$size = isset($_SERVER['CONTENT_LENGTH']) ? $_SERVER['CONTENT_LENGTH'] : 0;
$size = $_SERVER['CONTENT_LENGTH'] ?? 0;
$this->checkMaxFileSize($size);
$statusUpload = $this->store->getVar($sipUpload, STORE_EXTRA, SANITIZE_ALLOW_ALL);
......
......@@ -9,7 +9,7 @@
namespace IMATHUZH\Qfq\Core\Helper;
use IMATHUZH\Qfq\Core\Store\Store;
/**
* Class HelperFormElement
......@@ -40,16 +40,20 @@ class HelperFormElement {
/**
* Set default values for given FormElement.
* Hint: to copy values from Form, copyAttributesToFormElements() is more appropriate.
*
* @param array $elements
*
* @param array $formSpec
* @return array
*/
public static function formElementSetDefault(array $elements) {
public static function formElementSetDefault(array $elements, array $formSpec) {
foreach ($elements AS $key => $element) {
$elements[$key][FE_TG_INDEX] = 0;
unset($elements[$key][FE_ADMIN_NOTE]);
// $elements[$key][FE_DATA_REFERENCE] = '';
}
return $elements;
......@@ -89,9 +93,11 @@ class HelperFormElement {
// For retype elements: copy the language specific value.
if (isset($element[FE_RETYPE_SOURCE_NAME])) {
if (!empty($element[FE_RETYPE_LABEL])) {
$element[FE_LABEL] = $element[FE_RETYPE_LABEL];
}
if (!empty($element[FE_RETYPE_NOTE])) {
$element[FE_NOTE] = $element[FE_RETYPE_NOTE];
}
......@@ -271,6 +277,7 @@ class HelperFormElement {
if ($feSpecNative[$key][F_FE_LABEL_ALIGN] == F_FE_LABEL_ALIGN_DEFAULT) {
$feSpecNative[$key][F_FE_LABEL_ALIGN] = $formSpec[F_FE_LABEL_ALIGN];
}
Support::setIfNotSet($feSpecNative[$key], F_FE_REQUIRED_POSITION, $formSpec[F_FE_REQUIRED_POSITION]);
}
return $feSpecNative;
......@@ -398,8 +405,7 @@ EOF;
$skip = (!($formElement[FE_MODE] == FE_MODE_SHOW || $formElement[FE_MODE] == FE_MODE_REQUIRED || $formElement[FE_MODE] == FE_MODE_SHOW_REQUIRED));
// LOCK
if (!$skip && isset($formElement[FE_INPUT_EXTRA_BUTTON_LOCK])) {
if (!$skip && HelperFormElement::booleParameter($formElement[FE_INPUT_EXTRA_BUTTON_LOCK] ?? '-')) {
$formElement[FE_MODE] = FE_MODE_READONLY;
$extraButton .= <<<EOF
......@@ -411,7 +417,8 @@ EOF;
}
// PASSWORD
if (!$skip && isset($formElement[FE_INPUT_EXTRA_BUTTON_PASSWORD])) {
// if (!$skip && isset($formElement[FE_INPUT_EXTRA_BUTTON_PASSWORD])) {
if (!$skip && HelperFormElement::booleParameter($formElement[FE_INPUT_EXTRA_BUTTON_PASSWORD] ?? '-')) {
$formElement[FE_TYPE] = 'password';
......@@ -464,4 +471,59 @@ EOF;
return json_encode($rgb);
}
/**
* Depending on value in $requiredPosition the array $classArr will contain the CSS class to align the required mark.
* @param $requiredPosition
* @return array
* @throws \UserFormException
*/
public static function getRequiredPositionClass($requiredPosition) {