Fixed bug #11937: Do not show E_DEPRECATED messages on productive systems
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_foldertree.php
old mode 100755 (executable)
new mode 100644 (file)
index b0ae951..a09fc92
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2004 Kasper Skaarhoj (kasper@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
@@ -30,7 +30,7 @@
  * $Id$
  * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @coauthor   RenĂ© Fritz <r.fritz@colorcube.de>
  */
 /**
  *
  *
  *
- *   81: class t3lib_folderTree extends t3lib_treeView
- *   88:     function t3lib_folderTree()
- *  106:     function wrapIcon($icon,$row)
- *  126:     function getId($v)
- *  136:     function getJumpToParam($v)
- *  148:     function getTitleStr($row,$titleLen=30)
- *  158:     function getBrowsableTree()
- *  221:     function getFolderTree($files_path, $depth=999, $depthData='')
- *  301:     function getCount($files_path)
- *  317:     function initializePositionSaving()
+ *   82: class t3lib_folderTree extends t3lib_treeView
+ *   89:     function t3lib_folderTree()
+ *  107:     function wrapIcon($icon,$row)
+ *  130:     function wrapTitle($title,$row,$bank=0)
+ *  145:     function getId($v)
+ *  155:     function getJumpToParam($v)
+ *  167:     function getTitleStr($row,$titleLen=30)
+ *  177:     function getBrowsableTree()
+ *  240:     function getFolderTree($files_path, $depth=999, $depthData='')
+ *  320:     function getCount($files_path)
+ *  336:     function initializePositionSaving()
  *
- * TOTAL FUNCTIONS: 9
+ * TOTAL FUNCTIONS: 10
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
-require_once (PATH_t3lib.'class.t3lib_treeview.php');
 
 
 
@@ -72,7 +72,7 @@ require_once (PATH_t3lib.'class.t3lib_treeview.php');
 /**
  * Extension class for the t3lib_treeView class, specially made for browsing folders in the File module
  *
- * @author     Kasper Skaarhoj <kasper@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  * @coauthor   RenĂ© Fritz <r.fritz@colorcube.de>
  * @package TYPO3
  * @subpackage t3lib
@@ -111,19 +111,37 @@ class t3lib_folderTree extends t3lib_treeView  {
                if (!$this->ext_IconMode)       {
                        $theFolderIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theFolderIcon,$row['path'],'',0);
                } elseif (!strcmp($this->ext_IconMode,'titlelink'))     {
-                       $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'_'.$this->bank.'\');';
+                       $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$this->bank.');';
                        $theFolderIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theFolderIcon.'</a>';
                }
                return $theFolderIcon;
        }
 
        /**
+        * Wrapping $title in a-tags.
+        *
+        * @param       string          Title string
+        * @param       string          Item record
+        * @param       integer         Bank pointer (which mount point number)
+        * @return      string
+        * @access private
+        */
+       function wrapTitle($title,$row,$bank=0) {
+               $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
+               $CSM = '';
+               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'])       {
+                       $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('',$row['path'],'',0,'','',TRUE)).'"';
+               }
+               return '<a href="#" title="'.htmlspecialchars($row['title']).'" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
+       }
+
+       /**
         * Returns the id from the record - for folders, this is an md5 hash.
         *
         * @param       array           Record array
         * @return      integer         The "uid" field value.
         */
-       function getId($v) {
+       function getId($v)      {
                return t3lib_div::md5Int($v['path']);
        }
 
@@ -133,7 +151,7 @@ class t3lib_folderTree extends t3lib_treeView  {
         * @param       array           The record array.
         * @return      string          The jump-url parameter.
         */
-       function getJumpToParam($v) {
+       function getJumpToParam($v)     {
                return rawurlencode($v['path']);
        }
 
@@ -180,10 +198,19 @@ class t3lib_folderTree extends t3lib_treeView  {
                        $icon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif','width="18" height="16"').' alt="" />';
                        $firstHtml= $this->PM_ATagWrap($icon,$cmd);
 
-                       switch($val['type'])    {
-                               case 'user':    $icon = 'gfx/i/_icon_ftp_user.gif';     break;
-                               case 'group':   $icon = 'gfx/i/_icon_ftp_group.gif'; break;
-                               default:                $icon = 'gfx/i/_icon_ftp.gif'; break;
+                       switch ($val['type']) {
+                               case 'user':
+                                       $icon = 'gfx/i/_icon_ftp_user.gif';
+                                       break;
+                               case 'group':
+                                       $icon = 'gfx/i/_icon_ftp_group.gif';
+                                       break;
+                               case 'readonly':
+                                       $icon = 'gfx/i/_icon_ftp_readonly.gif';
+                                       break;
+                               default:
+                                       $icon = 'gfx/i/_icon_ftp.gif';
+                                       break;
                        }
 
                                // Preparing rootRec for the mount
@@ -200,7 +227,7 @@ class t3lib_folderTree extends t3lib_treeView  {
                        if ($isOpen)    {
                                        // Set depth:
                                $depthD='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/blank.gif','width="18" height="16"').' alt="" />';
-                               $this->getFolderTree($val['path'],999,$depthD);
+                               $this->getFolderTree($val['path'], 999, $depthD, $val['type']);
                        }
 
                                // Add tree:
@@ -218,7 +245,7 @@ class t3lib_folderTree extends t3lib_treeView  {
         * @return      integer         The count of items on the level
         * @see getBrowsableTree()
         */
-       function getFolderTree($files_path, $depth=999, $depthData='' {
+       function getFolderTree($files_path, $depth=999, $depthData='', $type='') {
 
                        // This generates the directory tree
                $dirs = t3lib_div::get_dirs($files_path);
@@ -238,7 +265,7 @@ class t3lib_folderTree extends t3lib_treeView  {
                                $treeKey = key($this->tree);    // Get the key for this space
                                $LN = ($a==$c)?'blank':'line';
 
-                               $val = ereg_replace('^\./','',$val);
+                               $val = preg_replace('/^\.\//','',$val);
                                $title = $val;
                                $path = $files_path.$val.'/';
                                $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
@@ -255,7 +282,8 @@ class t3lib_folderTree extends t3lib_treeView  {
                                        $nextCount=$this->getFolderTree(
                                                $path,
                                                $depth-1,
-                                               $this->makeHTML ? $depthData.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$LN.'.gif','width="18" height="16"').' alt="" />' : ''
+                                               $this->makeHTML ? $depthData.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$LN.'.gif','width="18" height="16"').' alt="" />' : '',
+                                               $type
                                        );
                                        $exp=1;         // Set "did expand" flag
                                } else {
@@ -267,16 +295,16 @@ class t3lib_folderTree extends t3lib_treeView  {
                                if ($this->makeHTML)    {
                                        $HTML=$depthData.$this->PMicon($row,$a,$c,$nextCount,$exp);
 
-                                       $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
+                                       $icon = 'gfx/i/_icon_' .$webpath . 'folders' . ($type == 'readonly' ? '_ro' : '') . '.gif';
                                        if ($val=='_temp_')     {
                                                $icon = 'gfx/i/sysf.gif';
-                                               $row['title']='TEMP';
-                                               $row['_title']='<b>TEMP</b>';
+                                               $row['title'] = $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true);
+                                               $row['_title'] = '<strong>' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true) . '</strong>';
                                        }
                                        if ($val=='_recycler_') {
                                                $icon = 'gfx/i/recycler.gif';
-                                               $row['title']='RECYCLER';
-                                               $row['_title']='<b>RECYCLER</b>';
+                                               $row['title'] = $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true);
+                                               $row['_title'] = '<strong>' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true) . '</strong>';
                                        }
                                        $HTML.=$this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' alt="" />',$row);
                                }
@@ -346,4 +374,5 @@ class t3lib_folderTree extends t3lib_treeView  {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php'])       {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']);
 }
+
 ?>
\ No newline at end of file