Fixed bug #17091: Pagetree: undelete recursive deleted pages only undeletes the top...
authorSusanne Moog <typo3@susannemoog.de>
Sat, 22 Jan 2011 12:08:27 +0000 (12:08 +0000)
committerSusanne Moog <typo3@susannemoog.de>
Sat, 22 Jan 2011 12:08:27 +0000 (12:08 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10244 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/js/extjs/components/pagetree/javascript/actions.js
t3lib/js/extjs/components/pagetree/javascript/deletiondropzone.js
t3lib/js/extjs/components/pagetree/javascript/tree.js
t3lib/tree/pagetree/extdirect/class.t3lib_tree_pagetree_extdirect_commands.php
t3lib/tree/pagetree/extdirect/class.t3lib_tree_pagetree_extdirect_tree.php
typo3/sysext/cms/layout/locallang.xml

index 23f09f8..196eb67 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-22  Susann Moog  <typo3@susanne-moog.de>
+
+       * Fixed bug #17091: Pagetree: undelete recursive deleted pages only undeletes the top node, not the other child nodes of the deleted page (Thanks to Stefan Galinski)
+
 2011-01-22  Steffen Gebert  <steffen@steffen-gebert.de>
 
        * Fixed bug #17107: page/branch action submenus close whole menu on click (Thanks to Stefan Galinski)
index e88aa31..885ada3 100644 (file)
@@ -102,24 +102,32 @@ TYPO3.Components.PageTree.Actions = {
         *
         * @param {Ext.tree.TreeNode} node
         * @param {TYPO3.Components.PageTree.Tree} tree
+        * @param {Function} callback
+        * @param {Boolean} recursiveDelete
         * @return {void}
         */
-       confirmDelete: function(node, tree) {
-               TYPO3.Components.PageTree.Commands.getConfirmContentDeletionMessage(node.attributes.nodeData.id, function(message, options) {
-                       Ext.Msg.show({
-                               title: message.title,
-                               msg: message.message,
-                               buttons: Ext.Msg.YESNO,
-                               fn: function (answer, text, button) {
-                                       if (answer === 'yes') {
-                                               TYPO3.Components.PageTree.Actions.deleteNode(node, tree);
-                                               return true;
-                                       }
-                                       return false;
-                               },
-                               animEl: 'elId'
-                       });
-               }, this);
+       confirmDelete: function(node, tree, callback, recursiveDelete) {
+               callback = callback || null;
+
+               var title = TYPO3.Components.PageTree.LLL.deleteDialogTitle,
+                       message = TYPO3.Components.PageTree.LLL.deleteDialogMessage;
+               if (recursiveDelete) {
+                       message = TYPO3.Components.PageTree.LLL.recursiveDeleteDialogMessage;
+               }
+
+               Ext.Msg.show({
+                       title: title,
+                       msg: message,
+                       buttons: Ext.Msg.YESNO,
+                       fn: function (answer) {
+                               if (answer === 'yes') {
+                                       TYPO3.Components.PageTree.Actions.deleteNode(node, tree, callback);
+                                       return true;
+                               }
+                               return false;
+                       },
+                       animEl: 'elId'
+               });
        },
 
        /**
@@ -127,13 +135,19 @@ TYPO3.Components.PageTree.Actions = {
         *
         * @param {Ext.tree.TreeNode} node
         * @param {TYPO3.Components.PageTree.Tree} tree
+        * @param {Function} callback
         * @return {void}
         */
-       deleteNode: function(node, tree) {
+       deleteNode: function(node, tree, callback) {
                TYPO3.Components.PageTree.Commands.deleteNode(
                        node.attributes.nodeData,
                        function(response) {
-                               if (this.evaluateResponse(response)) {
+                               var succeeded = this.evaluateResponse(response);
+                               if (callback !== null) {
+                                       callback(node, tree, succeeded);
+                               }
+
+                               if (succeeded) {
                                                // the node may not be removed in workspace mode
                                        if (top.TYPO3.configuration.inWorkspace && response.id) {
                                                this.updateNode(node, node.isExpanded(), response);
@@ -161,8 +175,6 @@ TYPO3.Components.PageTree.Actions = {
                }
        },
 
-
-
        /**
         * Restores a given node and moves it to the given destination inside the tree. Use this
         * method if you want to add it as the first child of the destination.
@@ -708,4 +720,4 @@ TYPO3.Components.PageTree.Actions = {
                        this
                );
        }
-};
+};
\ No newline at end of file
index 1c00424..a5a2ea7 100644 (file)
@@ -173,42 +173,67 @@ TYPO3.Components.PageTree.DeletionDropZone = Ext.extend(Ext.Panel, {
                                }
 
                                var tree = node.ownerTree;
-                               if (!top.TYPO3.configuration.inWorkspace) {
-                                       this.setHeight(50);
-                                       this.updateIcon(TYPO3.Components.PageTree.Sprites.TrashCanRestore);
-                                       this.updateText(
-                                               node.text + '<br />' +
-                                               '<span class="' + this.id + '-restore">' +
-                                                       '<span class="' + this.id + '-restoreText">' +
-                                                       TYPO3.Components.PageTree.LLL.dropZoneElementRemoved +
-                                                       '</span>' +
-                                               '</span>',
-                                               false
-                                       );
-
-                                       ++this.amountOfDrops;
-                                       (function() {
-                                               if (!--this.amountOfDrops) {
-                                                       this.toOriginState();
-                                               }
-                                       }).defer(10000, this);
-
-                                       this.textClickHandler = this.restoreNode.createDelegate(this, [node, tree]);
-                                       Ext.get(this.id + '-text').on('click', this.textClickHandler);
+                               var nodeHasChildNodes = (node.hasChildNodes() || node.isExpandable());
 
-                                       this.isPreviousSibling = false;
-                                       this.previousNode = node.parentNode;
-                                       if (node.previousSibling) {
-                                               this.previousNode = node.previousSibling;
-                                               this.isPreviousSibling = true;
-                                       }
+                               var callback = null;
+                               if (!top.TYPO3.configuration.inWorkspace && !nodeHasChildNodes) {
+                                       callback = this.setRecoverState.createDelegate(this);
                                }
 
-                               node.ownerTree.commandProvider.deleteNode(node, tree);
+                               if (nodeHasChildNodes) {
+                                       node.ownerTree.commandProvider.confirmDelete(node, tree, callback, true);
+                               } else {
+                                       node.ownerTree.commandProvider.deleteNode(node, tree, callback);
+                               }
                        }.createDelegate(this)
                }));
        },
 
+       /**
+        * Sets the drop zone into the recovery state
+        *
+        * @param {Ext.tree.TreeNode} node
+        * @param {TYPO3.Components.PageTree.Tree} tree
+        * @param {Boolean} succeeded
+        * @return {void}
+        */
+       setRecoverState: function(node, tree, succeeded) {
+               if (!succeeded) {
+                       this.toOriginState();
+                       return;
+               }
+
+               this.show();
+               this.setHeight(50);
+               this.updateIcon(TYPO3.Components.PageTree.Sprites.TrashCanRestore);
+               this.updateText(
+                       node.text + '<br />' +
+                       '<span class="' + this.id + '-restore">' +
+                               '<span class="' + this.id + '-restoreText">' +
+                               TYPO3.Components.PageTree.LLL.dropZoneElementRemoved +
+                               '</span>' +
+                       '</span>',
+                       false
+               );
+
+               ++this.amountOfDrops;
+               (function() {
+                       if (!--this.amountOfDrops) {
+                               this.toOriginState();
+                       }
+               }).defer(10000, this);
+
+               this.textClickHandler = this.restoreNode.createDelegate(this, [node, tree]);
+               Ext.get(this.id + '-text').on('click', this.textClickHandler);
+
+               this.isPreviousSibling = false;
+               this.previousNode = node.parentNode;
+               if (node.previousSibling) {
+                       this.previousNode = node.previousSibling;
+                       this.isPreviousSibling = true;
+               }
+       },
+
        /**
         * Updates the drop zone text label
         *
@@ -291,4 +316,4 @@ TYPO3.Components.PageTree.DeletionDropZone = Ext.extend(Ext.Panel, {
 });
 
 // XTYPE Registration
-Ext.reg('TYPO3.Components.PageTree.DeletionDropZone', TYPO3.Components.PageTree.DeletionDropZone);
+Ext.reg('TYPO3.Components.PageTree.DeletionDropZone', TYPO3.Components.PageTree.DeletionDropZone);
\ No newline at end of file
index 834f509..33550e3 100644 (file)
@@ -435,10 +435,16 @@ TYPO3.Components.PageTree.Tree = Ext.extend(Ext.tree.TreePanel, {
         * Enables the deletion drop zone if configured. Also it creates the
         * shown dd proxy element.
         *
+        * @param {TYPO3.Components.PageTree.Tree} treePane
+        * @param {Ext.tree.TreeNode} node
         * @return {void}
         */
-       initDd: function() {
-               if (this.deletionDropZoneId) {
+       initDd: function(treePanel, node) {
+               var nodeHasChildNodes = (node.hasChildNodes() || node.isExpandable());
+               if (this.deletionDropZoneId &&
+                       (!nodeHasChildNodes ||
+                       (nodeHasChildNodes && TYPO3.Components.PageTree.Configuration.canDeleteRecursivly)
+               )) {
                        Ext.getCmp(this.deletionDropZoneId).show();
                }
                this.initDDProxyElement();
index ee96157..a3a33da 100644 (file)
@@ -120,19 +120,6 @@ class t3lib_tree_pagetree_extdirect_Commands {
                return $returnValue;
        }
 
-       /**
-        * Gets title and message for JS deletion confirmation window
-        *
-        * @param  $uid The uid of the record to be deleted
-        * @return array The title and the message for the confirmation window
-        */
-       public function getConfirmContentDeletionMessage($uid) {
-               return array(
-                       'title' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:deleteItem'),
-                       'message' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:deleteWarning')
-               );
-       }
-
        /**
         * Restore the page
         *
index 5aede9a..d6c5e35 100644 (file)
@@ -198,11 +198,15 @@ class t3lib_tree_pagetree_extdirect_Tree extends t3lib_tree_ExtDirect_AbstractEx
                                'dropZoneElementRestored' => $GLOBALS['LANG']->sL($file . 'tree.dropZoneElementRestored', TRUE),
                                'searchTermInfo' => $GLOBALS['LANG']->sL($file . 'tree.searchTermInfo', TRUE),
                                'temporaryMountPointIndicatorInfo' => $GLOBALS['LANG']->sl($file . 'labels.temporaryDBmount', TRUE),
+                               'deleteDialogTitle' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:deleteItem', TRUE),
+                               'deleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:deleteWarning', TRUE),
+                               'recursiveDeleteDialogMessage' => $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xml:recursiveDeleteWarning', TRUE),
                        ),
 
                        'Configuration' => array(
                                'hideFilter' => $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.hideFilter'),
                                'displayDeleteConfirmation' => $GLOBALS['BE_USER']->jsConfirmation(4),
+                               'canDeleteRecursivly' => $GLOBALS['BE_USER']->uc['recursiveDelete'] == TRUE,
                                'disableIconLinkToContextmenu' => $GLOBALS['BE_USER']->getTSConfigVal(
                                        'options.pageTree.disableIconLinkToContextmenu'
                                ),
index 9f49795..f990723 100755 (executable)
@@ -21,6 +21,7 @@
                        <label index="move_page">Move page</label>
                        <label index="deleteItem">Delete</label>
                        <label index="deleteWarning">Are you sure you want to delete this record?</label>
+                       <label index="recursiveDeleteWarning">You can recover pages with subpages only with the recycler. Are you sure you want to delete these pages?</label>
                        <label index="editColumn">Edit this column</label>
                        <label index="editPageProperties_curLang">Edit translation properties</label>
                        <label index="editInRTE">Edit in Rich Text Editor</label>