See four lines in changelog, 2004-05-18. Basically a lot of fixes for character set...
[Packages/TYPO3.CMS.git] / typo3 / class.file_list.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *
5 *  (c) 1999-2004 Kasper Skaarhoj (kasper@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 <kasper@typo3.com>
34  */
35 /**
36  * [CLASS/FUNCTION INDEX of SCRIPT]
37  *
38  *
39  *
40  *   74: class fileList extends t3lib_recordList
41  *  111:     function start($path,$pointer,$sort,$sortRev,$clipBoard=0)
42  *  132:     function generateList()
43  *  145:     function writeTop($path)
44  *  204:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
45  *  218:     function getTable($files,$dirs,$rowlist)
46  *  306:     function formatDirList($items)
47  *  369:     function linkWrapDir($code,$path)
48  *  381:     function linkWrapFile($code,$path)
49  *  395:     function listURL()
50  *  405:     function dirData($theFile)
51  *  430:     function formatFileList($items)
52  *  504:     function isImage($ext)
53  *  516:     function linkWrapSort($code,$path,$col)
54  *  534:     function readDirectory($path,$type,$extList='')
55  *  588:     function makeClip($theData)
56  *
57  * TOTAL FUNCTIONS: 15
58  * (This index is automatically created/updated by the extension "extdeveval")
59  *
60  */
61
62
63
64
65
66
67 /**
68  * Class for rendering of File>Filelist
69  *
70  * @author      Kasper Skaarhoj <kasper@typo3.com>
71  * @package TYPO3
72  * @subpackage core
73  */
74 class fileList extends t3lib_recordList {
75         var $iLimit = 40;                                       // default Max items shown
76         var $thumbs = 0;                                        // Boolean. Thumbnails on records containing files (pictures)
77         var $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
78         var $fixedL = 30;                                       // Max length of strings
79         var $script = 'file_list.php';
80         var $clickMenus=1;                                      // If true click menus are generated on files and folders
81
82         var $sort = '';                                         // The field to sort by...
83         var $sortRev = 1;                                       // Reverse sorting flag
84         var $firstElementNumber=0;
85         var $clipBoard = 0;
86
87                 // internal
88         var $JScode = '';
89         var $HTMLcode = '';
90         var $totalbytes=0;
91         var $dirs = Array();
92         var $files = Array();
93         var $path = '';
94         var $eCounter=0;                                        // Counting the elements no matter what...
95         var $totalItems='';
96
97         var $CBnames=array();
98
99
100
101         /**
102          * Initialization of class
103          *
104          * @param       string          The path to list
105          * @param       integer         Pointer
106          * @param       boolean         Sorting column
107          * @param       boolean         Sorting direction
108          * @param       boolean         Show clipboard flag
109          * @return      void
110          */
111         function start($path,$pointer,$sort,$sortRev,$clipBoard=0)      {
112                 $this->counter=0;
113                 $this->totalbytes=0;
114                 $this->JScode='';
115                 $this->HTMLcode='';
116                 $this->path = $path;
117                 $this->sort=$sort;
118                 $this->sortRev=$sortRev;
119                 $this->firstElementNumber=$pointer;
120                 $this->clipBoard = $clipBoard;
121
122                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
123                         $this->thumbScript='gfx/notfound_thumb.gif';
124                 }
125         }
126
127         /**
128          * Reading files and directories, counting elements and generating the list in ->HTMLcode
129          *
130          * @return      void
131          */
132         function generateList() {
133                 $this->dirs = $this->readDirectory($this->path,'dir,link');
134                 $this->files = $this->readDirectory($this->path,'file');
135                 $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
136                 $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw');
137         }
138
139         /**
140          * Make the top of the list
141          *
142          * @param       string          The path to list.
143          * @return      void
144          */
145         function writeTop($path)        {
146                         // Makes the code for the foldericon in the top
147                 $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
148
149                 if ($path)      {
150                         $out='';
151                         $this->counter++;
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,'',$this->leftMargin,$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,'',$this->leftMargin);
234
235
236
237                         // Directories are added
238                 $iOut = '';
239                 $iOut.= $this->formatDirList($dirs,$titleCol);
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.' Files, '.$GLOBALS['SOBE']->basicFF->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]=$GLOBALS['SOBE']->basicFF->formatSize($theFile[$field]);
333                                                         break;
334                                                         case 'rw':
335                                                                 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writeable'])?'':'<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(t3lib_div::fixed_lgd($title,$this->fixedL),$path);
345                                                         break;
346                                                         case '_CLIPBOARD_':
347                                                                 $theData[$field]=$this->makeClip($theFile);
348                                                         break;
349                                                         default:
350                                                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
351                                                         break;
352                                                 }
353                                         }
354                                         $out.=$this->addelement(1,$theIcon,$theData);
355                                 }
356                                 $this->eCounter++;
357                         }
358                 }
359                 return $out;
360         }
361
362         /**
363          * Wraps the directory-titles
364          *
365          * @param       string          String to be wrapped in links
366          * @param       string          ID (path)
367          * @return      string          HTML
368          */
369         function linkWrapDir($code,$path)       {
370                 $href = $this->script.'?id='.rawurlencode($path);
371                 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
372         }
373
374         /**
375          * Wraps filenames in links which opens them in a window IF they are in web-path.
376          *
377          * @param       string          String to be wrapped in links
378          * @param       string          ID (path)
379          * @return      string          HTML
380          */
381         function linkWrapFile($code,$path)      {
382                 if (t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')))    {
383                         $href = substr($path,strlen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')));
384                         $aOnClick = "return top.openUrlInWindow('".$href."','WebFile');";
385                         $code = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$code.'</a>';
386                 }
387                 return $code;
388         }
389
390         /**
391          * Returns list URL; This is the URL of the current script with id and imagemode parameters, thats all.
392          *
393          * @return      string          URL
394          */
395         function listURL()      {
396                 return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
397         }
398
399         /**
400          * Returns some data specific for the directories...
401          *
402          * @param       array           File information array
403          * @return      array           (title, icon, path)
404          */
405         function dirData($theFile)      {
406                 $path = $theFile['path'].$theFile['file'].'/';
407                 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
408
409                 $title=htmlspecialchars($theFile['file']);
410                 $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
411                 if ($title=='_temp_')   {
412                         $icon = 'gfx/i/sysf.gif';
413                         $title='<b>TEMP</b>';
414                 }
415                 if ($title=='_recycler_')       {
416                         $icon = 'gfx/i/recycler.gif';
417                         $title='<b>RECYCLER</b>';
418                 }
419                 $icon = $theFile['writable'] ? 'gfx/i/_icon_'.$webpath.'folders_ro.gif' : $icon;
420
421                 return Array($title,$icon,$path);
422         }
423
424         /**
425          * This returns tablerows for the files in the array $items['sorting'].
426          *
427          * @param       array           File items
428          * @return      string          HTML table rows.
429          */
430         function formatFileList($items) {
431                 $out='';
432
433                         // Files:
434                 if (count($items['sorting']))   {
435                         reset($items['sorting']);
436                         while (list($key,) = each($items['sorting']))   {
437                                 list($flag,$code) = $this->fwd_rwd_nav();
438                                 $out.=$code;
439                                 if ($flag)      {
440                                                 // Initialization
441                                         $theFile = $items['files'][$key];
442                                         $this->counter++;
443
444                                         $this->totalbytes+=$theFile['size'];
445                                         $ext = $items['files'][$key][fileext];
446                                         $icon = t3lib_BEfunc::getFileIcon($ext);
447
448                                                 // The icon with link
449                                         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
450                                         if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
451
452                                                 //      Preparing and getting the data-array
453                                         $theData = Array();
454                                         reset($this->fieldArray);
455                                         while(list(,$field)=each($this->fieldArray))    {
456                                                 switch($field)  {
457                                                         case 'size':
458                                                                 $theData[$field]=$GLOBALS['SOBE']->basicFF->formatSize($theFile[$field]);
459                                                         break;
460                                                         case 'rw':
461                                                                 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writeable'])?'':'<span class="typo3-red"><b>W</b></span>');
462                                                         break;
463                                                         case 'fileext':
464                                                                 $theData[$field]=strtoupper($theFile[$field]);
465                                                         break;
466                                                         case 'tstamp':
467                                                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
468                                                         break;
469                                                         case '_CLIPBOARD_':
470                                                                 $theData[$field]=$this->makeClip($theFile);
471                                                         break;
472                                                         case 'file':
473                                                                 $theData[$field] = $this->linkWrapFile(t3lib_div::fixed_lgd($theFile[$field],$this->fixedL),$theFile['path'].$theFile['file']);
474                                                         break;
475                                                         default:
476                                                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
477                                                         break;
478                                                 }
479                                         }
480                                         $out.=$this->addelement(1,$theIcon,$theData);
481
482                                                 // Thumbsnails?
483                                         if ($this->thumbs && $this->isImage($theFile['fileext']))       {
484                                                 $thumbData=Array();
485                                                 $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
486                                                 $titleCol=$this->fieldArray[0];
487                                                 $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.$theFile_R;
488                                                 $thumbData[$titleCol]='<img src="'.htmlspecialchars($href).'" hspace="2" title="'.htmlspecialchars(trim($theFile['file'])).'" alt="" />';
489                                                 $out.=$this->addelement(4,'',$thumbData);
490                                         }
491                                 }
492                                 $this->eCounter++;
493                         }
494                 }
495                 return $out;
496         }
497
498         /**
499          * Returns true if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
500          *
501          * @param       string          file extension
502          * @return      boolean
503          */
504         function isImage($ext)  {
505                 return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
506         }
507
508         /**
509          * Wraps the directory-titles ($code) in a link to file_list.php (id=$path) and sorting commands...
510          *
511          * @param       string          String to be wrapped
512          * @param       string          ID (path)
513          * @param       string          Sorting column
514          * @return      string          HTML
515          */
516         function linkWrapSort($code,$path,$col) {
517                 if ($this->sort==$col && !$this->sortRev)       {               // reverse sorting
518                         $params='&SET[sort]='.$col.'&SET[reverse]=1';
519                 } else {
520                         $params='&SET[sort]='.$col.'&SET[reverse]=0';
521                 }
522                 $href = $this->script.'?id='.rawurlencode($path).$params;
523                 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
524         }
525
526         /**
527          * Returns an array with file/dir items + an array with the sorted items
528          *
529          * @param       string          Path (absolute) to read
530          * @param       string          $type is the technical type; file,dir,link. empty is all kinds of stuff.
531          * @param       string          $extList: List of fileextensions to select. If empty, all are selected.
532          * @return      array           Array('files'=>array(), 'sorting'=>array());
533          */
534         function readDirectory($path,$type,$extList='') {
535                 $items = Array('files'=>array(), 'sorting'=>array());
536                 $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
537
538                 if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/'))       {
539                         $d = @dir($path);
540                         $tempArray=Array();
541                         if (is_object($d))      {
542                                 while($entry=$d->read()) {
543                                         if ($entry!='.' && $entry!='..')        {
544                                                 $wholePath = $path.'/'.$entry;          // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
545                                                 if (@file_exists($wholePath) && (!$type || t3lib_div::inList($type,filetype($wholePath))))      {
546                                                         if ($extList)   {
547                                                                 $fI = t3lib_div::split_fileref($entry);
548                                                                 if (t3lib_div::inList($extList,$fI['fileext'])) {
549                                                                         $tempArray[] = $wholePath;
550                                                                 }
551                                                         } else {
552                                                                 $tempArray[] = $wholePath;
553                                                         }
554                                                 }
555                                         }
556                                 }
557                                 $d->close();
558                         }
559                                 // Get fileinfo
560                         reset($tempArray);
561                         while (list(,$val)=each($tempArray))    {
562                                 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
563                                 $items['files'][] = $temp;
564                                 if ($this->sort)        {
565                                         $items['sorting'][] = strtoupper($temp[$this->sort]);
566                                 } else {
567                                         $items['sorting'][] = '';
568                                 }
569                         }
570                                 // Sort if required
571                         if ($this->sort)        {
572                                 if (!$this->sortRev)    {
573                                         asort($items['sorting']);
574                                 } else {
575                                         arsort($items['sorting']);
576                                 }
577                         }
578                 }
579                 return $items;
580         }
581
582         /**
583          * Creates the clipboard control pad
584          *
585          * @param       array           Array with information about the file/directory for which to make the clipboard panel for the listing.
586          * @return      string          HTML-table
587          */
588         function makeClip($theData)     {
589                 $cells=array();
590                 $fullIdent = $theData['path'].$theData['file'];
591                 $md5=t3lib_div::shortmd5($fullIdent);
592
593                         // For normal clipboard, add copy/cut buttons:
594                 if ($this->clipObj->current=='normal')  {
595                         $isSel = $this->clipObj->isSelected('_FILE',$md5);
596                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
597                                                 '<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="" />'.
598                                                 '</a>';
599                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
600                                                 '<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="" />'.
601                                                 '</a>';
602                 } else {        // For numeric pads, add select checkboxes:
603                         $n='_FILE|'.$md5;
604                         $this->CBnames[]=$n;
605
606                         $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked="checked"':'');
607                         $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" />'.
608                                         '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" class="smallCheckboxes"'.$checked.' />';
609                 }
610
611                         // Display PASTE button, if directory:
612                 $elFromTable = $this->clipObj->elFromTable('_FILE');
613                 if (@is_dir($fullIdent) && count($elFromTable)) {
614                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'">'.
615                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_pasteInto',1).'" alt="" />'.
616                                                 '</a>';
617                 }
618
619                         // Compile items into a DIV-element:
620                 return '                                                        <!-- CLIPBOARD PANEL: -->
621                                                                                         <div class="typo3-clipCtrl">
622                                                                                                 '.implode('
623                                                                                                 ',$cells).'
624                                                                                         </div>';
625         }
626 }
627
628
629
630 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc'])       {
631         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
632 }
633 ?>