2 namespace TYPO3\CMS\Backend\Form\Container;
50 $table = $this->data[
'tableName'];
51 $row = $this->data[
'databaseRow'];
52 $fieldName = $this->data[
'fieldName'];
55 if (!is_array($this->data[
'processedTca'][
'columns'][$fieldName])) {
59 $parameterArray = array();
60 $parameterArray[
'fieldConf'] = $this->data[
'processedTca'][
'columns'][$fieldName];
66 if (isset($this->data[
'processedTca'][
'ctrl'][
'transOrigPointerField'])
67 && is_array($this->data[
'processedTca'][
'columns'][$this->data[
'processedTca'][
'ctrl'][
'transOrigPointerField']])
68 && is_array($row[$this->data[
'processedTca'][
'ctrl'][
'transOrigPointerField']])
69 && $row[$this->data[
'processedTca'][
'ctrl'][
'transOrigPointerField']][0] > 0
77 $parameterArray[
'fieldConf'][
'exclude'] && !$backendUser->check(
'non_exclude_fields', $table .
':' . $fieldName)
78 || $parameterArray[
'fieldConf'][
'config'][
'type'] ===
'passthrough'
80 || !$backendUser->isRTE() && $parameterArray[
'fieldConf'][
'config'][
'showIfRTE']
82 || $isOverlay && !$parameterArray[
'fieldConf'][
'l10n_display'] && $parameterArray[
'fieldConf'][
'l10n_mode'] ===
'exclude'
84 || $isOverlay && $this->data[
'localizationMode'] && $this->data[
'localizationMode'] !== $parameterArray[
'fieldConf'][
'l10n_cat']
85 || $this->inlineFieldShouldBeSkipped()
90 $parameterArray[
'fieldTSConfig'] = [];
91 if (isset($this->data[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'])
92 && is_array($this->data[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'])
94 $parameterArray[
'fieldTSConfig'] = $this->data[
'pageTsConfig'][
'TCEFORM.'][$table .
'.'][$fieldName .
'.'];
96 if ($parameterArray[
'fieldTSConfig'][
'disabled']) {
102 $parameterArray[
'itemFormElName'] =
'data[' . $table .
'][' . $row[
'uid'] .
'][' . $fieldName .
']';
103 $parameterArray[
'itemFormElID'] =
'data_' . $table .
'_' . $row[
'uid'] .
'_' . $fieldName;
104 $newElementBaseName = $this->data[
'elementBaseName'] .
'[' . $table .
'][' . $row[
'uid'] .
'][' . $fieldName .
']';
107 $parameterArray[
'itemFormElValue'] = $row[$fieldName];
109 if ($parameterArray[
'fieldConf'][
'l10n_display']
113 $parameterArray[
'fieldConf'][
'config'][
'readOnly'] =
true;
114 $parameterArray[
'itemFormElValue'] = $this->data[
'defaultLanguageRow'][$fieldName];
117 if (strpos($this->data[
'processedTca'][
'ctrl'][
'type'],
':') ===
false) {
118 $typeField = $this->data[
'processedTca'][
'ctrl'][
'type'];
120 $typeField = substr($this->data[
'processedTca'][
'ctrl'][
'type'], 0, strpos($this->data[
'processedTca'][
'ctrl'][
'type'],
':'));
124 if (!empty($this->data[
'processedTca'][
'ctrl'][
'type'])
125 && $fieldName === $typeField
126 || !empty($this->data[
'processedTca'][
'ctrl'][
'requestUpdate'])
127 &&
GeneralUtility::inList(str_replace(
' ',
'', $this->data[
'processedTca'][
'ctrl'][
'requestUpdate']), $fieldName)
130 $alertMsgOnChange =
'top.TYPO3.Modal.confirm(TBE_EDITOR.labels.refreshRequired.title, TBE_EDITOR.labels.refreshRequired.content).on("button.clicked", function(e) { if (e.target.name == "ok" && TBE_EDITOR.checkSubmit(-1)) { TBE_EDITOR.submitForm() } top.TYPO3.Modal.dismiss(); });';
132 $alertMsgOnChange =
'if (TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };';
135 $alertMsgOnChange =
'';
139 $parameterArray[
'fieldChangeFunc'] = array();
141 $parameterArray[
'fieldChangeFunc'][
'alert'] = $alertMsgOnChange;
144 if ($this->isInlineChildAndLabelField($table, $fieldName)) {
147 $inlineStackProcessor->initializeByGivenStructure($this->data[
'inlineStructure']);
148 $inlineDomObjectId = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data[
'inlineFirstPid']);
149 $inlineObjectId = implode(
162 $options[
'parameterArray'] = $parameterArray;
163 $options[
'elementBaseName'] = $newElementBaseName;
164 if (!empty($parameterArray[
'fieldConf'][
'config'][
'renderType'])) {
165 $options[
'renderType'] = $parameterArray[
'fieldConf'][
'config'][
'renderType'];
168 $options[
'renderType'] = $parameterArray[
'fieldConf'][
'config'][
'type'];
170 $resultArray = $this->nodeFactory->create($options)->render();
174 if (empty($resultArray[
'html'])) {
178 $html = $resultArray[
'html'];
185 $renderLanguageDiff =
true;
186 if ($parameterArray[
'fieldConf'][
'l10n_display'] && (
GeneralUtility::inList($parameterArray[
'fieldConf'][
'l10n_display'],
'hideDiff')
189 $renderLanguageDiff =
false;
191 if ($renderLanguageDiff) {
192 $html = $this->renderDefaultLanguageContent($table, $fieldName, $row, $html);
196 $fieldItemClasses = array(
197 't3js-formengine-field-item'
201 $nullControlNameAttribute =
' name="' . htmlspecialchars(
'control[active][' . $table .
'][' . $row[
'uid'] .
'][' . $fieldName .
']') .
'"';
202 if (!empty($parameterArray[
'fieldConf'][
'config'][
'eval']) &&
GeneralUtility::inList($parameterArray[
'fieldConf'][
'config'][
'eval'],
'null')
203 && (empty($parameterArray[
'fieldConf'][
'config'][
'mode']) || $parameterArray[
'fieldConf'][
'config'][
'mode'] !==
'useOrOverridePlaceholder')
215 $checked =
' checked="checked"';
216 if ($this->data[
'databaseRow'][$fieldName] === null) {
217 $fieldItemClasses[] =
'disabled';
221 $formElementName =
'data[' . $table .
'][' . $row[
'uid'] .
'][' . $fieldName .
']';
222 $onChange = htmlspecialchars(
226 $nullValueWrap = array();
227 $nullValueWrap[] =
'<div class="' . implode(
' ', $fieldItemClasses) .
'">';
228 $nullValueWrap[] =
'<div class="t3-form-field-disable"></div>';
229 $nullValueWrap[] =
'<div class="checkbox">';
230 $nullValueWrap[] =
'<label>';
231 $nullValueWrap[] =
'<input type="hidden"' . $nullControlNameAttribute .
' value="0" />';
232 $nullValueWrap[] =
'<input type="checkbox"' . $nullControlNameAttribute .
' value="1" onchange="' . $onChange .
'"' . $checked .
' /> ';
233 $nullValueWrap[] =
'</label>';
234 $nullValueWrap[] = $html;
235 $nullValueWrap[] =
'</div>';
236 $nullValueWrap[] =
'</div>';
238 $html = implode(LF, $nullValueWrap);
239 }
elseif (isset($parameterArray[
'fieldConf'][
'config'][
'mode']) && $parameterArray[
'fieldConf'][
'config'][
'mode'] ===
'useOrOverridePlaceholder') {
253 $placeholder = empty($parameterArray[
'fieldConf'][
'config'][
'placeholder']) ?
'' : $parameterArray[
'fieldConf'][
'config'][
'placeholder'];
255 $checked = $parameterArray[
'itemFormElValue'] === null ?
'' :
' checked="checked"';
257 $resultArray[
'additionalJavaScriptPost'][] =
'typo3form.fieldTogglePlaceholder('
262 $options[
'databaseRow'] = array();
263 $options[
'table'] =
'';
264 $options[
'parameterArray'] = $parameterArray;
266 $options[
'renderType'] =
'none';
267 $noneElementResult = $this->nodeFactory->create($options)->render();
268 $noneElementHtml = $noneElementResult[
'html'];
270 $placeholderWrap = array();
271 $placeholderWrap[] =
'<div class="' . implode(
' ', $fieldItemClasses) .
'">';
272 $placeholderWrap[] =
'<div class="t3-form-field-disable"></div>';
273 $placeholderWrap[] =
'<div class="checkbox">';
274 $placeholderWrap[] =
'<label>';
275 $placeholderWrap[] =
'<input type="hidden"' . $nullControlNameAttribute .
' value="0" />';
276 $placeholderWrap[] =
'<input type="checkbox"' . $nullControlNameAttribute .
' value="1" id="tce-forms-textfield-use-override-' . $fieldName .
'-' . $row[
'uid'] .
'" onchange="' . htmlspecialchars($onChange) .
'"' . $checked .
' />';
277 $placeholderWrap[] = sprintf($languageService->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.placeholder.override'),
BackendUtility::getRecordTitlePrep($placeholder, 20));
278 $placeholderWrap[] =
'</label>';
279 $placeholderWrap[] =
'</div>';
280 $placeholderWrap[] =
'<div class="t3js-formengine-placeholder-placeholder">';
281 $placeholderWrap[] = $noneElementHtml;
282 $placeholderWrap[] =
'</div>';
283 $placeholderWrap[] =
'<div class="t3js-formengine-placeholder-formfield">';
284 $placeholderWrap[] = $html;
285 $placeholderWrap[] =
'</div>';
286 $placeholderWrap[] =
'</div>';
288 $html = implode(LF, $placeholderWrap);
289 }
elseif ($parameterArray[
'fieldConf'][
'config'][
'type'] !==
'user' || empty($parameterArray[
'fieldConf'][
'config'][
'noTableWrapping'])) {
291 $standardWrap = array();
292 $standardWrap[] =
'<div class="' . implode(
' ', $fieldItemClasses) .
'">';
293 $standardWrap[] =
'<div class="t3-form-field-disable"></div>';
294 $standardWrap[] = $html;
295 $standardWrap[] =
'</div>';
297 $html = implode(LF, $standardWrap);
300 $resultArray[
'html'] = $html;
314 protected function renderDefaultLanguageContent($table, $field, $row, $item)
316 if (is_array($this->data[
'defaultLanguageRow'])) {
317 $defaultLanguageValue = BackendUtility::getProcessedValue(
320 $this->data[
'defaultLanguageRow'][$field],
324 $this->data[
'defaultLanguageRow'][
'uid'],
326 $this->data[
'defaultLanguageRow'][
'pid']
328 $fieldConfig = $this->data[
'processedTca'][
'columns'][$field];
330 if ($fieldConfig[
'config'][
'type'] !==
'inline') {
333 if ($defaultLanguageValue !==
'') {
334 $item .=
'<div class="t3-form-original-language" title="' . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_misc.xlf:localizeMergeIfNotBlank',
true) .
'">'
335 . $iconFactory->getIcon($this->data[
'systemLanguageRows'][0][
'flagIconIdentifier'],
Icon::SIZE_SMALL)->render()
336 . $this->getMergeBehaviourIcon($fieldConfig[
'l10n_mode'])
337 . $this->
previewFieldValue($defaultLanguageValue, $fieldConfig, $field) .
'</div>';
339 $additionalPreviewLanguages = $this->data[
'additionalLanguageRows'];
340 foreach ($additionalPreviewLanguages as $previewLanguage) {
341 $defaultLanguageValue = BackendUtility::getProcessedValue(
344 $previewLanguage[$field],
348 if ($defaultLanguageValue !==
'') {
349 $item .=
'<div class="t3-form-original-language" title="' . $this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_misc.xlf:localizeMergeIfNotBlank',
true) .
'">'
350 . $iconFactory->getIcon($this->data[
'systemLanguageRows'][$previewLanguage[
'sys_language_uid']][
'flagIconIdentifier'],
Icon::SIZE_SMALL)->render()
351 . $this->getMergeBehaviourIcon($fieldConfig[
'l10n_mode'])
352 . $this->
previewFieldValue($defaultLanguageValue, $fieldConfig, $field) .
'</div>';
369 protected function getMergeBehaviourIcon($l10nMode)
372 if ($l10nMode ===
'mergeIfNotBlank') {
375 $icon = $iconFactory->getIcon(
'actions-edit-merge-localization',
Icon::SIZE_SMALL)->render();
392 if (is_array($this->data[
'defaultLanguageDataDiff'][$table .
':' . $row[
'uid']])) {
395 'old' => $this->data[
'defaultLanguageDataDiff'][$table .
':' . $row[
'uid']],
396 'new' => $this->data[
'defaultLanguageData'][$table .
':' . $row[
'uid']]
399 if (isset($dLVal[
'old'][$field])) {
400 if ((
string)$dLVal[
'old'][$field] !== (
string)$dLVal[
'new'][$field]) {
403 $diffres = $diffUtility->makeDiffDisplay(
404 BackendUtility::getProcessedValue($table, $field, $dLVal[
'old'][$field], 0, 1),
405 BackendUtility::getProcessedValue($table, $field, $dLVal[
'new'][$field], 0, 1)
407 $item .=
'<div class="t3-form-original-language-diff">
408 <div class="t3-form-original-language-diffheader">' .
409 htmlspecialchars($this->
getLanguageService()->sL(
'LLL:EXT:lang/locallang_core.xlf:labels.changeInOrig')) .
411 <div class="t3-form-original-language-diffcontent">' . $diffres .
'</div>
428 protected function isInlineChildAndLabelField($table, $field)
432 $inlineStackProcessor->initializeByGivenStructure($this->data[
'inlineStructure']);
433 $level = $inlineStackProcessor->getStructureLevel(-1);
434 if ($level[
'config'][
'foreign_label']) {
435 $label = $level[
'config'][
'foreign_label'];
437 $label = $this->data[
'processedTca'][
'ctrl'][
'label'];
439 return $level[
'config'][
'foreign_table'] === $table && $label === $field;
447 protected function inlineFieldShouldBeSkipped()
449 $table = $this->data[
'tableName'];
450 $row = $this->data[
'databaseRow'];
451 $fieldName = $this->data[
'fieldName'];
452 $fieldConfig = $this->data[
'processedTca'][
'columns'][$fieldName][
'config'];
456 $inlineStackProcessor->initializeByGivenStructure($this->data[
'inlineStructure']);
457 $structureDepth = $inlineStackProcessor->getStructureDepth();
459 $skipThisField =
false;
460 if ($structureDepth > 0) {
461 $searchArray = array(
466 'foreign_table' => $table,
469 'appearance' => array(
'useCombination' =>
true),
470 'foreign_selector' => $fieldName
472 'MM' => $fieldConfig[
'MM']
478 'foreign_table' => $fieldConfig[
'foreign_table'],
479 'foreign_selector' => $fieldConfig[
'foreign_field']
486 $level = $inlineStackProcessor->getStructureLevel(-1);
488 if ($this->data[
'isOnSymmetricSide']) {
489 $searchArray[
'%OR'][
'config'][0][
'%AND'][
'%OR'][
'symmetric_field'] = $fieldName;
490 $searchArray[
'%OR'][
'config'][0][
'%AND'][
'%OR'][
'symmetric_sortby'] = $fieldName;
492 $searchArray[
'%OR'][
'config'][0][
'%AND'][
'%OR'][
'foreign_field'] = $fieldName;
493 $searchArray[
'%OR'][
'config'][0][
'%AND'][
'%OR'][
'foreign_sortby'] = $fieldName;
497 return $skipThisField;
536 if (is_array($searchArray) && !empty($searchArray)) {
540 $type = key($searchArray);
541 $searchArray = current($searchArray);
544 $type = strtoupper($type);
546 foreach ($searchArray as $key => $value) {
549 if ($key ===
'%OR') {
551 }
elseif ($key ===
'%AND') {
555 }
elseif (is_array($value)) {
558 if (isset($subjectArray[$key]) && isset($value)) {
560 if (is_bool($value)) {
561 $localMatches += !($subjectArray[$key] xor $value) ? 1 : 0;
562 }
elseif (is_numeric($subjectArray[$key]) && is_numeric($value)) {
563 $localMatches += $subjectArray[$key] == $value ? 1 : 0;
565 $localMatches += $subjectArray[$key] === $value ? 1 : 0;
570 if ($type ===
'%OR' && $localMatches > 0) {
574 if ($type ===
'%AND' && $localMatches == 0) {
580 return $localEntries === $localMatches;
591 return is_array($object) && !empty($object) && array_keys($object) !== range(0,
sizeof($object) - 1);