[BUGFIX] Adjustments to FAL-enabled RTE image and link dialogues
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 3 May 2012 16:18:59 +0000 (12:18 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 3 May 2012 16:21:27 +0000 (18:21 +0200)
When no folder is selected, use $BE_USER->getDefaultUploadFolder().
Use the id of the base script so that the same styles are applied to
the window.
When enabled, move the folder creation form to the bottom of the
window.
Honour readonly filemounts.
Slightly increase the default opening width of the image dialogue.

Change-Id: I710e60ffe00125874532137422a4ee461b8850e7
Releases: 6.0
Resolves: #36815
Reviewed-on: http://review.typo3.org/10969
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Image/typo3image.js
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php

index 35c2cce..62904ee 100644 (file)
@@ -87,7 +87,7 @@ HTMLArea.TYPO3Image = Ext.extend(HTMLArea.Plugin, {
                        this.getButton(buttonId).tooltip.title,
                        this.getWindowDimensions(
                                {
                        this.getButton(buttonId).tooltip.title,
                        this.getWindowDimensions(
                                {
-                                       width:  610,
+                                       width:  650,
                                        height: 500
                                },
                                buttonId
                                        height: 500
                                },
                                buttonId
index 296fc5b..d3a8650 100644 (file)
@@ -183,6 +183,9 @@ class tx_rtehtmlarea_browse_links extends browse_links {
        function init() {
                $this->initVariables();
                $this->initConfiguration();
        function init() {
                $this->initVariables();
                $this->initConfiguration();
+                       // init fileProcessor
+               $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
+               $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
                        // Creating backend template object:
                $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
                        // Creating backend template object:
                $this->doc = t3lib_div::makeInstance('template');
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
@@ -213,6 +216,8 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                }
                        // Setting intial values for link attributes
                $this->initLinkAttributes();
                }
                        // Setting intial values for link attributes
                $this->initLinkAttributes();
+                       // Apply the same styles as those of the base script
+               $this->doc->bodyTagId = 'typo3-browse-links-php';
                        // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
                $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
                        // Adding RTE JS code
                        // Add attributes to body tag. Note: getBodyTagAdditions will invoke the hooks
                $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
                        // Adding RTE JS code
@@ -697,38 +702,37 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                $this->expandFolder = $cmpPath;
                                        }
                                }
                                                $this->expandFolder = $cmpPath;
                                        }
                                }
+                                       // Get the selected folder
                                if ($this->expandFolder) {
                                        $selectedFolder = FALSE;
                                if ($this->expandFolder) {
                                        $selectedFolder = FALSE;
-
                                        $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
                                        $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
-                                               // it's a file
                                        if ($fileOrFolderObject instanceof t3lib_file_Folder) {
                                        if ($fileOrFolderObject instanceof t3lib_file_Folder) {
+                                               // it's a folder
                                                $selectedFolder = $fileOrFolderObject;
                                                $selectedFolder = $fileOrFolderObject;
-
                                        } elseif ($fileOrFolderObject instanceof t3lib_file_FileInterface) {
                                        } elseif ($fileOrFolderObject instanceof t3lib_file_FileInterface) {
+                                               // it's a file
                                                // @todo: find the parent folder, right now done a bit ugly, because the file does not
                                                // support finding the parent folder of a file on purpose
                                                $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
                                                $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
                                        }
                                }
                                                // @todo: find the parent folder, right now done a bit ugly, because the file does not
                                                // support finding the parent folder of a file on purpose
                                                $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
                                                $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
                                        }
                                }
-                                       // Add upload form if allowed
+                                       // If no folder is selected, get the user's default upload folder
                                if (!$selectedFolder) {
                                if (!$selectedFolder) {
-                                       $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
-                                       $fileStorage = reset($fileStorages);
-                                       $selectedFolder = $fileStorage->getRootLevelFolder();
+                                       $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
                                }
                                }
-                               if ($selectedFolder) {
+                                       // Build the file upload and folder creation forms
+                               $uploadForm = '';
+                               $createFolder = '';
+                               if ($selectedFolder && !$this->isReadOnlyFolder($selectedFolder)) {
                                        $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
                                        $uploadForm = ($this->act === 'file') ? $this->uploadForm($selectedFolder) : '';
-                                       $createFolder = $this->createFolder($selectedFolder);
-                               } else {
-                                       $uploadForm = $createFolder = '';
+                                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
+                                               $createFolder = $this->createFolder($selectedFolder);
+                                       }
                                }
                                }
+                                       // Insert the upload form on top, if so configured
                                if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                                        $content .= $uploadForm;
                                if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                                        $content .= $uploadForm;
-                                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                                               $content .= $createFolder;
-                                       }
                                }
                                        // Render the filelist if there is a folder selected
                                if ($selectedFolder) {
                                }
                                        // Render the filelist if there is a folder selected
                                if ($selectedFolder) {
@@ -737,7 +741,6 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                                $this->P['params']['allowedExtensions']
                                        );
                                }
                                                $this->P['params']['allowedExtensions']
                                        );
                                }
-
                                $content .= '
 
                        <!--
                                $content .= '
 
                        <!--
@@ -751,13 +754,13 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                        </table>
                                        ';
 
                                        </table>
                                        ';
 
-                                       // Adding create folder + upload forms if applicable:
+                                       // Adding create folder + upload form if applicable
                                if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                                        $content .= $uploadForm;
                                if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
                                        $content .= $uploadForm;
-                                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                                               $content .= $createFolder;
-                                       }
                                }
                                }
+                               $content .= '<br />';
+                               $content .= $createFolder;
+                               $content .= '<br />';
                        break;
                        case 'spec':
                                if (is_array($this->thisConfig['userLinks.']))  {
                        break;
                        case 'spec':
                                if (is_array($this->thisConfig['userLinks.']))  {
@@ -867,7 +870,12 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                return $content;
        }
 
                return $content;
        }
 
-       function addAttributesForm() {
+       /**
+        * Creates a form for link attributes
+        *
+        * @return string The HTML code of the form
+        */
+       public function addAttributesForm() {
                $ltargetForm = '';
                $additionalAttributeFields = '';
                        // Add page id, target, class selector box, title and parameters fields:
                $ltargetForm = '';
                $additionalAttributeFields = '';
                        // Add page id, target, class selector box, title and parameters fields:
@@ -878,7 +886,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                $ltitle = $this->addTitleSelector();
                $rel = $this->addRelField();
 
                $ltitle = $this->addTitleSelector();
                $rel = $this->addRelField();
 
-                       // additional fields for page links
+                       // additional fields for links
                if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'])) {
                        $_params = array(
                                'conf' => &$conf
                if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php']['addAttributeFields'])) {
                        $_params = array(
                                'conf' => &$conf
index ec8d6a0..aad0748 100644 (file)
@@ -143,6 +143,8 @@ class tx_rtehtmlarea_select_image extends browse_links {
 
                        // Creating backend template object:
                $this->doc = t3lib_div::makeInstance('template');
 
                        // Creating backend template object:
                $this->doc = t3lib_div::makeInstance('template');
+                       // Apply the same styles as those of the base script
+               $this->doc->bodyTagId = 'typo3-browse-links-php';
                $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
 
                $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
 
@@ -808,21 +810,38 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                                $this->expandFolder = $cmpPath;
                                        }
                                }
                                                $this->expandFolder = $cmpPath;
                                        }
                                }
-
+                                       // Get the selected folder
                                if ($this->expandFolder) {
                                if ($this->expandFolder) {
-                                       try {
-                                               $selectedFolder = t3lib_file_Factory::getInstance()->getFolderObjectFromCombinedIdentifier(
-                                                       $this->expandFolder
-                                               );
-                                       } catch (Exception $e) {
-                                               $selectedFolder = FALSE;
+                                       $selectedFolder = FALSE;
+                                       $fileOrFolderObject = t3lib_file_Factory::getInstance()->retrieveFileOrFolderObject($this->expandFolder);
+                                       if ($fileOrFolderObject instanceof t3lib_file_Folder) {
+                                               // it's a folder
+                                               $selectedFolder = $fileOrFolderObject;
+                                       } elseif ($fileOrFolderObject instanceof t3lib_file_FileInterface) {
+                                               // it's a file
+                                               // @todo: find the parent folder, right now done a bit ugly, because the file does not
+                                               // support finding the parent folder of a file on purpose
+                                               $folderIdentifier = dirname($fileOrFolderObject->getIdentifier());
+                                               $selectedFolder = $fileOrFolderObject->getStorage()->getFolder($folderIdentifier);
                                        }
                                }
                                        }
                                }
-                                       // Adding upload form, if allowed
-                               if ($selectedFolder) {
-                                       $this->content .= $this->insertUploadForm($selectedFolder);
+                                       // If no folder is selected, get the user's default upload folder
+                               if (!$selectedFolder) {
+                                       $selectedFolder = $GLOBALS['BE_USER']->getDefaultUploadFolder();
+                               }
+                                       // Build the file upload and folder creation form
+                               $uploadForm = '';
+                               $createFolder = '';
+                               if ($selectedFolder && !$this->isReadOnlyFolder($selectedFolder)) {
+                                       $uploadForm = $this->uploadForm($selectedFolder);
+                                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
+                                               $createFolder = $this->createFolder($selectedFolder);
+                                       }
+                               }
+                                       // Insert the upload form on top, if so configured
+                               if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+                                       $this->content .= $uploadForm;
                                }
                                }
-
                                        // Render the filelist if there is a folder selected
                                if ($selectedFolder) {
                                        $files = $this->TBE_expandFolder(
                                        // Render the filelist if there is a folder selected
                                if ($selectedFolder) {
                                        $files = $this->TBE_expandFolder(
@@ -851,6 +870,12 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                if ($helpMessage) {
                                        $this->content .= $this->getMsgBox($helpMessage);
                                }
                                if ($helpMessage) {
                                        $this->content .= $this->getMsgBox($helpMessage);
                                }
+                                       // Adding create folder + upload form if applicable
+                               if (!$GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+                                       $this->content .= $uploadForm;
+                               }
+                               $this->content .= $createFolder;
+                               $this->content .= '<br />';
                                break;
                        case 'dragdrop':
                                $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
                                break;
                        case 'dragdrop':
                                $foldertree = t3lib_div::makeInstance('TBE_FolderTree');
@@ -903,37 +928,6 @@ class tx_rtehtmlarea_select_image extends browse_links {
        }
 
        /**
        }
 
        /**
-        * Create upload/create folder forms, if a folder is given
-        *
-        * @param t3lib_file_Folder $selectedFolder Absolute filepath on server to which to upload.
-        * @return string HTML for an upload form.
-        */
-       protected function insertUploadForm(t3lib_file_Folder $selectedFolder) {
-               $content = '';
-               if (!$this->readOnly) {
-                               // Add upload form if allowed
-                       if (!$selectedFolder) {
-                               $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
-                               $fileStorage = reset($fileStorages);
-                               $selectedFolder = $fileStorage->getRootLevelFolder();
-                       }
-                       if ($selectedFolder) {
-                               $uploadForm = $this->uploadForm($selectedFolder);
-                               $createFolder = $this->createFolder($selectedFolder);
-                       } else {
-                               $uploadForm = $createFolder = '';
-                       }
-                       if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
-                               $content .= $uploadForm;
-                               if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
-                                       $content .= $createFolder;
-                               }
-                       }
-               }
-               return $content;
-       }
-
-       /**
         * Initializes the configuration variables
         *
         * @return      void
         * Initializes the configuration variables
         *
         * @return      void