From: Ingmar Schlecht Date: Mon, 19 Feb 2007 15:16:09 +0000 (+0000) Subject: Fixed bug: AJAX navtree erroneously showed whole tree inside of the expanded branch... X-Git-Tag: TYPO3_4-1-0RC2~18 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/a5c392f8a89f94acb03b90d14d08e34591ac1082 Fixed bug: AJAX navtree erroneously showed whole tree inside of the expanded branch on errors such as pages deleted in the meantime git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2048 709f56b5-9817-0410-a4d7-c38de5d9e867 --- diff --git a/ChangeLog b/ChangeLog index cea9815c65b..4301b7027c0 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2007-02-19 Ingmar Schlecht + * 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 diff --git a/typo3/alt_db_navframe.php b/typo3/alt_db_navframe.php index 614c3719cd8..f74bb248d16 100755 --- a/typo3/alt_db_navframe.php +++ b/typo3/alt_db_navframe.php @@ -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 { diff --git a/typo3/alt_file_navframe.php b/typo3/alt_file_navframe.php index 08a9959a417..e08a4e40ec2 100755 --- a/typo3/alt_file_navframe.php +++ b/typo3/alt_file_navframe.php @@ -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 { diff --git a/typo3/class.filelistfoldertree.php b/typo3/class.filelistfoldertree.php index 121325c0223..96c91e48554 100755 --- a/typo3/class.filelistfoldertree.php +++ b/typo3/class.filelistfoldertree.php @@ -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 .= "\n"; diff --git a/typo3/class.webpagetree.php b/typo3/class.webpagetree.php index 4b3c79254d6..0d75444982a 100755 --- a/typo3/class.webpagetree.php +++ b/typo3/class.webpagetree.php @@ -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 .= ''; diff --git a/typo3/tree.js b/typo3/tree.js index 8b95fc003db..d81334720b1 100755 --- a/typo3/tree.js +++ b/typo3/tree.js @@ -27,12 +27,7 @@ // 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;