[BUGFIX] Ensure backwards compatibility in element browser
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / Browser / ElementBrowser.php
index a92f59c..b183b94 100644 (file)
@@ -262,9 +262,12 @@ class ElementBrowser {
        }
 
        /**
+        * Calculate path to this script.
+        * This method is public, to be used in hooks of this class only.
+        *
         * @return string
         */
-       protected function getThisScript() {
+       public function getThisScript() {
                return strpos($this->thisScript, '?') === FALSE ? $this->thisScript . '?' : $this->thisScript . '&';
        }
 
@@ -648,6 +651,9 @@ class ElementBrowser {
                // General "jumpToUrl" function:
                $JScode .= '
                        function jumpToUrl(URL,anchor) {        //
+                               if (URL.charAt(0) === \'?\') {
+                                       URL = ' . GeneralUtility::quoteJSvalue($this->getThisScript()) . ' + URL.substring(1);
+                               }
                                var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
                                var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
                                var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params'
@@ -893,37 +899,37 @@ class ElementBrowser {
                        $menuDef['page']['isActive'] = $this->act == 'page';
                        $menuDef['page']['label'] = $GLOBALS['LANG']->getLL('page', TRUE);
                        $menuDef['page']['url'] = '#';
-                       $menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=page') . ');return false;"';
+                       $menuDef['page']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=page') . ');return false;"';
                }
                if (in_array('file', $allowedItems)) {
                        $menuDef['file']['isActive'] = $this->act == 'file';
                        $menuDef['file']['label'] = $GLOBALS['LANG']->getLL('file', TRUE);
                        $menuDef['file']['url'] = '#';
-                       $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=file') . ');return false;"';
+                       $menuDef['file']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=file') . ');return false;"';
                }
                if (in_array('folder', $allowedItems)) {
                        $menuDef['folder']['isActive'] = $this->act == 'folder';
                        $menuDef['folder']['label'] = $GLOBALS['LANG']->getLL('folder', TRUE);
                        $menuDef['folder']['url'] = '#';
-                       $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=folder') . ');return false;"';
+                       $menuDef['folder']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=folder') . ');return false;"';
                }
                if (in_array('url', $allowedItems)) {
                        $menuDef['url']['isActive'] = $this->act == 'url';
                        $menuDef['url']['label'] = $GLOBALS['LANG']->getLL('extUrl', TRUE);
                        $menuDef['url']['url'] = '#';
-                       $menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=url') . ');return false;"';
+                       $menuDef['url']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=url') . ');return false;"';
                }
                if (in_array('mail', $allowedItems)) {
                        $menuDef['mail']['isActive'] = $this->act == 'mail';
                        $menuDef['mail']['label'] = $GLOBALS['LANG']->getLL('email', TRUE);
                        $menuDef['mail']['url'] = '#';
-                       $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=mail') . ');return false;"';
+                       $menuDef['mail']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=mail') . ');return false;"';
                }
                if (is_array($this->thisConfig['userLinks.']) && in_array('spec', $allowedItems)) {
                        $menuDef['spec']['isActive'] = $this->act == 'spec';
                        $menuDef['spec']['label'] = $GLOBALS['LANG']->getLL('special', TRUE);
                        $menuDef['spec']['url'] = '#';
-                       $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue($this->getThisScript() . 'act=spec') . ');return false;"';
+                       $menuDef['spec']['addParams'] = 'onclick="jumpToUrl(' . GeneralUtility::quoteJSvalue('?act=spec') . ');return false;"';
                }
                // Call hook for extra options
                foreach ($this->hookObjects as $hookObject) {