Fixed bug: AJAX navtree erroneously showed whole tree inside of the expanded branch...
authorIngmar Schlecht <ingmar.schlecht@typo3.org>
Mon, 19 Feb 2007 15:16:09 +0000 (15:16 +0000)
committerIngmar Schlecht <ingmar.schlecht@typo3.org>
Mon, 19 Feb 2007 15:16:09 +0000 (15:16 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2048 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/alt_db_navframe.php
typo3/alt_file_navframe.php
typo3/class.filelistfoldertree.php
typo3/class.webpagetree.php
typo3/tree.js

index cea9815..4301b70 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2007-02-19  Ingmar Schlecht  <ingmar@typo3.org>
 
+       * Fixed bug: AJAX navtree erroneously showed whole tree inside of the expanded branch on errors such as pages deleted in the meantime (thanks to Benjamin Mack)
        * Fixed bug #4993: AJAX navtree does not expand in Konqueror (fixed by Benjamin Mack)
 
 2007-02-16  Martin Kutschker  <martin.t.kutschker@blackbox.net>
index 614c371..f74bb24 100755 (executable)
@@ -254,6 +254,7 @@ class SC_alt_db_navframe {
        function printContent() {
                        // If we handle an AJAX call, send headers:
                if ($this->ajax) {
+                       header('X-JSON: ('.($this->pagetree->ajaxStatus?'true':'false').')');
                        header('Content-type: text/html; charset=utf-8');
                        // If it's the regular call to fully output the tree:
                } else {
index 08a9959..e08a4e4 100755 (executable)
@@ -200,6 +200,7 @@ class SC_alt_file_navframe {
        function printContent() {
                        // If we handle an AJAX call, send headers:
                if ($this->ajax) {
+                       header('X-JSON: ('.($this->foldertree->ajaxStatus?'true':'false').')');
                        header('Content-type: text/html; charset=utf-8');
                        // If it's the regular call to fully output the tree:
                } else {
index 121325c..96c91e4 100755 (executable)
@@ -67,6 +67,7 @@ require_once (PATH_t3lib.'class.t3lib_foldertree.php');
 class filelistFolderTree extends t3lib_folderTree {
 
        var $ext_IconMode;
+       var $ajaxStatus = false; // Indicates, whether the ajax call was successful, i.e. the requested page has been found
 
        /**
         * Calls init functions
@@ -203,7 +204,10 @@ class filelistFolderTree extends t3lib_folderTree {
                        }
 
                        // ajax request: collapse
-                       if($doCollapse && $expandedFolderUid == $uid) { return $itemHTML; }
+                       if($doCollapse && $expandedFolderUid == $uid) {
+                               $this->ajaxStatus = true;
+                               return $itemHTML;
+                       }
 
                        // ajax request: expand
                        if($doExpand && $expandedFolderUid == $uid) {
@@ -213,6 +217,7 @@ class filelistFolderTree extends t3lib_folderTree {
                                if($v['invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {
                                        $ajaxOutput .= $itemHTML;
                                } else {
+                                       $this->ajaxStatus = true;
                                        return $ajaxOutput;
                                }
                        }
@@ -220,7 +225,10 @@ class filelistFolderTree extends t3lib_folderTree {
                        $out .= $itemHTML;
                }
 
-               if($ajaxOutput) { return $ajaxOutput; }
+               if($ajaxOutput) {
+                       $this->ajaxStatus = true;
+                       return $ajaxOutput;
+               }
 
                // finally close the first ul
                $out .= "</ul>\n";
index 4b3c792..0d75444 100755 (executable)
@@ -73,6 +73,7 @@ class webPageTree extends t3lib_browseTree {
 
        var $ext_showPageId;
        var $ext_IconMode;
+       var $ajaxStatus = false; // Indicates, whether the ajax call was successful, i.e. the requested page has been found
 
        /**
         * Calls init functions
@@ -232,7 +233,10 @@ class webPageTree extends t3lib_browseTree {
                        }
 
                        // ajax request: collapse
-                       if($doCollapse && $collapsedPageUid == $uid) { return $itemHTML; }
+                       if($doCollapse && $collapsedPageUid == $uid) {
+                               $this->ajaxStatus = true;
+                               return $itemHTML;
+                       }
 
                        // ajax request: expand
                        if($doExpand && $expandedPageUid == $uid) {
@@ -242,6 +246,7 @@ class webPageTree extends t3lib_browseTree {
                                if($v['invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {
                                        $ajaxOutput .= $itemHTML;
                                } else {
+                                       $this->ajaxStatus = true;
                                        return $ajaxOutput;
                                }
                        }
@@ -249,7 +254,10 @@ class webPageTree extends t3lib_browseTree {
                        $out .= $itemHTML;
                }
 
-               if($ajaxOutput) { return $ajaxOutput; }
+               if($ajaxOutput) {
+                       $this->ajaxStatus = true;
+                       return $ajaxOutput;
+               }
 
                // finally close the first ul
                $out .= '</ul>';
index 8b95fc0..d813347 100755 (executable)
        // Call this function, refresh_nav(), from another script in the backend if you want
        // to refresh the navigation frame (eg. after having changed a page title or moved pages etc.)
        //              See t3lib_BEfunc::getSetUpdateSignal()
-function refresh_nav() { window.setTimeout('_refresh_nav();',0); }
-function _refresh_nav()        {
-       var r = new Date();
-       // randNum is useful so pagetree does not get cached in browser cache when refreshing
-       window.location.href = Tree.thisScript + '?randNum=' + r.getTime();
-}
+function refresh_nav() { window.setTimeout('Tree.refresh();',0); }
 
 
 var Tree = {
@@ -63,8 +58,11 @@ var Tree = {
                new Ajax.Request(this.thisScript, {
                        method: 'get',
                        parameters: 'ajax=1&PM=' + params,
-                       onComplete: function(xhr) {
-                                       // the parent node needs to be overwritten, not the object
+                       onComplete: function(xhr, status) { 
+                               // if this is not a valid ajax response, the whole page gets refreshed 
+                               if (!status) return this.refresh();
+
+                               // the parent node needs to be overwritten, not the object
                                $(obj.parentNode).replace(xhr.responseText);
                                this.registerDragDropHandlers();
                                this.reSelectActiveItem();
@@ -72,6 +70,13 @@ var Tree = {
                });
        },
 
+       // does the complete page refresh (previously known as "_refresh_nav()")
+       refresh: function() {
+               var r = new Date();
+               // randNum is useful so pagetree does not get cached in browser cache when refreshing
+               window.location.href = this.thisScript + '?randNum=' + r.getTime();
+       },
+
        // attaches the events to the elements needed for the drag and drop (for the titles and the icons)
        registerDragDropHandlers: function() {
                if (!this.activateDragDrop) return;