[TASK] Optimize invocation of cObj::checkIf 18/31418/2
authorOliver Hader <oliver@typo3.org>
Mon, 20 Jan 2014 15:52:37 +0000 (16:52 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Sun, 6 Jul 2014 21:24:05 +0000 (23:24 +0200)
The stdWrap property "if" can be used to allow output only if a
defined criterion is met. However, the checkIf() method gets
called even if the property is not set in TypoScript.

Fix this by adding a quick empty() check to all calls.
Also optimizes the code structure to exit early in case the if
does not evaluate to TRUE.

Resolves: #55173
Releases: 6.3, 6.2
Change-Id: Ie1178a5df2e98fd19b848aa2300c901c1200f555
Reviewed-on: https://review.typo3.org/31418
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/frontend/Classes/ContentObject/CaseContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ColumnsContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectArrayContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/HierarchicalMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ImageContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/ImageMenuContentObject.php

index 99e6f38..846e9cb 100644 (file)
@@ -28,20 +28,22 @@ class CaseContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConten
         * @return string Output
         */
        public function render($conf = array()) {
-               if ($this->cObj->checkIf($conf['if.'])) {
-                       $setCurrent = isset($conf['setCurrent.']) ? $this->cObj->stdWrap($conf['setCurrent'], $conf['setCurrent.']) : $conf['setCurrent'];
-                       if ($setCurrent) {
-                               $this->cObj->data[$this->cObj->currentValKey] = $setCurrent;
-                       }
-                       $key = isset($conf['key.']) ? $this->cObj->stdWrap($conf['key'], $conf['key.']) : $conf['key'];
-                       $key = strlen($conf[$key]) ? $key : 'default';
-                       $name = $conf[$key];
-                       $theValue = $this->cObj->cObjGetSingle($name, $conf[$key . '.'], $key);
-                       if (isset($conf['stdWrap.'])) {
-                               $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
-                       }
-                       return $theValue;
+               if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
+                       return '';
                }
+
+               $setCurrent = isset($conf['setCurrent.']) ? $this->cObj->stdWrap($conf['setCurrent'], $conf['setCurrent.']) : $conf['setCurrent'];
+               if ($setCurrent) {
+                       $this->cObj->data[$this->cObj->currentValKey] = $setCurrent;
+               }
+               $key = isset($conf['key.']) ? $this->cObj->stdWrap($conf['key'], $conf['key.']) : $conf['key'];
+               $key = strlen($conf[$key]) ? $key : 'default';
+               $name = $conf[$key];
+               $theValue = $this->cObj->cObjGetSingle($name, $conf[$key . '.'], $key);
+               if (isset($conf['stdWrap.'])) {
+                       $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
+               }
+               return $theValue;
        }
 
 }
index ba30ed7..3bf42fb 100644 (file)
@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * @author Xavier Perseguers <typo3@perseguers.ch>
  * @author Steffen Kamper <steffen@typo3.org>
  */
-class ColumnsContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject {
+class ColumnsContentObject extends AbstractContentObject {
 
        /**
         * Rendering the cObject, COLUMNS
@@ -28,74 +28,76 @@ class ColumnsContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractCon
         * @return string Output
         */
        public function render($conf = array()) {
+               if (empty($conf) || !empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
+                       return '';
+               }
+
                $content = '';
-               if (is_array($conf) && $this->cObj->checkIf($conf['if.'])) {
-                       $tdRowCount = 0;
-                       $tableParams = isset($conf['tableParams.']) ? $this->cObj->stdWrap($conf['tableParams'], $conf['tableParams.']) : $conf['tableParams'];
-                       $tableParams = $tableParams ? ' ' . $tableParams : ' border="0" cellspacing="0" cellpadding="0"';
-                       $TDparams = isset($conf['TDParams.']) ? $this->cObj->stdWrap($conf['TDParams'], $conf['TDParams.']) : $conf['TDParams'];
-                       $TDparams = $TDparams ? ' ' . $TDparams : ' valign="top"';
-                       $rows = isset($conf['rows.']) ? $this->cObj->stdWrap($conf['rows'], $conf['rows.']) : $conf['rows'];
-                       $rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($rows, 2, 20);
-                       $totalWidth = isset($conf['totalWidth.']) ? (int)$this->cObj->stdWrap($conf['totalWidth'], $conf['totalWidth.']) : (int)$conf['totalWidth'];
-                       $columnWidth = 0;
-                       $totalGapWidth = 0;
-                       $gapData = array(
-                               'gapWidth' => isset($conf['gapWidth.']) ? $this->cObj->stdWrap($conf['gapWidth'], $conf['gapWidth.']) : $conf['gapWidth'],
-                               'gapBgCol' => isset($conf['gapBgCol.']) ? $this->cObj->stdWrap($conf['gapBgCol'], $conf['gapBgCol.']) : $conf['gapBgCol'],
-                               'gapLineThickness' => isset($conf['gapLineThickness.']) ? $this->cObj->stdWrap($conf['gapLineThickness'], $conf['gapLineThickness.']) : $conf['gapLineThickness'],
-                               'gapLineCol' => isset($conf['gapLineCol.']) ? $this->cObj->stdWrap($conf['gapLineCol'], $conf['gapLineCol.']) : $conf['gapLineCol']
-                       );
-                       $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData, $rows - 1);
-                       foreach ($gapData as $val) {
-                               $totalGapWidth += (int)$val['gapWidth'];
-                       }
-                       if ($totalWidth) {
-                               $columnWidth = ceil(($totalWidth - $totalGapWidth) / $rows);
-                               $TDparams .= ' width="' . $columnWidth . '"';
-                               $tableParams .= ' width="' . $totalWidth . '"';
-                       } else {
-                               $TDparams .= ' width="' . floor(100 / $rows) . '%"';
-                               $tableParams .= ' width="100%"';
-                       }
-                       for ($a = 1; $a <= $rows; $a++) {
-                               $tdRowCount++;
-                               $content .= '<td' . $TDparams . '>';
-                               $content .= $this->cObj->cObjGetSingle($conf[$a], $conf[$a . '.'], $a);
-                               $content .= '</td>';
-                               if ($a < $rows) {
-                                       $gapConf = $gapData[$a - 1];
-                                       $gapWidth = (int)$gapConf['gapWidth'];
-                                       if ($gapWidth) {
-                                               $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="' . $gapConf['gapBgCol'] . '"' : '';
-                                               $gapLine = (int)$gapConf['gapLineThickness'];
-                                               if ($gapLine) {
-                                                       $gapSurround = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($gapWidth - $gapLine) / 2, 1, 1000);
-                                                       // right gap
-                                                       $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapSurround . '" height="1" alt="" title="" /></td>';
-                                                       $tdRowCount++;
-                                                       // line:
-                                                       $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="' . $gapConf['gapLineCol'] . '"' : ' bgcolor="black"';
-                                                       $content .= '<td' . $GtdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapLine . '" height="1" alt="" title="" /></td>';
-                                                       $tdRowCount++;
-                                                       // left gap
-                                                       $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapSurround . '" height="1" alt="" title="" /></td>';
-                                                       $tdRowCount++;
-                                               } else {
-                                                       $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapWidth . '" height="1" alt="" title="" /></td>';
-                                                       $tdRowCount++;
-                                               }
+
+               $tdRowCount = 0;
+               $tableParams = isset($conf['tableParams.']) ? $this->cObj->stdWrap($conf['tableParams'], $conf['tableParams.']) : $conf['tableParams'];
+               $tableParams = $tableParams ? ' ' . $tableParams : ' border="0" cellspacing="0" cellpadding="0"';
+               $TDparams = isset($conf['TDParams.']) ? $this->cObj->stdWrap($conf['TDParams'], $conf['TDParams.']) : $conf['TDParams'];
+               $TDparams = $TDparams ? ' ' . $TDparams : ' valign="top"';
+               $rows = isset($conf['rows.']) ? $this->cObj->stdWrap($conf['rows'], $conf['rows.']) : $conf['rows'];
+               $rows = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($rows, 2, 20);
+               $totalWidth = isset($conf['totalWidth.']) ? (int)$this->cObj->stdWrap($conf['totalWidth'], $conf['totalWidth.']) : (int)$conf['totalWidth'];
+               $totalGapWidth = 0;
+               $gapData = array(
+                       'gapWidth' => isset($conf['gapWidth.']) ? $this->cObj->stdWrap($conf['gapWidth'], $conf['gapWidth.']) : $conf['gapWidth'],
+                       'gapBgCol' => isset($conf['gapBgCol.']) ? $this->cObj->stdWrap($conf['gapBgCol'], $conf['gapBgCol.']) : $conf['gapBgCol'],
+                       'gapLineThickness' => isset($conf['gapLineThickness.']) ? $this->cObj->stdWrap($conf['gapLineThickness'], $conf['gapLineThickness.']) : $conf['gapLineThickness'],
+                       'gapLineCol' => isset($conf['gapLineCol.']) ? $this->cObj->stdWrap($conf['gapLineCol'], $conf['gapLineCol.']) : $conf['gapLineCol']
+               );
+               $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData, $rows - 1);
+               foreach ($gapData as $val) {
+                       $totalGapWidth += (int)$val['gapWidth'];
+               }
+               if ($totalWidth) {
+                       $columnWidth = ceil(($totalWidth - $totalGapWidth) / $rows);
+                       $TDparams .= ' width="' . $columnWidth . '"';
+                       $tableParams .= ' width="' . $totalWidth . '"';
+               } else {
+                       $TDparams .= ' width="' . floor(100 / $rows) . '%"';
+                       $tableParams .= ' width="100%"';
+               }
+               for ($a = 1; $a <= $rows; $a++) {
+                       $tdRowCount++;
+                       $content .= '<td' . $TDparams . '>';
+                       $content .= $this->cObj->cObjGetSingle($conf[$a], $conf[$a . '.'], $a);
+                       $content .= '</td>';
+                       if ($a < $rows) {
+                               $gapConf = $gapData[$a - 1];
+                               $gapWidth = (int)$gapConf['gapWidth'];
+                               if ($gapWidth) {
+                                       $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="' . $gapConf['gapBgCol'] . '"' : '';
+                                       $gapLine = (int)$gapConf['gapLineThickness'];
+                                       if ($gapLine) {
+                                               $gapSurround = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($gapWidth - $gapLine) / 2, 1, 1000);
+                                               // right gap
+                                               $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapSurround . '" height="1" alt="" title="" /></td>';
+                                               $tdRowCount++;
+                                               // line:
+                                               $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="' . $gapConf['gapLineCol'] . '"' : ' bgcolor="black"';
+                                               $content .= '<td' . $GtdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapLine . '" height="1" alt="" title="" /></td>';
+                                               $tdRowCount++;
+                                               // left gap
+                                               $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapSurround . '" height="1" alt="" title="" /></td>';
+                                               $tdRowCount++;
+                                       } else {
+                                               $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $gapWidth . '" height="1" alt="" title="" /></td>';
+                                               $tdRowCount++;
                                        }
                                }
                        }
-                       $content = '<tr>' . $content . '</tr>';
-                       $content = '<table' . $tableParams . '>' . $content . '</table>';
-                       if ($conf['after'] || isset($conf['after.'])) {
-                               $content .= $this->cObj->cObjGetSingle($conf['after'], $conf['after.'], 'after');
-                       }
-                       if (isset($conf['stdWrap.'])) {
-                               $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
-                       }
+               }
+               $content = '<tr>' . $content . '</tr>';
+               $content = '<table' . $tableParams . '>' . $content . '</table>';
+               if ($conf['after'] || isset($conf['after.'])) {
+                       $content .= $this->cObj->cObjGetSingle($conf['after'], $conf['after.'], 'after');
+               }
+               if (isset($conf['stdWrap.'])) {
+                       $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
                }
                return $content;
        }
index f39c011..a84a1e6 100644 (file)
@@ -19,7 +19,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * @author Xavier Perseguers <typo3@perseguers.ch>
  * @author Steffen Kamper <steffen@typo3.org>
  */
-class ContentObjectArrayContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject {
+class ContentObjectArrayContentObject extends AbstractContentObject {
 
        /**
         * Rendering the cObject, COBJ_ARRAY / COA
@@ -28,23 +28,24 @@ class ContentObjectArrayContentObject extends \TYPO3\CMS\Frontend\ContentObject\
         * @return string Output
         */
        public function render($conf = array()) {
-               if (is_array($conf)) {
-                       $content = '';
-                       if ($this->cObj->checkIf($conf['if.'])) {
-                               $this->cObj->includeLibs($conf);
-                               $content = $this->cObj->cObjGet($conf);
-                               $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
-                               if ($wrap) {
-                                       $content = $this->cObj->wrap($content, $wrap);
-                               }
-                               if (isset($conf['stdWrap.'])) {
-                                       $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
-                               }
-                       }
-                       return $content;
-               } else {
+               if (empty($conf)) {
                        $GLOBALS['TT']->setTSlogMessage('No elements in this content object array (COBJ_ARRAY, COA).', 2);
+                       return '';
                }
+               if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
+                       return '';
+               }
+
+               $this->cObj->includeLibs($conf);
+               $content = $this->cObj->cObjGet($conf);
+               $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
+               if ($wrap) {
+                       $content = $this->cObj->wrap($content, $wrap);
+               }
+               if (isset($conf['stdWrap.'])) {
+                       $content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
+               }
+               return $content;
        }
 
 }
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.
index b4034e9..235c327 100644 (file)
@@ -28,30 +28,33 @@ class HierarchicalMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Ab
         * @return string Output
         */
        public function render($conf = array()) {
+               if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
+                       return '';
+               }
+
                $theValue = '';
-               if ($this->cObj->checkIf($conf['if.'])) {
-                       $menuType = $conf[1];
-                       try {
-                               $menuObjectFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\MenuContentObjectFactory');
-                               $menu = $menuObjectFactory->getMenuObjectByType($menuType);
-                               $GLOBALS['TSFE']->register['count_HMENU']++;
-                               $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
-                               $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
-                               $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
-                               $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
-                               $menu->parent_cObj = $this->cObj;
-                               $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
-                               $menu->makeMenu();
-                               $theValue .= $menu->writeMenu();
-                       } catch (\TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException $e) {
-                       }
-                       $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
-                       if ($wrap) {
-                               $theValue = $this->cObj->wrap($theValue, $wrap);
-                       }
-                       if (isset($conf['stdWrap.'])) {
-                               $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
-                       }
+               $menuType = $conf[1];
+               try {
+                       /** @var $menuObjectFactory \TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory */
+                       $menuObjectFactory = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\MenuContentObjectFactory');
+                       $menu = $menuObjectFactory->getMenuObjectByType($menuType);
+                       $GLOBALS['TSFE']->register['count_HMENU']++;
+                       $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
+                       $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
+                       $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
+                       $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
+                       $menu->parent_cObj = $this->cObj;
+                       $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
+                       $menu->makeMenu();
+                       $theValue .= $menu->writeMenu();
+               } catch (\TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException $e) {
+               }
+               $wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
+               if ($wrap) {
+                       $theValue = $this->cObj->wrap($theValue, $wrap);
+               }
+               if (isset($conf['stdWrap.'])) {
+                       $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
                }
                return $theValue;
        }
index b907c3e..3400cb2 100644 (file)
@@ -28,13 +28,15 @@ class ImageContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConte
         * @return string Output
         */
        public function render($conf = array()) {
-               if ($this->cObj->checkIf($conf['if.'])) {
-                       $theValue = $this->cObj->cImage($conf['file'], $conf);
-                       if (isset($conf['stdWrap.'])) {
-                               $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
-                       }
-                       return $theValue;
+               if (!empty($conf['if.']) && !$this->cObj->checkIf($conf['if.'])) {
+                       return '';
                }
+
+               $theValue = $this->cObj->cImage($conf['file'], $conf);
+               if (isset($conf['stdWrap.'])) {
+                       $theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
+               }
+               return $theValue;
        }
 
 }
index 2e233e2..eba9729 100644 (file)
@@ -149,7 +149,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                                        /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
                                                                        $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                                                        $cObj->start($cObjData, 'pages');
-                                                                       if (!$cObj->checkIf($theValArr['if.'])) {
+                                                                       if (!empty($theValArr['if.']) && !$cObj->checkIf($theValArr['if.'])) {
                                                                                $setObjFlag = 0;
                                                                        }
                                                                        unset($theValArr['if.']);