diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php index 7a10ac7e18573db1fe05db379217090b9c24f851..b5682ba8ef977e683bf921b803fc296858b4737d 100644 --- a/extension/qfq/qfq/AbstractBuildForm.php +++ b/extension/qfq/qfq/AbstractBuildForm.php @@ -336,8 +336,8 @@ abstract class AbstractBuildForm { // Iterate over all FormElements foreach ($this->feSpecNative as $fe) { - if (($filter === FORM_ELEMENTS_NATIVE && $fe['type'] === 'subrecord') - || ($filter === FORM_ELEMENTS_SUBRECORD && $fe['type'] !== 'subrecord') + if (($filter === FORM_ELEMENTS_NATIVE && $fe[FE_TYPE] === 'subrecord') + || ($filter === FORM_ELEMENTS_SUBRECORD && $fe[FE_TYPE] !== 'subrecord') // || ($filter === FORM_ELEMENTS_DYNAMIC_UPDATE && $fe['dynamicUpdate'] === 'no') ) { continue; // skip this FE @@ -369,7 +369,7 @@ abstract class AbstractBuildForm { $htmlFormElementId = HelperFormElement::buildFormElementId($formElement['name'], ($htmlElementNameIdZero) ? 0 : $recordId); // Construct Marshaller Name: buildElement - $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement['type']]; + $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]]; $jsonElement = array(); // Render pure element @@ -397,7 +397,7 @@ abstract class AbstractBuildForm { } // Construct Marshaller Name: buildRow - $buildRowName = 'buildRow' . $this->buildRowName[$formElement['type']]; + $buildRowName = 'buildRow' . $this->buildRowName[$formElement[FE_TYPE]]; $html .= $this->$buildRowName($formElement, $elementHtml, $htmlFormElementId); // break; @@ -566,7 +566,7 @@ abstract class AbstractBuildForm { $attribute .= $this->getAttributeMode($formElement); - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); return "$htmlTag $attribute>$textarea" . $this->getHelpBlock(); @@ -580,7 +580,7 @@ abstract class AbstractBuildForm { // MIN( $formElement['maxLength'], tabledefinition) $maxLength = $this->getColumnSize($formElement['name']); - switch ($formElement['type']) { + switch ($formElement[FE_TYPE]) { case 'date': $feMaxLength = 10; break; @@ -647,7 +647,7 @@ abstract class AbstractBuildForm { * Builds a HTML attribute list, based on $attributeList. * * E.g.: attributeList: [ 'type', 'autofocus' ] - * generates: 'type="$formElement['type']" autofocus="$formElement['autofocus']" ' + * generates: 'type="$formElement[FE_TYPE]" autofocus="$formElement['autofocus']" ' * * @param array $formElement * @param array $attributeList @@ -714,7 +714,7 @@ abstract class AbstractBuildForm { } /** - * Set corresponding html attributes readonly/required/disabled, based on $formElement['mode']. + * Set corresponding html attributes readonly/required/disabled, based on $formElement[FE_MODE]. * * @param array $formElement * @return string @@ -723,7 +723,7 @@ abstract class AbstractBuildForm { private function getAttributeMode(array $formElement) { $attribute = ''; - switch ($formElement['mode']) { + switch ($formElement[FE_MODE]) { case 'show': break; case 'readonly': @@ -740,8 +740,8 @@ abstract class AbstractBuildForm { default: // Preparation for Log, Debug $this->store->setVar(SYSTEM_FORM_ELEMENT, Logger::formatFormElementName($formElement), STORE_SYSTEM); - $this->store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, 'mode', STORE_SYSTEM); - throw new UserFormException("Unknown mode '" . $formElement['mode'] . "'", ERROR_UNKNOWN_MODE); + $this->store->setVar(SYSTEM_FORM_ELEMENT_COLUMN, FE_MODE, STORE_SYSTEM); + throw new UserFormException("Unknown mode '" . $formElement[FE_MODE] . "'", ERROR_UNKNOWN_MODE); break; } return $attribute; @@ -790,7 +790,7 @@ abstract class AbstractBuildForm { } $attributeBase = $this->getAttributeMode($formElement); - $attributeBase .= Support::doAttribute('type', $formElement['type']); + $attributeBase .= Support::doAttribute('type', $formElement[FE_TYPE]); switch ($formElement['checkBoxMode']) { case 'single': @@ -803,7 +803,7 @@ abstract class AbstractBuildForm { throw new UserFormException('checkBoxMode: \'' . $formElement['checkBoxMode'] . '\' is unknown.', ERROR_CHECKBOXMODE_UNKNOWN); } - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); // return Support::wrapTag('<div class="checkbox">', $html, true); return $html; } @@ -1099,7 +1099,7 @@ abstract class AbstractBuildForm { $attributeBase = $this->getAttributeMode($formElement); $attributeBase .= Support::doAttribute('name', $htmlFormElementId); - $attributeBase .= Support::doAttribute('type', $formElement['type']); + $attributeBase .= Support::doAttribute('type', $formElement[FE_TYPE]); $attributeBase .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : ''); $jj = 0; @@ -1126,8 +1126,8 @@ abstract class AbstractBuildForm { // $element = Support::wrapTag('<label>',$element); -// if(isset($this->feDivClass[$formElement['type']]) && $this->feDivClass[$formElement['type']] != '') { -// $element = Support::wrapTag('<div class="' . $this->feDivClass[$formElement['type']] .'">', $element); +// if(isset($this->feDivClass[$formElement[FE_TYPE]]) && $this->feDivClass[$formElement[FE_TYPE]] != '') { +// $element = Support::wrapTag('<div class="' . $this->feDivClass[$formElement[FE_TYPE]] .'">', $element); // } $html .= $element; @@ -1138,7 +1138,7 @@ abstract class AbstractBuildForm { } } - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); return $html; } @@ -1192,7 +1192,7 @@ abstract class AbstractBuildForm { $option .= '>' . $itemValue[$ii] . '</option>'; } - $json = $this->getJsonElementUpdate($htmlFormElementId, $jsonValues, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $jsonValues, $formElement[FE_MODE]); return '<select ' . $attribute . '>' . $option . '</select>' . $this->getHelpBlock(); } @@ -1577,7 +1577,7 @@ abstract class AbstractBuildForm { } else { $textDeleteClass = ''; $uploadClass = 'hidden'; - $formElement['mode'] = 'disabled'; + $formElement[FE_MODE] = 'disabled'; } $attribute .= $this->getAttributeMode($formElement); @@ -1591,7 +1591,7 @@ abstract class AbstractBuildForm { // <button type="button" class="file-delete" data-sip="571d1fc9e6974"><span class="glyphicon glyphicon-trash"></span></button> - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); return $htmlTextDelete . $htmlInputFile . $hiddenSipUpload; } @@ -1643,7 +1643,7 @@ abstract class AbstractBuildForm { $attribute .= $this->getAttributeMode($formElement); - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); return "$htmlTag $attribute>$textarea"; @@ -1671,11 +1671,11 @@ abstract class AbstractBuildForm { $arrMinMax = null; $this->adjustMaxLength($formElement); - $showTime = ($formElement['type'] == 'time' || $formElement['type'] == 'datetime') ? 1 : 0; + $showTime = ($formElement[FE_TYPE] == 'time' || $formElement[FE_TYPE] == 'datetime') ? 1 : 0; $value = Support::convertDateTime($value, $formElement[FE_DATE_FORMAT], $formElement[FE_SHOW_ZERO], $showTime, $formElement[FE_SHOW_SECONDS]); $tmpPattern = $formElement['checkPattern']; - $formElement['checkPattern'] = Support::dateTimeRegexp($formElement['type'], $formElement['dateFormat']); + $formElement['checkPattern'] = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement['dateFormat']); switch ($formElement['checkType']) { @@ -1702,7 +1702,7 @@ abstract class AbstractBuildForm { $value = substr($value, 0, $formElement['maxLength']); } - $type = $formElement['type']; + $type = $formElement[FE_TYPE]; if ($type === 'datetime') $type = 'datetime-local'; @@ -1715,7 +1715,7 @@ abstract class AbstractBuildForm { if ($formElement['placeholder'] == '') { $timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm'; - switch ($formElement['type']) { + switch ($formElement[FE_TYPE]) { case 'date': $placeholder = $formElement['dateFormat']; break; @@ -1726,7 +1726,7 @@ abstract class AbstractBuildForm { $placeholder = $timePattern; break; default: - throw new UserFormException("Unexpected Formelement type: '" . $formElement['type'] . "'", ERROR_FORMELEMENT_TYPE); + throw new UserFormException("Unexpected Formelement type: '" . $formElement[FE_TYPE] . "'", ERROR_FORMELEMENT_TYPE); } $formElement['placeholder'] = $placeholder; } @@ -1743,7 +1743,7 @@ abstract class AbstractBuildForm { $attribute .= $this->getAttributeMode($formElement); - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); return "<input $attribute>" . $this->getHelpBlock(); @@ -1827,7 +1827,7 @@ abstract class AbstractBuildForm { // restore parent processed FE's $this->feSpecNative = $tmpStore; - $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement['mode']); + $json = $this->getJsonElementUpdate($htmlFormElementId, $value, $formElement[FE_MODE]); return $html; } diff --git a/extension/qfq/qfq/BuildFormPlain.php b/extension/qfq/qfq/BuildFormPlain.php index 116573c7e4544f336ec7b13240da324b73679023..5558eea537978c06e6e6b30b8590d1adccfae82d 100644 --- a/extension/qfq/qfq/BuildFormPlain.php +++ b/extension/qfq/qfq/BuildFormPlain.php @@ -70,7 +70,7 @@ class BuildFormPlain extends AbstractBuildForm { $html = ''; // Construct Marshaller Name -// $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement['type']]; +// $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]]; if($formElement['nestedInFieldSet']==='no') diff --git a/extension/qfq/qfq/BuildFormTable.php b/extension/qfq/qfq/BuildFormTable.php index f993de75602d5f459e10e55c0adf62ed27707fdd..6964eb9a8863ab26f2b6225956cee80c11bc7b9d 100644 --- a/extension/qfq/qfq/BuildFormTable.php +++ b/extension/qfq/qfq/BuildFormTable.php @@ -97,9 +97,9 @@ class BuildFormTable extends AbstractBuildForm { $html = ''; // Construct Marshaller Name - $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement['type']]; + $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]]; - if ($formElement['type'] === 'subrecord') { + if ($formElement[FE_TYPE] === 'subrecord') { // subrecord in render='table' are outside the table $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $formElement['label']); $html .= $this->wrapItem(WRAP_SETUP_SUBRECORD, $htmlElement); diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 1814fa1a14d51423151f071d4b935d54037cec93..84f3562ff375e68b32f67154f9794d0534f92570 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -373,6 +373,7 @@ const FE_SUBRECORD_ROW_TITLE = '_rowTitle'; // FormElement columns: real const FE_TYPE = 'type'; +const FE_MODE = 'mode'; // FormElement columns: via parameter field const FE_DATE_FORMAT = 'dateFormat'; // value: FORMAT_DATE_INTERNATIONAL | FORMAT_DATE_GERMAN diff --git a/extension/qfq/qfq/Save.php b/extension/qfq/qfq/Save.php index ca3aaae73e8ec2b21426e6d38d3468591fbd0cde..33b7fc3c56092dbd0cfc41f8ddab2341bec517cc 100644 --- a/extension/qfq/qfq/Save.php +++ b/extension/qfq/qfq/Save.php @@ -123,7 +123,7 @@ class Save { foreach ($this->feSpecNative AS $formElement) { // skip non upload formElements - if ($formElement['type'] != 'upload') { + if ($formElement[FE_TYPE] != 'upload') { continue; } diff --git a/extension/qfq/qfq/helper/Support.php b/extension/qfq/qfq/helper/Support.php index 71417abb522139e807e545c5bbfdcc97cded1b40..f3c1446a2976fcc11196a1d9a3f6f1dc977a0f97 100644 --- a/extension/qfq/qfq/helper/Support.php +++ b/extension/qfq/qfq/helper/Support.php @@ -425,7 +425,7 @@ class Support { public static function getDateTimePlaceholder(array $formElement) { $timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm'; - switch ($formElement['type']) { + switch ($formElement[FE_TYPE]) { case 'date': $placeholder = $formElement['dateFormat']; break; @@ -436,7 +436,7 @@ class Support { $placeholder = $timePattern; break; default: - throw new UserFormException("Unexpected Formelement type: '" . $formElement['type'] . "'", ERROR_FORMELEMENT_TYPE); + throw new UserFormException("Unexpected Formelement type: '" . $formElement[FE_TYPE] . "'", ERROR_FORMELEMENT_TYPE); } return $placeholder; diff --git a/extension/qfq/qfq/store/FillStoreForm.php b/extension/qfq/qfq/store/FillStoreForm.php index 24d3ab92de93098e6459fd93445bd2792ce46dd6..5c8ee5e70c1ed11a3cb6ab728181979534a9d983 100644 --- a/extension/qfq/qfq/store/FillStoreForm.php +++ b/extension/qfq/qfq/store/FillStoreForm.php @@ -120,7 +120,7 @@ class FillStoreForm { // Preparation for Log, Debug // $this->store->setVar(SYSTEM_FORM_ELEMENT, $formElement['name'] . ' / ' . $formElement['id'], STORE_SYSTEM); - if ($formElement['type'] == 'hidden') { + if ($formElement[FE_TYPE] == 'hidden') { // Hidden elements will be transferred by SIP if (!isset($sipValues[$formElement['name']])) { throw new CodeException("Missing the hidden field '" . $formElement['name'] . "' in SIP.", ERROR_MISSING_HIDDEN_FIELD_IN_SIP); @@ -130,13 +130,13 @@ class FillStoreForm { continue; } - if ($formElement['mode'] === FE_MODE_REQUIRED) { + if ($formElement[FE_MODE] === FE_MODE_REQUIRED) { if (!isset($clientValues[$clientFieldName]) || ($clientValues[$clientFieldName] === '')) { throw new UserFormException("Missing required value.", ERROR_REQUIRED_VALUE_EMPTY); } } - switch ($formElement['mode']) { + switch ($formElement[FE_MODE]) { case FE_MODE_REQUIRED: case FE_MODE_SHOW: if (isset($clientValues[$clientFieldName])) { @@ -151,7 +151,7 @@ class FillStoreForm { $clientValues[$clientFieldName] = implode(',', $clientValues[$clientFieldName]); } - switch ($formElement['type']) { + switch ($formElement[FE_TYPE]) { case 'date': case 'datetime': case 'time': @@ -171,7 +171,7 @@ class FillStoreForm { case FE_MODE_DISABLED: continue; default: - throw new CodeException("Unknown mode: " . $formElement['mode'], ERROR_UNKNOWN_MODE); + throw new CodeException("Unknown mode: " . $formElement[FE_MODE], ERROR_UNKNOWN_MODE); } } @@ -188,14 +188,14 @@ class FillStoreForm { */ private function doDateTime(array &$formElement, $value) { - $regexp = Support::dateTimeRegexp($formElement['type'], $formElement['dateFormat']); + $regexp = Support::dateTimeRegexp($formElement[FE_TYPE], $formElement['dateFormat']); if (1 !== preg_match('/' . $regexp . '/', $value, $matches)) { $placeholder = Support::getDateTimePlaceholder($formElement); throw new UserFormException("DateTime format not recognized: $placeholder / $value ", ERROR_DATE_TIME_FORMAT_NOT_RECOGNISED); } - $showTime = $formElement['type'] == 'date' ? '0' : '1'; + $showTime = $formElement[FE_TYPE] == 'date' ? '0' : '1'; $value = Support::convertDateTime($value, FORMAT_DATE_INTERNATIONAL, '1', $showTime, $formElement[FE_SHOW_SECONDS]); return $value; diff --git a/extension/qfq/tests/phpunit/BuildFormPlainTest.php b/extension/qfq/tests/phpunit/BuildFormPlainTest.php index 93d1b65533cde5a44cad451289830b0c1928e13f..fea1762a85394e672e4659762d04fff1800d3353 100644 --- a/extension/qfq/tests/phpunit/BuildFormPlainTest.php +++ b/extension/qfq/tests/phpunit/BuildFormPlainTest.php @@ -193,9 +193,9 @@ class BuildFormPlainTest extends AbstractDatabaseTest { 'enabled' => 'yes', 'name' => 'name', 'label' => 'Name', - 'mode' => 'show', + FE_MODE => 'show', 'class' => 'native', - 'type' => 'input', + FE_TYPE => 'input', 'value' => '', 'sql1' => '', 'parameter' => '',