[FEATURE] Add a "virtual root" to pagetree (for mountpoints)
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 11 Feb 2012 00:17:32 +0000 (01:17 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Sun, 26 Feb 2012 19:54:28 +0000 (20:54 +0100)
If there is no "root" of pages (page 0) shown, add a
"virtual root" that functions as a root for all mountpoints
below it.

Change-Id: Iab25790db1ac5de4ab333d605163355eb1c62b91
Resolves: #33852
Releases: 4.7
Reviewed-on: http://review.typo3.org/8977
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
t3lib/config_default.php
t3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php
typo3/sysext/impexp/ext_tables.php

index f415650..7445253 100644 (file)
@@ -242,6 +242,21 @@ $TYPO3_CONF_VARS = array(
                        options.contextMenu.options.leftIcons = 1
                        options.contextMenu {
                                table {
+                                       virtual_root {
+                                               disableItems =
+
+                                               items {
+                                                       100 = ITEM
+                                                       100 {
+                                                               name = history
+                                                               label = LLL:EXT:lang/locallang_misc.xml:CM_history
+                                                               spriteIcon = actions-document-history-open
+                                                               displayCondition = canShowHistory != 0
+                                                               callbackAction = openHistoryPopUp
+                                                       }
+                                               }
+                                       }
+
                                        pages_root {
                                                disableItems =
 
index b0077f2..9ff4617 100644 (file)
@@ -120,6 +120,26 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                }
 
                $subpages = $this->getSubpages($node->getId());
+
+                       // check if fetching subpages the "root"-page
+                       // and in case of a virtual root return the mountpoints as virtual "subpages"
+               if (intval($node->getId()) === 0) {
+                       $mountPoints = intval($GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint']);
+                               // check no temporary mountpoint is used
+                       if (!$mountPoints) {
+                               $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
+                               $mountPoints = array_unique($mountPoints);
+                               if (!in_array(0, $mountPoints)) {
+                                               // using a virtual root node
+                                               // so then return the mount points here as "subpages" of the first node
+                                       $subpages = array();
+                                       foreach ($mountPoints as $mountPoint) {
+                                               $subpages[] = array('uid' => $mountPoint);
+                                       }
+                               }
+                       }
+               }
+
                if (is_array($subpages) && count($subpages) > 0) {
 
                        foreach ($subpages as $subpage) {
@@ -273,10 +293,18 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                $nodeCollection = t3lib_div::makeInstance('t3lib_tree_pagetree_NodeCollection');
 
                $isTemporaryMountPoint = FALSE;
+               $rootNodeIsVirtual = FALSE;
                $mountPoints = intval($GLOBALS['BE_USER']->uc['pageTree_temporaryMountPoint']);
                if (!$mountPoints) {
                        $mountPoints = array_map('intval', $GLOBALS['BE_USER']->returnWebmounts());
                        $mountPoints = array_unique($mountPoints);
+                       if (!in_array(0, $mountPoints)) {
+                               $rootNodeIsVirtual = TRUE;
+                                       // use a virtual root
+                                       // the real mountpoints will be fetched in getNodes() then
+                                       // since those will be the "subpages" of the virtual root
+                               $mountPoints = array(0);
+                       }
                } else {
                        $isTemporaryMountPoint = TRUE;
                        $mountPoints = array($mountPoints);
@@ -300,7 +328,11 @@ class t3lib_tree_pagetree_DataProvider extends t3lib_tree_AbstractDataProvider {
                                );
                                $subNode = t3lib_tree_pagetree_Commands::getNewNode($record);
                                $subNode->setLabelIsEditable(FALSE);
-                               $subNode->setType('pages_root');
+                               if ($rootNodeIsVirtual) {
+                                       $subNode->setType('virtual_root');
+                               } else {
+                                       $subNode->setType('pages_root');
+                               }
                        } else {
                                if (in_array($mountPoint, $this->hiddenRecords)) {
                                        continue;
index a30d89a..dcca160 100755 (executable)
@@ -45,6 +45,10 @@ if (TYPO3_MODE == 'BE')      {
                // context menu user default configuration
        $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] .= '
                options.contextMenu.table {
+                       virtual_root.items {
+                               ' . $importExportActions . '
+                       }
+
                        pages_root.items {
                                ' . $importExportActions . '
                        }