4573866d8a1dd09558d6dccb93bd53d74dd3931f
[Packages/TYPO3.CMS.git] / typo3 / js / extjs / components / pagetree / javascript / actions.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2010-2011 Stefan Galinski <stefan.galinski@gmail.com>
5 * All rights reserved
6 *
7 * This script is part of the TYPO3 project. The TYPO3 project is
8 * free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * The GNU General Public License can be found at
14 * http://www.gnu.org/copyleft/gpl.html.
15 * A copy is found in the text file GPL.txt and important notices to the license
16 * from the author is found in LICENSE.txt distributed with these scripts.
17 *
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 Ext.namespace('TYPO3.Components.PageTree');
27
28 /**
29 * @class TYPO3.Components.PageTree.Actions
30 *
31 * Actions dedicated for the page tree
32 *
33 * @namespace TYPO3.Components.PageTree
34 * @author Stefan Galinski <stefan.galinski@gmail.com>
35 */
36 TYPO3.Components.PageTree.Actions = {
37 /**
38 * Evaluates a response from an ext direct call and shows a flash message
39 * if it was an exceptional result
40 *
41 * @param {Object} response
42 * @return {Boolean}
43 */
44 evaluateResponse: function(response) {
45 if (response.success === false) {
46 TYPO3.Flashmessage.display(4, 'Exception', response.message);
47 return false;
48 }
49
50 return true;
51 },
52
53 /**
54 * Releases the cut and copy mode from the context menu
55 *
56 * @param {TYPO3.Components.PageTree.Tree} tree
57 * @return {void}
58 */
59 releaseCutAndCopyModes: function(tree) {
60 tree.t3ContextInfo.inCutMode = false;
61 tree.t3ContextInfo.inCopyMode = false;
62
63 if (tree.t3ContextNode) {
64 tree.t3ContextNode.attributes.nodeData.t3InCutMode = false;
65 tree.t3ContextNode.attributes.nodeData.t3InCopyMode = false;
66 tree.t3ContextNode = null;
67 }
68 },
69
70 /**
71 * Updates an existing node with the given alternative. The new tree node
72 * is returned afterwards.
73 *
74 * @param {Ext.tree.TreeNode} node
75 * @param {Boolean} isExpanded
76 * @param {Object} updatedNode
77 * @param {Function} callback
78 * @return {Ext.tree.TreeNode}
79 */
80 updateNode: function(node, isExpanded, updatedNode, callback) {
81 if (!updatedNode) {
82 return null;
83 }
84
85 updatedNode.uiProvider = node.ownerTree.uiProvider;
86 var newTreeNode = new Ext.tree.TreeNode(updatedNode);
87
88 var refreshCallback = this.restoreNodeStateAfterRefresh;
89 if (callback) {
90 refreshCallback = refreshCallback.createSequence(callback);
91 }
92
93 node.parentNode.replaceChild(newTreeNode, node);
94 newTreeNode.ownerTree.refreshNode(newTreeNode, refreshCallback);
95
96 return newTreeNode;
97 },
98
99 /**
100 * Restores the node state
101 *
102 * @param {Ext.tree.TreeNode} node
103 * @param {Boolean} isExpanded
104 * @return {void}
105 */
106 restoreNodeStateAfterRefresh: function(node, isExpanded) {
107 node.parentNode.expand(false, false);
108 if (isExpanded) {
109 node.expand(false, false);
110 } else {
111 node.collapse(false, false);
112 }
113 },
114
115 /**
116 * Shows deletion confirmation window
117 *
118 * @param {Ext.tree.TreeNode} node
119 * @param {TYPO3.Components.PageTree.Tree} tree
120 * @param {Function} callback
121 * @param {Boolean} recursiveDelete
122 * @return {void}
123 */
124 confirmDelete: function(node, tree, callback, recursiveDelete) {
125 callback = callback || null;
126
127 var title = TYPO3.Components.PageTree.LLL.deleteDialogTitle,
128 message = TYPO3.Components.PageTree.LLL.deleteDialogMessage;
129 if (recursiveDelete) {
130 message = TYPO3.Components.PageTree.LLL.recursiveDeleteDialogMessage;
131 }
132
133 Ext.Msg.show({
134 title: title,
135 msg: message,
136 buttons: Ext.Msg.YESNO,
137 fn: function (answer) {
138 if (answer === 'yes') {
139 TYPO3.Components.PageTree.Actions.deleteNode(node, tree, callback);
140 return true;
141 }
142 return false;
143 },
144 animEl: 'elId'
145 });
146 },
147
148 /**
149 * Deletes a node directly
150 *
151 * @param {Ext.tree.TreeNode} node
152 * @param {TYPO3.Components.PageTree.Tree} tree
153 * @param {Function} callback
154 * @return {void}
155 */
156 deleteNode: function(node, tree, callback) {
157 TYPO3.Components.PageTree.Commands.deleteNode(
158 node.attributes.nodeData,
159 function(response) {
160 var succeeded = this.evaluateResponse(response);
161 if (Ext.isFunction(callback)) {
162 callback(node, tree, succeeded);
163 }
164
165 if (succeeded) {
166 // the node may not be removed in workspace mode
167 if (top.TYPO3.configuration.inWorkspace && response.id) {
168 this.updateNode(node, node.isExpanded(), response);
169 } else {
170 node.remove();
171 }
172 }
173 },
174 this
175 );
176 },
177
178 /**
179 * Removes a node either directly or first shows deletion popup
180 *
181 * @param {Ext.tree.TreeNode} node
182 * @param {TYPO3.Components.PageTree.Tree} tree
183 * @return {void}
184 */
185 removeNode: function(node, tree) {
186 if (TYPO3.Components.PageTree.Configuration.displayDeleteConfirmation) {
187 this.confirmDelete(node);
188 } else {
189 this.deleteNode(node, tree);
190 }
191 },
192
193 /**
194 * Restores a given node and moves it to the given destination inside the tree. Use this
195 * method if you want to add it as the first child of the destination.
196 *
197 * @param {Ext.tree.TreeNode} node
198 * @param {TYPO3.Components.PageTree.Tree} tree
199 * @param {Ext.tree.TreeNode} destination
200 * @return {void}
201 */
202 restoreNodeToFirstChildOfDestination: function(node, tree, destination) {
203 TYPO3.Components.PageTree.Commands.restoreNode(
204 node.attributes.nodeData,
205 destination.attributes.nodeData.id,
206 function(updatedNode) {
207 if (this.evaluateResponse(updatedNode)) {
208 var newTreeNode = new Ext.tree.TreeNode(
209 Ext.apply(node.attributes, updatedNode)
210 );
211 destination.insertBefore(newTreeNode, destination.firstChild);
212 }
213 },
214 this
215 );
216 },
217
218 /**
219 * Restores a given node and moves it to the given destination inside the tree. Use this
220 * method if you want to add the node after the destination node.
221 *
222 * @param {Ext.tree.TreeNode} node
223 * @param {TYPO3.Components.PageTree.Tree} tree
224 * @param {Ext.tree.TreeNode} destination
225 * @return {void}
226 */
227 restoreNodeAfterDestination: function(node, tree, destination) {
228 TYPO3.Components.PageTree.Commands.restoreNode(
229 node.attributes.nodeData,
230 -destination.attributes.nodeData.id,
231 function(updatedNode) {
232 if (this.evaluateResponse(updatedNode)) {
233 var newTreeNode = new Ext.tree.TreeNode(
234 Ext.apply(node.attributes, updatedNode)
235 );
236 destination.parentNode.insertBefore(newTreeNode, destination.nextSibling);
237 }
238 },
239 this
240 );
241 },
242
243 /**
244 * Collapses a whole tree branch
245 *
246 * @param {Ext.tree.TreeNode} node
247 * @return {void}
248 */
249 collapseBranch: function(node) {
250 node.collapse(true);
251 },
252
253 /**
254 * Expands a whole tree branch
255 *
256 * @param {Ext.tree.TreeNode} node
257 * @return {void}
258 */
259 expandBranch: function(node) {
260 node.expand(true);
261 },
262
263 /**
264 * Opens a popup windows for previewing the given node/page
265 *
266 * @param {Ext.tree.TreeNode} node
267 * @return {void}
268 */
269 viewPage: function(node) {
270 var frontendWindow = window.open('', 'newTYPO3frontendWindow');
271 TYPO3.Components.PageTree.Commands.getViewLink(
272 node.attributes.nodeData,
273 function(result) {
274 frontendWindow.location = result;
275 frontendWindow.focus();
276 }
277 );
278 },
279
280 /**
281 * Creates a temporary tree mount point
282 *
283 * @param {Ext.tree.TreeNode} node
284 * @param {TYPO3.Components.PageTree.Tree} tree
285 * @return {void}
286 */
287 mountAsTreeRoot: function(node, tree) {
288 TYPO3.Components.PageTree.Commands.setTemporaryMountPoint(
289 node.attributes.nodeData,
290 function(response) {
291 if (TYPO3.Components.PageTree.Configuration.temporaryMountPoint) {
292 TYPO3.Backend.NavigationContainer.PageTree.removeIndicator(
293 TYPO3.Backend.NavigationContainer.PageTree.temporaryMountPointInfoIndicator
294 );
295 }
296
297 TYPO3.Components.PageTree.Configuration.temporaryMountPoint = response;
298 TYPO3.Backend.NavigationContainer.PageTree.addTemporaryMountPointIndicator();
299
300 var selectedNode = TYPO3.Backend.NavigationContainer.PageTree.getSelected();
301 tree.stateId = 'Pagetree' + TYPO3.Components.PageTree.Configuration.temporaryMountPoint;
302 tree.refreshTree(function() {
303 var nodeIsSelected = false;
304 if (selectedNode) {
305 nodeIsSelected = TYPO3.Backend.NavigationContainer.PageTree.select(
306 selectedNode.attributes.nodeData.id
307 );
308 }
309
310 var node = (nodeIsSelected ? TYPO3.Backend.NavigationContainer.PageTree.getSelected() : null);
311 if (node) {
312 this.singleClick(node, tree);
313 } else {
314 this.singleClick(tree.getRootNode().firstChild, tree);
315 }
316 }, this);
317 },
318 this
319 );
320 },
321
322 /**
323 * Opens the edit page properties dialog
324 *
325 * @param {Ext.tree.TreeNode} node
326 * @return {void}
327 */
328 editPageProperties: function(node) {
329 node.select();
330 var returnUrl = TYPO3.Backend.ContentContainer.src;
331 if (returnUrl.indexOf('returnUrl') !== -1) {
332 returnUrl = TYPO3.Utility.getParameterFromUrl(returnUrl, 'returnUrl');
333 } else {
334 returnUrl = encodeURIComponent(returnUrl);
335 }
336
337 TYPO3.Backend.ContentContainer.setUrl(
338 'alt_doc.php?edit[pages][' + node.attributes.nodeData.id + ']=edit&returnUrl=' + returnUrl
339 );
340 },
341
342 /**
343 * Opens the new page wizard
344 *
345 * @param {Ext.tree.TreeNode} node
346 * @return {void}
347 */
348 newPageWizard: function(node) {
349 node.select();
350 TYPO3.Backend.ContentContainer.setUrl(
351 'db_new.php?id=' + node.attributes.nodeData.id + '&pagesOnly=1'
352 );
353 },
354
355 /**
356 * Opens the info popup
357 *
358 * @param {Ext.tree.TreeNode} node
359 * @return {void}
360 */
361 openInfoPopUp: function(node) {
362 launchView('pages', node.attributes.nodeData.id);
363 },
364
365 /**
366 * Opens the history popup
367 *
368 * @param {Ext.tree.TreeNode} node
369 * @return {void}
370 */
371 openHistoryPopUp: function(node) {
372 node.select();
373 TYPO3.Backend.ContentContainer.setUrl(
374 'show_rechis.php?element=pages:' + node.attributes.nodeData.id
375 );
376 },
377
378 /**
379 * Opens the export .t3d file dialog
380 *
381 * @param {Ext.tree.TreeNode} node
382 * @return {void}
383 */
384 exportT3d: function(node) {
385 node.select();
386 TYPO3.Backend.ContentContainer.setUrl(
387 'sysext/impexp/app/index.php?tx_impexp[action]=export&' +
388 'id=0&tx_impexp[pagetree][id]=' + node.attributes.nodeData.id +
389 '&tx_impexp[pagetree][levels]=0' +
390 '&tx_impexp[pagetree][tables][]=_ALL'
391 );
392 },
393
394 /**
395 * Opens the import .t3d file dialog
396 *
397 * @param {Ext.tree.TreeNode} node
398 * @return {void}
399 */
400 importT3d: function(node) {
401 node.select();
402 TYPO3.Backend.ContentContainer.setUrl(
403 'sysext/impexp/app/index.php?id=' + node.attributes.nodeData.id +
404 '&table=pages&tx_impexp[action]=import'
405 );
406 },
407
408 /**
409 * Enables the cut mode of a node
410 *
411 * @param {Ext.tree.TreeNode} node
412 * @param {TYPO3.Components.PageTree.Tree} tree
413 * @return {void}
414 */
415 enableCutMode: function(node, tree) {
416 this.disableCopyMode(node, tree);
417 node.attributes.nodeData.t3InCutMode = true;
418 tree.t3ContextInfo.inCutMode = true;
419 tree.t3ContextNode = node;
420 },
421
422 /**
423 * Disables the cut mode of a node
424 *
425 * @param {Ext.tree.TreeNode} node
426 * @param {TYPO3.Components.PageTree.Tree} tree
427 * @return {void}
428 */
429 disableCutMode: function(node, tree) {
430 this.releaseCutAndCopyModes(tree);
431 node.attributes.nodeData.t3InCutMode = false;
432 },
433
434 /**
435 * Enables the copy mode of a node
436 *
437 * @param {Ext.tree.TreeNode} node
438 * @param {TYPO3.Components.PageTree.Tree} tree
439 * @return {void}
440 */
441 enableCopyMode: function(node, tree) {
442 this.disableCutMode(node, tree);
443 node.attributes.nodeData.t3InCopyMode = true;
444 tree.t3ContextInfo.inCopyMode = true;
445 tree.t3ContextNode = node;
446 },
447
448 /**
449 * Disables the copy mode of a node
450 *
451 * @param {Ext.tree.TreeNode} node
452 * @param {TYPO3.Components.PageTree.Tree} tree
453 * @return {void}
454 */
455 disableCopyMode: function(node, tree) {
456 this.releaseCutAndCopyModes(tree);
457 node.attributes.nodeData.t3InCopyMode = false;
458 },
459
460 /**
461 * Pastes the cut/copy context node into the given node
462 *
463 * @param {Ext.tree.TreeNode} node
464 * @param {TYPO3.Components.PageTree.Tree} tree
465 * @return {void}
466 */
467 pasteIntoNode: function(node, tree) {
468 if (!tree.t3ContextNode) {
469 return;
470 }
471
472 if (tree.t3ContextInfo.inCopyMode) {
473 // This is hard stuff to do. So increase the timeout for the AJAX request
474 Ext.Ajax.timeout = 3600000;
475
476 var newNode = tree.t3ContextNode = new Ext.tree.TreeNode(tree.t3ContextNode.attributes);
477 newNode.id = 'fakeNode';
478 node.insertBefore(newNode, node.childNodes[0]);
479 node.attributes.nodeData.t3InCopyMode = false;
480 this.copyNodeToFirstChildOfDestination(newNode, tree);
481
482 } else if (tree.t3ContextInfo.inCutMode) {
483 if (node.getPath().indexOf(tree.t3ContextNode.id) !== -1) {
484 return;
485 }
486
487 node.appendChild(tree.t3ContextNode);
488 node.attributes.nodeData.t3InCutMode = false;
489 this.moveNodeToFirstChildOfDestination(node, tree);
490 }
491 },
492
493 /**
494 * Pastes a cut/copy context node after the given node
495 *
496 * @param {Ext.tree.TreeNode} node
497 * @param {TYPO3.Components.PageTree.Tree} tree
498 * @return {void}
499 */
500 pasteAfterNode: function(node, tree) {
501 if (!tree.t3ContextNode) {
502 return;
503 }
504
505 if (tree.t3ContextInfo.inCopyMode) {
506 // This is hard stuff to do. So increase the timeout for the AJAX request
507 Ext.Ajax.timeout = 3600000;
508
509 var newNode = tree.t3ContextNode = new Ext.tree.TreeNode(tree.t3ContextNode.attributes);
510 newNode.id = 'fakeNode';
511 node.parentNode.insertBefore(newNode, node.nextSibling);
512 node.attributes.nodeData.t3InCopyMode = false;
513 this.copyNodeAfterDestination(newNode, tree);
514
515 } else if (tree.t3ContextInfo.inCutMode) {
516 if (node.getPath().indexOf(tree.t3ContextNode.id) !== -1) {
517 return;
518 }
519
520 node.parentNode.insertBefore(tree.t3ContextNode, node.nextSibling);
521 node.attributes.nodeData.t3InCutMode = false;
522 this.moveNodeAfterDestination(node, tree);
523 }
524 },
525
526 /**
527 * Moves the current tree context node after the given node
528 *
529 * @param {Ext.tree.TreeNode} node
530 * @param {TYPO3.Components.PageTree.Tree} tree
531 * @return {void}
532 */
533 moveNodeAfterDestination: function(node, tree) {
534 TYPO3.Components.PageTree.Commands.moveNodeAfterDestination(
535 tree.t3ContextNode.attributes.nodeData,
536 node.attributes.nodeData.id,
537 function(response) {
538 if (this.evaluateResponse(response) && tree.t3ContextNode) {
539 this.updateNode(tree.t3ContextNode, tree.t3ContextNode.isExpanded(), response);
540 }
541 this.releaseCutAndCopyModes(tree);
542 },
543 this
544 );
545 },
546
547 /**
548 * Moves the current tree context node as the first child of the given node
549 *
550 * @param {Ext.tree.TreeNode} node
551 * @param {TYPO3.Components.PageTree.Tree} tree
552 * @return {void}
553 */
554 moveNodeToFirstChildOfDestination: function(node, tree) {
555 TYPO3.Components.PageTree.Commands.moveNodeToFirstChildOfDestination(
556 tree.t3ContextNode.attributes.nodeData,
557 node.attributes.nodeData.id,
558 function(response) {
559 if (this.evaluateResponse(response) && tree.t3ContextNode) {
560 this.updateNode(tree.t3ContextNode, tree.t3ContextNode.isExpanded(), response);
561 }
562 this.releaseCutAndCopyModes(tree);
563 },
564 this
565 );
566 },
567
568 /**
569 * Inserts a new node after the given node
570 *
571 * @param {Ext.tree.TreeNode} node
572 * @param {TYPO3.Components.PageTree.Tree} tree
573 * @return {void}
574 */
575 insertNodeAfterDestination: function(node, tree) {
576 TYPO3.Components.PageTree.Commands.insertNodeAfterDestination(
577 tree.t3ContextNode.attributes.nodeData,
578 node.previousSibling.attributes.nodeData.id,
579 tree.t3ContextInfo.serverNodeType,
580 function(response) {
581 if (this.evaluateResponse(response)) {
582 this.updateNode(node, node.isExpanded(), response, function(node) {
583 tree.triggerEdit(node);
584 });
585 }
586 this.releaseCutAndCopyModes(tree);
587 },
588 this
589 );
590 },
591
592 /**
593 * Inserts a new node as the first child of the given node
594 *
595 * @param {Ext.tree.TreeNode} node
596 * @param {TYPO3.Components.PageTree.Tree} tree
597 * @return {void}
598 */
599 insertNodeToFirstChildOfDestination: function(node, tree) {
600 TYPO3.Components.PageTree.Commands.insertNodeToFirstChildOfDestination(
601 tree.t3ContextNode.attributes.nodeData,
602 tree.t3ContextInfo.serverNodeType,
603 function(response) {
604 if (this.evaluateResponse(response)) {
605 this.updateNode(node, true, response, function(node) {
606 tree.triggerEdit(node);
607 });
608 }
609 this.releaseCutAndCopyModes(tree);
610 },
611 this
612 );
613 },
614
615 /**
616 * Copies the current tree context node after the given node
617 *
618 * @param {Ext.tree.TreeNode} node
619 * @param {TYPO3.Components.PageTree.Tree} tree
620 * @return {void}
621 */
622 copyNodeAfterDestination: function(node, tree) {
623 TYPO3.Components.PageTree.Commands.copyNodeAfterDestination(
624 tree.t3ContextNode.attributes.nodeData,
625 node.previousSibling.attributes.nodeData.id,
626 function(response) {
627 if (this.evaluateResponse(response)) {
628 this.updateNode(node, true, response, function(node) {
629 tree.triggerEdit(node);
630 });
631 }
632 this.releaseCutAndCopyModes(tree);
633 },
634 this
635 );
636 },
637
638 /**
639 * Copies the current tree context node as the first child of the given node
640 *
641 * @param {Ext.tree.TreeNode} node
642 * @param {TYPO3.Components.PageTree.Tree} tree
643 * @return {void}
644 */
645 copyNodeToFirstChildOfDestination: function(node, tree) {
646 TYPO3.Components.PageTree.Commands.copyNodeToFirstChildOfDestination(
647 tree.t3ContextNode.attributes.nodeData,
648 node.parentNode.attributes.nodeData.id,
649 function(response) {
650 if (this.evaluateResponse(response)) {
651 this.updateNode(node, true, response, function(node) {
652 tree.triggerEdit(node);
653 });
654 }
655 this.releaseCutAndCopyModes(tree);
656 },
657 this
658 );
659 },
660
661 /**
662 * Visibilizes a page
663 *
664 * @param {Ext.tree.TreeNode} node
665 * @return {void}
666 */
667 enablePage: function(node) {
668 TYPO3.Components.PageTree.Commands.visiblyNode(
669 node.attributes.nodeData,
670 function(response) {
671 if (this.evaluateResponse(response)) {
672 this.updateNode(node, node.isExpanded(), response);
673 }
674 },
675 this
676 );
677 },
678
679 /**
680 * Disables a page
681 *
682 * @param {Ext.tree.TreeNode} node
683 * @return {void}
684 */
685 disablePage: function(node) {
686 TYPO3.Components.PageTree.Commands.disableNode(
687 node.attributes.nodeData,
688 function(response) {
689 if (this.evaluateResponse(response)) {
690 this.updateNode(node, node.isExpanded(), response);
691 }
692 },
693 this
694 );
695 },
696
697 /**
698 * Reloads the content frame with the current module and node id
699 *
700 * @param {Ext.tree.TreeNode} node
701 * @param {TYPO3.Components.PageTree.Tree} tree
702 * @return {void}
703 */
704 singleClick: function(node, tree) {
705 tree.currentSelectedNode = node;
706
707 var separator = '?';
708 if (currentSubScript.indexOf('?') !== -1) {
709 separator = '&';
710 }
711
712 node.select();
713 if (tree.stateHash) {
714 tree.stateHash.lastSelectedNode = node.id;
715 } else {
716 TYPO3.Components.PageTree.Commands.addRootlineOfNodeToStateHash(
717 TYPO3.Backend.NavigationContainer.PageTree.mainTree.stateId,
718 node.attributes.nodeData.id, function(stateHash) {
719 TYPO3.Backend.NavigationContainer.PageTree.mainTree.stateHash = stateHash;
720 TYPO3.Backend.NavigationContainer.PageTree.mainTree.refreshTree();
721 }
722 );
723 }
724
725 fsMod.recentIds['web'] = node.attributes.nodeData.id;
726
727 TYPO3.Backend.ContentContainer.setUrl(
728 TS.PATH_typo3 + currentSubScript + separator + 'id=' + node.attributes.nodeData.id
729 );
730 },
731
732 /**
733 * Opens a configured url inside the content frame
734 *
735 * @param {Ext.tree.TreeNode} node
736 * @param {TYPO3.Components.PageTree.Tree} tree
737 * @param {Object} contextItem
738 * @return {void}
739 */
740 openCustomUrlInContentFrame: function(node, tree, contextItem) {
741 if (!contextItem.customAttributes || !contextItem.customAttributes.contentUrl) {
742 return;
743 }
744
745 node.select();
746 TYPO3.Backend.ContentContainer.setUrl(
747 contextItem.customAttributes.contentUrl.replace('###ID###', node.attributes.nodeData.id)
748 );
749 },
750
751 /**
752 * Updates the title of a node
753 *
754 * @param {Ext.tree.TreeNode} node
755 * @param {String} newText
756 * @param {String} oldText
757 * @param {TYPO3.Components.PageTree.TreeEditor} treeEditor
758 * @return {void}
759 */
760 saveTitle: function(node, newText, oldText, treeEditor) {
761 if (newText === oldText || newText == '') {
762 treeEditor.updateNodeText(
763 node,
764 node.editNode.attributes.nodeData.editableText,
765 Ext.util.Format.htmlEncode(oldText)
766 );
767 return;
768 }
769
770 TYPO3.Components.PageTree.Commands.updateLabel(
771 node.editNode.attributes.nodeData,
772 newText,
773 function(response) {
774 if (this.evaluateResponse(response)) {
775 treeEditor.updateNodeText(node, response.editableText, response.updatedText);
776 } else {
777 treeEditor.updateNodeText(
778 node,
779 node.editNode.attributes.nodeData.editableText,
780 Ext.util.Format.htmlEncode(oldText)
781 );
782 }
783 this.singleClick(node.editNode, node.editNode.ownerTree);
784 },
785 this
786 );
787 }
788 };