[FEATURE] Enabling displayCond for sheets in flexforms
authorPhilipp Kitzberger <philipp@cron-it.de>
Tue, 24 Jan 2012 15:21:36 +0000 (16:21 +0100)
committerTolleiv Nietsch <info@tolleiv.de>
Sat, 28 Jan 2012 14:43:00 +0000 (15:43 +0100)
Adds the feature of displayCond to sheets in flexforms, so entire sheets
of fields can be excluded from the editing mask. Until now this was only
available for single fields.

Change-Id: I9306c32ef075d080ab225cb226540bd3b2d340fc
Resolves: #33390
Release: 4.7
Reviewed-on: http://review.typo3.org/8677
Reviewed-by: Ernesto Baschny
Tested-by: Ernesto Baschny
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
t3lib/class.t3lib_tceforms.php

index e5226bd..409992b 100644 (file)
@@ -2473,6 +2473,38 @@ class t3lib_TCEforms {
                                foreach ($tabsToTraverse as $sheet) {
                                        list ($dataStruct, $sheet) = t3lib_div::resolveSheetDefInDS($dataStructArray, $sheet);
 
+                                               // If sheet has displayCond
+                                       if ($dataStruct['ROOT']['TCEforms']['displayCond']) {
+                                               $splittedCondition = t3lib_div::trimExplode(':', $dataStruct['ROOT']['TCEforms']['displayCond']);
+                                               $skipCondition = FALSE;
+                                               switch ($splittedCondition[0]) {
+                                                       case 'FIELD':
+                                                               list($sheetName, $fieldName) = t3lib_div::trimExplode('.', $splittedCondition[1]);
+                                                               $fieldValue = $editData['data'][$sheetName][$lang][$fieldName];
+                                                               $splittedCondition[1] = $fieldName;
+                                                               $dataStruct['ROOT']['TCEforms']['displayCond'] = join(':', $splittedCondition);
+                                                               $fakeRow = array($fieldName => $fieldValue);
+                                                               break;
+                                                       case 'HIDE_FOR_NON_ADMINS':
+                                                       case 'VERSION':
+                                                       case 'HIDE_L10N_SIBLINGS':
+                                                       case 'EXT':
+                                                               break;
+                                                       case 'REC':
+                                                               $fakeRow = array('uid' => $row['uid']);
+                                                               break;
+                                                       default:
+                                                               $skipCondition = TRUE;
+                                                               break;
+                                               }
+
+                                                       // If sheets displayCond leads to false
+                                               if (!$skipCondition && !$this->isDisplayCondition($dataStruct['ROOT']['TCEforms']['displayCond'], $fakeRow, 'vDEF')) {
+                                                               // don't create this sheet
+                                                       continue;
+                                               }
+                                       }
+
                                                // Render sheet:
                                        if (is_array($dataStruct['ROOT']) && is_array($dataStruct['ROOT']['el'])) {
                                                $lang = 'l' . $lKey; // Default language, other options are "lUK" or whatever country code (independant of system!!!)