Added a $ sign at the end of the regular expression and fixed indenting in the new...
[Packages/TYPO3.CMS.git] / typo3 / class.file_list.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 *  All rights reserved
7 *
8 *  This script is part of the TYPO3 project. The TYPO3 project is
9 *  free software; you can redistribute it and/or modify
10 *  it under the terms of the GNU General Public License as published by
11 *  the Free Software Foundation; either version 2 of the License, or
12 *  (at your option) any later version.
13 *
14 *  The GNU General Public License can be found at
15 *  http://www.gnu.org/copyleft/gpl.html.
16 *  A copy is found in the textfile GPL.txt and important notices to the license
17 *  from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 *  This script is distributed in the hope that it will be useful,
21 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 *  GNU General Public License for more details.
24 *
25 *  This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28  * Include file extending t3lib_recordList
29  *
30  * $Id$
31  * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32  *
33  * @author      Kasper Skaarhoj <kasperYYYY@typo3.com>
34  */
35 /**
36  * [CLASS/FUNCTION INDEX of SCRIPT]
37  *
38  *
39  *
40  *   75: class fileList extends t3lib_recordList
41  *  112:     function start($path,$pointer,$sort,$sortRev,$clipBoard=0)
42  *  133:     function generateList()
43  *  146:     function writeTop($path)
44  *  204:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
45  *  218:     function getTable($files,$dirs,$rowlist)
46  *  306:     function formatDirList($items)
47  *  372:     function linkWrapDir($code,$path)
48  *  391:     function linkWrapFile($code,$path)
49  *  406:     function listURL()
50  *  416:     function dirData($theFile)
51  *  441:     function formatFileList($items)
52  *  518:     function isImage($ext)
53  *  530:     function linkWrapSort($code,$path,$col)
54  *  548:     function readDirectory($path,$type,$extList='')
55  *  602:     function makeClip($theData)
56  *  647:     function makeRef($theData)
57  *
58  * TOTAL FUNCTIONS: 16
59  * (This index is automatically created/updated by the extension "extdeveval")
60  *
61  */
62
63
64
65
66
67
68 /**
69  * Class for rendering of File>Filelist
70  *
71  * @author      Kasper Skaarhoj <kasperYYYY@typo3.com>
72  * @package TYPO3
73  * @subpackage core
74  */
75 class fileList extends t3lib_recordList {
76         var $iLimit = 40;                                       // default Max items shown
77         var $thumbs = 0;                                        // Boolean. Thumbnails on records containing files (pictures)
78         var $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
79         var $fixedL = 30;                                       // Max length of strings
80         var $script = 'file_list.php';
81         var $clickMenus=1;                                      // If true click menus are generated on files and folders
82
83         var $sort = '';                                         // The field to sort by...
84         var $sortRev = 1;                                       // Reverse sorting flag
85         var $firstElementNumber=0;
86         var $clipBoard = 0;
87
88                 // internal
89         var $JScode = '';
90         var $HTMLcode = '';
91         var $totalbytes=0;
92         var $dirs = Array();
93         var $files = Array();
94         var $path = '';
95         var $eCounter=0;                                        // Counting the elements no matter what...
96         var $totalItems='';
97
98         var $CBnames=array();
99
100
101
102         /**
103          * Initialization of class
104          *
105          * @param       string          The path to list
106          * @param       integer         Pointer
107          * @param       boolean         Sorting column
108          * @param       boolean         Sorting direction
109          * @param       boolean         Show clipboard flag
110          * @return      void
111          */
112         function start($path,$pointer,$sort,$sortRev,$clipBoard=0)      {
113                 $this->counter=0;
114                 $this->totalbytes=0;
115                 $this->JScode='';
116                 $this->HTMLcode='';
117                 $this->path = $path;
118                 $this->sort=$sort;
119                 $this->sortRev=$sortRev;
120                 $this->firstElementNumber=$pointer;
121                 $this->clipBoard = $clipBoard;
122
123                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
124                         $this->thumbScript='gfx/notfound_thumb.gif';
125                 }
126         }
127
128         /**
129          * Reading files and directories, counting elements and generating the list in ->HTMLcode
130          *
131          * @return      void
132          */
133         function generateList() {
134                 $this->dirs = $this->readDirectory($this->path,'dir,link');
135                 $this->files = $this->readDirectory($this->path,'file');
136                 $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
137                 $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw,_REF_');
138         }
139
140         /**
141          * Make the top of the list
142          *
143          * @param       string          The path to list.
144          * @return      void
145          */
146         function writeTop($path)        {
147                         // Makes the code for the foldericon in the top
148                 $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
149
150                 if ($path)      {
151                         $out='';
152                         $theFile = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($path);
153                         $root = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($theFile['path']);
154                         $titleCol='path';
155                         $this->fieldArray = Array($titleCol,'up');
156
157                         list($title,$icon,$path) =  $this->dirData($theFile);
158
159                                 // Start compiling the HTML
160                         $theData = Array();
161                         $theData[$titleCol] = $this->widthGif;
162
163                         $title = $GLOBALS['SOBE']->basicFF->blindPath($path);
164                         $theData['up']='<a href="'.htmlspecialchars($this->listURL()).'">'.
165                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/refresh_n.gif','width="14" height="14"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'.
166                                         '</a>';
167
168                         if ($root)      {
169                                         // The icon with link
170                                 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
171                                 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
172
173                                 $theData[$titleCol].='<br />'.t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20));      // No HTML specialchars here - HTML like <b> </b> is allowed
174                                 $theData['up'].=$this->linkWrapDir('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/folder_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />',$theFile['path']);
175                         } else {
176                                         // root:0
177                                 $theIcon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_ftp.gif','width="18" height="16"').' alt="" />';
178                                 $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20)));
179                         }
180
181                                 // Adding top element
182                         $out.=$this->addelement(1,'',$theData,'','',$theIcon);
183
184                         $this->HTMLcode.='
185
186                 <!--
187                         Page header for file list
188                 -->
189                                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-filelist-top">
190                                         '.$out.'
191                                 </table>';
192                 }
193         }
194
195         /**
196          * Wrapping input string in a link with clipboard command.
197          *
198          * @param       string          String to be linked - must be htmlspecialchar'ed / prepared before.
199          * @param       string          table - NOT USED
200          * @param       string          "cmd" value
201          * @param       string          Warning for JS confirm message
202          * @return      string          Linked string
203          */
204         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
205                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.submit();';
206                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
207                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">'.$string.'</a>';
208         }
209
210         /**
211          * Returns a table with directories and files listed.
212          *
213          * @param       array           Array of files from path
214          * @param       array           Array of directories from path
215          * @param       string          List of rows to display horizontallyh
216          * @return      string          HTML-table
217          */
218         function getTable($files,$dirs,$rowlist)        {
219                         // Adds the code of files/dirs
220                 $out='';
221                 $titleCol = 'file';
222
223                         // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
224                 $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
225                 $rowlist = t3lib_div::uniqueList($rowlist);
226                 $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
227                 if ($this->clipBoard)   $rowlist.=',_CLIPBOARD_';
228                 $this->fieldArray = explode(',',$rowlist);
229
230                         // half line is drawn
231                 $theData = Array();
232                 $theData[$titleCol] = $this->widthGif;
233                 $out.=$this->addelement(0,'',$theData,'');
234
235
236
237                         // Directories are added
238                 $iOut = '';
239                 $iOut.= $this->formatDirList($dirs);
240
241                 if (count($dirs['sorting']))    {
242                                 // half line is drawn
243                         $theData = Array();
244                         $theData[$titleCol] = '';
245                         $iOut.=$this->addelement(0,'',$theData);
246                 }
247
248
249
250                         // Files are added
251                 $iOut.= $this->formatFileList($files,$titleCol);
252
253                         // Header line is drawn
254                 $theData = Array();
255                 reset($this->fieldArray);
256                 while(list(,$v)=each($this->fieldArray))        {
257                         if ($v=='_CLIPBOARD_')  {
258                                 $cells=array();
259                                 $table='_FILE';
260                                 $elFromTable = $this->clipObj->elFromTable($table);
261                                 if (count($elFromTable))        {
262                                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$this->path)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$this->path,'into',$elFromTable)).'">'.
263                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_paste',1).'" alt="" /></a>';
264                                 }
265                                 if ($this->clipObj->current!='normal' && $iOut) {
266                                         $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_selectMarked',1).'" alt="" />',$table,'setCB');
267                                         $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_deleteMarked',1).'" alt="" />',$table,'delete',$GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'));
268                                         $onClick = 'checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;';
269                                         $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
270                                                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_markRecords',1).'" alt="" />'.
271                                                         '</a>';
272                                 }
273
274                                 $theData[$v] = implode('',$cells);
275                         } else {        // Normal row:
276                                 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
277                                 $theData[$v] = $theT;
278                         }
279                 }
280                 $out.=$this->addelement(1,'',$theData,' class="c-headLine"','');
281                 $out.=$iOut;
282
283                         // half line is drawn
284                 $theData = Array();
285                 $theData[$titleCol] = $this->counter.' File(s), '.t3lib_div::formatSize($this->totalbytes).'bytes';
286                 $out.=$this->addelement(1,'',$theData);
287
288                         // finish
289                 return '
290
291
292                 <!--
293                         File list table:
294                 -->
295                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-filelist">
296                                 '.$out.'
297                         </table>';
298         }
299
300         /**
301          * This returns tablerows for the directories in the array $items['sorting'].
302          *
303          * @param       array           Directory items
304          * @return      string          HTML table rows.
305          */
306         function formatDirList($items)  {
307                 $out='';
308
309                         // Files:
310                 if (count($items['sorting']))   {
311                         reset($items['sorting']);
312                         while (list($key,) = each($items['sorting']))   {
313                                 list($flag,$code) = $this->fwd_rwd_nav();
314                                 $out.=$code;
315                                 if ($flag)      {
316                                                 // Initialization
317                                         $theFile = $items['files'][$key];
318                                         $this->counter++;
319
320                                         list($title,$icon,$path) =  $this->dirData($theFile);
321
322                                                 // The icon with link
323                                         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
324                                         if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
325
326                                                 //      Preparing and getting the data-array
327                                         $theData = Array();
328                                         reset($this->fieldArray);
329                                         while(list(,$field)=each($this->fieldArray))    {
330                                                 switch($field)  {
331                                                         case 'size':
332         //                                                      $theData[$field]=t3lib_div::formatSize($theFile[$field]);
333                                                         break;
334                                                         case 'rw':
335                                                                 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writable'])?'':'<span class="typo3-red"><b>W</b></span>');
336                                                         break;
337                                                         case 'fileext':
338         //                                                      $theData[$field]=strtoupper($theFile['fileext']);
339                                                         break;
340                                                         case 'tstamp':
341                                                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile['tstamp']);
342                                                         break;
343                                                         case 'file':
344                                                                 $theData[$field]= $this->linkWrapDir($title,$path);
345                                                         break;
346                                                         case '_CLIPBOARD_':
347                                                                 $theData[$field]=$this->makeClip($theFile);
348                                                         break;
349                                                         case '_REF_':
350                                                                 $theData[$field]=$this->makeRef($theFile);
351                                                         break;
352                                                         default:
353                                                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
354                                                         break;
355                                                 }
356                                         }
357                                         $out.=$this->addelement(1,$theIcon,$theData);
358                                 }
359                                 $this->eCounter++;
360                         }
361                 }
362                 return $out;
363         }
364
365         /**
366          * Wraps the directory-titles
367          *
368          * @param       string          String to be wrapped in links
369          * @param       string          ID (path)
370          * @return      string          HTML
371          */
372         function linkWrapDir($code,$path)       {
373                 $href = $this->script.'?id='.rawurlencode($path);
374                 $onclick = ' onclick="'.htmlspecialchars('top.content.nav_frame.hilight_row("file","folder'.t3lib_div::md5int($path).'_"+top.fsMod.currentBank)').'"';
375
376                         // Sometimes $code contains plain HTML tags. In such a case the string should not be modified!
377                 if(!strcmp($code,strip_tags($code)))    {
378                         return '<a href="'.htmlspecialchars($href).'"'.$onclick.' title="'.htmlspecialchars($code).'">'.t3lib_div::fixed_lgd($code,$this->fixedL).'</a>';
379                 } else  {
380                         return '<a href="'.htmlspecialchars($href).'"'.$onclick.'>'.$code.'</a>';
381                 }
382         }
383
384         /**
385          * Wraps filenames in links which opens them in a window IF they are in web-path.
386          *
387          * @param       string          String to be wrapped in links
388          * @param       string          ID (path)
389          * @return      string          HTML
390          */
391         function linkWrapFile($code,$path)      {
392
393                 if (t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')))    {
394                         $href = substr($path,strlen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')));
395                         $aOnClick = "return top.openUrlInWindow('".$href."','WebFile');";
396                         $code = '<a href="#" title="'.htmlspecialchars($code).'" onclick="'.htmlspecialchars($aOnClick).'">'.t3lib_div::fixed_lgd($code,$this->fixedL).'</a>';
397                 }
398                 return $code;
399         }
400
401         /**
402          * Returns list URL; This is the URL of the current script with id and imagemode parameters, thats all.
403          *
404          * @return      string          URL
405          */
406         function listURL()      {
407                 return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
408         }
409
410         /**
411          * Returns some data specific for the directories...
412          *
413          * @param       array           File information array
414          * @return      array           (title, icon, path)
415          */
416         function dirData($theFile)      {
417                 $path = $theFile['path'].$theFile['file'].'/';
418                 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
419
420                 $title=htmlspecialchars($theFile['file']);
421                 $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
422                 if ($title=='_temp_')   {
423                         $icon = 'gfx/i/sysf.gif';
424                         $title='<b>TEMP</b>';
425                 }
426                 if ($title=='_recycler_')       {
427                         $icon = 'gfx/i/recycler.gif';
428                         $title='<b>RECYCLER</b>';
429                 }
430                 $icon = $theFile['writable'] ? 'gfx/i/_icon_'.$webpath.'folders_ro.gif' : $icon;
431
432                 return Array($title,$icon,$path);
433         }
434
435         /**
436          * This returns tablerows for the files in the array $items['sorting'].
437          *
438          * @param       array           File items
439          * @return      string          HTML table rows.
440          */
441         function formatFileList($items) {
442                 $out='';
443
444                         // Files:
445                 if (count($items['sorting']))   {
446                         reset($items['sorting']);
447                         while (list($key,) = each($items['sorting']))   {
448                                 list($flag,$code) = $this->fwd_rwd_nav();
449                                 $out.=$code;
450                                 if ($flag)      {
451                                                 // Initialization
452                                         $theFile = $items['files'][$key];
453                                         $this->counter++;
454
455                                         $this->totalbytes+=$theFile['size'];
456                                         $ext = $items['files'][$key][fileext];
457                                         $icon = t3lib_BEfunc::getFileIcon($ext);
458
459                                                 // The icon with link
460                                         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
461                                         if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
462
463                                                 //      Preparing and getting the data-array
464                                         $theData = Array();
465                                         reset($this->fieldArray);
466                                         while(list(,$field)=each($this->fieldArray))    {
467                                                 switch($field)  {
468                                                         case 'size':
469                                                                 $theData[$field]=t3lib_div::formatSize($theFile[$field]);
470                                                         break;
471                                                         case 'rw':
472                                                                 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writable'])?'':'<span class="typo3-red"><b>W</b></span>');
473                                                         break;
474                                                         case 'fileext':
475                                                                 $theData[$field]=strtoupper($theFile[$field]);
476                                                         break;
477                                                         case 'tstamp':
478                                                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
479                                                         break;
480                                                         case '_CLIPBOARD_':
481                                                                 $theData[$field]=$this->makeClip($theFile);
482                                                         break;
483                                                         case '_REF_':
484                                                                 $theData[$field]=$this->makeRef($theFile);
485                                                         break;
486                                                         case 'file':
487                                                                 $theData[$field] = $this->linkWrapFile($theFile[$field],$theFile['path'].$theFile['file']);
488                                                         break;
489                                                         default:
490                                                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
491                                                         break;
492                                                 }
493                                         }
494                                         $out.= $this->addelement(1,$theIcon,$theData);
495
496                                                 // Thumbsnails?
497                                         if ($this->thumbs && $this->isImage($theFile['fileext']))       {
498                                                 $thumbData = array();
499                                                 $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
500                                                 $titleCol = $this->fieldArray[0];
501
502                                                 $theFile_abs = $theFile['path'].$theFile['file'];
503                                                 $check = basename($theFile_abs).':'.filemtime($theFile_abs).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
504                                                 $params = '&file='.$theFile_R;
505                                                 $params.= '&md5sum='.t3lib_div::shortMD5($check);
506                                                 $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
507
508                                                 $thumbData[$titleCol]='<img src="'.htmlspecialchars($href).'" hspace="2" title="'.htmlspecialchars(trim($theFile['file'])).'" alt="" />';
509                                                 $out.= $this->addelement(4,'',$thumbData);
510                                         }
511                                 }
512                                 $this->eCounter++;
513                         }
514                 }
515                 return $out;
516         }
517
518         /**
519          * Returns true if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
520          *
521          * @param       string          file extension
522          * @return      boolean
523          */
524         function isImage($ext)  {
525                 return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
526         }
527
528         /**
529          * Wraps the directory-titles ($code) in a link to file_list.php (id=$path) and sorting commands...
530          *
531          * @param       string          String to be wrapped
532          * @param       string          ID (path)
533          * @param       string          Sorting column
534          * @return      string          HTML
535          */
536         function linkWrapSort($code,$path,$col) {
537                 if ($this->sort==$col && !$this->sortRev)       {               // reverse sorting
538                         $params='&SET[sort]='.$col.'&SET[reverse]=1';
539                 } else {
540                         $params='&SET[sort]='.$col.'&SET[reverse]=0';
541                 }
542                 $href = $this->script.'?id='.rawurlencode($path).$params;
543                 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
544         }
545
546         /**
547          * Returns an array with file/dir items + an array with the sorted items
548          *
549          * @param       string          Path (absolute) to read
550          * @param       string          $type is the technical type; file,dir,link. empty is all kinds of stuff.
551          * @param       string          $extList: List of fileextensions to select. If empty, all are selected.
552          * @return      array           Array('files'=>array(), 'sorting'=>array());
553          */
554         function readDirectory($path,$type,$extList='') {
555                 $items = Array('files'=>array(), 'sorting'=>array());
556                 $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
557
558                 if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/'))       {
559                         $d = @dir($path);
560                         $tempArray=Array();
561                         if (is_object($d))      {
562                                 while($entry=$d->read()) {
563                                         if ($entry!='.' && $entry!='..')        {
564                                                 $wholePath = $path.'/'.$entry;          // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
565                                                 if (@file_exists($wholePath) && (!$type || t3lib_div::inList($type,filetype($wholePath))))      {
566                                                         if ($extList)   {
567                                                                 $fI = t3lib_div::split_fileref($entry);
568                                                                 if (t3lib_div::inList($extList,$fI['fileext'])) {
569                                                                         $tempArray[] = $wholePath;
570                                                                 }
571                                                         } else {
572                                                                 $tempArray[] = $wholePath;
573                                                         }
574                                                 }
575                                         }
576                                 }
577                                 $d->close();
578                         }
579                                 // Get fileinfo
580                         reset($tempArray);
581                         while (list(,$val)=each($tempArray))    {
582                                 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
583                                 $items['files'][] = $temp;
584                                 if ($this->sort)        {
585                                         $items['sorting'][] = strtoupper($temp[$this->sort]);
586                                 } else {
587                                         $items['sorting'][] = '';
588                                 }
589                         }
590                                 // Sort if required
591                         if ($this->sort)        {
592                                 if (!$this->sortRev)    {
593                                         asort($items['sorting']);
594                                 } else {
595                                         arsort($items['sorting']);
596                                 }
597                         }
598                 }
599                 return $items;
600         }
601
602         /**
603          * Creates the clipboard control pad
604          *
605          * @param       array           Array with information about the file/directory for which to make the clipboard panel for the listing.
606          * @return      string          HTML-table
607          */
608         function makeClip($theData)     {
609                 $cells=array();
610                 $fullIdent = $theData['path'].$theData['file'];
611                 $md5=t3lib_div::shortmd5($fullIdent);
612
613                         // For normal clipboard, add copy/cut buttons:
614                 if ($this->clipObj->current=='normal')  {
615                         $isSel = $this->clipObj->isSelected('_FILE',$md5);
616                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
617                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy'.($isSel=='copy'?'_h':'').'.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.copy',1).'" alt="" />'.
618                                                 '</a>';
619                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
620                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_cut'.($isSel=='cut'?'_h':'').'.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.cut',1).'" alt="" />'.
621                                                 '</a>';
622                 } else {        // For numeric pads, add select checkboxes:
623                         $n='_FILE|'.$md5;
624                         $this->CBnames[]=$n;
625
626                         $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked="checked"':'');
627                         $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" />'.
628                                         '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" class="smallCheckboxes"'.$checked.' />';
629                 }
630
631                         // Display PASTE button, if directory:
632                 $elFromTable = $this->clipObj->elFromTable('_FILE');
633                 if (@is_dir($fullIdent) && count($elFromTable)) {
634                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'">'.
635                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_pasteInto',1).'" alt="" />'.
636                                                 '</a>';
637                 }
638
639                         // Compile items into a DIV-element:
640                 return '                                                        <!-- CLIPBOARD PANEL: -->
641                                                                                         <div class="typo3-clipCtrl">
642                                                                                                 '.implode('
643                                                                                                 ',$cells).'
644                                                                                         </div>';
645         }
646
647         /**
648          * Make reference count
649          *
650          * @param       array           Array with information about the file/directory for which to make the clipboard panel for the listing.
651          * @return      string          HTML
652          */
653         function makeRef($theData)      {
654
655                         // First, fit path to match what is stored in the refindex:
656                 $fullIdent = $theData['path'].$theData['file'];
657
658                 if (t3lib_div::isFirstPartOfStr($fullIdent,PATH_site))  {
659                         $fullIdent = substr($fullIdent,strlen(PATH_site));
660                 }
661
662                         // Look up the path:
663                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
664                         '*',
665                         'sys_refindex',
666                         'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE','sys_refindex').
667                                 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($fullIdent,'sys_refindex').
668                                 ' AND deleted=0'
669                 );
670
671                         // Compile information for title tag:
672                 $infoData=array();
673                 if (is_array($rows)) {
674                         foreach($rows as $row)  {
675                                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
676                         }
677                 }
678
679                 return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$theData['path'].$theData['file'].'\', \'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
680         }
681 }
682
683
684
685 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc'])       {
686         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
687 }
688 ?>