[BUGFIX] RTE: Folder expansion broken in link and image dialogues 06/36006/3
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 14 Jan 2015 14:07:43 +0000 (09:07 -0500)
committerBenjamin Mack <benni@typo3.org>
Thu, 29 Jan 2015 09:24:16 +0000 (10:24 +0100)
Data provided to jQuery Ajax request should not be encoded when
specified as an object. jQuery encodes such data which would therefore
be encoded twice.
Also, TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController
does not set custom parameters on an Ajax expand/collapse request.

Releases: master
Resolves: #64269
Change-Id: Ia0aa10421708250380a401f9d596782e3e6c0347
Reviewed-on: http://review.typo3.org/36006
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/backend/Resources/Public/JavaScript/LegacyTree.js
typo3/sysext/rtehtmlarea/Classes/BrowseLinks.php
typo3/sysext/rtehtmlarea/Classes/FolderTree.php

index 8be8800..395de0e 100644 (file)
@@ -125,9 +125,9 @@ define(['jquery'], function($) {
                        $.ajax({
                                url: TYPO3.settings.ajaxUrls[this.ajaxID],
                                data: {
-                                       PM: encodeURIComponent(params),
-                                       scopeData: encodeURIComponent(scopeData),
-                                       scopeHash: encodeURIComponent(scopeHash)
+                                       PM: params,
+                                       scopeData: scopeData,
+                                       scopeHash: scopeHash
                                }
                        }).done(function(data) {
                                // the parent node needs to be overwritten, not the object
index d33a54e..b7d5318 100644 (file)
@@ -138,6 +138,9 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
                $this->doc->getPageRenderer()->addCssFile($this->doc->backPath . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('t3skin') . 'rtehtmlarea/htmlarea.css');
                // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
                $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
+               $this->doc->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/LegacyTree', 'function(Tree) {
+                       Tree.ajaxID = "SC_alt_file_navframe::expandCollapse";
+               }');
        }
 
        /**
index 9cc0f5a..ac9008d 100644 (file)
@@ -1,22 +1,51 @@
 <?php
 namespace TYPO3\CMS\Rtehtmlarea;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
- * Base extension class which generates the folder tree.
- * Used directly by the RTE.
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ * RTE class which generates the folder tree.
  */
 class FolderTree extends \localFolderTree {
 
        /**
-        * Constructor function of the class
+        * Will create and return the HTML code for a browsable tree of folders.
+        * Is based on the mounts found in the internal array ->MOUNTS (set in the constructor)
+        *
+        * @return string HTML code for the browsable tree
         */
-       public function __construct() {
-               // The backpath is set here to fix problems with relatives path when used in ajax scope
-               $GLOBALS['BACK_PATH'] = isset($GLOBALS['ajaxID']) ? '../../../' : $GLOBALS['BACK_PATH'];
-               parent::__construct();
+       public function getBrowsableTree() {
+               // TYPO3\CMS\Backend\Controller\FileSystemNavigationFrameController does not set custom parameters on an Ajax expand/collapse request
+               if (!$GLOBALS['SOBE']->browser->editorNo) {
+                       $scopeData = (string)GeneralUtility::_GP('scopeData');
+                       $scopeHash = (string)GeneralUtility::_GP('scopeHash');
+                       if (!empty($scopeData) && GeneralUtility::hmac($scopeData) === $scopeHash) {
+                               $scopeData = unserialize($scopeData);
+                               if ($scopeData['browser']['editorNo']) {
+                                       $GLOBALS['SOBE']->browser->editorNo = $scopeData['browser']['editorNo'];
+                               }
+                               if ($scopeData['browser']['sys_language_content']) {
+                                       $GLOBALS['SOBE']->browser->sys_language_content = $scopeData['browser']['sys_language_content'];
+                               }
+                               if ($scopeData['browser']['contentTypo3Language']) {
+                                       $GLOBALS['SOBE']->browser->contentTypo3Language = $scopeData['browser']['contentTypo3Language'];
+                               }
+                       }
+               }
+               return parent::getBrowsableTree();
        }
 
        /**
@@ -28,7 +57,15 @@ class FolderTree extends \localFolderTree {
         */
        public function wrapTitle($title, \TYPO3\CMS\Core\Resource\Folder $folderObject) {
                if ($this->ext_isLinkable($folderObject)) {
-                       $aOnClick = 'return jumpToUrl(\'' . $this->getThisScript() . 'act=' . $GLOBALS['SOBE']->browser->act . '&mode=' . $GLOBALS['SOBE']->browser->mode . '&editorNo=' . $GLOBALS['SOBE']->browser->editorNo . '&contentTypo3Language=' . $GLOBALS['SOBE']->browser->contentTypo3Language . '&contentTypo3Charset=' . $GLOBALS['SOBE']->browser->contentTypo3Charset . '&expandFolder=' . rawurlencode($folderObject->getCombinedIdentifier()) . '\');';
+                       $aOnClick = 'return jumpToUrl(\''
+                               . $this->getThisScript()
+                               . 'act=' . $GLOBALS['SOBE']->browser->act
+                               . '&mode=' . $GLOBALS['SOBE']->browser->mode
+                               . '&editorNo=' . $GLOBALS['SOBE']->browser->editorNo
+                               . ($GLOBALS['SOBE']->browser->sys_language_content ? '&sys_language_content=' . $GLOBALS['SOBE']->browser->sys_language_content : '')
+                               . ($GLOBALS['SOBE']->browser->contentTypo3Language ? '&contentTypo3Language=' . $GLOBALS['SOBE']->browser->contentTypo3Language : '')
+                               . '&expandFolder=' . $this->getJumpToParam($folderObject)
+                               . '\');';
                        return '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $title . '</a>';
                } else {
                        return '<span class="typo3-dimmed">' . $title . '</span>';
@@ -45,7 +82,6 @@ class FolderTree extends \localFolderTree {
         * @access private
         */
        public function PMiconATagWrap($icon, $cmd, $isExpand = TRUE) {
-
                if (empty($this->scope)) {
                        $this->scope = array(
                                'class' => get_class($this),
@@ -53,21 +89,20 @@ class FolderTree extends \localFolderTree {
                                'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs,
                                'browser' => array(
                                        'mode' => $GLOBALS['SOBE']->browser->mode,
-                                       'act' => $GLOBALS['SOBE']->browser->act,
-                                       'editorNo' => $GLOBALS['SOBE']->browser->editorNo
-                               ),
+                                       'act' => $GLOBALS['SOBE']->browser->act
+                               )
                        );
+                       if ($GLOBALS['SOBE']->browser->editorNo) {
+                               $this->scope['browser']['editorNo'] = $GLOBALS['SOBE']->browser->editorNo;
+                       }
+                       if ($GLOBALS['SOBE']->browser->sys_language_content) {
+                               $this->scope['browser']['sys_language_content'] = $GLOBALS['SOBE']->browser->sys_language_content;
+                       }
+                       if ($GLOBALS['SOBE']->browser->contentTypo3Language) {
+                               $this->scope['browser']['contentTypo3Language'] = $GLOBALS['SOBE']->browser->contentTypo3Language;
+                       }
                }
-
-               if ($this->thisScript) {
-                       // Activates dynamic AJAX based tree
-                       $scopeData = serialize($this->scope);
-                       $scopeHash = GeneralUtility::hmac($scopeData);
-                       $js = htmlspecialchars('Tree.load(' . GeneralUtility::quoteJSvalue($cmd) . ', ' . (int)$isExpand . ', this, ' . GeneralUtility::quoteJSvalue($scopeData) . ', ' . GeneralUtility::quoteJSvalue($scopeHash) . ');');
-                       return '<a class="pm" onclick="' . $js . '">' . $icon . '</a>';
-               } else {
-                       return $icon;
-               }
+               return parent::PMiconATagWrap($icon, $cmd, $isExpand);
        }
 
 }