From: Oliver Hader Date: Wed, 7 Aug 2013 17:01:53 +0000 (+0200) Subject: [BUGFIX] Faulty expand/collapse behavior in Element Browser X-Git-Tag: TYPO3_6-2-0alpha3~59 X-Git-Url: http://git.typo3.org/Packages/TYPO3.CMS.git/commitdiff_plain/070a6cd49231d88b77d34c93afede166855a2ce5?hp=d16f55106fb55dda6b55b48f5f4e7eb81f9942cc [BUGFIX] Faulty expand/collapse behavior in Element Browser On using the element browser in combination with files, the expand/collapse behavior is wrong. On opening a collapsed folder, an AJAX call fetches the sub-nodes that will be added to the DOM tree. However, the calling scope of the original rendering process and the AJAX call differ a lot. The only possibility to get this working is to transfer the scope and rebuild it in the AJAX context. Change-Id: I1bf7b56ae2d82d15e0246bd651f77793adde705b Fixes: #45859 Releases: 6.0, 6.1, 6.2 Reviewed-on: https://review.typo3.org/22934 Reviewed-by: Henrik Ziegenhain Tested-by: Henrik Ziegenhain Reviewed-by: Markus Schubath Tested-by: Markus Schubath Reviewed-by: Wouter Wolters Tested-by: Wouter Wolters Reviewed-by: Anja Leichsenring Tested-by: Anja Leichsenring --- diff --git a/typo3/class.browse_links.php b/typo3/class.browse_links.php index c203fa18e9b6..b1fbf07983d1 100644 --- a/typo3/class.browse_links.php +++ b/typo3/class.browse_links.php @@ -283,6 +283,11 @@ class TBE_FolderTree extends localFolderTree { */ public $ext_noTempRecyclerDirs = 0; + /** + * @var array + */ + protected $scope; + /** * Returns TRUE if the input "record" contains a folder which can be linked. * @@ -314,6 +319,30 @@ class TBE_FolderTree extends localFolderTree { return '' . $title . ''; } } + + /** + * Wrap the plus/minus icon in a link + * + * @param string $icon HTML string to wrap, probably an image tag. + * @param string $cmd Command for 'PM' get var + * @param boolean $isExpand Whether to be expanded + * @return string Link-wrapped input string + * @internal + */ + public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) { + $this->scope = array( + 'class' => get_class($this), + 'script' => $this->thisScript, + 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs, + 'browser' => array( + 'mode' => $GLOBALS['SOBE']->browser->mode, + 'act' => $GLOBALS['SOBE']->browser->act, + ), + ); + + return parent::PMiconATagWrap($icon, $cmd, $isExpand); + } + } ?> \ No newline at end of file diff --git a/typo3/js/tree.js b/typo3/js/tree.js index 36e3e249b03e..d3d21c2d768c 100644 --- a/typo3/js/tree.js +++ b/typo3/js/tree.js @@ -124,10 +124,16 @@ var Tree = { pageID: 0, // reloads a part of the page tree (useful when "expand" / "collapse") - load: function(params, isExpand, obj) { + load: function(params, isExpand, obj, scopeData, scopeHash) { + var scope = ''; + + if (scopeData && scopeHash) { + scope = '&scopeData=' + encodeURIComponent(scopeData) + '&scopeHash=' + encodeURIComponent(scopeHash); + } + // fallback if AJAX is not possible (e.g. IE < 6) if (typeof Ajax.getTransport() !== 'object') { - window.location.href = this.thisScript + '?ajaxID=' + this.ajaxID + '&PM=' + encodeURIComponent(params); + window.location.href = this.thisScript + '?ajaxID=' + this.ajaxID + '&PM=' + encodeURIComponent(params) + scope; return; } @@ -150,7 +156,7 @@ var Tree = { var call = new Ajax.Request(this.thisScript, { method: 'get', - parameters: 'ajaxID=' + this.ajaxID + '&PM=' + encodeURIComponent(params), + parameters: 'ajaxID=' + this.ajaxID + '&PM=' + encodeURIComponent(params) + scope, onComplete: function(xhr) { // the parent node needs to be overwritten, not the object $(obj.parentNode.parentNode).replace(xhr.responseText); diff --git a/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php b/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php index f3412e81c680..e3a4f8bcb427 100644 --- a/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php +++ b/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php @@ -74,6 +74,11 @@ class FileSystemNavigationFrameController { */ public $cMR; + /** + * @var array + */ + protected $scopeData; + /** * Constructor */ @@ -94,11 +99,28 @@ class FileSystemNavigationFrameController { // Setting GPvars: $this->currentSubScript = GeneralUtility::_GP('currentSubScript'); $this->cMR = GeneralUtility::_GP('cMR'); + + $scopeData = (string) GeneralUtility::_GP('scopeData'); + $scopeHash = (string) GeneralUtility::_GP('scopeHash'); + + if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) { + $this->scopeData = unserialize($scopeData); + } + // Create folder tree object: - /** @var $foldertree \TYPO3\CMS\Filelist\FileListFolderTree */ - $this->foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree'); + if (!empty($this->scopeData)) { + $this->foldertree = GeneralUtility::makeInstance($this->scopeData['class']); + $this->foldertree->thisScript = $this->scopeData['script']; + $this->foldertree->ext_noTempRecyclerDirs = $this->scopeData['ext_noTempRecyclerDirs']; + $GLOBALS['SOBE']->browser = new \stdClass(); + $GLOBALS['SOBE']->browser->mode = $this->scopeData['browser']['mode']; + $GLOBALS['SOBE']->browser->act = $this->scopeData['browser']['act']; + } else { + $this->foldertree = GeneralUtility::makeInstance('TYPO3\\CMS\\Filelist\\FileListFolderTree'); + $this->foldertree->thisScript = 'alt_file_navframe.php'; + } + $this->foldertree->ext_IconMode = $GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.disableIconLinkToContextmenu'); - $this->foldertree->thisScript = 'alt_file_navframe.php'; } /** diff --git a/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php b/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php index ac1f228f2549..bd8c95d643e9 100644 --- a/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php @@ -107,7 +107,14 @@ class FolderTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView { public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) { if ($this->thisScript) { // Activates dynamic AJAX based tree - $js = htmlspecialchars('Tree.load(\'' . $cmd . '\', ' . intval($isExpand) . ', this);'); + $scopeData = ''; + $scopeHash = ''; + // $this->scope is defined in TBE_FolderTree + if (!empty($this->scope)) { + $scopeData = serialize($this->scope); + $scopeHash = GeneralUtility::hmac($scopeData); + } + $js = htmlspecialchars('Tree.load(\'' . $cmd . '\', ' . intval($isExpand) . ', this, \'' . $scopeData . '\', \'' . $scopeHash . '\');'); return '' . $icon . ''; } else { return $icon; @@ -666,4 +673,4 @@ class FolderTreeView extends \TYPO3\CMS\Backend\Tree\View\AbstractTreeView { } -?> \ No newline at end of file +?>