[BUGFIX] Re-enable menu configuration caching 01/35001/3
authorMartin Helmich <m.helmich@mittwald.de>
Wed, 3 Dec 2014 17:00:40 +0000 (18:00 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Tue, 10 Mar 2015 22:08:18 +0000 (23:08 +0100)
It is ensured that the menu configuration is always an array.

The PageRepository::getHash() method is extended to return the
raw cache content. This allows to cache empty arrays.

Change-Id: If92c80feabb8e68b66497827667b9fd0ab1c214e
Resolves: #63550
Releases: master, 6.2
Reviewed-on: http://review.typo3.org/35001
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/GraphicalMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/ImageMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/TextMenuContentObject.php

index cac61b4..579d538 100644 (file)
@@ -892,10 +892,11 @@ class AbstractMenuContentObject {
                        } else {
                                $cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout();
                        }
-                       $cachedData = $this->sys_page->getHash($this->hash);
+                       $cache = $this->getCache();
+                       $cachedData = $cache->get($this->hash);
                        if (!is_array($cachedData)) {
                                $this->generate();
-                               $this->sys_page->storeHash($this->hash, $this->result, 'MENUDATA', $cacheTimeout);
+                               $cache->set($this->hash, $this->result, array('ident_MENUDATA'), (int)$cacheTimeout);
                        } else {
                                $this->result = $cachedData;
                        }
@@ -1917,4 +1918,12 @@ class AbstractMenuContentObject {
        public function getParentContentObject() {
                return $this->parent_cObj;
        }
+
+       /**
+        * @return \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
+        */
+       protected function getCache() {
+               return GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('cache_hash');
+       }
+
 }
index 69d38f7..8b79e8f 100644 (file)
@@ -362,105 +362,106 @@ class GraphicalMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\
         * @todo Define visibility
         */
        public function writeMenu() {
-               if (is_array($this->menuArr) && is_array($this->result) && count($this->result) && is_array($this->result['NO'])) {
-                       // Create new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer for our use
-                       $this->WMcObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
-                       $this->WMresult = '';
-                       $this->INPfixMD5 = substr(md5(microtime() . $this->GMENU_fixKey), 0, 4);
-                       $this->WMmenuItems = count($this->result['NO']);
-                       $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix' => $this->mconf['submenuObjSuffixes']), $this->WMmenuItems);
-                       $this->extProc_init();
-                       for ($key = 0; $key < $this->WMmenuItems; $key++) {
-                               if ($this->result['NO'][$key]['output_file']) {
-                                       // Initialize the cObj with the page record of the menu item
-                                       $this->WMcObj->start($this->menuArr[$key], 'pages');
-                                       $this->I = array();
-                                       $this->I['key'] = $key;
-                                       $this->I['INPfix'] = ($this->imgNameNotRandom ? '' : '_' . $this->INPfixMD5) . '_' . $key;
-                                       $this->I['val'] = $this->result['NO'][$key];
-                                       $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
-                                       $this->I['uid'] = $this->menuArr[$key]['uid'];
-                                       $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
-                                       $this->I['pid'] = $this->menuArr[$key]['pid'];
-                                       $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
-                                       if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {
-                                               $this->I['spacer'] = 1;
-                                       }
-                                       $this->I['noLink'] = $this->I['spacer'] || $this->I['val']['noLink'] || !count($this->menuArr[$key]);
-                                       // !count($this->menuArr[$key]) means that this item is a dummyItem
-                                       $this->I['name'] = '';
-                                       // Set access key
-                                       if ($this->mconf['accessKey']) {
-                                               $this->I['accessKey'] = $this->accessKey($this->I['title']);
-                                       } else {
-                                               $this->I['accessKey'] = array();
-                                       }
-                                       // Make link tag
-                                       $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
-                                       if (isset($this->I['val']['additionalParams.'])) {
-                                               $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'], $this->I['val']['additionalParams.']);
-                                       }
-                                       $this->I['linkHREF'] = $this->link($key, $this->I['val']['altTarget'], $this->mconf['forceTypeValue']);
-                                       // Title attribute of links:
-                                       $titleAttrValue = isset($this->I['val']['ATagTitle.']) ? $this->WMcObj->stdWrap($this->I['val']['ATagTitle'], $this->I['val']['ATagTitle.']) . $this->I['accessKey']['alt'] : $this->I['val']['ATagTitle'] . $this->I['accessKey']['alt'];
-                                       if (strlen($titleAttrValue)) {
-                                               $this->I['linkHREF']['title'] = $titleAttrValue;
-                                       }
-                                       // Set rollover
-                                       if ($this->result['RO'][$key] && !$this->I['noLink']) {
-                                               $this->I['theName'] = $this->imgNamePrefix . $this->I['uid'] . $this->I['INPfix'];
-                                               $this->I['name'] = ' ' . $this->nameAttribute . '="' . $this->I['theName'] . '"';
-                                               $this->I['linkHREF']['onMouseover'] = $this->WMfreezePrefix . 'over(\'' . $this->I['theName'] . '\');';
-                                               $this->I['linkHREF']['onMouseout'] = $this->WMfreezePrefix . 'out(\'' . $this->I['theName'] . '\');';
-                                               $GLOBALS['TSFE']->JSImgCode .= LF . $this->I['theName'] . '_n=new Image(); ' . $this->I['theName'] . '_n.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '"; ';
-                                               $GLOBALS['TSFE']->JSImgCode .= LF . $this->I['theName'] . '_h=new Image(); ' . $this->I['theName'] . '_h.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->result['RO'][$key]['output_file'] . '"; ';
-                                               $GLOBALS['TSFE']->imagesOnPage[] = $this->result['RO'][$key]['output_file'];
-                                               $GLOBALS['TSFE']->setJS('mouseOver');
-                                               $this->extProc_RO($key);
-                                       }
-                                       // Set altText
-                                       $this->I['altText'] = $this->I['title'] . $this->I['accessKey']['alt'];
-                                       // Calling extra processing function
-                                       $this->extProc_beforeLinking($key);
-                                       // Set linking
-                                       if (!$this->I['noLink']) {
-                                               $this->setATagParts();
-                                       } else {
-                                               $this->I['A1'] = '';
-                                               $this->I['A2'] = '';
-                                       }
-                                       $this->I['IMG'] = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '" width="' . $this->I['val']['output_w'] . '" height="' . $this->I['val']['output_h'] . '" ' . $this->parent_cObj->getBorderAttr('border="0"') . ($this->mconf['disableAltText'] ? '' : ' alt="' . htmlspecialchars($this->I['altText']) . '"') . $this->I['name'] . ($this->I['val']['imgParams'] ? ' ' . $this->I['val']['imgParams'] : '') . ' />';
-                                       // Make before, middle and after parts
-                                       $this->I['parts'] = array();
-                                       $this->I['parts']['ATag_begin'] = $this->I['A1'];
-                                       $this->I['parts']['image'] = $this->I['IMG'];
-                                       $this->I['parts']['ATag_end'] = $this->I['A2'];
-                                       // Passing I to a user function
-                                       if ($this->mconf['IProcFunc']) {
-                                               $this->I = $this->userProcess('IProcFunc', $this->I);
-                                       }
-                                       // Putting the item together.
-                                       // Merge parts + beforeAllWrap
-                                       $this->I['theItem'] = implode('', $this->I['parts']);
-                                       $this->I['theItem'] = $this->extProc_beforeAllWrap($this->I['theItem'], $key);
-                                       // wrap:
-                                       $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'], $this->I['val']['wrap']);
-                                       // allWrap:
-                                       $allWrap = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
-                                       $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'], $allWrap);
-                                       if ($this->I['val']['subst_elementUid']) {
-                                               $this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
-                                       }
-                                       // allStdWrap:
-                                       if (is_array($this->I['val']['allStdWrap.'])) {
-                                               $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
-                                       }
-                                       $GLOBALS['TSFE']->imagesOnPage[] = $this->I['val']['output_file'];
-                                       $this->extProc_afterLinking($key);
+               if (!is_array($this->menuArr) || empty($this->result) || !is_array($this->result['NO'])) {
+                       return '';
+               }
+               // Create new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer for our use
+               $this->WMcObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
+               $this->WMresult = '';
+               $this->INPfixMD5 = substr(md5(microtime() . $this->GMENU_fixKey), 0, 4);
+               $this->WMmenuItems = count($this->result['NO']);
+               $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix' => $this->mconf['submenuObjSuffixes']), $this->WMmenuItems);
+               $this->extProc_init();
+               for ($key = 0; $key < $this->WMmenuItems; $key++) {
+                       if ($this->result['NO'][$key]['output_file']) {
+                               // Initialize the cObj with the page record of the menu item
+                               $this->WMcObj->start($this->menuArr[$key], 'pages');
+                               $this->I = array();
+                               $this->I['key'] = $key;
+                               $this->I['INPfix'] = ($this->imgNameNotRandom ? '' : '_' . $this->INPfixMD5) . '_' . $key;
+                               $this->I['val'] = $this->result['NO'][$key];
+                               $this->I['title'] = $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
+                               $this->I['uid'] = $this->menuArr[$key]['uid'];
+                               $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
+                               $this->I['pid'] = $this->menuArr[$key]['pid'];
+                               $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
+                               if (!$this->I['uid'] && !$this->menuArr[$key]['_OVERRIDE_HREF']) {
+                                       $this->I['spacer'] = 1;
+                               }
+                               $this->I['noLink'] = $this->I['spacer'] || $this->I['val']['noLink'] || !count($this->menuArr[$key]);
+                               // !count($this->menuArr[$key]) means that this item is a dummyItem
+                               $this->I['name'] = '';
+                               // Set access key
+                               if ($this->mconf['accessKey']) {
+                                       $this->I['accessKey'] = $this->accessKey($this->I['title']);
+                               } else {
+                                       $this->I['accessKey'] = array();
+                               }
+                               // Make link tag
+                               $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
+                               if (isset($this->I['val']['additionalParams.'])) {
+                                       $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'], $this->I['val']['additionalParams.']);
+                               }
+                               $this->I['linkHREF'] = $this->link($key, $this->I['val']['altTarget'], $this->mconf['forceTypeValue']);
+                               // Title attribute of links:
+                               $titleAttrValue = isset($this->I['val']['ATagTitle.']) ? $this->WMcObj->stdWrap($this->I['val']['ATagTitle'], $this->I['val']['ATagTitle.']) . $this->I['accessKey']['alt'] : $this->I['val']['ATagTitle'] . $this->I['accessKey']['alt'];
+                               if (strlen($titleAttrValue)) {
+                                       $this->I['linkHREF']['title'] = $titleAttrValue;
+                               }
+                               // Set rollover
+                               if ($this->result['RO'][$key] && !$this->I['noLink']) {
+                                       $this->I['theName'] = $this->imgNamePrefix . $this->I['uid'] . $this->I['INPfix'];
+                                       $this->I['name'] = ' ' . $this->nameAttribute . '="' . $this->I['theName'] . '"';
+                                       $this->I['linkHREF']['onMouseover'] = $this->WMfreezePrefix . 'over(\'' . $this->I['theName'] . '\');';
+                                       $this->I['linkHREF']['onMouseout'] = $this->WMfreezePrefix . 'out(\'' . $this->I['theName'] . '\');';
+                                       $GLOBALS['TSFE']->JSImgCode .= LF . $this->I['theName'] . '_n=new Image(); ' . $this->I['theName'] . '_n.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '"; ';
+                                       $GLOBALS['TSFE']->JSImgCode .= LF . $this->I['theName'] . '_h=new Image(); ' . $this->I['theName'] . '_h.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->result['RO'][$key]['output_file'] . '"; ';
+                                       $GLOBALS['TSFE']->imagesOnPage[] = $this->result['RO'][$key]['output_file'];
+                                       $GLOBALS['TSFE']->setJS('mouseOver');
+                                       $this->extProc_RO($key);
+                               }
+                               // Set altText
+                               $this->I['altText'] = $this->I['title'] . $this->I['accessKey']['alt'];
+                               // Calling extra processing function
+                               $this->extProc_beforeLinking($key);
+                               // Set linking
+                               if (!$this->I['noLink']) {
+                                       $this->setATagParts();
+                               } else {
+                                       $this->I['A1'] = '';
+                                       $this->I['A2'] = '';
+                               }
+                               $this->I['IMG'] = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '" width="' . $this->I['val']['output_w'] . '" height="' . $this->I['val']['output_h'] . '" ' . $this->parent_cObj->getBorderAttr('border="0"') . ($this->mconf['disableAltText'] ? '' : ' alt="' . htmlspecialchars($this->I['altText']) . '"') . $this->I['name'] . ($this->I['val']['imgParams'] ? ' ' . $this->I['val']['imgParams'] : '') . ' />';
+                               // Make before, middle and after parts
+                               $this->I['parts'] = array();
+                               $this->I['parts']['ATag_begin'] = $this->I['A1'];
+                               $this->I['parts']['image'] = $this->I['IMG'];
+                               $this->I['parts']['ATag_end'] = $this->I['A2'];
+                               // Passing I to a user function
+                               if ($this->mconf['IProcFunc']) {
+                                       $this->I = $this->userProcess('IProcFunc', $this->I);
+                               }
+                               // Putting the item together.
+                               // Merge parts + beforeAllWrap
+                               $this->I['theItem'] = implode('', $this->I['parts']);
+                               $this->I['theItem'] = $this->extProc_beforeAllWrap($this->I['theItem'], $key);
+                               // wrap:
+                               $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'], $this->I['val']['wrap']);
+                               // allWrap:
+                               $allWrap = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
+                               $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'], $allWrap);
+                               if ($this->I['val']['subst_elementUid']) {
+                                       $this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
+                               }
+                               // allStdWrap:
+                               if (is_array($this->I['val']['allStdWrap.'])) {
+                                       $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
                                }
+                               $GLOBALS['TSFE']->imagesOnPage[] = $this->I['val']['output_file'];
+                               $this->extProc_afterLinking($key);
                        }
-                       return $this->extProc_finish();
                }
+               return $this->extProc_finish();
        }
 
        /**
index eba9729..01edd16 100644 (file)
@@ -13,13 +13,15 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\TypoScript\TemplateService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * ImageMap based menus
  *
  * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject {
+class ImageMenuContentObject extends AbstractMenuContentObject {
 
        /**
         * Calls procesItemStates() so that the common configuration for the menu items are resolved into individual configuration per item.
@@ -33,6 +35,8 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                $splitCount = count($this->menuArr);
                if ($splitCount) {
                        list($NOconf) = $this->procesItemStates($splitCount);
+               } else {
+                       $NOconf = array();
                }
                if ($this->mconf['debugItemConf']) {
                        echo '<h3>$NOconf:</h3>';
@@ -56,22 +60,20 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                        $conf = array();
                }
                if (is_array($this->mconf['main.'])) {
-                       $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder');
+                       $gifCreator = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Imaging\\GifBuilder');
                        $gifCreator->init();
                        $itemsConf = $conf;
                        $conf = $this->mconf['main.'];
                        if (is_array($conf)) {
-                               $gifObjCount = 0;
-                               $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($conf);
+                               $sKeyArray = TemplateService::sortedKeyList($conf);
                                $gifObjCount = (int)end($sKeyArray);
-                               $lastOriginal = $gifObjCount;
                                // Now we add graphical objects to the gifbuilder-setup
                                $waArr = array();
                                foreach ($itemsConf as $key => $val) {
                                        if (is_array($val)) {
                                                $gifObjCount++;
                                                $waArr[$key]['free'] = $gifObjCount;
-                                               $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($val);
+                                               $sKeyArray = TemplateService::sortedKeyList($val);
                                                foreach ($sKeyArray as $theKey) {
                                                        $theValue = $val[$theKey];
                                                        if ((int)$theKey && ($theValArr = $val[$theKey . '.'])) {
@@ -102,7 +104,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                                                $theValArr['imgMap.']['target'] = $LD['target'];
                                                                        }
                                                                        if (is_array($theValArr['imgMap.']['altText.'])) {
-                                                                               $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
+                                                                               $cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                                                                $cObj->start($cObjData, 'pages');
                                                                                if (isset($theValArr['imgMap.']['altText.'])) {
                                                                                        $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']);
@@ -110,7 +112,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                                                unset($theValArr['imgMap.']['altText.']);
                                                                        }
                                                                        if (is_array($theValArr['imgMap.']['titleText.'])) {
-                                                                               $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
+                                                                               $cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                                                                $cObj->start($cObjData, 'pages');
                                                                                if (isset($theValArr['imgMap.']['titleText.'])) {
                                                                                        $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']);
@@ -121,7 +123,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                                // This code goes one level in if the object is an image. If 'file' and/or 'mask' appears to be GIFBUILDER-objects, they are both searched for TEXT objects, and if a textobj is found, it's checked with the currently loaded record!!
                                                                if ($theValue == 'IMAGE') {
                                                                        if ($theValArr['file'] == 'GIFBUILDER') {
-                                                                               $temp_sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($theValArr['file.']);
+                                                                               $temp_sKeyArray = TemplateService::sortedKeyList($theValArr['file.']);
                                                                                foreach ($temp_sKeyArray as $temp_theKey) {
                                                                                        if ($theValArr['mask.'][$temp_theKey] == 'TEXT') {
                                                                                                $gifCreator->data = $this->menuArr[$key] ?: array();
@@ -132,7 +134,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                                                }
                                                                        }
                                                                        if ($theValArr['mask'] == 'GIFBUILDER') {
-                                                                               $temp_sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($theValArr['mask.']);
+                                                                               $temp_sKeyArray = TemplateService::sortedKeyList($theValArr['mask.']);
                                                                                foreach ($temp_sKeyArray as $temp_theKey) {
                                                                                        if ($theValArr['mask.'][$temp_theKey] == 'TEXT') {
                                                                                                $gifCreator->data = $this->menuArr[$key] ?: array();
@@ -147,7 +149,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                                $setObjFlag = 1;
                                                                if ($theValArr['if.']) {
                                                                        /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
-                                                                       $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
+                                                                       $cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                                                                        $cObj->start($cObjData, 'pages');
                                                                        if (!empty($theValArr['if.']) && !$cObj->checkIf($theValArr['if.'])) {
                                                                                $setObjFlag = 0;
@@ -165,6 +167,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                }
                                $gifCreator->start($conf, $GLOBALS['TSFE']->page);
                                // calculations
+                               $dConf = array();
                                foreach ($waArr as $key => $val) {
                                        if ($dConf[$key] = $itemsConf[$key]['distrib']) {
                                                $textBB = $gifCreator->objBB[$val['textNum']];
@@ -173,10 +176,10 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                                        array($textBB[0], $textBB[1]),
                                                        $dConf[$key]
                                                );
-                                               $dConf[$key] = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $gifCreator->calcOffset($dConf[$key]));
+                                               $dConf[$key] = GeneralUtility::intExplode(',', $gifCreator->calcOffset($dConf[$key]));
                                        }
                                }
-                               $workArea = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $gifCreator->calcOffset($this->mconf['dWorkArea']));
+                               $workArea = GeneralUtility::intExplode(',', $gifCreator->calcOffset($this->mconf['dWorkArea']));
                                foreach ($waArr as $key => $val) {
                                        $index = $val['free'];
                                        $gifCreator->setup[$index] = 'WORKAREA';
@@ -193,8 +196,9 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                $gifCreator->createTempSubDir('menu/');
                                $gifFileName = $gifCreator->fileName('menu/');
                                // Gets the ImageMap from the cache...
+                               $cache = $this->getCache();
                                $imgHash = md5($gifFileName);
-                               $imgMap = $this->sys_page->getHash($imgHash);
+                               $imgMap = $cache->get($imgHash);
                                // File exists
                                if ($imgMap && file_exists($gifFileName)) {
                                        $info = @getimagesize($gifFileName);
@@ -208,10 +212,10 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                                        $gifCreator->output($gifFileName);
                                        $gifCreator->destroy();
                                        $imgMap = $gifCreator->map;
-                                       $this->sys_page->storeHash($imgHash, $imgMap, 'MENUIMAGEMAP');
+                                       $cache->set($imgHash, $imgMap, array('ident_MENUIMAGEMAP'), 0);
                                }
                                $imgMap .= $this->mconf['imgMapExtras'];
-                               $gifFileName = \TYPO3\CMS\Core\Utility\GeneralUtility::png_to_gif_by_imagemagick($gifFileName);
+                               $gifFileName = GeneralUtility::png_to_gif_by_imagemagick($gifFileName);
                                $this->result = array('output_file' => $gifFileName, 'output_w' => $w, 'output_h' => $h, 'imgMap' => $imgMap);
                        }
                }
@@ -228,7 +232,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                if ($this->result) {
                        $res = &$this->result;
                        // shortMD5 260900
-                       $menuName = 'menu_' . \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($res['imgMap']);
+                       $menuName = 'menu_' . GeneralUtility::shortMD5($res['imgMap']);
                        $result = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $res['output_file'] . '" width="' . $res['output_w'] . '" height="' . $res['output_h'] . '" usemap="#' . $menuName . '" border="0" ' . $this->mconf['params'];
                        // Adding alt attribute if not set.
                        if (!strstr($result, 'alt="')) {
@@ -238,6 +242,7 @@ class ImageMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abst
                        $GLOBALS['TSFE']->imagesOnPage[] = $res['output_file'];
                        return $this->tmpl->wrap($result, $this->mconf['wrap']);
                }
+               return '';
        }
 
 }
index 44098de..8af39de 100644 (file)
@@ -50,117 +50,118 @@ class TextMenuContentObject extends \TYPO3\CMS\Frontend\ContentObject\Menu\Abstr
         * @todo Define visibility
         */
        public function writeMenu() {
-               if (is_array($this->result) && count($this->result)) {
-                       // Create new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer for our use
-                       $this->WMcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
-                       $this->WMresult = '';
-                       $this->INPfixMD5 = substr(md5(microtime() . 'tmenu'), 0, 4);
-                       $this->WMmenuItems = count($this->result);
-                       $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix' => $this->mconf['submenuObjSuffixes']), $this->WMmenuItems);
-                       $this->extProc_init();
-                       foreach ($this->result as $key => $val) {
-                               $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
-                               $GLOBALS['TSFE']->register['count_MENUOBJ']++;
-                               // Initialize the cObj with the page record of the menu item
-                               $this->WMcObj->start($this->menuArr[$key], 'pages');
-                               $this->I = array();
-                               $this->I['key'] = $key;
-                               $this->I['INPfix'] = ($this->imgNameNotRandom ? '' : '_' . $this->INPfixMD5) . '_' . $key;
-                               $this->I['val'] = $val;
-                               $this->I['title'] = isset($this->I['val']['stdWrap.']) ? $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']), $this->I['val']['stdWrap.']) : $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
-                               $this->I['uid'] = $this->menuArr[$key]['uid'];
-                               $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
-                               $this->I['pid'] = $this->menuArr[$key]['pid'];
-                               $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
-                               // Set access key
-                               if ($this->mconf['accessKey']) {
-                                       $this->I['accessKey'] = $this->accessKey($this->I['title']);
-                               } else {
-                                       $this->I['accessKey'] = array();
-                               }
-                               // Make link tag
-                               $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
-                               if (isset($this->I['val']['additionalParams.'])) {
-                                       $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'], $this->I['val']['additionalParams.']);
-                               }
-                               $this->I['linkHREF'] = $this->link($key, $this->I['val']['altTarget'], $this->mconf['forceTypeValue']);
-                               // Title attribute of links:
-                               $titleAttrValue = isset($this->I['val']['ATagTitle.']) ? $this->WMcObj->stdWrap($this->I['val']['ATagTitle'], $this->I['val']['ATagTitle.']) . $this->I['accessKey']['alt'] : $this->I['val']['ATagTitle'] . $this->I['accessKey']['alt'];
-                               if (strlen($titleAttrValue)) {
-                                       $this->I['linkHREF']['title'] = $titleAttrValue;
-                               }
+               if (empty($this->result)) {
+                       return '';
+               }
+               // Create new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer for our use
+               $this->WMcObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
+               $this->WMresult = '';
+               $this->INPfixMD5 = substr(md5(microtime() . 'tmenu'), 0, 4);
+               $this->WMmenuItems = count($this->result);
+               $this->WMsubmenuObjSuffixes = $this->tmpl->splitConfArray(array('sOSuffix' => $this->mconf['submenuObjSuffixes']), $this->WMmenuItems);
+               $this->extProc_init();
+               foreach ($this->result as $key => $val) {
+                       $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
+                       $GLOBALS['TSFE']->register['count_MENUOBJ']++;
+                       // Initialize the cObj with the page record of the menu item
+                       $this->WMcObj->start($this->menuArr[$key], 'pages');
+                       $this->I = array();
+                       $this->I['key'] = $key;
+                       $this->I['INPfix'] = ($this->imgNameNotRandom ? '' : '_' . $this->INPfixMD5) . '_' . $key;
+                       $this->I['val'] = $val;
+                       $this->I['title'] = isset($this->I['val']['stdWrap.']) ? $this->WMcObj->stdWrap($this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']), $this->I['val']['stdWrap.']) : $this->getPageTitle($this->menuArr[$key]['title'], $this->menuArr[$key]['nav_title']);
+                       $this->I['uid'] = $this->menuArr[$key]['uid'];
+                       $this->I['mount_pid'] = $this->menuArr[$key]['mount_pid'];
+                       $this->I['pid'] = $this->menuArr[$key]['pid'];
+                       $this->I['spacer'] = $this->menuArr[$key]['isSpacer'];
+                       // Set access key
+                       if ($this->mconf['accessKey']) {
+                               $this->I['accessKey'] = $this->accessKey($this->I['title']);
+                       } else {
+                               $this->I['accessKey'] = array();
+                       }
+                       // Make link tag
+                       $this->I['val']['ATagParams'] = $this->WMcObj->getATagParams($this->I['val']);
+                       if (isset($this->I['val']['additionalParams.'])) {
+                               $this->I['val']['additionalParams'] = $this->WMcObj->stdWrap($this->I['val']['additionalParams'], $this->I['val']['additionalParams.']);
+                       }
+                       $this->I['linkHREF'] = $this->link($key, $this->I['val']['altTarget'], $this->mconf['forceTypeValue']);
+                       // Title attribute of links:
+                       $titleAttrValue = isset($this->I['val']['ATagTitle.']) ? $this->WMcObj->stdWrap($this->I['val']['ATagTitle'], $this->I['val']['ATagTitle.']) . $this->I['accessKey']['alt'] : $this->I['val']['ATagTitle'] . $this->I['accessKey']['alt'];
+                       if (strlen($titleAttrValue)) {
+                               $this->I['linkHREF']['title'] = $titleAttrValue;
+                       }
 
-                               // Calling extra processing function
-                               $this->extProc_beforeLinking($key);
-                               // stdWrap for doNotLinkIt
-                               if (isset($this->I['val']['doNotLinkIt.'])) {
-                                       $this->I['val']['doNotLinkIt'] = $this->WMcObj->stdWrap($this->I['val']['doNotLinkIt'], $this->I['val']['doNotLinkIt.']);
-                               }
-                               // Compile link tag
-                               if (!$this->I['val']['doNotLinkIt']) {
-                                       $this->I['val']['doNotLinkIt'] = 0;
-                               }
-                               if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt'] != 1) {
-                                       $this->setATagParts();
-                               } else {
-                                       $this->I['A1'] = '';
-                                       $this->I['A2'] = '';
-                               }
-                               // ATagBeforeWrap processing:
-                               if ($this->I['val']['ATagBeforeWrap']) {
-                                       $wrapPartsBefore = explode('|', $this->I['val']['linkWrap']);
-                                       $wrapPartsAfter = array('', '');
-                               } else {
-                                       $wrapPartsBefore = array('', '');
-                                       $wrapPartsAfter = explode('|', $this->I['val']['linkWrap']);
-                               }
-                               if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) {
-                                       $stdWrap2 = isset($this->I['val']['stdWrap2.']) ? $this->WMcObj->stdWrap('|', $this->I['val']['stdWrap2.']) : '|';
-                                       $wrapPartsStdWrap = explode($this->I['val']['stdWrap2'] ? $this->I['val']['stdWrap2'] : '|', $stdWrap2);
-                               } else {
-                                       $wrapPartsStdWrap = array('', '');
-                               }
-                               // Make before, middle and after parts
-                               $this->I['parts'] = array();
-                               $this->I['parts']['before'] = $this->getBeforeAfter('before');
-                               $this->I['parts']['stdWrap2_begin'] = $wrapPartsStdWrap[0];
-                               // stdWrap for doNotShowLink
-                               if (isset($this->I['val']['doNotShowLink.'])) {
-                                       $this->I['val']['doNotShowLink'] = $this->WMcObj->stdWrap($this->I['val']['doNotShowLink'], $this->I['val']['doNotShowLink.']);
-                               }
-                               if (!$this->I['val']['doNotShowLink']) {
-                                       $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0];
-                                       $this->I['parts']['ATag_begin'] = $this->I['A1'];
-                                       $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0];
-                                       $this->I['parts']['title'] = $this->I['title'];
-                                       $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1];
-                                       $this->I['parts']['ATag_end'] = $this->I['A2'];
-                                       $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1];
-                               }
-                               $this->I['parts']['stdWrap2_end'] = $wrapPartsStdWrap[1];
-                               $this->I['parts']['after'] = $this->getBeforeAfter('after');
-                               // Passing I to a user function
-                               if ($this->mconf['IProcFunc']) {
-                                       $this->I = $this->userProcess('IProcFunc', $this->I);
-                               }
-                               // Merge parts + beforeAllWrap
-                               $this->I['theItem'] = implode('', $this->I['parts']);
-                               $this->I['theItem'] = $this->extProc_beforeAllWrap($this->I['theItem'], $key);
-                               // allWrap:
-                               $allWrap = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
-                               $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'], $allWrap);
-                               if ($this->I['val']['subst_elementUid']) {
-                                       $this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
-                               }
-                               // allStdWrap:
-                               if (is_array($this->I['val']['allStdWrap.'])) {
-                                       $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
-                               }
-                               // Calling extra processing function
-                               $this->extProc_afterLinking($key);
+                       // Calling extra processing function
+                       $this->extProc_beforeLinking($key);
+                       // stdWrap for doNotLinkIt
+                       if (isset($this->I['val']['doNotLinkIt.'])) {
+                               $this->I['val']['doNotLinkIt'] = $this->WMcObj->stdWrap($this->I['val']['doNotLinkIt'], $this->I['val']['doNotLinkIt.']);
+                       }
+                       // Compile link tag
+                       if (!$this->I['val']['doNotLinkIt']) {
+                               $this->I['val']['doNotLinkIt'] = 0;
+                       }
+                       if (!$this->I['spacer'] && $this->I['val']['doNotLinkIt'] != 1) {
+                               $this->setATagParts();
+                       } else {
+                               $this->I['A1'] = '';
+                               $this->I['A2'] = '';
+                       }
+                       // ATagBeforeWrap processing:
+                       if ($this->I['val']['ATagBeforeWrap']) {
+                               $wrapPartsBefore = explode('|', $this->I['val']['linkWrap']);
+                               $wrapPartsAfter = array('', '');
+                       } else {
+                               $wrapPartsBefore = array('', '');
+                               $wrapPartsAfter = explode('|', $this->I['val']['linkWrap']);
+                       }
+                       if ($this->I['val']['stdWrap2'] || isset($this->I['val']['stdWrap2.'])) {
+                               $stdWrap2 = isset($this->I['val']['stdWrap2.']) ? $this->WMcObj->stdWrap('|', $this->I['val']['stdWrap2.']) : '|';
+                               $wrapPartsStdWrap = explode($this->I['val']['stdWrap2'] ? $this->I['val']['stdWrap2'] : '|', $stdWrap2);
+                       } else {
+                               $wrapPartsStdWrap = array('', '');
+                       }
+                       // Make before, middle and after parts
+                       $this->I['parts'] = array();
+                       $this->I['parts']['before'] = $this->getBeforeAfter('before');
+                       $this->I['parts']['stdWrap2_begin'] = $wrapPartsStdWrap[0];
+                       // stdWrap for doNotShowLink
+                       if (isset($this->I['val']['doNotShowLink.'])) {
+                               $this->I['val']['doNotShowLink'] = $this->WMcObj->stdWrap($this->I['val']['doNotShowLink'], $this->I['val']['doNotShowLink.']);
+                       }
+                       if (!$this->I['val']['doNotShowLink']) {
+                               $this->I['parts']['notATagBeforeWrap_begin'] = $wrapPartsAfter[0];
+                               $this->I['parts']['ATag_begin'] = $this->I['A1'];
+                               $this->I['parts']['ATagBeforeWrap_begin'] = $wrapPartsBefore[0];
+                               $this->I['parts']['title'] = $this->I['title'];
+                               $this->I['parts']['ATagBeforeWrap_end'] = $wrapPartsBefore[1];
+                               $this->I['parts']['ATag_end'] = $this->I['A2'];
+                               $this->I['parts']['notATagBeforeWrap_end'] = $wrapPartsAfter[1];
+                       }
+                       $this->I['parts']['stdWrap2_end'] = $wrapPartsStdWrap[1];
+                       $this->I['parts']['after'] = $this->getBeforeAfter('after');
+                       // Passing I to a user function
+                       if ($this->mconf['IProcFunc']) {
+                               $this->I = $this->userProcess('IProcFunc', $this->I);
+                       }
+                       // Merge parts + beforeAllWrap
+                       $this->I['theItem'] = implode('', $this->I['parts']);
+                       $this->I['theItem'] = $this->extProc_beforeAllWrap($this->I['theItem'], $key);
+                       // allWrap:
+                       $allWrap = isset($this->I['val']['allWrap.']) ? $this->WMcObj->stdWrap($this->I['val']['allWrap'], $this->I['val']['allWrap.']) : $this->I['val']['allWrap'];
+                       $this->I['theItem'] = $this->tmpl->wrap($this->I['theItem'], $allWrap);
+                       if ($this->I['val']['subst_elementUid']) {
+                               $this->I['theItem'] = str_replace('{elementUid}', $this->I['uid'], $this->I['theItem']);
+                       }
+                       // allStdWrap:
+                       if (is_array($this->I['val']['allStdWrap.'])) {
+                               $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
                        }
-                       return $this->extProc_finish();
+                       // Calling extra processing function
+                       $this->extProc_afterLinking($key);
                }
+               return $this->extProc_finish();
        }
 
        /**