[BUGFIX] Creating new pages via drag'n'drop respects page TS
authorPhilipp Kitzberger <philipp@cron-it.de>
Mon, 19 Mar 2012 15:25:25 +0000 (16:25 +0100)
committerSteffen Ritter <info@rs-websystems.de>
Mon, 26 Mar 2012 14:39:23 +0000 (16:39 +0200)
When creating a new page node via drag'n'drop shortcuts in pagetree,
the TCAdefaults.pages array from page TsConfig is now being respected.
This allows to preset certain field values for new pages.

Change-Id: I21c2f84951699469b00a745b62d2a95fb114809e
Fixes: #25021
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/9747
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Stefan Neufeind
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
t3lib/tree/pagetree/class.t3lib_tree_pagetree_commands.php

index 532761e..69c3923 100644 (file)
@@ -134,11 +134,20 @@ final class t3lib_tree_pagetree_Commands {
         */
        public static function createNode(t3lib_tree_pagetree_Node $parentNode, $targetId, $pageType) {
                $placeholder = 'NEW12345';
-               $data['pages'][$placeholder] = array(
-                       'pid' => $parentNode->getWorkspaceId(),
-                       'doktype' => $pageType,
-                       'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tree.defaultPageTitle', TRUE),
-               );
+               $pid = $parentNode->getWorkspaceId();
+
+                       // Use page TsConfig as default page initialization
+               $pageTs = t3lib_BEfunc::getPagesTSconfig($pid);
+               if (array_key_exists('TCAdefaults.', $pageTs) && array_key_exists('pages.', $pageTs['TCAdefaults.'])) {
+                       $data['pages'][$placeholder] = $pageTs['TCAdefaults.']['pages.'];
+               } else {
+                       $data['pages'][$placeholder] = array();
+               }
+
+               $data['pages'][$placeholder]['pid'] = $pid;
+               $data['pages'][$placeholder]['doktype'] = $pageType;
+               $data['pages'][$placeholder]['title'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tree.defaultPageTitle', TRUE);
+
                $newPageId = self::processTceCmdAndDataMap(array(), $data);
                $node = self::getNode($newPageId[$placeholder]);