Commit 61aee0ae authored by Carsten  Rose's avatar Carsten Rose
Browse files

B3613 - revert broken fixes #3616 (Revision 0bb99fd1, Revision 77096ca7)

parent a6622ff1
Pipeline #1043 passed with stage
in 1 minute and 56 seconds
...@@ -720,37 +720,41 @@ EOF; ...@@ -720,37 +720,41 @@ EOF;
$htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClass); $htmlLabel = $this->buildLabel($htmlFormElementName, $formElement[FE_LABEL], $addClass);
} }
$html .= $this->customWrap($formElement, $htmlLabel, WRAP_SETUP_LABEL, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS], $html .= $this->customWrap($formElement, $htmlLabel, FE_WRAP_LABEL, $formElement[FE_BS_LABEL_COLUMNS],
$formElement[FE_HTML_ID] . HTML_ID_EXTENSION_LABEL); [$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 // Input
$html .= $this->customWrap($formElement, $htmlElement, WRAP_SETUP_INPUT, FE_WRAP_INPUT, $formElement[FE_BS_INPUT_COLUMNS], $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); $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_INPUT, $classHideElement);
// Note // Note
$note = $formElement[FE_NOTE]; $note = $formElement[FE_NOTE];
$html .= $this->customWrap($formElement, $note, WRAP_SETUP_NOTE, FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS], $html .= $this->customWrap($formElement, $note, FE_WRAP_NOTE, $formElement[FE_BS_NOTE_COLUMNS],
$formElement[FE_HTML_ID] . HTML_ID_EXTENSION_NOTE); [$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 // Row
$html = $this->customWrap($formElement, $html, WRAP_SETUP_ELEMENT, FE_WRAP_ROW -1, $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW, $classHideRow); $openTag = $formElement[FE_FLAG_ROW_OPEN_TAG] ? $this->getRowOpenTag($classHideRow) : '';
$closeTag = $formElement[FE_FLAG_ROW_CLOSE_TAG] ? $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END] : '';
$html = $this->customWrap($formElement, $html, FE_WRAP_ROW, -1, [$openTag, $closeTag], $formElement[FE_HTML_ID] . HTML_ID_EXTENSION_ROW);
return $html; return $html;
} }
/** /**
* Wrap content as defined in this->wrap or, if specified use $formElement[$wrapName]. Inject $htmlId in wrap. * Wrap content with $wrapArray or, if specified use $formElement[$wrapName]. Inject $htmlId in wrap.
* *
* Result: * Result:
* - if $bsColumns==0 and empty $formElement[$wrapName]: no wrap * - if $bsColumns==0 and empty $formElement[$wrapName]: no wrap
* - if $formElement[$customWrapName] is given: wrap with that one. * - if $formElement[$wrapName] is given: wrap with that one. Else: wrap with $wrapArray
* - if $htmlId is given, inject it in $wrap. * - if $htmlId is give, inject it in $wrap.
* *
* @param array $formElement Complete FormElement, especially some FE_WRAP * @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap. * @param string $htmlElement Content to wrap.
* @param string $wrapType WRAP_SETUP_ELEMENT, WRAP_SETUP_LABEL, WRAP_SETUP_INPUT, WRAP_SETUP_NOTE
* @param string $wrapName FE_WRAP_ROW, FE_WRAP_LABEL, FE_WRAP_INPUT, FE_WRAP_NOTE * @param string $wrapName FE_WRAP_ROW, FE_WRAP_LABEL, FE_WRAP_INPUT, FE_WRAP_NOTE
* @param int $bsColumns * @param int $bsColumns
* @param array $wrapArray Systemwide Defaults: [ 'open wrap', 'close wrap' ]
* @param string $htmlId * @param string $htmlId
* @param string $class * @param string $class
* *
...@@ -758,46 +762,29 @@ EOF; ...@@ -758,46 +762,29 @@ EOF;
* @throws CodeException * @throws CodeException
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
private function customWrap(array $formElement, $htmlElement, $wrapType, $wrapName, $bsColumns, $htmlId = '', $class = '') { private function customWrap(array $formElement, $htmlElement, $wrapName, $bsColumns, array $wrapArray, $htmlId = '', $class = '') {
$openTag = '';
$closeTag = '';
// If $bsColumns==0: do not wrap with default. // If $bsColumns==0: do not wrap with default.
if ($bsColumns != 0) { if ($bsColumns == 0) {
switch ($wrapType) { $wrapArray[0] = '';
case WRAP_SETUP_ELEMENT; $wrapArray[1] = '';
$openTag = $formElement[FE_FLAG_ROW_OPEN_TAG] ? $this->getRowOpenTag($class) : '';
$closeTag = $formElement[FE_FLAG_ROW_CLOSE_TAG] ? $this->wrap[$wrapType][WRAP_SETUP_END] : '';
break;
case WRAP_SETUP_LABEL:
case WRAP_SETUP_INPUT:
case WRAP_SETUP_NOTE:
$hasOpen = Support::findInSet($wrapType, $formElement[FE_WRAP_ROW_LABEL_INPUT_NOTE]);
$hasClose = Support::findInSet("/$wrapType", $formElement[FE_WRAP_ROW_LABEL_INPUT_NOTE]);
$openTag = $hasOpen ? $this->wrap[$wrapType][WRAP_SETUP_START] : '';
$closeTag = $hasClose ? $this->wrap[$wrapType][WRAP_SETUP_END] : '';
break;
default:
throw new UserFormException("Unknown wrap for FormElement.parameter '$wrapType'.", ERROR_MISSING_VALUE);
break;
}
} }
// If there is a 'per FormElement'-wrap, take it. // If there is a 'per FormElement'-wrap, take it.
if (isset($formElement[$wrapName])) { if (isset($formElement[$wrapName])) {
$wrapArray = explode('|', $formElement[$wrapName], 2); $wrapArray = explode('|', $formElement[$wrapName], 2);
$openTag = $wrapArray[0] ?? '';
$closeTag = $wrapArray[1] ?? '';
} }
if ($openTag != '') { if (count($wrapArray) != 2) {
$openTag = Support::insertAttribute($openTag, 'id', $htmlId); throw new UserFormException("Need open & close wrap token for FormElement.parameter" . $wrapName . " - E.g.: <div ...>|</div>", ERROR_MISSING_VALUE);
$openTag = Support::insertAttribute($openTag, 'class', $class); // might be problematic, if there is already a 'class' defined. }
if ($wrapArray[0] != '') {
$wrapArray[0] = Support::insertAttribute($wrapArray[0], 'id', $htmlId);
$wrapArray[0] = Support::insertAttribute($wrapArray[0], 'class', $class); // might be problematic, if there is already a 'class' defined.
} }
return $openTag . $htmlElement . $closeTag; return $wrapArray[0] . $htmlElement . $wrapArray[1];
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment