[FEATURE] New TCA displayCond options BIT and !BIT 72/20272/3
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 28 Apr 2013 19:04:07 +0000 (21:04 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 5 May 2013 11:54:14 +0000 (13:54 +0200)
Add option to check with a multi-value field in displayCond.

Example: FIELD:content:BIT:1

Change-Id: I1f2bc770b55cb2843ac1b508a6d6856a638dac25
Resolves: #45514
Releases: 6.2
Reviewed-on: https://review.typo3.org/20272
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/backend/Classes/Form/ElementConditionMatcher.php
typo3/sysext/backend/Tests/Unit/Form/ElementConditionMatcherTest.php

index eae870b..6486814 100644 (file)
@@ -240,6 +240,13 @@ class ElementConditionMatcher {
                                        $result = !$result;
                                }
                                break;
+                       case 'BIT':
+                       case '!BIT':
+                               $result = (intval($fieldValue) & $operand) ? TRUE : FALSE;
+                               if ($operator{0} === '!') {
+                                       $result = !$result;
+                               }
+                               break;
                }
                return $result;
        }
@@ -336,4 +343,4 @@ class ElementConditionMatcher {
        }
 }
 
-?>
\ No newline at end of file
+?>
index 153738d..56f6344 100644 (file)
@@ -108,6 +108,24 @@ class ElementConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                NULL,
                                TRUE,
                        ),
+                       'Field value comparison of 1 against multi-value field of 5 returns true' => array(
+                               'FIELD:content:BIT:1',
+                               array('content' => '5'),
+                               NULL,
+                               TRUE
+                       ),
+                       'Field value comparison of 2 against multi-value field of 5 returns false' => array(
+                               'FIELD:content:BIT:2',
+                               array('content' => '5'),
+                               NULL,
+                               FALSE
+                       ),
+                       'Field value of 5 negated comparison against multi-value field of 5 returns false' => array(
+                               'FIELD:content:!BIT:5',
+                               array('content' => '5'),
+                               NULL,
+                               FALSE
+                       ),
                        'Field value comparison for required value is false for different value' => array(
                                'FIELD:foo:REQ:FALSE',
                                array('foo' => 'bar'),