Fixed bug #9296: htmlArea RTE: remove upload form when element browser is in readOnly...
authorStanislas Rolland <typo3@sjbr.ca>
Fri, 5 Sep 2008 01:19:00 +0000 (01:19 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 5 Sep 2008 01:19:00 +0000 (01:19 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4065 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/mod3/browse_links.php
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php
typo3/sysext/rtehtmlarea/mod4/select_image.php

index 1f038c0..3167445 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-09-04  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Added feature #9262: Adding counting classes to table rows/columns in RTE (thanks to Thorsten Krohn)
+       * Fixed bug #9296: htmlArea RTE: remove upload form when element browser is in readOnly mode
 
 2008-09-04  Oliver Hader  <oliver@typo3.org>
 
index 30830d9..03f179d 100644 (file)
@@ -1,6 +1,7 @@
 2008-09-04  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Added feature #9262: Adding counting classes to table rows/columns in RTE (thanks to Thorsten Krohn)
+       * Fixed bug #9296: htmlArea RTE: remove upload form when element browser is in readOnly mode
 
 2008-09-02  Stanislas Rolland  <typo3@sjbr.ca>
 
index a92210a..3cbcae4 100644 (file)
@@ -3,7 +3,7 @@
 *  Copyright notice
 *
 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
-*  (c) 2005-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2005-2008 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -35,7 +35,7 @@
  * $Id$
  *
  * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- * @author     Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author     Stanislas Rolland <typo3(arobas)sjbr.ca>
  */
 
 error_reporting (E_ALL ^ E_NOTICE);
@@ -55,50 +55,42 @@ $LANG->includeLLFile('EXT:rtehtmlarea/htmlarea/locallang_dialogs.xml');
  * @subpackage core
  */
 class tx_rtehtmlarea_SC_browse_links {
-       var $mode;
-       var $button = 'link';
+       public $mode = 'rte';
+       public $button = 'link';
+       public $readOnly = false;
+       protected $content = '';
 
        /**
-        * Main function, detecting the current mode of the element browser and branching out to internal methods.
+        * Main function, rendering the element browser in RTE mode.
         *
         * @return      void
         */
        function main() {
-               global $BE_USER, $SOBE;
-
-               $this->mode = t3lib_div::_GP('mode');
-               if (!$this->mode)       {
-                       $this->mode = 'rte';
-               }
-
-               $this->content = '';
-
-               //altMountPoints
+                       // Setting alternative web browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
                $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.altElementBrowserMountPoints'));
                if ($altMountPoints) {
                        $GLOBALS['BE_USER']->groupData['webmounts'] = implode(',', array_unique(t3lib_div::intExplode(',', $altMountPoints)));
                        $GLOBALS['WEBMOUNTS'] = $GLOBALS['BE_USER']->returnWebmounts();
-                       $browser_readOnly = true;
+                       $this->readOnly = true;
                }
-                       
-                       // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
+                       // Setting alternative file browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
                $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
                if ($altMountPoints) {
                        $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
-                       foreach($altMountPoints as $filePathRelativeToFileadmindir)     {
+                       foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
                                $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
                        }
                        $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
-                       $browser_readOnly = true;
+                       $this->readOnly = true;
                }
-                       
-                       // render type by user func
+                       // Render type by user function
                $browserRendered = false;
-               if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
                                $browserRenderObj = t3lib_div::getUserObj($classRef);
-                               if(is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render'))   {
+                               if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render'))  {
                                        if ($browserRenderObj->isValid($this->mode, $this)) {
+                                               $browserRenderObj->readOnly = $this->readOnly;
                                                $this->content .=  $browserRenderObj->render($this->mode, $this);
                                                $browserRendered = true;
                                                break;
@@ -106,39 +98,15 @@ class tx_rtehtmlarea_SC_browse_links {
                                }
                        }
                }
-
-                       // if type was not rendered use default rendering functions
-               if(!$browserRendered) {
-
-                       $SOBE->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links');
-                       $SOBE->browser->init();
-                       if ($browser_readOnly) {
-                               $SOBE->browser->readOnly = true;        
-                       }
-                       
-                       $modData = $BE_USER->getModuleData('browse_links.php','ses');
-                       list($modData, $store) = $SOBE->browser->processSessionData($modData);
-                       $BE_USER->pushModuleData('browse_links.php',$modData);
-                       
-                       
-                       
-                       
-                                                       // Output the correct content according to $this->mode
-                       switch((string)$this->mode)     {
-                               case 'rte':
-                                       $this->content = $SOBE->browser->main_rte();
-                               break;
-                               case 'db':
-                                       $this->content = $SOBE->browser->main_db();
-                               break;
-                               case 'file':
-                               case 'filedrag':
-                                       $this->content = $SOBE->browser->main_file();
-                               break;
-                               case 'wizard':
-                                       $this->content = $SOBE->browser->main_rte(1);
-                               break;
-                       }
+                       // If type was not rendered, use default rendering functions
+               if (!$browserRendered) {
+                       $GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_browse_links');
+                       $GLOBALS['SOBE']->browser->readOnly = $this->readOnly;
+                       $GLOBALS['SOBE']->browser->init();
+                       $modData = $GLOBALS['BE_USER']->getModuleData('browse_links.php','ses');
+                       list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
+                       $GLOBALS['BE_USER']->pushModuleData('browse_links.php',$modData);
+                       $this->content = $GLOBALS['SOBE']->browser->main_rte();
                }
        }
 
@@ -150,15 +118,13 @@ class tx_rtehtmlarea_SC_browse_links {
        function printContent() {
                echo $this->content;
        }
-
-
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/browse_links.php'])  {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod3/browse_links.php']);
 }
 
-// Make instance:
+       // Make instance:
 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_SC_browse_links');
 $SOBE->main();
 $SOBE->printContent();
index 07ec729..e53f902 100644 (file)
@@ -868,10 +868,8 @@ class tx_rtehtmlarea_select_image extends browse_links {
         * @return      string          the html content for the upload form
         */
        protected function insertUploadForm($folderPath) {
-               global $BE_USER;
-               
                $content = '';
-               if ($BE_USER->getTSConfigVal('options.uploadFieldsInTopOfEB')) {
+               if ($GLOBALS['BE_USER']->getTSConfigVal('options.uploadFieldsInTopOfEB') && !$this->readOnly && count($GLOBALS['FILEMOUNTS'])) {
                        $path = $folderPath;
                        $fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
                        $fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
@@ -886,7 +884,7 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                $uploadForm='';
                        }
                        $content .= $uploadForm;
-                       if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.createFoldersInEB')) {
+                       if ($GLOBALS['BE_USER']->isAdmin() || $GLOBALS['BE_USER']->getTSConfigVal('options.createFoldersInEB')) {
                                $content.=$createFolder;
                        }
                }
index 60147ec..cc037b1 100644 (file)
@@ -3,7 +3,7 @@
 *  Copyright notice
 *
 *  (c) 1999-2008 Kasper Skaarhoj (kasper@typo3.com)
-*  (c) 2004-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+*  (c) 2004-2008 Stanislas Rolland <typo3(arobas)jbr.ca>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -29,7 +29,7 @@
  * Displays image selector for the RTE
  *
  * @author     Kasper Skaarhoj <kasper@typo3.com>
- * @author     Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
+ * @author     Stanislas Rolland <typo3(arobas)jbr.ca>
  *
  * $Id$  *
  */
@@ -52,43 +52,35 @@ $LANG->includeLLFile('EXT:rtehtmlarea/htmlarea/locallang_dialogs.xml');
  * @subpackage core
  */
 class tx_rtehtmlarea_SC_select_image {
-       var $mode;
-       var $button = 'image';
+       public $mode = 'rte';
+       public $button = 'image';
+       public $readOnly = false;
+       protected $content = '';
 
        /**
-        * Main function, detecting the current mode of the element browser and branching out to internal methods.
+        * Main function, rendering the element browser in RTE mode.
         *
         * @return      void
         */
        function main() {
-               global $BE_USER, $SOBE;
-
-
-               $this->mode = t3lib_div::_GP('mode');
-               if (!$this->mode)       {
-                       $this->mode = 'rte';
-               }
-
-               $this->content = '';
-
-               // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
+                       // Setting alternative browsing mounts (ONLY local to browse_links.php this script so they stay "read-only")
                $altMountPoints = trim($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.altElementBrowserMountPoints'));
                if ($altMountPoints) {
                        $altMountPoints = t3lib_div::trimExplode(',', $altMountPoints);
-                       foreach($altMountPoints as $filePathRelativeToFileadmindir)     {
+                       foreach ($altMountPoints as $filePathRelativeToFileadmindir) {
                                $GLOBALS['BE_USER']->addFileMount('', $filePathRelativeToFileadmindir, $filePathRelativeToFileadmindir, 1, 0);
                        }
                        $GLOBALS['FILEMOUNTS'] = $GLOBALS['BE_USER']->returnFilemounts();
-                       $browser_readOnly = true;
+                       $this->readOnly = true;
                }
-               
-                       // render type by user func
+                       // Rendering type by user function
                $browserRendered = false;
-               if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'])) {
                        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/browse_links.php']['browserRendering'] as $classRef) {
                                $browserRenderObj = t3lib_div::getUserObj($classRef);
-                               if(is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render'))   {
+                               if (is_object($browserRenderObj) && method_exists($browserRenderObj, 'isValid') && method_exists($browserRenderObj, 'render')) {
                                        if ($browserRenderObj->isValid($this->mode, $this)) {
+                                               $browserRenderObj->readOnly = $this->readOnly;
                                                $this->content .=  $browserRenderObj->render($this->mode, $this);
                                                $browserRendered = true;
                                                break;
@@ -96,20 +88,15 @@ class tx_rtehtmlarea_SC_select_image {
                                }
                        }
                }
-
-                       // if type was not rendered use default rendering functions
-               if(!$browserRendered) {
-
-                       $SOBE->browser = t3lib_div::makeInstance('tx_rtehtmlarea_select_image');
-                       $SOBE->browser->init();
-                       if ($browser_readOnly) {
-                               $SOBE->browser->readOnly = true;
-                       }
-                       $modData = $BE_USER->getModuleData('select_image.php','ses');
-                       list($modData, $store) = $SOBE->browser->processSessionData($modData);
-                       $BE_USER->pushModuleData('select_image.php',$modData);
-
-                       $this->content = $SOBE->browser->main_rte();
+                       // If type was not rendered, use default rendering functions
+               if (!$browserRendered) {
+                       $GLOBALS['SOBE']->browser = t3lib_div::makeInstance('tx_rtehtmlarea_select_image');
+                       $GLOBALS['SOBE']->browser->readOnly = $this->readOnly;
+                       $GLOBALS['SOBE']->browser->init();
+                       $modData = $GLOBALS['BE_USER']->getModuleData('select_image.php','ses');
+                       list($modData, $store) = $GLOBALS['SOBE']->browser->processSessionData($modData);
+                       $GLOBALS['BE_USER']->pushModuleData('select_image.php',$modData);
+                       $this->content = $GLOBALS['SOBE']->browser->main_rte();
                }
        }
 
@@ -121,16 +108,14 @@ class tx_rtehtmlarea_SC_select_image {
        function printContent() {
                echo $this->content;
        }
-
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/select_image.php'])  {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/mod4/select_image.php']);
 }
 
-// Make instance:
+       // Make instance:
 $SOBE = t3lib_div::makeInstance('tx_rtehtmlarea_SC_select_image');
 $SOBE->main();
 $SOBE->printContent();
-
 ?>