Fixed bug #14202: htmlArea RTE: Tables may get lost when using remove format feature
[Packages/TYPO3.CMS.git] / typo3 / class.browse_links.php
old mode 100755 (executable)
new mode 100644 (file)
index d36b885..5584435
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  *
  */
 
-require_once (PATH_t3lib.'class.t3lib_browsetree.php');
-require_once (PATH_t3lib.'class.t3lib_foldertree.php');
-require_once (PATH_t3lib.'class.t3lib_stdgraphic.php');
-require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
-
 
        // Include classes
-require_once (PATH_t3lib.'class.t3lib_page.php');
-require_once (PATH_t3lib.'class.t3lib_recordlist.php');
 require_once (PATH_typo3.'/class.db_list.inc');
 require_once (PATH_typo3.'/class.db_list_extra.inc');
-require_once (PATH_t3lib.'/class.t3lib_pagetree.php');
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 
 
@@ -162,6 +139,7 @@ class TBE_browser_recordList extends localRecordList {
         * @return      void
         */
        function TBE_browser_recordList () {
+               parent::__construct();
                $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
        }
 
@@ -215,7 +193,7 @@ class TBE_browser_recordList extends localRecordList {
                if (!$code) {
                        $code = '<i>['.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title',1).']</i>';
                } else {
-                       $code = htmlspecialchars(t3lib_div::fixed_lgd_cs($code,$this->fixedL));
+                       $code = t3lib_BEfunc::getRecordTitlePrep($code, $this->fixedL);
                }
 
                $title = t3lib_BEfunc::getRecordTitle($table,$row,FALSE,TRUE);
@@ -260,6 +238,12 @@ class TBE_browser_recordList extends localRecordList {
 class localPageTree extends t3lib_browseTree {
 
        /**
+        * whether the page ID should be shown next to the title, activate through userTSconfig (options.pageTree.showPageIdWithTitle)
+        * @boolean
+        */
+       public $ext_showPageId = FALSE;
+
+       /**
         * Constructor. Just calling init()
         *
         * @return      void
@@ -377,8 +361,12 @@ class localPageTree extends t3lib_browseTree {
         * @param       array           The row for the current element
         * @return      string          The processed icon input value.
         */
-       function wrapIcon($icon,$row)   {
-               return $this->addTagAttributes($icon,' title="id='.$row['uid'].'"');
+       function wrapIcon($icon, $row) {
+               $content = $this->addTagAttributes($icon, ' title="id=' . $row['uid'] . '"');
+               if ($this->ext_showPageId) {
+                       $content .= '[' . $row['uid'] . ']&nbsp;';
+               }
+               return $content;
        }
 }
 
@@ -790,12 +778,18 @@ class browse_links {
                if (!$this->mode)       {
                        $this->mode = 'rte';
                }
+                       // Creating backend template object:
+               $this->doc = t3lib_div::makeInstance('template');
+               $this->doc->backPath = $GLOBALS['BACK_PATH'];
+                       // Load the Prototype library and browse_links.js
+               $this->doc->getPageRenderer()->loadPrototype();
+               $this->doc->loadJavascriptLib('js/browse_links.js');
 
                        // init hook objects:
                $this->hookObjects = array();
                if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
                        foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
-                               $processObject = &t3lib_div::getUserObj($classData);
+                               $processObject = t3lib_div::getUserObj($classData);
 
                                if(!($processObject instanceof t3lib_browseLinksHook)) {
                                        throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
@@ -812,15 +806,15 @@ class browse_links {
 
                        // the script to link to
                $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
-                       
+
                        // init fileProcessor
                $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
                $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
-               
-               
+
+
                        // CurrentUrl - the current link url must be passed around if it exists
                if ($this->mode == 'wizard')    {
-                       $currentLinkParts = t3lib_div::trimExplode(' ',$this->P['currentValue']);
+                       $currentLinkParts = t3lib_div::unQuoteFilenames($this->P['currentValue'], TRUE);
                        $initialCurUrlArray = array (
                                'href'   => $currentLinkParts[0],
                                'target' => $currentLinkParts[1],
@@ -889,14 +883,6 @@ class browse_links {
                        // Initializing the title value (RTE)
                $this->setTitle = ($this->curUrlArray['title'] != '-') ? $this->curUrlArray['title'] : '';
 
-                       // Creating backend template object:
-               $this->doc = t3lib_div::makeInstance('template');
-               $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');
-
                        // BEGIN accumulation of header JavaScript:
                $JScode = '
                                // This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
@@ -992,6 +978,14 @@ class browse_links {
                                                if (cur_title == "" && cur_class == "-") {
                                                        cur_class = "";
                                                }
+                                               cur_class = cur_class.replace(/[\'\"]/g, "");
+                                               if (cur_class.indexOf(" ") != -1) {
+                                                       cur_class = "\"" + cur_class + "\"";
+                                               }
+                                               cur_title = cur_title.replace(/(^\")|(\"$)/g, "");
+                                               if (cur_title.indexOf(" ") != -1) {
+                                                       cur_title = "\"" + cur_title + "\"";
+                                               }
                                                input = input + " " + cur_target + " " + cur_class + " " + cur_title;
                                                field.value = input;
                                                '.$update.'
@@ -1427,8 +1421,24 @@ class browse_links {
                        case 'page':
                                $pagetree = t3lib_div::makeInstance('rtePageTree');
                                $pagetree->thisScript = $this->thisScript;
+                               $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
                                $tree=$pagetree->getBrowsableTree();
                                $cElements = $this->expandPage();
+
+                               // Outputting Temporary DB mount notice:
+                               if (intval($GLOBALS['BE_USER']->getSessionData('pageTree_temporaryMountPoint')))        {
+                                       $link = '<a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('setTempDBmount' => 0))) . '">' .
+                                                                               $LANG->sl('LLL:EXT:lang/locallang_core.xml:labels.temporaryDBmount', 1) .
+                                                                       '</a>';
+                                       $flashMessage = t3lib_div::makeInstance(
+                                               't3lib_FlashMessage',
+                                               $link,
+                                               '',
+                                               t3lib_FlashMessage::INFO
+                                       );
+                                       $dbmount = $flashMessage->render();
+                               }
+
                                $content.= '
 
                        <!--
@@ -1436,7 +1446,7 @@ class browse_links {
                        -->
                                        <table border="0" cellpadding="0" cellspacing="0" id="typo3-linkPages">
                                                <tr>
-                                                       <td class="c-wCell" valign="top">'.$this->barheader($GLOBALS['LANG']->getLL('pageTree').':').$tree.'</td>
+                                                       <td class="c-wCell" valign="top">' . $this->barheader($GLOBALS['LANG']->getLL('pageTree') . ':') . $dbmount . $tree . '</td>
                                                        <td class="c-wCell" valign="top">'.$cElements.'</td>
                                                </tr>
                                        </table>
@@ -1574,6 +1584,7 @@ class browse_links {
                $pagetree->thisScript=$this->thisScript;
                $pagetree->ext_pArrPages = !strcmp($pArr[3],'pages')?1:0;
                $pagetree->ext_showNavTitle = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showNavTitle');
+               $pagetree->ext_showPageId = $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showPageIdWithTitle');
                $pagetree->addField('nav_title');
                $tree=$pagetree->getBrowsableTree();
 
@@ -1706,7 +1717,7 @@ class browse_links {
                        // Init variable:
                $parameters = explode('|', $this->bparams);
 
-               
+
                $path = $this->expandFolder;
                if (!$path || !@is_dir($path)) {
                                // The closest TEMP-path is found
@@ -2089,6 +2100,7 @@ class browse_links {
        function TBE_expandFolder($expandFolder=0,$extensionList='',$noThumbs=0)        {
                global $LANG;
 
+               $extensionList = ($extensionList == '*') ? '' : $extensionList;
                $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
                $out='';
                if ($expandFolder && $this->checkFolder($expandFolder)) {
@@ -2357,6 +2369,7 @@ class browse_links {
        function TBE_dragNDrop($expandFolder=0,$extensionList='')       {
                global $BACK_PATH;
 
+               $extensionList = ($extensionList == '*') ? '' : $extensionList;
                $expandFolder = $expandFolder ? $expandFolder : $this->expandFolder;
                $out='';
                if ($expandFolder && $this->checkFolder($expandFolder)) {
@@ -2483,7 +2496,7 @@ class browse_links {
         * @return      boolean         If the input path is found in PATH_site then it returns true.
         */
        function isWebFolder($folder)   {
-               $folder = ereg_replace('\/$','',$folder).'/';
+               $folder = rtrim($folder, '/').'/';
                return t3lib_div::isFirstPartOfStr($folder,PATH_site) ? TRUE : FALSE;
        }
 
@@ -2494,7 +2507,7 @@ class browse_links {
         * @return      boolean         If the input path is found in the backend users filemounts, then return true.
         */
        function checkFolder($folder)   {
-               return $this->fileProcessor->checkPathAgainstMounts(ereg_replace('\/$', '', $folder) . '/') ? true : false;
+               return $this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/') ? true : false;
        }
 
        /**
@@ -2504,7 +2517,7 @@ class browse_links {
         * @return      boolean         If the input path is found in the backend users filemounts and if the filemount is of type readonly, then return true.
         */
        function isReadOnlyFolder($folder) {
-               return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(ereg_replace('\/$', '', $folder) . '/')]['type'] == 'readonly');
+               return ($GLOBALS['FILEMOUNTS'][$this->fileProcessor->checkPathAgainstMounts(rtrim($folder, '/') . '/')]['type'] == 'readonly');
        }
 
        /**
@@ -2599,7 +2612,8 @@ class browse_links {
                                } else {        // URL is a page (id parameter)
                                        $uP=parse_url($rel);
                                        if (!trim($uP['path'])) {
-                                               $pp = explode('id=',$uP['query']);
+                                               $pp = preg_split('/^id=/', $uP['query']);
+                                               $pp[1] = preg_replace( '/&id=[^&]*/', '', $pp[1]);
                                                $parameters = explode('&', $pp[1]);
                                                $id = array_shift($parameters);
                                                if ($id)        {
@@ -2650,7 +2664,7 @@ class browse_links {
         */
        function uploadForm($path)      {
                global $BACK_PATH;
-               
+
                if ($this->isReadOnlyFolder($path)) return '';
 
                        // Read configuration of upload field count
@@ -2663,7 +2677,7 @@ class browse_links {
 
                        // Create header, showing upload path:
                $header = t3lib_div::isFirstPartOfStr($path,PATH_site)?substr($path,strlen(PATH_site)):$path;
-               $code=$this->barheader($GLOBALS['LANG']->getLL('uploadImage').':');
+               $code=$this->barheader($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle',1).':');
                $code.='
 
                        <!--
@@ -2713,9 +2727,9 @@ class browse_links {
         */
        function createFolder($path)    {
                global $BACK_PATH;
-               
+
                if ($this->isReadOnlyFolder($path)) return '';
-               
+
                        // Don't show Folder-create form if it's denied
                if ($GLOBALS['BE_USER']->getTSConfigVal('options.folderTree.hideCreateFolder')) {
                        return '';
@@ -2778,10 +2792,9 @@ class browse_links {
        }
 }
 
-// Include extension?
+
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php'])   {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.browse_links.php']);
 }
 
-
-?>
+?>
\ No newline at end of file