2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
51 foreach ($result[
'processedTca'][
'columns'] as $columnName => $columnConfiguration) {
52 if (!isset($columnConfiguration[
'displayCond'])) {
57 unset($result[
'processedTca'][
'columns'][$columnName]);
72 foreach ($result[
'processedTca'][
'columns'] as $columnName => $columnConfiguration) {
73 if (!isset($columnConfiguration[
'config'][
'type'])
74 || $columnConfiguration[
'config'][
'type'] !==
'flex'
75 || !isset($result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'])
76 || !is_array($result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'])
81 $flexFormRowData = is_array($result[
'databaseRow'][$columnName][
'data']) ? $result[
'databaseRow'][$columnName][
'data'] : array();
83 $flexFormRowData[
'parentRec'] = $result[
'databaseRow'];
85 $flexFormSheets = $result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'];
86 foreach ($flexFormSheets as $sheetName => $sheetConfiguration) {
87 if (!isset($sheetConfiguration[
'ROOT'][
'displayCond'])) {
91 unset($result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'][$sheetName]);
107 foreach ($result[
'processedTca'][
'columns'] as $columnName => $columnConfiguration) {
108 if (!isset($columnConfiguration[
'config'][
'type'])
109 || $columnConfiguration[
'config'][
'type'] !==
'flex'
110 || !isset($result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'])
111 || !is_array($result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'])
116 $flexFormRowData = is_array($result[
'databaseRow'][$columnName][
'data']) ? $result[
'databaseRow'][$columnName][
'data'] : array();
117 $flexFormRowData[
'parentRec'] = $result[
'databaseRow'];
119 foreach ($result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'] as $sheetName => $sheetConfiguration) {
120 $flexFormSheetRowData = $flexFormRowData[$sheetName][
'lDEF'];
121 $flexFormSheetRowData[
'parentRec'] = $result[
'databaseRow'];
123 $result[
'processedTca'][
'columns'][$columnName][
'config'][
'ds'][
'sheets'][$sheetName],
124 $flexFormSheetRowData
142 foreach ($structure as $key => $value) {
143 if ($key ===
'el' && is_array($value)) {
144 $newSubStructure = [];
145 foreach ($value as $subKey => $subValue) {
146 if (!isset($subValue[
'displayCond']) || $this->
evaluateDisplayCondition($subValue[
'displayCond'], $flexFormRowData,
true)) {
147 $newSubStructure[$subKey] = $subValue;
150 $value = $newSubStructure;
152 if (is_array($value)) {
155 $newStructure[$key] = $value;
158 return $newStructure;
169 $flatFlexFormRowData = [];
170 foreach ($flexFormRowData as $sheetName => $sheetConfiguration) {
171 foreach ($sheetConfiguration[
'lDEF'] as $fieldName => $fieldConfiguration) {
172 $flatFlexFormRowData[$sheetName .
'.' . $fieldName] = $fieldConfiguration;
176 return $flatFlexFormRowData;
192 protected function evaluateDisplayCondition($displayCondition, array $record = array(), $flexformContext =
false, $recursionLevel = 0)
194 if ($recursionLevel > 99) {
198 if (!is_array($displayCondition)) {
203 $conditionEvaluations = array(
207 foreach ($displayCondition as $logicalOperator => $groupedDisplayConditions) {
208 $logicalOperator = strtoupper($logicalOperator);
209 if (($logicalOperator !==
'AND' && $logicalOperator !==
'OR') || !is_array($groupedDisplayConditions)) {
213 foreach ($groupedDisplayConditions as $key => $singleDisplayCondition) {
214 $key = strtoupper($key);
215 if (($key ===
'AND' || $key ===
'OR') && is_array($singleDisplayCondition)) {
218 array($key => $singleDisplayCondition),
226 $singleDisplayCondition,
234 if (!empty($conditionEvaluations[
'OR']) && in_array(
true, $conditionEvaluations[
'OR'],
true)) {
237 }
elseif (!empty($conditionEvaluations[
'AND']) && !in_array(
false, $conditionEvaluations[
'AND'],
true)) {
240 }
elseif (!empty($conditionEvaluations[
'OR']) || !empty($conditionEvaluations[
'AND'])) {
267 list($matchType, $condition) = explode(
':', $displayCondition, 2);
268 switch ($matchType) {
275 case 'HIDE_FOR_NON_ADMINS':
278 case 'HIDE_L10N_SIBLINGS':
308 list($extensionKey, $operator, $operand) = explode(
':', $condition, 3);
309 if ($operator ===
'LOADED') {
310 if (strtoupper($operand) ===
'TRUE') {
312 }
elseif (strtoupper($operand) ===
'FALSE') {
333 list($fieldName, $operator, $operand) = explode(
':', $condition, 3);
334 if ($flexformContext) {
335 if (strpos($fieldName,
'parentRec.') !==
false) {
336 $fieldNameParts = explode(
'.', $fieldName, 2);
337 $fieldValue = $record[
'parentRec'][$fieldNameParts[1]];
339 $fieldValue = $record[$fieldName][
'vDEF'];
342 $fieldValue = $record[$fieldName];
347 if (is_array($fieldValue) && count($fieldValue) === 1) {
348 $fieldValue = array_shift($fieldValue);
350 if (strtoupper($operand) ===
'TRUE') {
351 $result = (bool)$fieldValue;
353 $result = !$fieldValue;
357 if (is_array($fieldValue) && count($fieldValue) === 1) {
358 $fieldValue = array_shift($fieldValue);
360 $result = $fieldValue > $operand;
363 if (is_array($fieldValue) && count($fieldValue) === 1) {
364 $fieldValue = array_shift($fieldValue);
366 $result = $fieldValue < $operand;
369 if (is_array($fieldValue) && count($fieldValue) === 1) {
370 $fieldValue = array_shift($fieldValue);
372 $result = $fieldValue >= $operand;
375 if (is_array($fieldValue) && count($fieldValue) === 1) {
376 $fieldValue = array_shift($fieldValue);
378 $result = $fieldValue <= $operand;
382 if (is_array($fieldValue) && count($fieldValue) === 1) {
383 $fieldValue = array_shift($fieldValue);
385 list($minimum, $maximum) = explode(
'-', $operand);
386 $result = $fieldValue >= $minimum && $fieldValue <= $maximum;
387 if ($operator[0] ===
'!') {
393 if (is_array($fieldValue) && count($fieldValue) === 1) {
394 $fieldValue = array_shift($fieldValue);
396 $result = $fieldValue == $operand;
397 if ($operator[0] ===
'!') {
403 if (is_array($fieldValue)) {
404 $result = count(array_intersect($fieldValue, explode(
',', $operand))) > 0;
408 if ($operator[0] ===
'!') {
414 $result = (bool)((
int)$fieldValue & $operand);
415 if ($operator[0] ===
'!') {
442 GeneralUtility::deprecationLog(
'HIDE_L10N_SIBLINGS in Flexform display conditions has been deprecated with TYPO3 CMS 7 and will be removed with TYPO3 CMS 8.');
460 list($operator, $operand) = explode(
':', $condition, 2);
461 if ($operator ===
'NEW') {
462 if (strtoupper($operand) ===
'TRUE') {
463 $result = !((int)$record[
'uid'] > 0);
464 }
elseif (strtoupper($operand) ===
'FALSE') {
465 $result = ((int)$record[
'uid'] > 0);
482 list($operator, $operand) = explode(
':', $condition, 2);
483 if ($operator ===
'IS') {
484 $isNewRecord = !((int)$record[
'uid'] > 0);
487 if ((
int)$record[
'pid'] === -1 || (
int)$record[
'_ORIG_pid'] === -1) {
488 $isRecordDetectedAsVersion =
true;
490 $isRecordDetectedAsVersion =
false;
496 $isVersion = ($isUserInWorkspace || $isRecordDetectedAsVersion) && !$isNewRecord;
497 if (strtoupper($operand) ===
'TRUE') {
498 $result = $isVersion;
499 }
elseif (strtoupper($operand) ===
'FALSE') {
500 $result = !$isVersion;
515 $conditionParameters = explode(
':', $condition);
516 $userFunction = array_shift($conditionParameters);
520 'flexformValueKey' =>
'vDEF',
521 'conditionParameters' => $conditionParameters