Fixed bug #9197: Misbehaviour of DAM media tab in htmlArea RTE link insertion dialogue
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 20 Aug 2008 02:18:13 +0000 (02:18 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 20 Aug 2008 02:18:13 +0000 (02:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4006 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php

index 7c11d07..ed2ecc2 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-08-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Follow-up for issue #9185: Incorrect initialization when hooks are present
+       * Fixed bug #9197: Misbehaviour of DAM media tab in htmlArea RTE link insertion dialogue
 
 2008-08-18  Stanislas Rolland  <typo3@sjbr.ca>
 
index 9a9afc8..1e3c1fb 100644 (file)
@@ -1,6 +1,7 @@
 2008-08-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Follow-up for issue #9185: Incorrect initialization when hooks are present
+       * Fixed bug #9197: Misbehaviour of DAM media tab in htmlArea RTE link insertion dialogue
 
 2008-08-18  Stanislas Rolland  <typo3@sjbr.ca>
 
index 36a02d3..56fa857 100644 (file)
@@ -220,7 +220,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
         * @return      void
         */
        function init() {
-               global $BACK_PATH,$LANG,$TYPO3_CONF_VARS;
+               global $BACK_PATH,$LANG;
 
                $this->initVariables();
                $this->initConfiguration();
@@ -314,9 +314,128 @@ class tx_rtehtmlarea_browse_links extends browse_links {
 
                        // Creating backend template object:
                $this->doc = t3lib_div::makeInstance('template');
-               $this->doc->bodyTagAdditions = 'onLoad="initDialog();"';
+               $this->doc->bodyTagAdditions = $this->getBodyTagAdditions();
                $this->doc->backPath = $BACK_PATH;
 
+                       // Load the Prototype library and browse_links.js
+               $this->doc->loadJavascriptLib('contrib/prototype/prototype.js');
+               $this->doc->loadJavascriptLib('js/browse_links.js');
+
+               $this->doc->getContextMenuCode();
+       }
+       
+       /**
+        * Initialize class variables
+        *
+        * @return      void
+        */
+       public function initVariables() {
+               
+                       // Process bparams
+               $this->bparams = t3lib_div::_GP('bparams');
+               $pArr = explode('|', $this->bparams);
+               $pRteArr = explode(':', $pArr[1]);
+               $this->editorNo = $pRteArr[0];
+               $this->contentTypo3Language = $pRteArr[1];
+               $this->contentTypo3Charset = $pRteArr[2];
+               $this->RTEtsConfigParams = $pArr[2];
+               if (!$this->editorNo) {
+                       $this->editorNo = t3lib_div::_GP('editorNo');
+                       $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
+                       $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
+                       $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
+               }
+               $this->pointer = t3lib_div::_GP('pointer');
+               $this->expandPage = t3lib_div::_GP('expandPage');
+               $this->expandFolder = t3lib_div::_GP('expandFolder');
+               $this->P = t3lib_div::_GP('P');
+               $this->PM = t3lib_div::_GP('PM');
+               $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
+               $pArr[2] = $this->RTEtsConfigParams;
+               $this->bparams = implode('|', $pArr);
+               
+                       // Find "mode"
+               $this->mode = t3lib_div::_GP('mode');
+               if (!$this->mode)       {
+                       $this->mode = 'rte';
+               }
+                       // Current site url
+               $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
+               
+                       // the script to link to
+               $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
+       }
+       
+       /**
+        * Initializes the configuration variables
+        *
+        * @return      void
+        */
+        public function initConfiguration() {
+               $this->thisConfig = $this->getRTEConfig();
+               $this->buttonConfig = $this->getButtonConfig('link');
+        }
+        
+       /**
+        * Get the RTE configuration from Page TSConfig
+        *
+        * @return      array           RTE configuration array
+        */
+       protected function getRTEConfig()       {
+               global $BE_USER;
+               
+               $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
+               $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
+               $this->RTEProperties = $RTEsetup['properties'];
+               return t3lib_BEfunc::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
+       }
+       
+       /**
+        * Get the configuration of the button
+        *
+        * @param       string          $buttonName: the name of the button
+        * @return      array           the configuration array of the image button
+        */
+       protected function getButtonConfig($buttonName) {
+               return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName.'.'])) ? $this->thisConfig['buttons.'][$buttonName.'.'] : array());
+       }
+       
+       /**
+        * Initialize hook objects implementing interface t3lib_browseLinksHook
+        * @param       string          $hookKey: the hook key
+        * @return      void
+        */
+       protected function initHookObjects($hookKey) {
+               global $TYPO3_CONF_VARS;
+               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
+                       foreach ($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
+                               $processObject = &t3lib_div::getUserObj($classData);
+                               if(!($processObject instanceof t3lib_browseLinksHook)) {
+                                       throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
+                               }
+                               $parameters = array();
+                               $processObject->init($this, $parameters);
+                               $this->hookObjects[] = $processObject;
+                       }
+               }
+       }
+       
+       /**
+        * Provide the additional parameters to be included in the template body tag
+        *
+        * @return      string          the body tag additions
+        */
+       public function getBodyTagAdditions() {
+               return 'onLoad="initDialog();"';
+       }
+       
+       /**
+        * Generate JS code to be used on the link insert/modify dialogue
+        *
+        * @return      string          the generated JS code
+        */
+       function getJSCode()    {
+               global $BACK_PATH;
                        // BEGIN accumulation of header JavaScript:
                $JScode = '';
                $JScode.= '
@@ -467,104 +586,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                }
                        }
                ';
-                       // Finally, add the accumulated JavaScript to the template object:
-               $this->doc->JScode = $this->doc->wrapScriptTags($JScode);
-       }
-       
-       /**
-        * Initialize class variables
-        *
-        * @return      void
-        */
-       public function initVariables() {
-               
-                       // Process bparams
-               $this->bparams = t3lib_div::_GP('bparams');
-               $pArr = explode('|', $this->bparams);
-               $pRteArr = explode(':', $pArr[1]);
-               $this->editorNo = $pRteArr[0];
-               $this->contentTypo3Language = $pRteArr[1];
-               $this->contentTypo3Charset = $pRteArr[2];
-               $this->RTEtsConfigParams = $pArr[2];
-               if (!$this->editorNo) {
-                       $this->editorNo = t3lib_div::_GP('editorNo');
-                       $this->contentTypo3Language = t3lib_div::_GP('contentTypo3Language');
-                       $this->contentTypo3Charset = t3lib_div::_GP('contentTypo3Charset');
-                       $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
-               }
-               $this->pointer = t3lib_div::_GP('pointer');
-               $this->expandPage = t3lib_div::_GP('expandPage');
-               $this->expandFolder = t3lib_div::_GP('expandFolder');
-               $this->P = t3lib_div::_GP('P');
-               $this->PM = t3lib_div::_GP('PM');
-               $pArr[1] = implode(':', array($this->editorNo, $this->contentTypo3Language, $this->contentTypo3Charset));
-               $pArr[2] = $this->RTEtsConfigParams;
-               $this->bparams = implode('|', $pArr);
-               
-                       // Find "mode"
-               $this->mode = t3lib_div::_GP('mode');
-               if (!$this->mode)       {
-                       $this->mode = 'rte';
-               }
-                       // Current site url
-               $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
-               
-                       // the script to link to
-               $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
-       }
-       
-       /**
-        * Initializes the configuration variables
-        *
-        * @return      void
-        */
-        public function initConfiguration() {
-               $this->thisConfig = $this->getRTEConfig();
-               $this->buttonConfig = $this->getButtonConfig('link');
-        }
-        
-       /**
-        * Get the RTE configuration from Page TSConfig
-        *
-        * @return      array           RTE configuration array
-        */
-       protected function getRTEConfig()       {
-               global $BE_USER;
-               
-               $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
-               $RTEsetup = $BE_USER->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
-               $this->RTEProperties = $RTEsetup['properties'];
-               return t3lib_BEfunc::RTEsetup($this->RTEProperties, $RTEtsConfigParts[0],$RTEtsConfigParts[2],$RTEtsConfigParts[4]);
-       }
-       
-       /**
-        * Get the configuration of the button
-        *
-        * @param       string          $buttonName: the name of the button
-        * @return      array           the configuration array of the image button
-        */
-       protected function getButtonConfig($buttonName) {
-               return ((is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.'][$buttonName.'.'])) ? $this->thisConfig['buttons.'][$buttonName.'.'] : array());
-       }
-       
-       /**
-        * Initialize hook objects implementing interface t3lib_browseLinksHook
-        * @param       string          $hookKey: the hook key
-        * @return      void
-        */
-       protected function initHookObjects($hookKey) {
-               global $TYPO3_CONF_VARS;
-               if (is_array($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'])) {
-                       foreach ($TYPO3_CONF_VARS['SC_OPTIONS'][$hookKey]['browseLinksHook'] as $classData) {
-                               $processObject = &t3lib_div::getUserObj($classData);
-                               if(!($processObject instanceof t3lib_browseLinksHook)) {
-                                       throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195115652);
-                               }
-                               $parameters = array();
-                               $processObject->init($this, $parameters);
-                               $this->hookObjects[] = $processObject;
-                       }
-               }
+               return $JScode;
        }
        
        /******************************************************************
@@ -830,6 +852,8 @@ class tx_rtehtmlarea_browse_links extends browse_links {
 
                        // End page, return content:
                $content.= $this->doc->endPage();
+               $this->doc->JScodeArray['rtehtmlarea'] = $this->getJSCode();
+               $content = $this->doc->insertStylesAndJS($content);
                return $content;
        }