Added feature #13379: Introduced a Sprite Icon API to render icons from sprites ...
[Packages/TYPO3.CMS.git] / typo3 / class.filelistfoldertree.php
old mode 100755 (executable)
new mode 100644 (file)
index 29ea45d..1847791
@@ -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
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
-
-require_once (PATH_t3lib.'class.t3lib_foldertree.php');
-
-
-
 /**
  * Extension class for the t3lib_filetree class, needed for drag and drop and ajax functionality
  *
@@ -138,7 +133,7 @@ class filelistFolderTree extends t3lib_folderTree {
 
                $out = '
                        <!-- TYPO3 folder tree structure. -->
-                       <ul class="tree">
+                       <ul class="tree" id="treeRoot">
                ';
                $titleLen=intval($this->BE_USER->uc['titleLen']);
                if (!is_array($treeArr))        $treeArr=$this->tree;
@@ -174,7 +169,7 @@ class filelistFolderTree extends t3lib_folderTree {
                        // if this item is the start of a new level,
                        // then a new level <ul> is needed, but not in ajax mode
                        if($v['isFirst'] && !($doCollapse) && !($doExpand && $expandedFolderUid == $uid))       {
-                               $itemHTML = "<ul>\n";
+                               $itemHTML = "</div><ul>\n";
                        }
 
                        // add CSS classes to the list item
@@ -182,12 +177,12 @@ class filelistFolderTree extends t3lib_folderTree {
                        if($v['isLast']) { $classAttr = ($classAttr) ? ' last'  : 'last';        }
 
                        $itemHTML .='
-                               <li id="'.$idAttr.'"'.($classAttr ? ' class="'.$classAttr.'"' : '').'>'.
+                               <li id="'.$idAttr.'"'.($classAttr ? ' class="'.$classAttr.'"' : '').'><div class="treeLinkItem">'.
                                        $v['HTML'].
                                        $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$v['bank']);
 
 
-                       if(!$v['hasSub']) { $itemHTML .= "</li>\n"; }
+                       if(!$v['hasSub']) { $itemHTML .= "</div></li>\n"; }
 
                        // we have to remember if this is the last one
                        // on level X so the last child on level X+1 closes the <ul>-tag
@@ -298,6 +293,7 @@ class filelistFolderTree extends t3lib_folderTree {
 
                        // Traverse mounts:
                foreach($this->MOUNTS as $key => $val)  {
+                       $hasSub = false;
                        $specUID = t3lib_div::md5int($val['path']);
                        $this->specUIDmap[$specUID] = $val['path'];
 
@@ -333,8 +329,12 @@ class filelistFolderTree extends t3lib_folderTree {
                        $row['path']  = $val['path'];
                        $row['title'] = $val['name'];
 
+                               // hasSub is true when the root of the mount is expanded
+                       if ($isOpen) {
+                               $hasSub = true;
+                       }
                                // Add the root of the mount to ->tree
-                       $this->tree[] = array('HTML' => $firstHtml, 'row' => $row, 'bank' => $this->bank);
+                       $this->tree[] = array('HTML' => $firstHtml, 'row' => $row, 'bank' => $this->bank, 'hasSub' => $hasSub);
 
                                // If the mount is expanded, go down:
                        if ($isOpen)
@@ -375,7 +375,7 @@ class filelistFolderTree extends t3lib_folderTree {
                        end($this->tree);
                        $treeKey = key($this->tree);    // Get the key for this space
 
-                       $val = ereg_replace('^\./','',$val);
+                       $val = preg_replace('/^\.\//','',$val);
                        $title = $val;
                        $path = $files_path.$val.'/';
 
@@ -406,10 +406,17 @@ class filelistFolderTree extends t3lib_folderTree {
                                $HTML = $this->PMicon($row,$a,$c,$nextCount,$exp);
 
                                $webpath = t3lib_BEfunc::getPathType_web_nonweb($path);
+
+                               if (is_writable($path)) {
+                                       $type = '';
+                               } else {
+                                       $type = 'readonly';
+                               }
+
                                $icon = 'gfx/i/_icon_' .$webpath . 'folders' . ($type == 'readonly' ? '_ro' : '') . '.gif';
                                if ($val == '_temp_')   {
                                        $icon = 'gfx/i/sysf.gif';
-                                       $row['title'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true); 
+                                       $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_')       {