Revert "[CLEANUP] MENU Content Object classes" 83/36583/2
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 1 Feb 2015 16:28:06 +0000 (17:28 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sun, 1 Feb 2015 16:28:27 +0000 (17:28 +0100)
This reverts commit 2bb692ae9fc1747372d4d0079f414e3782a65587.

Change-Id: I44fd2457bb39c7302ca9de141c15d3b34a67a936
Reviewed-on: http://review.typo3.org/36583
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/CategoryMenuUtility.php
typo3/sysext/frontend/Classes/ContentObject/Menu/GraphicalMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/ImageMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/JavaScriptMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/MenuContentObjectFactory.php
typo3/sysext/frontend/Classes/ContentObject/Menu/TextMenuContentObject.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php

index 714be41..240c12d 100644 (file)
@@ -14,30 +14,25 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Database\DatabaseConnection;
-use TYPO3\CMS\Core\Database\RelationHandler;
-use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
-use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
-use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
- * Generating navigation/menus from TypoScript
+ * Generating navigation / menus from TypoScript
  *
- * The HMENU content object uses this (or more precisely one of the extension classes).
- * Among others the class generates an array of menu items. Thereafter functions from the subclasses are called.
- * The class is always used through extension classes (like GraphicalMenuContentObject or TextMenuContentObject).
+ * Base class. The HMENU content object uses this (or more precisely one of the extension classes).
+ * Among others the class generates an array of menuitems. Thereafter functions from the subclasses are called.
+ * The class is ALWAYS used through extension classes (like GraphicalMenuContentObject or TextMenuContentObject which are classics) and
  *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  */
-abstract class AbstractMenuContentObject {
+class AbstractMenuContentObject {
 
        /**
-        * tells you which menu number this is. This is important when getting data from the setup
+        * tells you which menu-number this is. This is important when getting data from the setup
         *
         * @var int
         */
@@ -65,7 +60,7 @@ abstract class AbstractMenuContentObject {
        public $doktypeExcludeList = '6';
 
        /**
-        * @var int[]
+        * @var array
         */
        public $alwaysActivePIDlist = array();
 
@@ -89,7 +84,7 @@ abstract class AbstractMenuContentObject {
         *
         * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
         */
-       public $parent_cObj = NULL;
+       public $parent_cObj;
 
        /**
         * @var string
@@ -99,7 +94,7 @@ abstract class AbstractMenuContentObject {
        /**
         * accumulation of mount point data
         *
-        * @var string[]
+        * @var array
         */
        public $MP_array = array();
 
@@ -118,14 +113,18 @@ abstract class AbstractMenuContentObject {
        public $mconf = array();
 
        /**
+        * template-object
+        *
         * @var \TYPO3\CMS\Core\TypoScript\TemplateService
         */
-       public $tmpl = NULL;
+       public $tmpl;
 
        /**
+        * sys_page-object, pagefunctions
+        *
         * @var \TYPO3\CMS\Frontend\Page\PageRepository
         */
-       public $sys_page = NULL;
+       public $sys_page;
 
        /**
         * The base page-id of the menu.
@@ -145,7 +144,7 @@ abstract class AbstractMenuContentObject {
        /**
         * The array of menuItems which is built
         *
-        * @var array[]
+        * @var array
         */
        public $menuArr;
 
@@ -173,7 +172,7 @@ abstract class AbstractMenuContentObject {
        public $INPfixMD5;
 
        /**
-        * @var array[]
+        * @var array
         */
        public $I;
 
@@ -193,7 +192,7 @@ abstract class AbstractMenuContentObject {
        public $WMmenuItems;
 
        /**
-        * @var array[]
+        * @var array
         */
        public $WMsubmenuObjSuffixes;
 
@@ -203,11 +202,6 @@ abstract class AbstractMenuContentObject {
        public $WMextraScript;
 
        /**
-        * @var ContentObjectRenderer
-        */
-       protected $WMcObj = NULL;
-
-       /**
         * Can be set to contain menu item arrays for sub-levels.
         *
         * @var string
@@ -232,30 +226,29 @@ abstract class AbstractMenuContentObject {
        /**
         * The initialization of the object. This just sets some internal variables.
         *
-        * @param TemplateService $tmpl The $this->getTypoScriptFrontendController()->tmpl object
-        * @param PageRepository $sys_page The $this->getTypoScriptFrontendController()->sys_page object
-        * @param int|string $id A starting point page id. This should probably be blank since the 'entryLevel' value will be used then.
+        * @param TemplateService $tmpl The $GLOBALS['TSFE']->tmpl object
+        * @param PageRepository $sys_page The $GLOBALS['TSFE']->sys_page object
+        * @param int $id A starting point page id. This should probably be blank since the 'entryLevel' value will be used then.
         * @param array $conf The TypoScript configuration for the HMENU cObject
-        * @param int $menuNumber Menu number; 1,2,3. Should probably be 1
+        * @param int $menuNumber Menu number; 1,2,3. Should probably be '1'
         * @param string $objSuffix Submenu Object suffix. This offers submenus a way to use alternative configuration for specific positions in the menu; By default "1 = TMENU" would use "1." for the TMENU configuration, but if this string is set to eg. "a" then "1a." would be used for configuration instead (while "1 = " is still used for the overall object definition of "TMENU")
         * @return bool Returns TRUE on success
         * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::HMENU()
         */
-       public function start($tmpl, $sys_page, $id, $conf, $menuNumber, $objSuffix = '') {
-               $tsfe = $this->getTypoScriptFrontendController();
+       public function start(&$tmpl, &$sys_page, $id, $conf, $menuNumber, $objSuffix = '') {
                // Init:
                $this->conf = $conf;
                $this->menuNumber = $menuNumber;
                $this->mconf = $conf[$this->menuNumber . $objSuffix . '.'];
-               $this->debug = $tsfe->debug;
+               $this->debug = $GLOBALS['TSFE']->debug;
                // In XHTML there is no "name" attribute anymore
-               switch ($tsfe->xhtmlDoctype) {
+               switch ($GLOBALS['TSFE']->xhtmlDoctype) {
                        case 'xhtml_strict':
-                               // intended fall-through
+
                        case 'xhtml_11':
-                               // intended fall-through
+
                        case 'xhtml_2':
-                               // intended fall-through
+
                        case 'html5':
                                $this->nameAttribute = 'id';
                                break;
@@ -278,7 +271,7 @@ abstract class AbstractMenuContentObject {
                        }
                        // 'not in menu' doktypes
                        if ($this->conf['excludeDoktypes']) {
-                               $this->doktypeExcludeList = $this->getDatabaseConnection()->cleanIntList($this->conf['excludeDoktypes']);
+                               $this->doktypeExcludeList = $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['excludeDoktypes']);
                        }
                        // EntryLevel
                        $this->entryLevel = $this->parent_cObj->getKey(
@@ -353,9 +346,9 @@ abstract class AbstractMenuContentObject {
                                        $this->conf['special.']['value.']
                                ) : $this->conf['special.']['value'];
                                if ($value == '') {
-                                       $value = $tsfe->page['uid'];
+                                       $value = $GLOBALS['TSFE']->page['uid'];
                                }
-                               $directoryLevel = (int)$tsfe->tmpl->getRootlineLevel($value);
+                               $directoryLevel = (int)$GLOBALS['TSFE']->tmpl->getRootlineLevel($value);
                        }
                        // Setting "nextActive": This is the page uid + MPvar of the NEXT page in rootline. Used to expand the menu if we are in the right branch of the tree
                        // Notice: The automatic expansion of a menu is designed to work only when no "special" modes (except "directory") are used.
@@ -390,7 +383,7 @@ abstract class AbstractMenuContentObject {
                        $this->imgNameNotRandom = $this->mconf['imgNameNotRandom'];
                        $retVal = TRUE;
                } else {
-                       $this->getTimeTracker()->setTSlogMessage('ERROR in menu', 3);
+                       $GLOBALS['TT']->setTSlogMessage('ERROR in menu', 3);
                        $retVal = FALSE;
                }
                return $retVal;
@@ -399,119 +392,101 @@ abstract class AbstractMenuContentObject {
        /**
         * Creates the menu in the internal variables, ready for output.
         * Basically this will read the page records needed and fill in the internal $this->menuArr
-        * Based on a hash of this array and some other variables the $this->result variable will be
-        * loaded either from cache OR by calling the generate() method of the class to create the menu for real.
+        * Based on a hash of this array and some other variables the $this->result variable will be loaded either from cache OR by calling the generate() method of the class to create the menu for real.
         *
         * @return void
         */
        public function makeMenu() {
-               if (!$this->id) {
-                       return;
-               }
-
-               $this->useCacheHash = FALSE;
-
-               // Initializing showAccessRestrictedPages
-               $SAVED_where_groupAccess = '';
-               if ($this->mconf['showAccessRestrictedPages']) {
-                       // SAVING where_groupAccess
-                       $SAVED_where_groupAccess = $this->sys_page->where_groupAccess;
-                       // Temporarily removing fe_group checking!
-                       $this->sys_page->where_groupAccess = '';
-               }
-
-               $menuItems = $this->prepareMenuItems();
-
-               $c = 0;
-               $c_b = 0;
-               $minItems = (int)($this->mconf['minItems'] ?: $this->conf['minItems']);
-               $maxItems = (int)($this->mconf['maxItems'] ?: $this->conf['maxItems']);
-               $begin = $this->parent_cObj->calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
-               $minItemsConf = isset($this->mconf['minItems.']) ? $this->mconf['minItems.'] : (isset($this->conf['minItems.']) ? $this->conf['minItems.'] : NULL);
-               $minItems = is_array($minItemsConf) ? $this->parent_cObj->stdWrap($minItems, $minItemsConf) : $minItems;
-               $maxItemsConf = isset($this->mconf['maxItems.']) ? $this->mconf['maxItems.'] : (isset($this->conf['maxItems.']) ? $this->conf['maxItems.'] : NULL);
-               $maxItems = is_array($maxItemsConf) ? $this->parent_cObj->stdWrap($maxItems, $maxItemsConf) : $maxItems;
-               $beginConf = isset($this->mconf['begin.']) ? $this->mconf['begin.'] : (isset($this->conf['begin.']) ? $this->conf['begin.'] : NULL);
-               $begin = is_array($beginConf) ? $this->parent_cObj->stdWrap($begin, $beginConf) : $begin;
-               $banUidArray = $this->getBannedUids();
-               // Fill in the menuArr with elements that should go into the menu:
-               $this->menuArr = array();
-               foreach ($menuItems as $data) {
-                       $spacer = GeneralUtility::inList(
-                                       $this->spacerIDList,
-                                       $data['doktype']
-                               ) || $data['ITEM_STATE'] === 'SPC';
-                       // if item is a spacer, $spacer is set
-                       if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
-                               $c_b++;
-                               // If the beginning item has been reached.
-                               if ($begin <= $c_b) {
-                                       $this->menuArr[$c] = $data;
-                                       $this->menuArr[$c]['isSpacer'] = $spacer;
-                                       $c++;
-                                       if ($maxItems && $c >= $maxItems) {
-                                               break;
+               if ($this->id) {
+                       $this->useCacheHash = FALSE;
+
+                       // Initializing showAccessRestrictedPages
+                       if ($this->mconf['showAccessRestrictedPages']) {
+                               // SAVING where_groupAccess
+                               $SAVED_where_groupAccess = $this->sys_page->where_groupAccess;
+                               // Temporarily removing fe_group checking!
+                               $this->sys_page->where_groupAccess = '';
+                       }
+
+                       $menuItems = $this->prepareMenuItems();
+
+                       $c = 0;
+                       $c_b = 0;
+                       $minItems = (int)($this->mconf['minItems'] ?: $this->conf['minItems']);
+                       $maxItems = (int)($this->mconf['maxItems'] ?: $this->conf['maxItems']);
+                       $begin = $this->parent_cObj->calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
+                       $minItemsConf = isset($this->mconf['minItems.']) ? $this->mconf['minItems.'] : (isset($this->conf['minItems.']) ? $this->conf['minItems.'] : NULL);
+                       $minItems = is_array($minItemsConf) ? $this->parent_cObj->stdWrap($minItems, $minItemsConf) : $minItems;
+                       $maxItemsConf = isset($this->mconf['maxItems.']) ? $this->mconf['maxItems.'] : (isset($this->conf['maxItems.']) ? $this->conf['maxItems.'] : NULL);
+                       $maxItems = is_array($maxItemsConf) ? $this->parent_cObj->stdWrap($maxItems, $maxItemsConf) : $maxItems;
+                       $beginConf = isset($this->mconf['begin.']) ? $this->mconf['begin.'] : (isset($this->conf['begin.']) ? $this->conf['begin.'] : NULL);
+                       $begin = is_array($beginConf) ? $this->parent_cObj->stdWrap($begin, $beginConf) : $begin;
+                       $banUidArray = $this->getBannedUids();
+                       // Fill in the menuArr with elements that should go into the menu:
+                       $this->menuArr = array();
+                       foreach ($menuItems as $data) {
+                               $spacer = GeneralUtility::inList(
+                                               $this->spacerIDList,
+                                               $data['doktype']
+                                       ) || $data['ITEM_STATE'] === 'SPC';
+                               // if item is a spacer, $spacer is set
+                               if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
+                                       $c_b++;
+                                       // If the beginning item has been reached.
+                                       if ($begin <= $c_b) {
+                                               $this->menuArr[$c] = $data;
+                                               $this->menuArr[$c]['isSpacer'] = $spacer;
+                                               $c++;
+                                               if ($maxItems && $c >= $maxItems) {
+                                                       break;
+                                               }
                                        }
                                }
                        }
-               }
-               // Fill in fake items, if min-items is set.
-               if ($minItems) {
-                       while ($c < $minItems) {
-                               $this->menuArr[$c] = array(
-                                       'title' => '...',
-                                       'uid' => $this->getTypoScriptFrontendController()->id
-                               );
-                               $c++;
+                       // Fill in fake items, if min-items is set.
+                       if ($minItems) {
+                               while ($c < $minItems) {
+                                       $this->menuArr[$c] = array(
+                                               'title' => '...',
+                                               'uid' => $GLOBALS['TSFE']->id
+                                       );
+                                       $c++;
+                               }
+                       }
+                       //      Passing the menuArr through a user defined function:
+                       if ($this->mconf['itemArrayProcFunc']) {
+                               if (!is_array($this->parentMenuArr)) {
+                                       $this->parentMenuArr = array();
+                               }
+                               $this->menuArr = $this->userProcess('itemArrayProcFunc', $this->menuArr);
+                       }
+                       // Setting number of menu items
+                       $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
+                       $this->hash = md5(
+                               serialize($this->menuArr) .
+                               serialize($this->mconf) .
+                               serialize($this->tmpl->rootLine) .
+                               serialize($this->MP_array)
+                       );
+                       // Get the cache timeout:
+                       if ($this->conf['cache_period']) {
+                               $cacheTimeout = $this->conf['cache_period'];
+                       } else {
+                               $cacheTimeout = $GLOBALS['TSFE']->get_cache_timeout();
+                       }
+                       $cachedData = $this->sys_page->getHash($this->hash);
+                       if (!is_array($cachedData)) {
+                               $this->generate();
+                               $this->sys_page->storeHash($this->hash, $this->result, 'MENUDATA', $cacheTimeout);
+                       } else {
+                               $this->result = $cachedData;
+                       }
+                       // End showAccessRestrictedPages
+                       if ($this->mconf['showAccessRestrictedPages']) {
+                               // RESTORING where_groupAccess
+                               $this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
                        }
                }
-               //      Passing the menuArr through a user defined function:
-               if ($this->mconf['itemArrayProcFunc']) {
-                       $this->menuArr = $this->userProcess('itemArrayProcFunc', $this->menuArr);
-               }
-               // Setting number of menu items
-               $this->getTypoScriptFrontendController()->register['count_menuItems'] = count($this->menuArr);
-               $this->hash = md5(
-                       serialize($this->menuArr) .
-                       serialize($this->mconf) .
-                       serialize($this->tmpl->rootLine) .
-                       serialize($this->MP_array)
-               );
-               // Get the cache timeout:
-               if ($this->conf['cache_period']) {
-                       $cacheTimeout = $this->conf['cache_period'];
-               } else {
-                       $cacheTimeout = $this->getTypoScriptFrontendController()->get_cache_timeout();
-               }
-               $cachedData = $this->sys_page->getHash($this->hash);
-               if (!is_array($cachedData)) {
-                       $this->generate();
-                       $this->sys_page->storeHash($this->hash, $this->result, 'MENUDATA', $cacheTimeout);
-               } else {
-                       $this->result = $cachedData;
-               }
-               // End showAccessRestrictedPages
-               if ($this->mconf['showAccessRestrictedPages']) {
-                       // RESTORING where_groupAccess
-                       $this->sys_page->where_groupAccess = $SAVED_where_groupAccess;
-               }
-       }
-
-       /**
-        * Generates the the menu data.
-        *
-        * Subclasses should overwrite this method.
-        *
-        * @return void
-        */
-       public function generate() {
-       }
-
-       /**
-       * @return string The HTML for the menu
-       */
-       public function writeMenu() {
-               return '';
        }
 
        /**
@@ -578,8 +553,8 @@ abstract class AbstractMenuContentObject {
                                        );
                                        break;
                                case 'categories':
-                                       /** @var CategoryMenuUtility $categoryMenuUtility */
-                                       $categoryMenuUtility = GeneralUtility::makeInstance(CategoryMenuUtility::class);
+                                       /** @var \TYPO3\CMS\Frontend\ContentObject\Menu\CategoryMenuUtility $categoryMenuUtility */
+                                       $categoryMenuUtility = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\Menu\CategoryMenuUtility::class);
                                        $menuItems = $categoryMenuUtility->collectPages($value, $this->conf['special.'], $this);
                                        break;
                                case 'rootline':
@@ -636,26 +611,25 @@ abstract class AbstractMenuContentObject {
        protected function prepareMenuItemsForLanguageMenu($specialValue) {
                $menuItems = array();
                // Getting current page record NOT overlaid by any translation:
-               $tsfe = $this->getTypoScriptFrontendController();
-               $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $tsfe->page['uid']);
+               $currentPageWithNoOverlay = $this->sys_page->getRawRecord('pages', $GLOBALS['TSFE']->page['uid']);
                // Traverse languages set up:
                $languageItems = GeneralUtility::intExplode(',', $specialValue);
                foreach ($languageItems as $sUid) {
                        // Find overlay record:
                        if ($sUid) {
-                               $lRecs = $this->sys_page->getPageOverlay($tsfe->page['uid'], $sUid);
+                               $lRecs = $this->sys_page->getPageOverlay($GLOBALS['TSFE']->page['uid'], $sUid);
                        } else {
                                $lRecs = array();
                        }
                        // Checking if the "disabled" state should be set.
-                       if (GeneralUtility::hideIfNotTranslated($tsfe->page['l18n_cfg']) && $sUid &&
-                               !count($lRecs) || $tsfe->page['l18n_cfg'] & 1 &&
+                       if (GeneralUtility::hideIfNotTranslated($GLOBALS['TSFE']->page['l18n_cfg']) && $sUid &&
+                               !count($lRecs) || $GLOBALS['TSFE']->page['l18n_cfg'] & 1 &&
                                (!$sUid || !count($lRecs)) ||
                                !$this->conf['special.']['normalWhenNoLanguage'] && $sUid && !count($lRecs)
                        ) {
-                               $iState = $tsfe->sys_language_uid == $sUid ? 'USERDEF2' : 'USERDEF1';
+                               $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'USERDEF2' : 'USERDEF1';
                        } else {
-                               $iState = $tsfe->sys_language_uid == $sUid ? 'ACT' : 'NO';
+                               $iState = $GLOBALS['TSFE']->sys_language_uid == $sUid ? 'ACT' : 'NO';
                        }
                        if ($this->conf['addQueryString']) {
                                $getVars = $this->parent_cObj->getQueryArguments(
@@ -688,10 +662,9 @@ abstract class AbstractMenuContentObject {
         * @return array
         */
        protected function prepareMenuItemsForDirectoryMenu($specialValue, $sortingField) {
-               $tsfe = $this->getTypoScriptFrontendController();
                $menuItems = array();
                if ($specialValue == '') {
-                       $specialValue = $tsfe->page['uid'];
+                       $specialValue = $GLOBALS['TSFE']->page['uid'];
                }
                $items = GeneralUtility::intExplode(',', $specialValue);
                foreach ($items as $id) {
@@ -710,8 +683,8 @@ abstract class AbstractMenuContentObject {
                        }
                        // Get sub-pages:
                        $res = $this->parent_cObj->exec_getQuery('pages', array('pidInList' => $id, 'orderBy' => $sortingField));
-                       while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
-                               $tsfe->sys_page->versionOL('pages', $row, TRUE);
+                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
                                if (is_array($row)) {
                                        // Keep mount point?
                                        $mount_info = $this->sys_page->getMountPointInfo($row['uid'], $row);
@@ -730,7 +703,7 @@ abstract class AbstractMenuContentObject {
                                                }
                                        }
                                        // Add external MP params, then the row:
-                                       if (isset($row)) {
+                                       if (is_array($row)) {
                                                if ($MP) {
                                                        $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
                                                }
@@ -753,8 +726,8 @@ abstract class AbstractMenuContentObject {
                if ($specialValue == '') {
                        $specialValue = $this->id;
                }
-               /** @var RelationHandler $loadDB*/
-               $loadDB = GeneralUtility::makeInstance(RelationHandler::class);
+               /** @var \TYPO3\CMS\Core\Database\RelationHandler $loadDB*/
+               $loadDB = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\RelationHandler::class);
                $loadDB->setFetchAllFields(TRUE);
                $loadDB->start($specialValue, 'pages');
                $loadDB->additionalWhere['pages'] = $this->parent_cObj->enableFields('pages');
@@ -787,11 +760,11 @@ abstract class AbstractMenuContentObject {
                                $row = $loadDB->results['pages'][$val['id']];
                        }
                        // Add versioning overlay for current page (to respect workspaces)
-                       if (isset($row) && is_array($row)) {
+                       if (is_array($row)) {
                                $this->sys_page->versionOL('pages', $row, TRUE);
                        }
                        // Add external MP params, then the row:
-                       if (isset($row) && is_array($row)) {
+                       if (is_array($row)) {
                                if ($MP) {
                                        $row['_MP_PARAM'] = $MP . ($row['_MP_PARAM'] ? ',' . $row['_MP_PARAM'] : '');
                                }
@@ -809,10 +782,9 @@ abstract class AbstractMenuContentObject {
         * @return array
         */
        protected function prepareMenuItemsForUpdatedMenu($specialValue, $sortingField) {
-               $tsfe = $this->getTypoScriptFrontendController();
                $menuItems = array();
                if ($specialValue == '') {
-                       $specialValue = $tsfe->page['uid'];
+                       $specialValue = $GLOBALS['TSFE']->page['uid'];
                }
                $items = GeneralUtility::intExplode(',', $specialValue);
                if (MathUtility::canBeInterpretedAsInteger($this->conf['special.']['depth'])) {
@@ -868,8 +840,8 @@ abstract class AbstractMenuContentObject {
                        'orderBy' => $sortingField ?: $sortField . ' DESC',
                        'max' => $limit
                ));
-               while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
-                       $tsfe->sys_page->versionOL('pages', $row, TRUE);
+               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                       $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
                        if (is_array($row)) {
                                $menuItems[$row['uid']] = $this->sys_page->getPageOverlay($row);
                        }
@@ -885,11 +857,10 @@ abstract class AbstractMenuContentObject {
         * @return array
         */
        protected function prepareMenuItemsForKeywordsMenu($specialValue, $sortingField) {
-               $tsfe = $this->getTypoScriptFrontendController();
                $menuItems = array();
                list($specialValue) = GeneralUtility::intExplode(',', $specialValue);
                if (!$specialValue) {
-                       $specialValue = $tsfe->page['uid'];
+                       $specialValue = $GLOBALS['TSFE']->page['uid'];
                }
                if ($this->conf['special.']['setKeywords'] || $this->conf['special.']['setKeywords.']) {
                        $kw = isset($this->conf['special.']['setKeywords.']) ? $this->parent_cObj->stdWrap($this->conf['special.']['setKeywords'], $this->conf['special.']['setKeywords.']) : $this->conf['special.']['setKeywords'];
@@ -948,23 +919,21 @@ abstract class AbstractMenuContentObject {
                        $bA = MathUtility::forceIntegerInRange($this->conf['special.']['beginAtLevel'], 0, 100);
                        $id_list = $this->parent_cObj->getTreeList(-1 * $startUid, $depth - 1 + $bA, $bA - 1);
                        $kwArr = explode(',', $kw);
-                       $keyWordsWhereArr = array();
                        foreach ($kwArr as $word) {
                                $word = trim($word);
                                if ($word) {
-                                       $keyWordsWhereArr[] = $kfield . ' LIKE \'%' . $this->getDatabaseConnection()->quoteStr($word, 'pages') . '%\'';
+                                       $keyWordsWhereArr[] = $kfield . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($word, 'pages') . '%\'';
                                }
                        }
-                       $where = empty($keyWordsWhereArr) ? '' : '(' . implode(' OR ', $keyWordsWhereArr) . ')';
                        $res = $this->parent_cObj->exec_getQuery('pages', array(
                                'pidInList' => '0',
                                'uidInList' => $id_list,
-                               'where' => $where . $extraWhere,
+                               'where' => '(' . implode(' OR ', $keyWordsWhereArr) . ')' . $extraWhere,
                                'orderBy' => $sortingField ?: $sortField . ' desc',
                                'max' => $limit
                        ));
-                       while (($row = $this->getDatabaseConnection()->sql_fetch_assoc($res))){
-                               $tsfe->sys_page->versionOL('pages', $row, TRUE);
+                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               $GLOBALS['TSFE']->sys_page->versionOL('pages', $row, TRUE);
                                if (is_array($row)) {
                                        $menuItems[$row['uid']] = $this->sys_page->getPageOverlay($row);
                                }
@@ -1021,6 +990,7 @@ abstract class AbstractMenuContentObject {
                // Reverse order of elements (e.g. "1,2,3,4" gets "4,3,2,1"):
                if (isset($this->conf['special.']['reverseOrder']) && $this->conf['special.']['reverseOrder']) {
                        $menuItems = array_reverse($menuItems);
+                       $rl_MParray = array_reverse($rl_MParray);
                }
                return $menuItems;
        }
@@ -1037,7 +1007,7 @@ abstract class AbstractMenuContentObject {
                $menuItems = array();
                list($specialValue) = GeneralUtility::intExplode(',', $specialValue);
                if (!$specialValue) {
-                       $specialValue = $this->getTypoScriptFrontendController()->page['uid'];
+                       $specialValue = $GLOBALS['TSFE']->page['uid'];
                }
                // Will not work out of rootline
                if ($specialValue != $this->tmpl->rootLine[0]['uid']) {
@@ -1076,9 +1046,10 @@ abstract class AbstractMenuContentObject {
                                }
                                $lastKey = $k_b;
                        }
-
-                       $recArr['first'] = reset($prevnext_menu);
-                       $recArr['last'] = end($prevnext_menu);
+                       reset($prevnext_menu);
+                       $recArr['first'] = pos($prevnext_menu);
+                       end($prevnext_menu);
+                       $recArr['last'] = pos($prevnext_menu);
                        // prevsection / nextsection is found
                        // You can only do this, if there is a valid page two levels up!
                        if (is_array($recArr['index'])) {
@@ -1089,8 +1060,10 @@ abstract class AbstractMenuContentObject {
                                        if ($nextActive) {
                                                $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($v_b['uid'], '*', $sortingField, $additionalWhere));
                                                if (count($sectionRec_temp)) {
-                                                       $recArr['nextsection'] = reset($sectionRec_temp);
-                                                       $recArr['nextsection_last'] = end($sectionRec_temp);
+                                                       reset($sectionRec_temp);
+                                                       $recArr['nextsection'] = pos($sectionRec_temp);
+                                                       end($sectionRec_temp);
+                                                       $recArr['nextsection_last'] = pos($sectionRec_temp);
                                                        $nextActive = 0;
                                                }
                                        }
@@ -1098,8 +1071,10 @@ abstract class AbstractMenuContentObject {
                                                if ($lastKey) {
                                                        $sectionRec_temp = $this->removeInaccessiblePages($this->sys_page->getMenu($prevnextsection_menu[$lastKey]['uid'], '*', $sortingField, $additionalWhere));
                                                        if (count($sectionRec_temp)) {
-                                                               $recArr['prevsection'] = reset($sectionRec_temp);
-                                                               $recArr['prevsection_last'] = end($sectionRec_temp);
+                                                               reset($sectionRec_temp);
+                                                               $recArr['prevsection'] = pos($sectionRec_temp);
+                                                               end($sectionRec_temp);
+                                                               $recArr['prevsection_last'] = pos($sectionRec_temp);
                                                        }
                                                }
                                                $nextActive = 1;
@@ -1149,8 +1124,8 @@ abstract class AbstractMenuContentObject {
        protected function analyzeCacheHashRequirements($queryString) {
                $parameters = GeneralUtility::explodeUrl2Array($queryString);
                if (count($parameters) > 0) {
-                       /** @var CacheHashCalculator $cacheHashCalculator */
-                       $cacheHashCalculator = GeneralUtility::makeInstance(CacheHashCalculator::class);
+                       $cacheHashCalculator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\CacheHashCalculator::class);
+                       /** @var \TYPO3\CMS\Frontend\Page\CacheHashCalculator $cacheHashCalculator */
                        $cHashParameters = $cacheHashCalculator->getRelevantParameters($queryString);
                        if (count($cHashParameters) > 1) {
                                $this->useCacheHash = (
@@ -1163,23 +1138,20 @@ abstract class AbstractMenuContentObject {
        }
 
        /**
-        * Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong,
-        * if they are hidden in navigation, have a uid in the list of banned uids etc.
+        * Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong, if they are hidden in navigation, have a uid in the list of banned uids etc.
         *
         * @param array $data Array of menu items
         * @param array $banUidArray Array of page uids which are to be excluded
         * @param bool $spacer If set, then the page is a spacer.
         * @return bool Returns TRUE if the page can be safely included.
-        *
-        * @throws \UnexpectedValueException
         */
        public function filterMenuPages(&$data, $banUidArray, $spacer) {
                $includePage = TRUE;
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/tslib/class.tslib_menu.php']['filterMenuPages'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/tslib/class.tslib_menu.php']['filterMenuPages'] as $classRef) {
                                $hookObject = GeneralUtility::getUserObj($classRef);
-                               if (!$hookObject instanceof AbstractMenuFilterPagesHookInterface) {
-                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . AbstractMenuFilterPagesHookInterface::class, 1269877402);
+                               if (!$hookObject instanceof \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuFilterPagesHookInterface) {
+                                       throw new \UnexpectedValueException('$hookObject must implement interface ' . \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuFilterPagesHookInterface::class, 1269877402);
                                }
                                $includePage = $includePage && $hookObject->processFilter($data, $banUidArray, $spacer, $this);
                        }
@@ -1190,61 +1162,57 @@ abstract class AbstractMenuContentObject {
                if ($data['_SAFE']) {
                        return TRUE;
                }
-
-               if (
-                       ($this->mconf['SPC'] || !$spacer) // If the spacer-function is not enabled, spacers will not enter the $menuArr
-                       && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) // Not hidden in navigation
-                       && !GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) // Page may not be 'not_in_menu' or 'Backend User Section'
-                       && !GeneralUtility::inArray($banUidArray, $data['uid']) // not in banned uid's
-               ) {
-                       // Checks if the default language version can be shown:
-                       // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
-                       $tsfe = $this->getTypoScriptFrontendController();
-                       $blockPage = $data['l18n_cfg'] & 1 && (!$tsfe->sys_language_uid || $tsfe->sys_language_uid && !$data['_PAGES_OVERLAY']);
-                       if (!$blockPage) {
-                               // Checking if a page should be shown in the menu depending on whether a translation exists:
-                               $tok = TRUE;
-                               // There is an alternative language active AND the current page requires a translation:
-                               if ($tsfe->sys_language_uid && GeneralUtility::hideIfNotTranslated($data['l18n_cfg'])) {
-                                       if (!$data['_PAGES_OVERLAY']) {
-                                               $tok = FALSE;
-                                       }
-                               }
-                               // Continue if token is TRUE:
-                               if ($tok) {
-                                       // Checking if "&L" should be modified so links to non-accessible pages will not happen.
-                                       if ($this->conf['protectLvar']) {
-                                               $languageUid = (int)$tsfe->config['config']['sys_language_uid'];
-                                               if ($languageUid && ($this->conf['protectLvar'] == 'all' || GeneralUtility::hideIfNotTranslated($data['l18n_cfg']))) {
-                                                       $olRec = $tsfe->sys_page->getPageOverlay($data['uid'], $languageUid);
-                                                       if (!count($olRec)) {
-                                                               // If no pages_language_overlay record then page can NOT be accessed in
-                                                               // the language pointed to by "&L" and therefore we protect the link by setting "&L=0"
-                                                               $data['_ADD_GETVARS'] .= '&L=0';
+               $uid = $data['uid'];
+               // If the spacer-function is not enabled, spacers will not enter the $menuArr
+               if ($this->mconf['SPC'] || !$spacer) {
+                       // Page may not be 'not_in_menu' or 'Backend User Section'
+                       if (!GeneralUtility::inList($this->doktypeExcludeList, $data['doktype'])) {
+                               // Not hidden in navigation
+                               if (!$data['nav_hide'] || $this->conf['includeNotInMenu']) {
+                                       // not in banned uid's
+                                       if (!ArrayUtility::inArray($banUidArray, $uid)) {
+                                               // Checks if the default language version can be shown:
+                                               // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
+                                               $blockPage = $data['l18n_cfg'] & 1 && (!$GLOBALS['TSFE']->sys_language_uid || $GLOBALS['TSFE']->sys_language_uid && !$data['_PAGES_OVERLAY']);
+                                               if (!$blockPage) {
+                                                       // Checking if a page should be shown in the menu depending on whether a translation exists:
+                                                       $tok = TRUE;
+                                                       // There is an alternative language active AND the current page requires a translation:
+                                                       if ($GLOBALS['TSFE']->sys_language_uid && GeneralUtility::hideIfNotTranslated($data['l18n_cfg'])) {
+                                                               if (!$data['_PAGES_OVERLAY']) {
+                                                                       $tok = FALSE;
+                                                               }
+                                                       }
+                                                       // Continue if token is TRUE:
+                                                       if ($tok) {
+                                                               // Checking if "&L" should be modified so links to non-accessible pages will not happen.
+                                                               if ($this->conf['protectLvar']) {
+                                                                       $languageUid = (int)$GLOBALS['TSFE']->config['config']['sys_language_uid'];
+                                                                       if ($languageUid && ($this->conf['protectLvar'] == 'all' || GeneralUtility::hideIfNotTranslated($data['l18n_cfg']))) {
+                                                                               $olRec = $GLOBALS['TSFE']->sys_page->getPageOverlay($data['uid'], $languageUid);
+                                                                               if (!count($olRec)) {
+                                                                                       // If no pages_language_overlay record then page can NOT be accessed in the language pointed to by "&L" and therefore we protect the link by setting "&L=0"
+                                                                                       $data['_ADD_GETVARS'] .= '&L=0';
+                                                                               }
+                                                                       }
+                                                               }
+                                                               return TRUE;
                                                        }
                                                }
                                        }
-                                       return TRUE;
                                }
                        }
                }
-               return FALSE;
        }
 
        /**
-        * Generating the per-menu-item configuration arrays based on the settings for item states (NO, RO, ACT, CUR etc)
-        * set in ->mconf (config for the current menu object)
-        * Basically it will produce an individual array for each menu item based on the item states.
-        * BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values
-        * are "option-splitted" and the output will thus be resolved.
-        * Is called from the "generate" functions in the extension classes. The function is processor intensive due to
-        * the option split feature in particular. But since the generate function is not always called
-        * (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.
+        * Generating the per-menu-item configuration arrays based on the settings for item states (NO, RO, ACT, CUR etc) set in ->mconf (config for the current menu object)
+        * Basically it will produce an individual array for each menu item based on the item states. BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values are "option-splitted" and the output will thus be resolved.
+        * Is called from the "generate" functions in the extension classes. The function is processor intensive due to the option split feature in particular. But since the generate function is not always called (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.
         *
         * @param int $splitCount Number of menu items in the menu
         * @return array An array with two keys: array($NOconf,$ROconf) - where $NOconf contains the resolved configuration for each item when NOT rolled-over and $ROconf contains the ditto for the mouseover state (if any)
-        *
-        * @internal
+        * @access private
         */
        public function procesItemStates($splitCount) {
                // Prepare normal settings
@@ -1260,234 +1228,226 @@ abstract class AbstractMenuContentObject {
                }
                // Prepare IFSUB settings, overriding normal settings
                // IFSUB is TRUE if there exist submenu items to the current item
-               if (!empty($this->mconf['IFSUB'])) {
-                       $IFSUBconf = NULL;
-                       $IFSUBROconf = NULL;
+               if ($this->mconf['IFSUB']) {
+                       // Flag: If $IFSUB is generated
+                       $IFSUBinit = 0;
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('IFSUB', $key)) {
                                        // if this is the first IFSUB element, we must generate IFSUB.
-                                       if ($IFSUBconf === NULL) {
+                                       if (!$IFSUBinit) {
                                                $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'], $splitCount);
-                                               if (!empty($this->mconf['IFSUBRO'])) {
+                                               if ($this->mconf['IFSUBRO']) {
                                                        $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'], $splitCount);
                                                }
+                                               $IFSUBinit = 1;
                                        }
                                        // Substitute normal with ifsub
-                                       if (isset($IFSUBconf[$key])) {
-                                               $NOconf[$key] = $IFSUBconf[$key];
-                                       }
+                                       $NOconf[$key] = $IFSUBconf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($IFSUBROconf[$key]) ? $IFSUBROconf[$key] : $IFSUBconf[$key];
+                                               $ROconf[$key] = $IFSUBROconf[$key] ?: $IFSUBconf[$key];
                                        }
                                }
                        }
                }
                // Prepare active settings, overriding normal settings
-               if (!empty($this->mconf['ACT'])) {
-                       $ACTconf = NULL;
-                       $ACTROconf = NULL;
+               if ($this->mconf['ACT']) {
+                       // Flag: If $ACT is generated
+                       $ACTinit = 0;
                        // Find active
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('ACT', $key)) {
                                        // If this is the first 'active', we must generate ACT.
-                                       if ($ACTconf === NULL) {
+                                       if (!$ACTinit) {
                                                $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'], $splitCount);
                                                // Prepare active rollOver settings, overriding normal active settings
-                                               if (!empty($this->mconf['ACTRO'])) {
+                                               if ($this->mconf['ACTRO']) {
                                                        $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'], $splitCount);
                                                }
+                                               $ACTinit = 1;
                                        }
                                        // Substitute normal with active
-                                       if (isset($ACTconf[$key])) {
-                                               $NOconf[$key] = $ACTconf[$key];
-                                       }
+                                       $NOconf[$key] = $ACTconf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($ACTROconf[$key]) ? $ACTROconf[$key] : $ACTconf[$key];
+                                               $ROconf[$key] = $ACTROconf[$key] ?: $ACTconf[$key];
                                        }
                                }
                        }
                }
                // Prepare ACT (active)/IFSUB settings, overriding normal settings
                // ACTIFSUB is TRUE if there exist submenu items to the current item and the current item is active
-               if (!empty($this->mconf['ACTIFSUB'])) {
-                       $ACTIFSUBconf = NULL;
-                       $ACTIFSUBROconf = NULL;
+               if ($this->mconf['ACTIFSUB']) {
+                       // Flag: If $ACTIFSUB is generated
+                       $ACTIFSUBinit = 0;
                        // Find active
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('ACTIFSUB', $key)) {
                                        // If this is the first 'active', we must generate ACTIFSUB.
-                                       if ($ACTIFSUBconf === NULL) {
+                                       if (!$ACTIFSUBinit) {
                                                $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'], $splitCount);
                                                // Prepare active rollOver settings, overriding normal active settings
-                                               if (!empty($this->mconf['ACTIFSUBRO'])) {
+                                               if ($this->mconf['ACTIFSUBRO']) {
                                                        $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'], $splitCount);
                                                }
+                                               $ACTIFSUBinit = 1;
                                        }
                                        // Substitute normal with active
-                                       if (isset($ACTIFSUBconf[$key])) {
-                                               $NOconf[$key] = $ACTIFSUBconf[$key];
-                                       }
+                                       $NOconf[$key] = $ACTIFSUBconf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($ACTIFSUBROconf[$key]) ? $ACTIFSUBROconf[$key] : $ACTIFSUBconf[$key];
+                                               $ROconf[$key] = $ACTIFSUBROconf[$key] ?: $ACTIFSUBconf[$key];
                                        }
                                }
                        }
                }
                // Prepare CUR (current) settings, overriding normal settings
                // CUR is TRUE if the current page equals the item here!
-               if (!empty($this->mconf['CUR'])) {
-                       $CURconf = NULL;
-                       $CURROconf = NULL;
+               if ($this->mconf['CUR']) {
+                       // Flag: If $CUR is generated
+                       $CURinit = 0;
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('CUR', $key)) {
                                        // if this is the first 'current', we must generate CUR. Basically this control is just inherited
-                                       // from the other implementations as current would only exist one time and that's it
+                                       // from the other implementations as current would only exist one time and thats it
                                        // (unless you use special-features of HMENU)
-                                       if ($CURconf === NULL) {
+                                       if (!$CURinit) {
                                                $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'], $splitCount);
-                                               if (!empty($this->mconf['CURRO'])) {
+                                               if ($this->mconf['CURRO']) {
                                                        $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'], $splitCount);
                                                }
+                                               $CURinit = 1;
                                        }
                                        // Substitute normal with current
-                                       if (isset($CURconf[$key])) {
-                                               $NOconf[$key] = $CURconf[$key];
-                                       }
+                                       $NOconf[$key] = $CURconf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($CURROconf[$key]) ? $CURROconf[$key] : $CURconf[$key];
+                                               $ROconf[$key] = $CURROconf[$key] ?: $CURconf[$key];
                                        }
                                }
                        }
                }
                // Prepare CUR (current)/IFSUB settings, overriding normal settings
                // CURIFSUB is TRUE if there exist submenu items to the current item and the current page equals the item here!
-               if (!empty($this->mconf['CURIFSUB'])) {
-                       $CURIFSUBconf = NULL;
-                       $CURIFSUBROconf = NULL;
+               if ($this->mconf['CURIFSUB']) {
+                       // Flag: If $CURIFSUB is generated
+                       $CURIFSUBinit = 0;
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('CURIFSUB', $key)) {
                                        // If this is the first 'current', we must generate CURIFSUB.
-                                       if ($CURIFSUBconf === NULL) {
+                                       if (!$CURIFSUBinit) {
                                                $CURIFSUBconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUB.'], $splitCount);
                                                // Prepare current rollOver settings, overriding normal current settings
-                                               if (!empty($this->mconf['CURIFSUBRO'])) {
+                                               if ($this->mconf['CURIFSUBRO']) {
                                                        $CURIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUBRO.'], $splitCount);
                                                }
+                                               $CURIFSUBinit = 1;
                                        }
                                        // Substitute normal with active
-                                       if ($CURIFSUBconf[$key]) {
-                                               $NOconf[$key] = $CURIFSUBconf[$key];
-                                       }
+                                       $NOconf[$key] = $CURIFSUBconf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the current
                                        if ($ROconf) {
                                                // If RollOver on current then apply this
-                                               $ROconf[$key] = isset($CURIFSUBROconf[$key]) ? $CURIFSUBROconf[$key] : $CURIFSUBconf[$key];
+                                               $ROconf[$key] = $CURIFSUBROconf[$key] ?: $CURIFSUBconf[$key];
                                        }
                                }
                        }
                }
                // Prepare active settings, overriding normal settings
-               if (!empty($this->mconf['USR'])) {
-                       $USRconf = NULL;
-                       $USRROconf = NULL;
+               if ($this->mconf['USR']) {
+                       // Flag: If $USR is generated
+                       $USRinit = 0;
                        // Find active
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('USR', $key)) {
                                        // if this is the first active, we must generate USR.
-                                       if ($USRconf === NULL) {
+                                       if (!$USRinit) {
                                                $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'], $splitCount);
                                                // Prepare active rollOver settings, overriding normal active settings
-                                               if (!empty($this->mconf['USRRO'])) {
+                                               if ($this->mconf['USRRO']) {
                                                        $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'], $splitCount);
                                                }
+                                               $USRinit = 1;
                                        }
                                        // Substitute normal with active
-                                       if ($USRconf[$key]) {
-                                               $NOconf[$key] = $USRconf[$key];
-                                       }
+                                       $NOconf[$key] = $USRconf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($USRROconf[$key]) ? $USRROconf[$key] : $USRconf[$key];
+                                               $ROconf[$key] = $USRROconf[$key] ?: $USRconf[$key];
                                        }
                                }
                        }
                }
                // Prepare spacer settings, overriding normal settings
-               if (!empty($this->mconf['SPC'])) {
-                       $SPCconf = NULL;
+               if ($this->mconf['SPC']) {
+                       // Flag: If $SPC is generated
+                       $SPCinit = 0;
                        // Find spacers
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('SPC', $key)) {
                                        // If this is the first spacer, we must generate SPC.
-                                       if ($SPCconf === NULL) {
+                                       if (!$SPCinit) {
                                                $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'], $splitCount);
+                                               $SPCinit = 1;
                                        }
                                        // Substitute normal with spacer
-                                       if (isset($SPCconf[$key])) {
-                                               $NOconf[$key] = $SPCconf[$key];
-                                       }
+                                       $NOconf[$key] = $SPCconf[$key];
                                }
                        }
                }
                // Prepare Userdefined settings
-               if (!empty($this->mconf['USERDEF1'])) {
-                       $USERDEF1conf = NULL;
-                       $USERDEF1ROconf = NULL;
+               if ($this->mconf['USERDEF1']) {
+                       // Flag: If $USERDEF1 is generated
+                       $USERDEF1init = 0;
                        // Find active
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('USERDEF1', $key)) {
                                        // If this is the first active, we must generate USERDEF1.
-                                       if ($USERDEF1conf === NULL) {
+                                       if (!$USERDEF1init) {
                                                $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'], $splitCount);
                                                // Prepare active rollOver settings, overriding normal active settings
-                                               if (!empty($this->mconf['USERDEF1RO'])) {
+                                               if ($this->mconf['USERDEF1RO']) {
                                                        $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'], $splitCount);
                                                }
+                                               $USERDEF1init = 1;
                                        }
                                        // Substitute normal with active
-                                       if (isset($USERDEF1conf[$key])) {
-                                               $NOconf[$key] = $USERDEF1conf[$key];
-                                       }
+                                       $NOconf[$key] = $USERDEF1conf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($USERDEF1ROconf[$key]) ? $USERDEF1ROconf[$key] : $USERDEF1conf[$key];
+                                               $ROconf[$key] = $USERDEF1ROconf[$key] ?: $USERDEF1conf[$key];
                                        }
                                }
                        }
                }
                // Prepare Userdefined settings
-               if (!empty($this->mconf['USERDEF2'])) {
-                       $USERDEF2conf = NULL;
-                       $USERDEF2ROconf = NULL;
+               if ($this->mconf['USERDEF2']) {
+                       // Flag: If $USERDEF2 is generated
+                       $USERDEF2init = 0;
                        // Find active
                        foreach ($NOconf as $key => $val) {
                                if ($this->isItemState('USERDEF2', $key)) {
                                        // If this is the first active, we must generate USERDEF2.
-                                       if ($USERDEF2conf) {
+                                       if (!$USERDEF2init) {
                                                $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'], $splitCount);
                                                // Prepare active rollOver settings, overriding normal active settings
-                                               if (!empty($this->mconf['USERDEF2RO'])) {
+                                               if ($this->mconf['USERDEF2RO']) {
                                                        $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'], $splitCount);
                                                }
+                                               $USERDEF2init = 1;
                                        }
                                        // Substitute normal with active
-                                       if (isset($USERDEF2conf[$key])) {
-                                               $NOconf[$key] = $USERDEF2conf[$key];
-                                       }
+                                       $NOconf[$key] = $USERDEF2conf[$key];
                                        // If rollOver on normal, we must apply a state for rollOver on the active
                                        if ($ROconf) {
                                                // If RollOver on active then apply this
-                                               $ROconf[$key] = isset($USERDEF2ROconf[$key]) ? $USERDEF2ROconf[$key] : $USERDEF2conf[$key];
+                                               $ROconf[$key] = $USERDEF2ROconf[$key] ?: $USERDEF2conf[$key];
                                        }
                                }
                        }
@@ -1501,9 +1461,9 @@ abstract class AbstractMenuContentObject {
         *
         * @param int $key Pointer to a key in the $this->menuArr array where the value for that key represents the menu item we are linking to (page record)
         * @param string $altTarget Alternative target
-        * @param string $typeOverride Alternative type
+        * @param int $typeOverride Alternative type
         * @return array Returns an array with A-tag attributes as key/value pairs (HREF, TARGET and onClick)
-        * @internal
+        * @access private
         */
        public function link($key, $altTarget = '', $typeOverride = '') {
                // Mount points:
@@ -1529,14 +1489,11 @@ abstract class AbstractMenuContentObject {
                        $mainTarget = $this->mconf['target'];
                }
                // Creating link:
-               $addParams = $this->mconf['addParams'] . $MP_params;
                if ($this->mconf['collapse'] && $this->isActive($this->menuArr[$key]['uid'], $this->getMPvar($key))) {
                        $thePage = $this->sys_page->getPage($this->menuArr[$key]['pid']);
-                       $addParams .= $this->menuArr[$key]['_ADD_GETVARS'];
-                       $LD = $this->menuTypoLink($thePage, $mainTarget, '', '', $overrideArray, $addParams, $typeOverride);
+                       $LD = $this->menuTypoLink($thePage, $mainTarget, '', '', $overrideArray, $this->mconf['addParams'] . $MP_params . $this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
                } else {
-                       $addParams .= $this->I['val']['additionalParams'] . $this->menuArr[$key]['_ADD_GETVARS'];
-                       $LD = $this->menuTypoLink($this->menuArr[$key], $mainTarget, '', '', $overrideArray, $addParams, $typeOverride);
+                       $LD = $this->menuTypoLink($this->menuArr[$key], $mainTarget, '', '', $overrideArray, $this->mconf['addParams'] . $MP_params . $this->I['val']['additionalParams'] . $this->menuArr[$key]['_ADD_GETVARS'], $typeOverride);
                }
                // Override URL if using "External URL" as doktype with a valid e-mail address:
                if ($this->menuArr[$key]['doktype'] == PageRepository::DOKTYPE_LINK && $this->menuArr[$key]['urltype'] == 3 && GeneralUtility::validEmail($this->menuArr[$key]['url'])) {
@@ -1545,14 +1502,14 @@ abstract class AbstractMenuContentObject {
                        $LD['target'] = '';
                }
 
-               $tsfe = $this->getTypoScriptFrontendController();
-
                // Override url if current page is a shortcut
                $shortcut = NULL;
                if ($this->menuArr[$key]['doktype'] == PageRepository::DOKTYPE_SHORTCUT && $this->menuArr[$key]['shortcut_mode'] != PageRepository::SHORTCUT_MODE_RANDOM_SUBPAGE) {
+
                        $menuItem = $this->determineOriginalShortcutPage($this->menuArr[$key]);
+
                        try {
-                               $shortcut = $tsfe->getPageShortcut(
+                               $shortcut = $GLOBALS['TSFE']->getPageShortcut(
                                        $menuItem['shortcut'],
                                        $menuItem['shortcut_mode'],
                                        $menuItem['uid'],
@@ -1561,6 +1518,7 @@ abstract class AbstractMenuContentObject {
                                        TRUE
                                );
                        } catch (\Exception $ex) {
+
                        }
                        if (!is_array($shortcut)) {
                                return array();
@@ -1568,7 +1526,7 @@ abstract class AbstractMenuContentObject {
                        // Only setting url, not target
                        $LD['totalURL'] = $this->parent_cObj->typoLink_URL(array(
                                'parameter' => $shortcut['uid'],
-                               'additionalParams' => $addParams . $this->I['val']['additionalParams'] . $menuItem['_ADD_GETVARS'],
+                               'additionalParams' => $this->mconf['addParams'] . $MP_params . $this->I['val']['additionalParams'] . $menuItem['_ADD_GETVARS'],
                                'linkAccessRestrictedPages' => $this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE'
                        ));
                }
@@ -1593,8 +1551,8 @@ abstract class AbstractMenuContentObject {
                        $conf = $this->mconf['JSWindow.'];
                        $url = $LD['totalURL'];
                        $LD['totalURL'] = '#';
-                       $onClick = 'openPic(\'' . $tsfe->baseUrlWrap($url) . '\',\'' . ($conf['newWindow'] ? md5($url) : 'theNewPage') . '\',\'' . $conf['params'] . '\'); return false;';
-                       $tsfe->setJS('openPic');
+                       $onClick = 'openPic(\'' . $GLOBALS['TSFE']->baseUrlWrap($url) . '\',\'' . ($conf['newWindow'] ? md5($url) : 'theNewPage') . '\',\'' . $conf['params'] . '\'); return false;';
+                       $GLOBALS['TSFE']->setJS('openPic');
                }
                // look for type and popup
                // following settings are valid in field target:
@@ -1614,7 +1572,7 @@ abstract class AbstractMenuContentObject {
                        if ($matches[3] && $matches[4]) {
                                $JSparamWH = 'width=' . $matches[3] . ',height=' . $matches[4] . ($matches[5] ? ',' . substr($matches[5], 1) : '');
                                $onClick = 'vHWin=window.open('
-                                       . GeneralUtility::quoteJSvalue($tsfe->baseUrlWrap($LD['totalURL']))
+                                       . GeneralUtility::quoteJSvalue($GLOBALS['TSFE']->baseUrlWrap($LD['totalURL']))
                                        . ',\'FEopenLink\',\'' . $JSparamWH . '\');vHWin.focus();return false;';
                                $LD['target'] = '';
                        }
@@ -1624,7 +1582,7 @@ abstract class AbstractMenuContentObject {
                // Added this check: What it does is to enter the baseUrl (if set, which it should for "realurl" based sites)
                // as URL if the calculated value is empty. The problem is that no link is generated with a blank URL
                // and blank URLs might appear when the realurl encoding is used and a link to the frontpage is generated.
-               $list['HREF'] = strlen($LD['totalURL']) ? $LD['totalURL'] : $tsfe->baseUrl;
+               $list['HREF'] = (string)$LD['totalURL'] !== '' ? $LD['totalURL'] : $GLOBALS['TSFE']->baseUrl;
                $list['TARGET'] = $LD['target'];
                $list['onClick'] = $onClick;
                return $list;
@@ -1640,11 +1598,12 @@ abstract class AbstractMenuContentObject {
         *
         * @param array $page
         * @return array
+        * @todo Once the page_language_overlay behaviour was removed, this method can be removed again
         */
        protected function determineOriginalShortcutPage(array $page) {
                // Check if modification is required
                if (
-                       $this->getTypoScriptFrontendController()->sys_language_uid > 0
+                       $GLOBALS['TSFE']->sys_language_uid > 0
                        && empty($page['shortcut'])
                        && !empty($page['uid'])
                        && !empty($page['_PAGES_OVERLAY'])
@@ -1672,7 +1631,7 @@ abstract class AbstractMenuContentObject {
         */
        public function changeLinksForAccessRestrictedPages(&$LD, $page, $mainTarget, $typeOverride) {
                // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
-               if ($this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE' && !$this->getTypoScriptFrontendController()->checkPageGroupAccess($page)) {
+               if ($this->mconf['showAccessRestrictedPages'] && $this->mconf['showAccessRestrictedPages'] !== 'NONE' && !$GLOBALS['TSFE']->checkPageGroupAccess($page)) {
                        $thePage = $this->sys_page->getPage($this->mconf['showAccessRestrictedPages']);
                        $addParams = str_replace(
                                array(
@@ -1695,7 +1654,7 @@ abstract class AbstractMenuContentObject {
         * @param int $uid Page id of the current page for which a submenu MAY be produced (if conditions are met)
         * @param string $objSuffix Object prefix, see ->start()
         * @return string HTML content of the submenu
-        * @internal
+        * @access private
         */
        public function subMenu($uid, $objSuffix = '') {
                // Setting alternative menu item array if _SUB_MENU has been defined in the current ->menuArr
@@ -1711,7 +1670,7 @@ abstract class AbstractMenuContentObject {
                }
                if (($this->mconf['expAll'] || $this->isNext($uid, $this->getMPvar($this->I['key'])) || is_array($altArray)) && !$this->mconf['sectionIndex']) {
                        try {
-                               $menuObjectFactory = GeneralUtility::makeInstance(MenuContentObjectFactory::class);
+                               $menuObjectFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\Menu\MenuContentObjectFactory::class);
                                $submenu = $menuObjectFactory->getMenuObjectByType($menuType);
                                $submenu->entryLevel = $this->entryLevel + 1;
                                $submenu->rL_uidRegister = $this->rL_uidRegister;
@@ -1721,6 +1680,7 @@ abstract class AbstractMenuContentObject {
                                }
                                // Especially scripts that build the submenu needs the parent data
                                $submenu->parent_cObj = $this->parent_cObj;
+                               $submenu->parentMenuArr = $this->menuArr;
                                // Setting alternativeMenuTempArray (will be effective only if an array)
                                if (is_array($altArray)) {
                                        $submenu->alternativeMenuTempArray = $altArray;
@@ -1728,22 +1688,18 @@ abstract class AbstractMenuContentObject {
                                if ($submenu->start($this->tmpl, $this->sys_page, $uid, $this->conf, $this->menuNumber + 1, $objSuffix)) {
                                        $submenu->makeMenu();
                                        // Memorize the current menu item count
-                                       $tsfe = $this->getTypoScriptFrontendController();
-                                       $tempCountMenuObj = $tsfe->register['count_MENUOBJ'];
+                                       $tempCountMenuObj = $GLOBALS['TSFE']->register['count_MENUOBJ'];
                                        // Reset the menu item count for the submenu
-                                       $tsfe->register['count_MENUOBJ'] = 0;
-                                       // Create new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer for our use
-                                       $this->WMcObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+                                       $GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
                                        $content = $submenu->writeMenu();
                                        // Restore the item count now that the submenu has been handled
-                                       $tsfe->register['count_MENUOBJ'] = $tempCountMenuObj;
-                                       $tsfe->register['count_menuItems'] = count($this->menuArr);
+                                       $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempCountMenuObj;
+                                       $GLOBALS['TSFE']->register['count_menuItems'] = count($this->menuArr);
                                        return $content;
                                }
-                       } catch (Exception\NoSuchMenuTypeException $e) {
+                       } catch (\TYPO3\CMS\Frontend\ContentObject\Menu\Exception\NoSuchMenuTypeException $e) {
                        }
                }
-               return '';
        }
 
        /**
@@ -1752,7 +1708,7 @@ abstract class AbstractMenuContentObject {
         * @param int $uid Page uid to evaluate.
         * @param string $MPvar MPvar for the current position of item.
         * @return bool TRUE if page with $uid is active
-        * @internal
+        * @access private
         * @see subMenu()
         */
        public function isNext($uid, $MPvar = '') {
@@ -1764,7 +1720,6 @@ abstract class AbstractMenuContentObject {
                if ($uid && $testUid == $this->nextActive) {
                        return TRUE;
                }
-               return FALSE;
        }
 
        /**
@@ -1773,7 +1728,7 @@ abstract class AbstractMenuContentObject {
         * @param int $uid Page uid to evaluate.
         * @param string $MPvar MPvar for the current position of item.
         * @return bool TRUE if page with $uid is active
-        * @internal
+        * @access private
         */
        public function isActive($uid, $MPvar = '') {
                // Check for always active PIDs:
@@ -1784,20 +1739,21 @@ abstract class AbstractMenuContentObject {
                if ($uid && in_array('ITEM:' . $testUid, $this->rL_uidRegister)) {
                        return TRUE;
                }
-               return FALSE;
        }
 
        /**
-        * Returns TRUE if the page with UID $uid is the CURRENT page (equals $this->getTypoScriptFrontendController()->id)
+        * Returns TRUE if the page with UID $uid is the CURRENT page (equals $GLOBALS['TSFE']->id)
         *
         * @param int $uid Page uid to evaluate.
         * @param string $MPvar MPvar for the current position of item.
-        * @return bool TRUE if page $uid = $this->getTypoScriptFrontendController()->id
-        * @internal
+        * @return bool TRUE if page $uid = $GLOBALS['TSFE']->id
+        * @access private
         */
        public function isCurrent($uid, $MPvar = '') {
                $testUid = $uid . ($MPvar ? ':' . $MPvar : '');
-               return $uid && end($this->rL_uidRegister) === 'ITEM:' . $testUid;
+               if ($uid && end($this->rL_uidRegister) === 'ITEM:' . $testUid) {
+                       return TRUE;
+               }
        }
 
        /**
@@ -1806,7 +1762,7 @@ abstract class AbstractMenuContentObject {
         *
         * @param int $uid Page uid for which to search for a submenu
         * @return bool Returns TRUE if there was a submenu with items found
-        * @internal
+        * @access private
         */
        public function isSubMenu($uid) {
                // Looking for a mount-pid for this UID since if that
@@ -1830,13 +1786,13 @@ abstract class AbstractMenuContentObject {
                        }
                        // No valid subpage if the default language should be shown and the page settings
                        // are excluding the visibility of the default language
-                       if (!$this->getTypoScriptFrontendController()->sys_language_uid && GeneralUtility::hideIfDefaultLanguage($theRec['l18n_cfg'])) {
+                       if (!$GLOBALS['TSFE']->sys_language_uid && GeneralUtility::hideIfDefaultLanguage($theRec['l18n_cfg'])) {
                                continue;
                        }
                        // No valid subpage if the alternative language should be shown and the page settings
                        // are requiring a valid overlay but it doesn't exists
                        $hideIfNotTranslated = GeneralUtility::hideIfNotTranslated($theRec['l18n_cfg']);
-                       if ($this->getTypoScriptFrontendController()->sys_language_uid && $hideIfNotTranslated && !$theRec['_PAGES_OVERLAY']) {
+                       if ($GLOBALS['TSFE']->sys_language_uid && $hideIfNotTranslated && !$theRec['_PAGES_OVERLAY']) {
                                continue;
                        }
                        // No valid subpage if the subpage is banned by excludeUidList
@@ -1854,21 +1810,21 @@ abstract class AbstractMenuContentObject {
         *
         * @param string $kind The item state to evaluate (SPC, IFSUB, ACT etc... but no xxxRO states of course)
         * @param int $key Key pointing to menu item from ->menuArr
-        * @return bool Returns TRUE if state matches
-        * @internal
+        * @return bool True (integer!=0) if match, otherwise FALSE (=0, zero)
+        * @access private
         * @see procesItemStates()
         */
        public function isItemState($kind, $key) {
-               $natVal = FALSE;
+               $natVal = 0;
                // If any value is set for ITEM_STATE the normal evaluation is discarded
                if ($this->menuArr[$key]['ITEM_STATE']) {
                        if ((string)$this->menuArr[$key]['ITEM_STATE'] === (string)$kind) {
-                               $natVal = TRUE;
+                               $natVal = 1;
                        }
                } else {
                        switch ($kind) {
                                case 'SPC':
-                                       $natVal = (bool)$this->menuArr[$key]['isSpacer'];
+                                       $natVal = $this->menuArr[$key]['isSpacer'];
                                        break;
                                case 'IFSUB':
                                        $natVal = $this->isSubMenu($this->menuArr[$key]['uid']);
@@ -1886,7 +1842,7 @@ abstract class AbstractMenuContentObject {
                                        $natVal = $this->isCurrent($this->menuArr[$key]['uid'], $this->getMPvar($key)) && $this->isSubMenu($this->menuArr[$key]['uid']);
                                        break;
                                case 'USR':
-                                       $natVal = (bool)$this->menuArr[$key]['fe_group'];
+                                       $natVal = $this->menuArr[$key]['fe_group'];
                                        break;
                        }
                }
@@ -1898,18 +1854,17 @@ abstract class AbstractMenuContentObject {
         *
         * @param string $title Menu item title.
         * @return array Returns an array with keys "code" ("accesskey" attribute for the img-tag) and "alt" (text-addition to the "alt" attribute) if an access key was defined. Otherwise array was empty
-        * @internal
+        * @access private
         */
        public function accessKey($title) {
-               $tsfe = $this->getTypoScriptFrontendController();
                // The global array ACCESSKEY is used to globally control if letters are already used!!
                $result = array();
                $title = trim(strip_tags($title));
                $titleLen = strlen($title);
                for ($a = 0; $a < $titleLen; $a++) {
                        $key = strtoupper(substr($title, $a, 1));
-                       if (preg_match('/[A-Z]/', $key) && !isset($tsfe->accessKey[$key])) {
-                               $tsfe->accessKey[$key] = 1;
+                       if (preg_match('/[A-Z]/', $key) && !isset($GLOBALS['TSFE']->accessKey[$key])) {
+                               $GLOBALS['TSFE']->accessKey[$key] = 1;
                                $result['code'] = ' accesskey="' . $key . '"';
                                $result['alt'] = ' (ALT+' . $key . ')';
                                $result['key'] = $key;
@@ -1926,7 +1881,7 @@ abstract class AbstractMenuContentObject {
         * @param string $mConfKey Key pointing for the property in the current ->mconf array holding possibly parameters to pass along to the function/method. Currently the keys used are "IProcFunc" and "itemArrayProcFunc".
         * @param mixed $passVar A variable to pass to the user function and which should be returned again from the user function. The idea is that the user function modifies this variable according to what you want to achieve and then returns it. For "itemArrayProcFunc" this variable is $this->menuArr, for "IProcFunc" it is $this->I
         * @return mixed The processed $passVar
-        * @internal
+        * @access private
         */
        public function userProcess($mConfKey, $passVar) {
                if ($this->mconf[$mConfKey]) {
@@ -1941,7 +1896,7 @@ abstract class AbstractMenuContentObject {
         * Creates the <A> tag parts for the current item (in $this->I, [A1] and [A2]) based on other information in this array (like $this->I['linkHREF'])
         *
         * @return void
-        * @internal
+        * @access private
         */
        public function setATagParts() {
                $params = trim($this->I['val']['ATagParams']) . $this->I['accessKey']['code'];
@@ -1956,7 +1911,7 @@ abstract class AbstractMenuContentObject {
         * @param string $title The current page title
         * @param string $nav_title The current value of the navigation title
         * @return string Returns the navigation title if it is NOT blank, otherwise the page title.
-        * @internal
+        * @access private
         */
        public function getPageTitle($title, $nav_title) {
                return trim($nav_title) !== '' ? $nav_title : $title;
@@ -1976,16 +1931,16 @@ abstract class AbstractMenuContentObject {
                        if ($this->menuArr[$key]['_MP_PARAM']) {
                                $localMP_array[] = $this->menuArr[$key]['_MP_PARAM'];
                        }
-                       return !empty($localMP_array) ? implode(',', $localMP_array) : '';
+                       $MP_params = count($localMP_array) ? implode(',', $localMP_array) : '';
+                       return $MP_params;
                }
-               return '';
        }
 
        /**
         * Returns where clause part to exclude 'not in menu' pages
         *
         * @return string where clause part.
-        * @internal
+        * @access private
         */
        public function getDoktypeExcludeWhere() {
                return $this->doktypeExcludeList ? ' AND pages.doktype NOT IN (' . $this->doktypeExcludeList . ')' : '';
@@ -1995,7 +1950,7 @@ abstract class AbstractMenuContentObject {
         * Returns an array of banned UIDs (from excludeUidList)
         *
         * @return array Array of banned UIDs
-        * @internal
+        * @access private
         */
        public function getBannedUids() {
                $excludeUidList = isset($this->conf['excludeUidList.'])
@@ -2006,7 +1961,7 @@ abstract class AbstractMenuContentObject {
                        return array();
                }
 
-               $banUidList = str_replace('current', $this->getTypoScriptFrontendController()->page['uid'], $excludeUidList);
+               $banUidList = str_replace('current', $GLOBALS['TSFE']->page['uid'], $excludeUidList);
                return GeneralUtility::intExplode(',', $banUidList);
        }
 
@@ -2016,10 +1971,10 @@ abstract class AbstractMenuContentObject {
         * @param array $page Page record (uid points where to link to)
         * @param string $oTarget Target frame/window
         * @param bool $no_cache TRUE if caching should be disabled
-        * @param string $script Alternative script name (unused)
-        * @param array|string $overrideArray Array to override values in $page, empty string to skip override
+        * @param string $script Alternative script name
+        * @param array $overrideArray Array to override values in $page
         * @param string $addParams Parameters to add to URL
-        * @param string $typeOverride "type" value
+        * @param array $typeOverride "type" value
         * @return array See linkData
         */
        public function menuTypoLink($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '') {
@@ -2058,7 +2013,7 @@ abstract class AbstractMenuContentObject {
         *
         * @param string $altSortField Alternative sorting field
         * @param int $pid The page id to search for sections
-        * @throws \UnexpectedValueException if the query to fetch the content elements unexpectedly fails
+        * @throws UnexpectedValueException if the query to fetch the content elements unexpectedly fails
         * @return array
         */
        protected function sectionIndex($altSortField, $pid = NULL) {
@@ -2067,11 +2022,10 @@ abstract class AbstractMenuContentObject {
                if (!is_array($basePageRow)) {
                        return array();
                }
-               $tsfe = $this->getTypoScriptFrontendController();
                $configuration = $this->mconf['sectionIndex.'];
                $useColPos = 0;
                if (trim($configuration['useColPos']) !== '' || is_array($configuration['useColPos.'])) {
-                       $useColPos = $tsfe->cObj->stdWrap($configuration['useColPos'], $configuration['useColPos.']);
+                       $useColPos = $GLOBALS['TSFE']->cObj->stdWrap($configuration['useColPos'], $configuration['useColPos.']);
                        $useColPos = (int)$useColPos;
                }
                $selectSetup = array(
@@ -2086,10 +2040,10 @@ abstract class AbstractMenuContentObject {
                        throw new \UnexpectedValueException($message, 1337334849);
                }
                $result = array();
-               while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($resource)) {
+               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resource)) {
                        $this->sys_page->versionOL('tt_content', $row);
-                       if ($tsfe->sys_language_contentOL && $basePageRow['_PAGES_OVERLAY_LANGUAGE']) {
-                               $row = $this->sys_page->getRecordOverlay('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE'], $tsfe->sys_language_contentOL);
+                       if ($GLOBALS['TSFE']->sys_language_contentOL && $basePageRow['_PAGES_OVERLAY_LANGUAGE']) {
+                               $row = $this->sys_page->getRecordOverlay('tt_content', $row, $basePageRow['_PAGES_OVERLAY_LANGUAGE'], $GLOBALS['TSFE']->sys_language_contentOL);
                        }
                        if ($this->mconf['sectionIndex.']['type'] !== 'all') {
                                $doIncludeInSectionIndex = $row['sectionIndex'] >= 1;
@@ -2115,7 +2069,7 @@ abstract class AbstractMenuContentObject {
                                $result[$uid]['sectionIndex_uid'] = $uid;
                        }
                }
-               $this->getDatabaseConnection()->sql_free_result($resource);
+               $GLOBALS['TYPO3_DB']->sql_free_result($resource);
                return $result;
        }
 
@@ -2137,25 +2091,4 @@ abstract class AbstractMenuContentObject {
                return $this->parent_cObj;
        }
 
-       /**
-        * @return DatabaseConnection
-        */
-       protected function getDatabaseConnection() {
-               return $GLOBALS['TYPO3_DB'];
-       }
-
-       /**
-        * @return TypoScriptFrontendController
-        */
-       protected function getTypoScriptFrontendController() {
-               return $GLOBALS['TSFE'];
-       }
-
-       /**
-        * @return TimeTracker
-        */
-       protected function getTimeTracker() {
-               return $GLOBALS['TT'];
-       }
-
 }
index 7ebd244..eb897ce 100644 (file)
@@ -14,9 +14,7 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Collection\AbstractRecordCollection;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\Category\Collection\CategoryCollection;
 
 /**
  * Utility class for menus based on category collections of pages.
@@ -56,16 +54,13 @@ class CategoryMenuUtility {
                // Get the pages for each selected category
                $selectedCategories = GeneralUtility::intExplode(',', $selectedCategories, TRUE);
                foreach ($selectedCategories as $aCategory) {
-                       $collection = CategoryCollection::load(
+                       $collection = \TYPO3\CMS\Frontend\Category\Collection\CategoryCollection::load(
                                $aCategory,
                                TRUE,
                                'pages',
                                $relationField
                        );
-                       $categoryUid = 0;
-                       if ($collection instanceof AbstractRecordCollection) {
-                               $categoryUid = $collection->getUid();
-                       }
+                       $categoryUid = $collection->getUid();
                        // Loop on the results, overlay each page record found
                        foreach ($collection as $pageItem) {
                                $parentObject->getSysPage()->versionOL('pages', $pageItem, TRUE);
@@ -119,7 +114,7 @@ class CategoryMenuUtility {
                                uasort(
                                        $pages,
                                        array(
-                                               CategoryMenuUtility::class,
+                                               \TYPO3\CMS\Frontend\ContentObject\Menu\CategoryMenuUtility::class,
                                                'sortPagesUtility'
                                        )
                                );
index 0590f72..c6f3ac5 100644 (file)
@@ -16,8 +16,6 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
 
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
-use TYPO3\CMS\Frontend\Imaging\GifBuilder;
 
 /**
  * Extension class creating graphic based menus (PNG or GIF files)
@@ -38,14 +36,13 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                if ($splitCount) {
                        list($NOconf, $ROconf) = $this->procesItemStates($splitCount);
                        //store initial count value
-                       $tsfe = $this->getTypoScriptFrontendController();
-                       $temp_HMENU_MENUOBJ = $tsfe->register['count_HMENU_MENUOBJ'];
-                       $temp_MENUOBJ = $tsfe->register['count_MENUOBJ'];
+                       $temp_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
+                       $temp_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
                        // Now we generate the giffiles:
                        $this->makeGifs($NOconf, 'NO');
                        // store count from NO obj
-                       $tempcnt_HMENU_MENUOBJ = $tsfe->register['count_HMENU_MENUOBJ'];
-                       $tempcnt_MENUOBJ = $tsfe->register['count_MENUOBJ'];
+                       $tempcnt_HMENU_MENUOBJ = $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'];
+                       $tempcnt_MENUOBJ = $GLOBALS['TSFE']->register['count_MENUOBJ'];
                        if ($this->mconf['debugItemConf']) {
                                echo '<h3>$NOconf:</h3>';
                                debug($NOconf);
@@ -53,8 +50,8 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                        // RollOver
                        if ($ROconf) {
                                // Start recount for rollover with initial values
-                               $tsfe->register['count_HMENU_MENUOBJ'] = $temp_HMENU_MENUOBJ;
-                               $tsfe->register['count_MENUOBJ'] = $temp_MENUOBJ;
+                               $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $temp_HMENU_MENUOBJ;
+                               $GLOBALS['TSFE']->register['count_MENUOBJ'] = $temp_MENUOBJ;
                                $this->makeGifs($ROconf, 'RO');
                                if ($this->mconf['debugItemConf']) {
                                        echo '<h3>$ROconf:</h3>';
@@ -62,8 +59,8 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                }
                        }
                        // Use count from NO obj
-                       $tsfe->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
-                       $tsfe->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
+                       $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = $tempcnt_HMENU_MENUOBJ;
+                       $GLOBALS['TSFE']->register['count_MENUOBJ'] = $tempcnt_MENUOBJ;
                }
        }
 
@@ -74,7 +71,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
         * @param array $conf Array with configuration for each item.
         * @param string $resKey Type of images: normal ("NO") or rollover ("RO"). Valid values are "NO" and "RO
         * @return void
-        * @internal
+        * @access private
         * @see generate()
         */
        public function makeGifs($conf, $resKey) {
@@ -84,14 +81,10 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                }
                $totalWH = array();
                $items = count($conf);
-               $minDim = 0;
-               $maxDim = 0;
-               $Hcounter = 0;
-               $Wcounter = 0;
-               $Hobjs = array();
-               $Wobjs = array();
                if ($isGD) {
                        // Generate the gif-files. the $menuArr is filled with some values like output_w, output_h, output_file
+                       $Hcounter = 0;
+                       $Wcounter = 0;
                        $Hobjs = $this->mconf['applyTotalH'];
                        if ($Hobjs) {
                                $Hobjs = GeneralUtility::intExplode(',', $Hobjs);
@@ -122,8 +115,8 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                $maxFlag = 0;
                $distributeAccu = array('H' => 0, 'W' => 0);
                foreach ($conf as $key => $val) {
-                       $this->getTypoScriptFrontendController()->register['count_HMENU_MENUOBJ']++;
-                       $this->getTypoScriptFrontendController()->register['count_MENUOBJ']++;
+                       $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']++;
+                       $GLOBALS['TSFE']->register['count_MENUOBJ']++;
                        if ($items == $c + 1 && $minDim) {
                                $Lobjs = $this->mconf['removeObjectsOfDummy'];
                                if ($Lobjs) {
@@ -149,10 +142,9 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                }
                        }
                        $c++;
-                       $gifCreator = NULL;
                        if ($isGD) {
                                // Pre-working the item
-                               $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                               $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                                $gifCreator->init();
                                $gifCreator->start($val, $this->menuArr[$key]);
                                // If useLargestItemH/W is specified
@@ -166,7 +158,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                        }
                                        // Regenerate the new values...
                                        $val['XY'] = implode(',', $tempXY);
-                                       $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                                       $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                                        $gifCreator->init();
                                        $gifCreator->start($val, $this->menuArr[$key]);
                                }
@@ -187,7 +179,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                        }
                                        // Regenerate the new values...
                                        $val['XY'] = implode(',', $tempXY);
-                                       $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                                       $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                                        $gifCreator->init();
                                        $gifCreator->start($val, $this->menuArr[$key]);
                                }
@@ -195,7 +187,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                if ($maxDim) {
                                        $tempXY = explode(',', $val['XY']);
                                        if ($maxDim[0] && $Wcounter + $gifCreator->XY[0] >= $maxDim[0]) {
-                                               $tempXY[0] = $maxDim[0] - $Wcounter;
+                                               $tempXY[0] == $maxDim[0] - $Wcounter;
                                                $maxFlag = 1;
                                        }
                                        if ($maxDim[1] && $Hcounter + $gifCreator->XY[1] >= $maxDim[1]) {
@@ -204,7 +196,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                        }
                                        if ($maxFlag) {
                                                $val['XY'] = implode(',', $tempXY);
-                                               $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                                               $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                                                $gifCreator->init();
                                                $gifCreator->start($val, $this->menuArr[$key]);
                                        }
@@ -230,7 +222,9 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                        // Finding alternative GIF names if any (by altImgResource)
                        $gifFileName = '';
                        if ($conf[$key]['altImgResource'] || is_array($conf[$key]['altImgResource.'])) {
-                               $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+                               if (!is_object($cObj)) {
+                                       $cObj = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
+                               }
                                $cObj->start($this->menuArr[$key], 'pages');
                                $altImgInfo = $cObj->getImgResource($conf[$key]['altImgResource'], $conf[$key]['altImgResource.']);
                                $gifFileName = $altImgInfo[3];
@@ -275,12 +269,12 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
         *
         * @param array $conf Same configuration array as passed to makeGifs()
         * @param int $items The number of menu items
-        * @param array $Hobjs Array with "applyTotalH" numbers (unused)
-        * @param array $Wobjs Array with "applyTotalW" numbers (unused)
+        * @param array $Hobjs Array with "applyTotalH" numbers
+        * @param array $Wobjs Array with "applyTotalW" numbers
         * @param array $minDim Array with "min" x/y
         * @param array $maxDim Array with "max" x/y
         * @return array Array with keys "H" and "W" which are in themselves arrays with the heights and widths of menu items inside. This can be used to find the max/min size of the menu items.
-        * @internal
+        * @access private
         * @see makeGifs()
         */
        public function findLargestDims($conf, $items, $Hobjs, $Wobjs, $minDim, $maxDim) {
@@ -321,13 +315,13 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                }
                        }
                        $c++;
-                       $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                       $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                        $gifCreator->init();
                        $gifCreator->start($val, $this->menuArr[$key]);
                        if ($maxDim) {
                                $tempXY = explode(',', $val['XY']);
                                if ($maxDim[0] && $Wcounter + $gifCreator->XY[0] >= $maxDim[0]) {
-                                       $tempXY[0] = $maxDim[0] - $Wcounter;
+                                       $tempXY[0] == $maxDim[0] - $Wcounter;
                                        $maxFlag = 1;
                                }
                                if ($maxDim[1] && $Hcounter + $gifCreator->XY[1] >= $maxDim[1]) {
@@ -336,7 +330,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                }
                                if ($maxFlag) {
                                        $val['XY'] = implode(',', $tempXY);
-                                       $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                                       $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                                        $gifCreator->init();
                                        $gifCreator->start($val, $this->menuArr[$key]);
                                }
@@ -366,14 +360,15 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
         */
        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::class);
                        $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();
-                       $tsfe = $this->getTypoScriptFrontendController();
-                       if (!isset($tsfe->additionalJavaScript['JSImgCode'])) {
-                               $tsfe->additionalJavaScript['JSImgCode'] = '';
+                       if (!isset($GLOBALS['TSFE']->additionalJavaScript['JSImgCode'])) {
+                               $GLOBALS['TSFE']->additionalJavaScript['JSImgCode'] = '';
                        }
                        for ($key = 0; $key < $this->WMmenuItems; $key++) {
                                if ($this->result['NO'][$key]['output_file']) {
@@ -417,10 +412,10 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                                $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'] . '\');';
-                                               $tsfe->additionalJavaScript['JSImgCode'] .= LF . $this->I['theName'] . '_n=new Image(); ' . $this->I['theName'] . '_n.src = "' . $tsfe->absRefPrefix . $this->I['val']['output_file'] . '"; ';
-                                               $tsfe->additionalJavaScript['JSImgCode'] .= LF . $this->I['theName'] . '_h=new Image(); ' . $this->I['theName'] . '_h.src = "' . $tsfe->absRefPrefix . $this->result['RO'][$key]['output_file'] . '"; ';
-                                               $tsfe->imagesOnPage[] = $this->result['RO'][$key]['output_file'];
-                                               $tsfe->setJS('mouseOver');
+                                               $GLOBALS['TSFE']->additionalJavaScript['JSImgCode'] .= LF . $this->I['theName'] . '_n=new Image(); ' . $this->I['theName'] . '_n.src = "' . $GLOBALS['TSFE']->absRefPrefix . $this->I['val']['output_file'] . '"; ';
+                                               $GLOBALS['TSFE']->additionalJavaScript['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
@@ -434,7 +429,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                                $this->I['A1'] = '';
                                                $this->I['A2'] = '';
                                        }
-                                       $this->I['IMG'] = '<img src="' . $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'] : '') . ' />';
+                                       $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'];
@@ -460,13 +455,12 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
                                        if (is_array($this->I['val']['allStdWrap.'])) {
                                                $this->I['theItem'] = $this->WMcObj->stdWrap($this->I['theItem'], $this->I['val']['allStdWrap.']);
                                        }
-                                       $tsfe->imagesOnPage[] = $this->I['val']['output_file'];
+                                       $GLOBALS['TSFE']->imagesOnPage[] = $this->I['val']['output_file'];
                                        $this->extProc_afterLinking($key);
                                }
                        }
                        return $this->extProc_finish();
                }
-               return '';
        }
 
        /**
@@ -474,7 +468,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
         * Can be used for various initialization
         *
         * @return void
-        * @internal
+        * @access private
         * @see writeMenu()
         */
        public function extProc_init() {
@@ -484,9 +478,9 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
        /**
         * Called after all processing for RollOver of an element has been done.
         *
-        * @param int $key Pointer to $this->menuArr[$key] where the current menu element record is found OR $this->result['RO'][$key] where the configuration for that elements RO version is found!
+        * @param int Pointer to $this->menuArr[$key] where the current menu element record is found OR $this->result['RO'][$key] where the configuration for that elements RO version is found!
         * @return void
-        * @internal
+        * @access private
         * @see writeMenu()
         */
        public function extProc_RO($key) {
@@ -496,9 +490,9 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
        /**
         * Called right before the creation of the link for the menu item
         *
-        * @param int $key Pointer to $this->menuArr[$key] where the current menu element record is found
+        * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
         * @return void
-        * @internal
+        * @access private
         * @see writeMenu()
         */
        public function extProc_beforeLinking($key) {
@@ -506,14 +500,13 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
        }
 
        /**
-        * Called right after the creation of links for the menu item. This is also the last function call before the
-        * for-loop traversing menu items goes to the next item.
+        * Called right after the creation of links for the menu item. This is also the last function call before the for-loop traversing menu items goes to the next item.
         * This function MUST set $this->WMresult.=[HTML for menu item] to add the generated menu item to the internal accumulation of items.
         * Further this calls the subMenu function in the parent class to create any submenu there might be.
         *
-        * @param int $key Pointer to $this->menuArr[$key] where the current menu element record is found
+        * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
         * @return void
-        * @internal
+        * @access private
         * @see writeMenu(), AbstractMenuContentObject::subMenu()
         */
        public function extProc_afterLinking($key) {
@@ -528,10 +521,10 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
        /**
         * Called before the "wrap" happens on the menu item.
         *
-        * @param string $item The current content of the menu item, $this->I['theItem'], passed along.
-        * @param int $key Pointer to $this->menuArr[$key] where the current menu element record is found (unused)
+        * @param string The current content of the menu item, $this->I['theItem'], passed along.
+        * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
         * @return string The modified version of $item, going back into $this->I['theItem']
-        * @internal
+        * @access private
         * @see writeMenu()
         */
        public function extProc_beforeAllWrap($item, $key) {
@@ -542,7 +535,7 @@ class GraphicalMenuContentObject extends AbstractMenuContentObject {
         * Called before the writeMenu() function returns (only if a menu was generated)
         *
         * @return string The total menu content should be returned by this function
-        * @internal
+        * @access private
         * @see writeMenu()
         */
        public function extProc_finish() {
index 3243ee7..46d69a8 100644 (file)
@@ -13,10 +13,6 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Frontend\Imaging\GifBuilder;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Core\TypoScript\TemplateService;
-use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 
@@ -35,12 +31,11 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
         * @see AbstractMenuContentObject::procesItemStates(), makeImageMap()
         */
        public function generate() {
-               $NOconf = array();
                $splitCount = count($this->menuArr);
                if ($splitCount) {
                        list($NOconf) = $this->procesItemStates($splitCount);
                }
-               if (!empty($this->mconf['debugItemConf'])) {
+               if ($this->mconf['debugItemConf']) {
                        echo '<h3>$NOconf:</h3>';
                        debug($NOconf);
                }
@@ -61,20 +56,22 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                        $conf = array();
                }
                if (is_array($this->mconf['main.'])) {
-                       $gifCreator = GeneralUtility::makeInstance(GifBuilder::class);
+                       $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                        $gifCreator->init();
                        $itemsConf = $conf;
                        $conf = $this->mconf['main.'];
                        if (is_array($conf)) {
-                               $sKeyArray = TemplateService::sortedKeyList($conf);
+                               $gifObjCount = 0;
+                               $sKeyArray = \TYPO3\CMS\Core\TypoScript\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 = TemplateService::sortedKeyList($val);
+                                               $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($val);
                                                foreach ($sKeyArray as $theKey) {
                                                        $theValue = $val[$theKey];
                                                        if ((int)$theKey && ($theValArr = $val[$theKey . '.'])) {
@@ -105,7 +102,7 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                                                $theValArr['imgMap.']['target'] = $LD['target'];
                                                                        }
                                                                        if (is_array($theValArr['imgMap.']['altText.'])) {
-                                                                               $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+                                                                               $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
                                                                                $cObj->start($cObjData, 'pages');
                                                                                if (isset($theValArr['imgMap.']['altText.'])) {
                                                                                        $theValArr['imgMap.']['altText'] = $cObj->stdWrap($theValArr['imgMap.']['altText'], $theValArr['imgMap.']['altText.']);
@@ -113,7 +110,7 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                                                unset($theValArr['imgMap.']['altText.']);
                                                                        }
                                                                        if (is_array($theValArr['imgMap.']['titleText.'])) {
-                                                                               $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+                                                                               $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
                                                                                $cObj->start($cObjData, 'pages');
                                                                                if (isset($theValArr['imgMap.']['titleText.'])) {
                                                                                        $theValArr['imgMap.']['titleText'] = $cObj->stdWrap($theValArr['imgMap.']['titleText'], $theValArr['imgMap.']['titleText.']);
@@ -124,7 +121,7 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                                // 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 = TemplateService::sortedKeyList($theValArr['file.']);
+                                                                               $temp_sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($theValArr['file.']);
                                                                                foreach ($temp_sKeyArray as $temp_theKey) {
                                                                                        if ($theValArr['mask.'][$temp_theKey] == 'TEXT') {
                                                                                                $gifCreator->data = $this->menuArr[$key] ?: array();
@@ -135,7 +132,7 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                                                }
                                                                        }
                                                                        if ($theValArr['mask'] == 'GIFBUILDER') {
-                                                                               $temp_sKeyArray = TemplateService::sortedKeyList($theValArr['mask.']);
+                                                                               $temp_sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($theValArr['mask.']);
                                                                                foreach ($temp_sKeyArray as $temp_theKey) {
                                                                                        if ($theValArr['mask.'][$temp_theKey] == 'TEXT') {
                                                                                                $gifCreator->data = $this->menuArr[$key] ?: array();
@@ -149,8 +146,8 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                                // Checks if disabled is set...
                                                                $setObjFlag = 1;
                                                                if ($theValArr['if.']) {
-                                                                       /** @var ContentObjectRenderer $cObj */
-                                                                       $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);
+                                                                       /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
+                                                                       $cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
                                                                        $cObj->start($cObjData, 'pages');
                                                                        if (!empty($theValArr['if.']) && !$cObj->checkIf($theValArr['if.'])) {
                                                                                $setObjFlag = 0;
@@ -166,9 +163,8 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                }
                                        }
                                }
-                               $gifCreator->start($conf, $this->getTypoScriptFrontendController()->page);
+                               $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']];
@@ -177,10 +173,10 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
                                                        array($textBB[0], $textBB[1]),
                                                        $dConf[$key]
                                                );
-                                               $dConf[$key] = GeneralUtility::intExplode(',', $gifCreator->calcOffset($dConf[$key]));
+                                               $dConf[$key] = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $gifCreator->calcOffset($dConf[$key]));
                                        }
                                }
-                               $workArea = GeneralUtility::intExplode(',', $gifCreator->calcOffset($this->mconf['dWorkArea']));
+                               $workArea = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $gifCreator->calcOffset($this->mconf['dWorkArea']));
                                foreach ($waArr as $key => $val) {
                                        $index = $val['free'];
                                        $gifCreator->setup[$index] = 'WORKAREA';
@@ -229,19 +225,18 @@ class ImageMenuContentObject extends AbstractMenuContentObject {
         */
        public function writeMenu() {
                if ($this->result) {
-                       $res = $this->result;
+                       $res = &$this->result;
                        // shortMD5 260900
-                       $menuName = 'menu_' . GeneralUtility::shortMD5($res['imgMap']);
-                       $result = '<img src="' . $this->getTypoScriptFrontendController()->absRefPrefix . $res['output_file'] . '" width="' . $res['output_w'] . '" height="' . $res['output_h'] . '" usemap="#' . $menuName . '" border="0" ' . $this->mconf['params'];
+                       $menuName = 'menu_' . \TYPO3\CMS\Core\Utility\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="')) {
                                $result .= ' alt="Menu Image Map"';
                        }
                        $result .= ' /><map name="' . $menuName . '" id="' . $menuName . '">' . $res['imgMap'] . '</map>';
-                       $this->getTypoScriptFrontendController()->imagesOnPage[] = $res['output_file'];
+                       $GLOBALS['TSFE']->imagesOnPage[] = $res['output_file'];
                        return $this->WMcObj->wrap($result, $this->mconf['wrap']);
                }
-               return '';
        }
 
-}
\ No newline at end of file
+}
index 7970d3a..75baff1 100644 (file)
@@ -13,9 +13,6 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Core\Utility\MathUtility;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 
@@ -27,19 +24,13 @@ use TYPO3\CMS\Core\Utility\ArrayUtility;
 class JavaScriptMenuContentObject extends AbstractMenuContentObject {
 
        /**
-        * @var int
-        */
-       protected $levels = 0;
-
-       /**
-        * @var string
+        * Dummy. Should do nothing, because we don't use the result-array here!
+        *
+        * @return void
         */
-       protected $JSVarName = '';
+       public function generate() {
 
-       /**
-        * @var string
-        */
-       protected $JSMenuName = '';
+       }
 
        /**
         * Creates the HTML (mixture of a <form> and a JavaScript section) for the JavaScript menu (basically an array of selector boxes with onchange handlers)
@@ -47,50 +38,49 @@ class JavaScriptMenuContentObject extends AbstractMenuContentObject {
         * @return string The HTML code for the menu
         */
        public function writeMenu() {
-               if (!$this->id) {
-                       return '';
-               }
-
-               $levels = MathUtility::forceIntegerInRange($this->mconf['levels'], 1, 5);
-               $this->levels = $levels;
-               $uniqueParam = GeneralUtility::shortMD5(microtime(), 5);
-               $this->JSVarName = 'eid' . $uniqueParam;
-               $this->JSMenuName = $this->mconf['menuName'] ?: 'JSmenu' . $uniqueParam;
-               $JScode = '
-var ' . $this->JSMenuName . ' = new JSmenu(' . $levels . ', \'' . $this->JSMenuName . 'Form\');';
-               for ($a = 1; $a <= $levels; $a++) {
-                       $JScode .= '
-var ' . $this->JSVarName . $a . '=0;';
-               }
-               $JScode .= $this->generate_level($levels, 1, $this->id, $this->menuArr, $this->MP_array) . LF;
-               $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode'] = '<script type="text/javascript" src="' . $GLOBALS['TSFE']->absRefPrefix . 'typo3/sysext/frontend/Resources/Public/JavaScript/jsfunc.menu.js"></script>';
-               $GLOBALS['TSFE']->additionalJavaScript['JSCode'] .= $JScode;
-               // Printing:
-               $allFormCode = '';
-               for ($a = 1; $a <= $this->levels; $a++) {
-                       $formCode = '';
-                       $levelConf = $this->mconf[$a . '.'];
-                       $length = $levelConf['width'] ?: 14;
-                       $lengthStr = '';
-                       for ($b = 0; $b < $length; $b++) {
-                               $lengthStr .= '_';
+               if ($this->id) {
+                       // Making levels:
+                       $levels = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->mconf['levels'], 1, 5);
+                       $this->levels = $levels;
+                       $uniqueParam = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5(microtime(), 5);
+                       $this->JSVarName = 'eid' . $uniqueParam;
+                       $this->JSMenuName = $this->mconf['menuName'] ?: 'JSmenu' . $uniqueParam;
+                       $JScode = '
+ var ' . $this->JSMenuName . ' = new JSmenu(' . $levels . ', \'' . $this->JSMenuName . 'Form\');';
+                       for ($a = 1; $a <= $levels; $a++) {
+                               $JScode .= '
+ var ' . $this->JSVarName . $a . '=0;';
                        }
-                       $height = $levelConf['elements'] ?: 5;
-                       $formCode .= '<select name="selector' . $a . '" onchange="' . $this->JSMenuName . '.act(' . $a . ');"' . ($levelConf['additionalParams'] ? ' ' . $levelConf['additionalParams'] : '') . '>';
-                       for ($b = 0; $b < $height; $b++) {
-                               $formCode .= '<option value="0">';
-                               if ($b == 0) {
-                                       $formCode .= $lengthStr;
+                       $JScode .= $this->generate_level($levels, 1, $this->id, $this->menuArr, $this->MP_array) . LF;
+                       $GLOBALS['TSFE']->additionalHeaderData['JSMenuCode'] = '<script type="text/javascript" src="' . $GLOBALS['TSFE']->absRefPrefix . 'typo3/sysext/frontend/Resources/Public/JavaScript/jsfunc.menu.js"></script>';
+                       $GLOBALS['TSFE']->additionalJavaScript['JSCode'] .= $JScode;
+                       // Printing:
+                       $allFormCode = '';
+                       for ($a = 1; $a <= $this->levels; $a++) {
+                               $formCode = '';
+                               $levelConf = $this->mconf[$a . '.'];
+                               $length = $levelConf['width'] ?: 14;
+                               $lengthStr = '';
+                               for ($b = 0; $b < $length; $b++) {
+                                       $lengthStr .= '_';
+                               }
+                               $height = $levelConf['elements'] ?: 5;
+                               $formCode .= '<select name="selector' . $a . '" onchange="' . $this->JSMenuName . '.act(' . $a . ');"' . ($levelConf['additionalParams'] ? ' ' . $levelConf['additionalParams'] : '') . '>';
+                               for ($b = 0; $b < $height; $b++) {
+                                       $formCode .= '<option value="0">';
+                                       if ($b == 0) {
+                                               $formCode .= $lengthStr;
+                                       }
+                                       $formCode .= '</option>';
                                }
-                               $formCode .= '</option>';
+                               $formCode .= '</select>';
+                               $allFormCode .= $this->WMcObj->wrap($formCode, $levelConf['wrap']);
                        }
-                       $formCode .= '</select>';
-                       $allFormCode .= $this->WMcObj->wrap($formCode, $levelConf['wrap']);
+                       $formCode = $this->WMcObj->wrap($allFormCode, $this->mconf['wrap']);
+                       $formCode = '<form action="" method="post" style="margin: 0 0 0 0;" name="' . $this->JSMenuName . 'Form">' . $formCode . '</form>';
+                       $formCode .= '<script type="text/javascript"> /*<![CDATA[*/ ' . $this->JSMenuName . '.writeOut(1,' . $this->JSMenuName . '.openID,1); /*]]>*/ </script>';
+                       return $this->WMcObj->wrap($formCode, $this->mconf['wrapAfterTags']);
                }
-               $formContent = $this->WMcObj->wrap($allFormCode, $this->mconf['wrap']);
-               $formCode = '<form action="" method="post" style="margin: 0 0 0 0;" name="' . $this->JSMenuName . 'Form">' . $formContent . '</form>';
-               $formCode .= '<script type="text/javascript"> /*<![CDATA[*/ ' . $this->JSMenuName . '.writeOut(1,' . $this->JSMenuName . '.openID,1); /*]]>*/ </script>';
-               return $this->WMcObj->wrap($formCode, $this->mconf['wrapAfterTags']);
        }
 
        /**
@@ -100,7 +90,7 @@ var ' . $this->JSVarName . $a . '=0;';
         * @param int $levels Number of levels to generate
         * @param int $count Current level being generated - and if this number is less than $levels it will call itself recursively with $count incremented
         * @param int $pid Page id of the starting point.
-        * @param array|string $menuItemArray $this->menuArr passed along
+        * @param array $menuItemArray $this->menuArr passed along
         * @param array $MP_array Previous MP vars
         * @return string JavaScript code lines.
         * @access private
@@ -134,11 +124,11 @@ var ' . $this->JSVarName . $a . '=0;';
                        $MP_var = implode(',', $MP_array_sub);
                        $MP_params = $MP_var ? '&MP=' . rawurlencode($MP_var) : '';
                        // If item is a spacer, $spacer is set
-                       $spacer = GeneralUtility::inList($this->spacerIDList, $data['doktype']) ? 1 : 0;
+                       $spacer = \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->spacerIDList, $data['doktype']) ? 1 : 0;
                        // If the spacer-function is not enabled, spacers will not enter the $menuArr
                        if ($this->mconf['SPC'] || !$spacer) {
                                // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
-                               if (!GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !ArrayUtility::inArray($banUidArray, $uid)) {
+                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !ArrayUtility::inArray($banUidArray, $uid)) {
                                        if ($count < $levels) {
                                                $addLines = $this->generate_level($levels, $count + 1, $data['uid'], '', $MP_array_sub);
                                        } else {
@@ -151,10 +141,10 @@ var ' . $this->JSVarName . $a . '=0;';
                                                $LD = $this->menuTypoLink($data, $this->mconf['target'], '', '', array(), $MP_params, $this->mconf['forceTypeValue']);
                                                // If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
                                                $this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']);
-                                               $url = $this->getTypoScriptFrontendController()->baseUrlWrap($LD['totalURL']);
+                                               $url = $GLOBALS['TSFE']->baseUrlWrap($LD['totalURL']);
                                                $target = $LD['target'];
                                        }
-                                       $codeLines .= LF . $var . $count . '=' . $menuName . '.add(' . $parent . ',' . $prev . ',0,' . GeneralUtility::quoteJSvalue($title, TRUE) . ',' . GeneralUtility::quoteJSvalue($url, TRUE) . ',' . GeneralUtility::quoteJSvalue($target, TRUE) . ');';
+                                       $codeLines .= LF . $var . $count . '=' . $menuName . '.add(' . $parent . ',' . $prev . ',0,' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($title, TRUE) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($url, TRUE) . ',' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($target, TRUE) . ');';
                                        // If the active one should be chosen...
                                        $active = $levelConf['showActive'] && $this->isActive($data['uid'], $MP_var);
                                        // If the first item should be shown
@@ -178,9 +168,9 @@ var ' . $this->JSVarName . $a . '=0;';
                        $levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
                }
                if ($levelConf['firstLabel'] && $codeLines) {
-                       $codeLines .= LF . $menuName . '.defTopTitle[' . $count . '] = ' . GeneralUtility::quoteJSvalue($levelConf['firstLabel'], TRUE) . ';';
+                       $codeLines .= LF . $menuName . '.defTopTitle[' . $count . '] = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($levelConf['firstLabel'], TRUE) . ';';
                }
                return $codeLines;
        }
 
-}
\ No newline at end of file
+}
index 77cd9a7..8f6bb40 100644 (file)
@@ -14,8 +14,6 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
 /**
  * Factory for menu content objects. Allows overriding the default
  * types like 'GMENU' with an own implementation (only one possible)
@@ -31,10 +29,10 @@ class MenuContentObjectFactory implements \TYPO3\CMS\Core\SingletonInterface {
         * @var array
         */
        protected $menuTypeToClassMapping = array(
-               'GMENU' => GraphicalMenuContentObject::class,
-               'TMENU' => TextMenuContentObject::class,
-               'IMGMENU' => ImageMenuContentObject::class,
-               'JSMENU' => JavaScriptMenuContentObject::class,
+               'GMENU' => \TYPO3\CMS\Frontend\ContentObject\Menu\GraphicalMenuContentObject::class,
+               'TMENU' => \TYPO3\CMS\Frontend\ContentObject\Menu\TextMenuContentObject::class,
+               'IMGMENU' => \TYPO3\CMS\Frontend\ContentObject\Menu\ImageMenuContentObject::class,
+               'JSMENU' => \TYPO3\CMS\Frontend\ContentObject\Menu\JavaScriptMenuContentObject::class,
        );
 
        /**
@@ -45,9 +43,9 @@ class MenuContentObjectFactory implements \TYPO3\CMS\Core\SingletonInterface {
         * @throws Exception\NoSuchMenuTypeException
         */
        public function getMenuObjectByType($type = '') {
-               $uppercasedClassName = strtoupper($type);
-               if (array_key_exists($uppercasedClassName, $this->menuTypeToClassMapping)) {
-                       $object = GeneralUtility::makeInstance($this->menuTypeToClassMapping[$uppercasedClassName]);
+               $uppercasedClassname = strtoupper($type);
+               if (array_key_exists($uppercasedClassname, $this->menuTypeToClassMapping)) {
+                       $object = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($this->menuTypeToClassMapping[$uppercasedClassname]);
                } else {
                        throw new Exception\NoSuchMenuTypeException(
                                'Menu type ' . (string)$type . ' has no implementing class.',
index 878e815..5150057 100644 (file)
@@ -13,7 +13,6 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 use TYPO3\CMS\Core\Imaging\GraphicalFunctions;
 
@@ -32,12 +31,11 @@ class TextMenuContentObject extends AbstractMenuContentObject {
         * @see AbstractMenuContentObject::procesItemStates()
         */
        public function generate() {
-               $NOconf = array();
                $splitCount = count($this->menuArr);
                if ($splitCount) {
                        list($NOconf) = $this->procesItemStates($splitCount);
                }
-               if (!empty($this->mconf['debugItemConf'])) {
+               if ($this->mconf['debugItemConf']) {
                        echo '<h3>$NOconf:</h3>';
                        debug($NOconf);
                }
@@ -46,125 +44,123 @@ class TextMenuContentObject extends AbstractMenuContentObject {
 
        /**
         * Traverses the ->result array of menu items configuration (made by ->generate()) and renders each item.
-        * During the execution of this function many internal methods prefixed "extProc_" from this class is called and
-        * many of these are for now dummy functions. But they can be used for processing as they are used by the TMENU_LAYERS
-        * An instance of ContentObjectRenderer is also made and for each menu item rendered it is loaded with
-        * the record for that page so that any stdWrap properties that applies will have the current menu items record available.
+        * During the execution of this function many internal methods prefixed "extProc_" from this class is called and many of these are for now dummy functions. But they can be used for processing as they are used by the TMENU_LAYERS
+        * An instance of ContentObjectRenderer is also made and for each menu item rendered it is loaded with the record for that page so that any stdWrap properties that applies will have the current menu items record available.
         *
         * @return string The HTML for the menu (returns result through $this->extProc_finish(); )
         */
        public function writeMenu() {
-               if (!is_array($this->result) || empty($this->result)) {
-                       return '';
-               }
-
-               $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 ($titleAttrValue !== '') {
-                               $this->I['linkHREF']['title'] = $titleAttrValue;
-                       }
+               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::class);
+                       $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 ($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']);
+                               // 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->WMcObj->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);
                        }
-                       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->WMcObj->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);
+                       return $this->extProc_finish();
                }
-               return $this->extProc_finish();
        }
 
        /**
@@ -213,7 +209,7 @@ class TextMenuContentObject extends AbstractMenuContentObject {
        /**
         * Called right before the creation of the link for the menu item
         *
-        * @param int $key Pointer to $this->menuArr[$key] where the current menu element record is found
+        * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
         * @return void
         * @access private
         * @see writeMenu()
@@ -226,7 +222,7 @@ class TextMenuContentObject extends AbstractMenuContentObject {
         * Called right after the creation of links for the menu item. This is also the last function call before the while-loop traversing menu items goes to the next item.
         * This function MUST set $this->WMresult.=[HTML for menu item] to add the generated menu item to the internal accumulation of items.
         *
-        * @param int $key Pointer to $this->menuArr[$key] where the current menu element record is found
+        * @param int Pointer to $this->menuArr[$key] where the current menu element record is found
         * @return void
         * @access private
         * @see writeMenu()
@@ -268,4 +264,4 @@ class TextMenuContentObject extends AbstractMenuContentObject {
                return $this->WMcObj->wrap($this->WMresult, $this->mconf['wrap']) . $this->WMextraScript;
        }
 
-}
\ No newline at end of file
+}
index ba96799..fe5aea8 100644 (file)
@@ -818,15 +818,6 @@ class TypoScriptFrontendController {
        protected $contentType = 'text/html';
 
        /**
-        * Doctype to use
-        *
-        * Currently set via PageGenerator
-        *
-        * @var string
-        */
-       public $xhtmlDoctype = '';
-
-       /**
         * Class constructor
         * Takes a number of GET/POST input variable as arguments and stores them internally.
         * The processing of these variables goes on later in this class.
index 4689d1e..d243a5c 100644 (file)
@@ -119,11 +119,6 @@ class GifBuilder extends \TYPO3\CMS\Core\Imaging\GraphicalFunctions {
        public $charRangeMap = array();
 
        /**
-        * @var int[]
-        */
-       public $XY = array();
-
-       /**
         * Initialization of the GIFBUILDER objects, in particular TEXT and IMAGE. This includes finding the bounding box, setting dimensions and offset values before the actual rendering is started.
         * Modifies the ->setup, ->objBB internal arrays
         * Should be called after the ->init() function which initializes the parent class functions/variables in general.
index cbbc680..d47367b 100644 (file)
@@ -29,8 +29,8 @@ class AbstractMenuContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * Set up this testcase
         */
        protected function setUp() {
-               $proxyClassName = $this->buildAccessibleProxy(\TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::class);
-               $this->fixture = $this->getMockForAbstractClass($proxyClassName);
+               $proxy = $this->buildAccessibleProxy(\TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::class);
+               $this->fixture = new $proxy();
                $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
                $GLOBALS['TSFE'] = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array($GLOBALS['TYPO3_CONF_VARS'], 1, 1));
                $GLOBALS['TSFE']->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();