[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)
committerGeorg Ringer <mail@ringerge.org>
Wed, 28 Mar 2012 12:30:55 +0000 (14:30 +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/9889
Reviewed-by: Stefan Neufeind
Reviewed-by: Philipp Gampe
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
t3lib/tree/pagetree/class.t3lib_tree_pagetree_commands.php

index 5adff9c..38cc37d 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]);
 
@@ -369,4 +378,4 @@ final class t3lib_tree_pagetree_Commands {
        }
 }
 
-?>
\ No newline at end of file
+?>