[TASK] Optimize invocation of cObj::checkIf
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / ContentObjectRenderer.php
index 2334f68..d082a76 100644 (file)
@@ -531,6 +531,16 @@ class ContentObjectRenderer {
        protected $userObjectType = FALSE;
 
        /**
+        * @var array
+        */
+       protected $stopRendering = array();
+
+       /**
+        * @var integer
+        */
+       protected $stdWrapRecursionLevel = 0;
+
+       /**
         * Indicates that object type is USER.
         *
         * @see ContentObjectRender::$userObjectType
@@ -1359,10 +1369,7 @@ class ContentObjectRenderer {
                        $activeSourceCollections = array();
                        foreach ($conf['sourceCollection.'] as $sourceCollectionKey => $sourceCollectionConfiguration) {
                                if (substr($sourceCollectionKey, -1) == '.') {
-                                       if (
-                                               (isset($sourceCollectionConfiguration['if.']) && $this->checkIf($sourceCollectionConfiguration['if.']))
-                                               || !isset($sourceCollectionConfiguration['if.'])
-                                       ) {
+                                       if (empty($sourceCollectionConfiguration['if.']) || $this->checkIf($sourceCollectionConfiguration['if.'])) {
                                                $activeSourceCollections[] = $sourceCollectionConfiguration;
                                        }
                                }
@@ -2073,21 +2080,21 @@ class ContentObjectRenderer {
                                                $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
                                        }
                                }
-                               // Get just that part of $conf that is needed for the particular function
-                               $singleConf = array(
-                                       $functionName => $conf[$functionName],
-                                       $functionProperties => $conf[$functionProperties]
-                               );
-                               // In this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
-                               if ($functionName == 'spaceBefore' || $functionName == 'spaceAfter') {
-                                       $singleConf['space.'] = $conf['space.'];
-                               }
-                               // Hand over the whole $conf array to the stdWrapHookObjects
-                               if ($functionType === 'hook') {
-                                       $singleConf = $conf;
-                               }
                                // Check if key is still containing something, since it might have been changed by next level stdWrap before
-                               if ((isset($conf[$functionName]) || $conf[$functionProperties]) && !($functionType == 'boolean' && !$conf[$functionName])) {
+                               if ((isset($conf[$functionName]) || $conf[$functionProperties]) && ($functionType !== 'boolean' || $conf[$functionName])) {
+                                       // Get just that part of $conf that is needed for the particular function
+                                       $singleConf = array(
+                                               $functionName => $conf[$functionName],
+                                               $functionProperties => $conf[$functionProperties]
+                                       );
+                                       // In this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
+                                       if ($functionName === 'spaceBefore' || $functionName === 'spaceAfter') {
+                                               $singleConf['space.'] = $conf['space.'];
+                                       }
+                                       // Hand over the whole $conf array to the stdWrapHookObjects
+                                       if ($functionType === 'hook') {
+                                               $singleConf = $conf;
+                                       }
                                        // Add both keys - with and without the dot - to the set of executed functions
                                        $isExecuted[$functionName] = TRUE;
                                        $isExecuted[$functionProperties] = TRUE;
@@ -2362,13 +2369,10 @@ class ContentObjectRenderer {
         *
         * @param string|NULL $content Input value undergoing processing in this function.
         * @param array $conf stdWrap properties for ifNull.
-        * @return string|NULL The processed input value
+        * @return string The processed input value
         */
        public function stdWrap_ifNull($content = '', $conf = array()) {
-               if ($content === NULL) {
-                       $content = $conf['ifNull'];
-               }
-               return $content;
+               return $content !== NULL ? $content : $conf['ifNull'];
        }
 
        /**
@@ -2521,11 +2525,11 @@ class ContentObjectRenderer {
         * @return string The processed input value
         */
        public function stdWrap_if($content = '', $conf = array()) {
-               if (!$this->checkIf($conf['if.'])) {
-                       $content = '';
-                       $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
+               if (empty($conf['if.']) || $this->checkIf($conf['if.'])) {
+                       return $content;
                }
-               return $content;
+               $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
+               return '';
        }
 
        /**
@@ -4756,7 +4760,7 @@ class ContentObjectRenderer {
         * @todo Define visibility
         */
        public function _parseFunc($theValue, $conf) {
-               if (!$this->checkIf($conf['if.'])) {
+               if (!empty($conf['if.']) && !$this->checkIf($conf['if.'])) {
                        return $theValue;
                }
                // Indicates that the data is from within a tag.