Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / class.file_list.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *  
5 *  (c) 1999-2003 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  *   73: class fileList extends t3lib_recordList 
41  *  110:     function start($path,$pointer,$sort,$sortRev,$clipBoard=0) 
42  *  131:     function generateList()    
43  *  144:     function writeTop($path)   
44  *  199:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')  
45  *  213:     function getTable($files,$dirs,$rowlist)   
46  *  305:     function formatDirList($items)     
47  *  369:     function linkWrapDir($code,$path)  
48  *  379:     function listURL() 
49  *  389:     function dirData($theFile) 
50  *  414:     function formatFileList($items)    
51  *  486:     function isImage($ext)     
52  *  498:     function linkWrapSort($code,$path,$col)    
53  *  516:     function readDirectory($path,$type,$extList='')    
54  *  570:     function makeClip($theData)        
55  *
56  * TOTAL FUNCTIONS: 14
57  * (This index is automatically created/updated by the extension "extdeveval")
58  *
59  */
60
61
62
63
64
65
66 /**
67  * Class for rendering of File>Filelist
68  * 
69  * @author      Kasper Skaarhoj <kasper@typo3.com>
70  * @package TYPO3
71  * @subpackage core
72  */
73 class fileList extends t3lib_recordList {
74         var $iLimit = 40;                                       // default Max items shown 
75         var $thumbs = 0;                                        // Boolean. Thumbnails on records containing files (pictures)
76         var $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
77         var $fixedL = 30;                                       // Max length of strings
78         var $script = 'file_list.php';
79         var $clickMenus=1;                                      // If true click menus are generated on files and folders
80
81         var $sort = '';                                         // The field to sort by...
82         var $sortRev = 1;                                       // Reverse sorting flag
83         var $firstElementNumber=0;
84         var $clipBoard = 0;
85         
86                 // internal
87         var $JScode = '';       
88         var $HTMLcode = '';
89         var $totalbytes=0;
90         var $dirs = Array();
91         var $files = Array();
92         var $path = '';
93         var $eCounter=0;                                        // Counting the elements no matter what...
94         var $totalItems='';
95
96         var $CBnames=array();
97
98
99
100         /**
101          * Initialization
102          * 
103          * @param       string          The path to list
104          * @param       integer         Pointer
105          * @param       boolean         Sorting column
106          * @param       boolean         Sorting direction
107          * @param       boolean         Show clipboard flag
108          * @return      void            
109          */
110         function start($path,$pointer,$sort,$sortRev,$clipBoard=0)      {
111                 $this->counter=0;
112                 $this->totalbytes=0;
113                 $this->JScode='';
114                 $this->HTMLcode='';
115                 $this->path = $path;
116                 $this->sort=$sort;
117                 $this->sortRev=$sortRev;
118                 $this->firstElementNumber=$pointer;
119                 $this->clipBoard = $clipBoard;
120
121                 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
122                         $this->thumbScript='gfx/notfound_thumb.gif';
123                 }
124         }
125
126         /**
127          * Reading files and directories, counting elements and generating the list in ->HTMLcode
128          * 
129          * @return      void            
130          */
131         function generateList() {
132                 $this->dirs = $this->readDirectory($this->path,'dir');
133                 $this->files = $this->readDirectory($this->path,'file');
134                 $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
135                 $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw');
136         }
137
138         /**
139          * Make the top of the list
140          * 
141          * @param       string          The path to list.
142          * @return      void            
143          */
144         function writeTop($path)        {
145                         // Makes the code for the foldericon in the top
146                 $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
147                 
148                 if ($path)      {
149                         $out='';
150                         $this->counter++;
151                         $theFile = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($path);
152                         $root = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($theFile['path']);
153                         $titleCol='path';
154                         $this->fieldArray = Array($titleCol,'up');
155         
156                         list($title,$icon,$path) =  $this->dirData($theFile);
157         
158                                 // Start compiling the HTML
159                         $out='<table border="0" cellpadding="0" cellspacing="0">';
160         
161                         $theData = Array();
162                         $theData[$titleCol] = $this->widthGif;
163         
164                         $title = $GLOBALS['SOBE']->basicFF->blindPath($path);
165                         $theData['up']='<a href="'.htmlspecialchars($this->listURL()).'">'.
166                                         '<img src="'.$this->backPath.'gfx/refresh_n.gif" width="14" hspace="2" height="14" vspace="1" border="0" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" align="top" alt="" />'.
167                                         '</a>';
168                                 
169                         if ($root)      {
170                                         // The icon with link   
171                                 $theIcon = '<img src="'.$this->backPath.$icon.'" width="18" height="16" border="0" title="'.htmlspecialchars($theFile['file']).'" align="top" alt="" />';
172                                 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
173
174                                 $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_pre($title,$this->fixedL+20));
175                                 $theData['up'].=$this->linkWrapDir('<img src="'.$this->backPath.'gfx/i/folder_up.gif" width="18" height="16" border="0" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" align="top" alt="" />',$theFile['path']);
176                         } else {        
177                                         // root:0
178                                 $theIcon='<img src="'.$this->backPath.'gfx/i/_icon_ftp.gif" width="18" height="16" border="0" align="top" alt="" />';
179                                 $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_pre($title,$this->fixedL+20));
180                         }
181         
182                                 // Adding top element
183                         $out.=$this->addelement(1,'',$theData,'',$this->leftMargin,$theIcon);
184         
185                         $out.='</table>';
186                         $this->HTMLcode.=$out;
187                 }
188         }
189
190         /**
191          * Wrapping input string in a link with clipboard command.
192          * 
193          * @param       string          String to be linked - must be htmlspecialchar'ed / prepared before.
194          * @param       string          table - NOT USED
195          * @param       string          "cmd" value
196          * @param       string          Warning for JS confirm message
197          * @return      string          Linked string
198          */
199         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
200                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.submit();';
201                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
202                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">'.$string.'</a>';
203         }
204
205         /**
206          * Returns a table with directories and files listed.
207          * 
208          * @param       array           Files
209          * @param       array           Directories
210          * @param       string          List of rows to display horizontallyh
211          * @return      string          HTML-table
212          */
213         function getTable($files,$dirs,$rowlist)        {
214                         // Adds the code of files/dirs
215                 $out='';
216                 $titleCol = 'file';
217                 
218                         // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
219                 $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
220                 $rowlist = t3lib_div::uniqueList($rowlist);
221                 $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
222                 if ($this->clipBoard)   $rowlist.=',_CLIPBOARD_';
223                 $this->fieldArray = explode(',',$rowlist);
224                 
225                         // Start table:
226                 $out.='
227                 <table border="0" cellpadding="0" cellspacing="0">';
228
229                         // half line is drawn
230                 $theData = Array();
231                 $theData[$titleCol] = $this->widthGif;
232                 $out.=$this->addelement(0,'',$theData,'',$this->leftMargin);
233
234
235
236                         // Directories are added
237                 $iOut = '';
238                 $iOut.= $this->formatDirList($dirs,$titleCol);
239
240                 if (count($dirs['sorting']))    {
241                                 // half line is drawn
242                         $theData = Array();
243                         $theData[$titleCol] = '';
244                         $iOut.=$this->addelement(0,'',$theData);
245                 }
246
247
248
249                         // Files are added
250                 $iOut.= $this->formatFileList($files,$titleCol);
251                 
252                         // Header line is drawn
253                 $theData = Array();
254                 reset($this->fieldArray);
255                 while(list(,$v)=each($this->fieldArray))        {
256                         if ($v=='_CLIPBOARD_')  {
257                                 $cells=array();
258                                 $table='_FILE';
259                                 $elFromTable = $this->clipObj->elFromTable($table);
260                                 if (count($elFromTable))        {
261                                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$this->path)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$this->path,'into',$elFromTable)).'">'.
262                                                 '<img src="gfx/clip_pasteafter.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->getLL('clip_paste'),1).' alt="" /></a>'.
263                                                 '<img src="clear.gif" width="2" height="1" alt="" />';
264                                 }
265                                 if ($this->clipObj->current!='normal' && $iOut) {
266                                         $cells[]=$this->linkClipboardHeaderIcon('<img src="gfx/clip_copy.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->getLL('clip_selectMarked'),1).' alt="" />',$table,'setCB');
267                                         $cells[]=$this->linkClipboardHeaderIcon('<img src="gfx/garbage.gif" width="11" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->getLL('clip_deleteMarked'),1).' alt="" />',$table,'delete',$GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'));
268                                         $cells[]='<img src="clear.gif" width="6" height="1" alt="" />';
269                                         $onClick = 'checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;';
270                                         $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
271                                                         '<img src="gfx/clip_select.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->getLL('clip_markRecords'),1).' alt="" />'.
272                                                         '</a>';
273                                 }
274
275                                 $theData[$v] = implode('',$cells).'&nbsp;';
276                         } else {        // Normal row:
277                                 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
278                                 if ($v==$titleCol)      {
279                                         $theData[$v] = '&nbsp;<b>'.$theT.'</b>&nbsp;<br /><img src="clear.gif" width="180" height="1" alt="" />';
280                                 } else {
281                                         $theData[$v] = '&nbsp;<b>'.$theT.'</b>&nbsp;';
282                                 }
283                         }
284                 }
285                 $out.=$this->addelement(1,'',$theData,' bgcolor="'.$this->headLineCol.'"','');
286                 $out.=$iOut;
287                 
288                         // half line is drawn
289                 $theData = Array();
290                 $theData[$titleCol] = $this->counter.' Files, '.$GLOBALS['SOBE']->basicFF->formatSize($this->totalbytes).'bytes';
291                 $out.=$this->addelement(1,'',$theData);
292                 
293                         // finish
294                 $out.='
295                 </table>';      
296                 return $out;
297         }
298
299         /**
300          * This returns tablerows for the directories in the array $items['sorting'].
301          * 
302          * @param       array           Items
303          * @return      string          HTML table rows.
304          */
305         function formatDirList($items)  {
306                 $out='';
307
308                         // Files:
309                 if (count($items['sorting']))   {
310                         reset($items['sorting']);
311                         while (list($key,) = each($items['sorting']))   {
312                                 list($flag,$code) = $this->fwd_rwd_nav();
313                                 $out.=$code;
314                                 if ($flag)      {
315                                                 // Initialization
316                                         $theFile = $items['files'][$key];
317                                         $this->counter++;
318         
319                                         list($title,$icon,$path) =  $this->dirData($theFile);
320         
321                                                 // The icon with link   
322                                         $theIcon = '<img src="'.$this->backPath.$icon.'" width="18" height="16" border="0" title="'.htmlspecialchars($theFile['file']).'">';
323                                         if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
324         
325                                                 //      Preparing and getting the data-array
326                                         $theData = Array();
327                                         reset($this->fieldArray);
328                                         while(list(,$field)=each($this->fieldArray))    {
329                                                 switch($field)  {
330                                                         case 'size':
331         //                                                      $theData[$field]=$GLOBALS['SOBE']->basicFF->formatSize($theFile[$field]);
332                                                         break;
333                                                         case 'rw':
334                                                                 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writeable'])?'':'<span class="typo3-red"><b>W</b></span>');
335                                                         break;
336                                                         case 'fileext': 
337         //                                                      $theData[$field]=strtoupper($theFile['fileext']);
338                                                         break;
339                                                         case 'tstamp':
340                                                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile['tstamp']);
341                                                         break;
342                                                         case 'file':
343                                                                 $theData[$field]= $this->linkWrapDir(htmlspecialchars(t3lib_div::fixed_lgd($title,$this->fixedL)),$path);
344                                                         break;
345                                                         case '_CLIPBOARD_':
346                                                                 $theData[$field]=$this->makeClip($theFile);
347                                                         break;
348                                                         default:
349                                                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
350                                                         break;
351                                                 }
352                                                 if ($field!='_CLIPBOARD_')      $theData[$field]='&nbsp;'.$theData[$field].'&nbsp;';
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          * Returns list URL
376          * 
377          * @return      string          URL
378          */
379         function listURL()      {
380                 return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
381         }
382
383         /**
384          * Returns some data specific for the directories...
385          * 
386          * @param       array           File information array
387          * @return      array           (title, icon, path)
388          */
389         function dirData($theFile)      {
390                 $path = $theFile['path'].$theFile['file'].'/';
391                 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
392
393                 $title=htmlspecialchars($theFile['file']);
394                 $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
395                 if ($title=='_temp_')   {
396                         $icon = 'gfx/i/sysf.gif';
397                         $title='<b>TEMP</b>';
398                 }
399                 if ($title=='_recycler_')       {
400                         $icon = 'gfx/i/recycler.gif';
401                         $title='<b>RECYCLER</b>';
402                 }
403                 $icon = $theFile['writable'] ? 'gfx/i/_icon_'.$webpath.'folders_ro.gif' : $icon;
404
405                 return Array($title,$icon,$path);
406         }
407
408         /**
409          * This returns tablerows for the files in the array $items['sorting'].
410          * 
411          * @param       array           Items
412          * @return      string          HTML table rows.
413          */
414         function formatFileList($items) {
415                 $out='';
416
417                         // Files:
418                 if (count($items['sorting']))   {
419                         reset($items['sorting']);
420                         while (list($key,) = each($items['sorting']))   {
421                                 list($flag,$code) = $this->fwd_rwd_nav();
422                                 $out.=$code;
423                                 if ($flag)      {
424                                                 // Initialization
425                                         $theFile = $items['files'][$key];
426                                         $this->counter++;
427         
428                                         $this->totalbytes+=$theFile['size'];
429                                         $ext = $items['files'][$key][fileext];
430                                         $icon = t3lib_BEfunc::getFileIcon($ext);
431
432                                                 // The icon with link   
433                                         $theIcon = '<img src="'.$this->backPath.'gfx/fileicons/'.$icon.'" width="18" height="16" border="0" title="'.htmlspecialchars($theFile['file']).'" alt="" />';
434                                         if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
435         
436                                                 //      Preparing and getting the data-array
437                                         $theData = Array();
438                                         reset($this->fieldArray);
439                                         while(list(,$field)=each($this->fieldArray))    {
440                                                 switch($field)  {
441                                                         case 'size':
442                                                                 $theData[$field]=$GLOBALS['SOBE']->basicFF->formatSize($theFile[$field]);
443                                                         break;
444                                                         case 'rw':
445                                                                 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writeable'])?'':'<span class="typo3-red"><b>W</b></span>');
446                                                         break;
447                                                         case 'fileext':
448                                                                 $theData[$field]=strtoupper($theFile[$field]);
449                                                         break;
450                                                         case 'tstamp':
451                                                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
452                                                         break;
453                                                         case '_CLIPBOARD_':
454                                                                 $theData[$field]=$this->makeClip($theFile);
455                                                         break;
456                                                         default:
457                                                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
458                                                         break;
459                                                 }
460                                                 if ($field!='_CLIPBOARD_')      $theData[$field]='&nbsp;'.$theData[$field].'&nbsp;';
461                                         }
462                                         $out.=$this->addelement(1,$theIcon,$theData);
463                                         
464                                                 // Thumbsnails?
465                                         if ($this->thumbs && $this->isImage($theFile['fileext']))       {
466                                                 $thumbData=Array();
467                                                 $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
468                                                 $titleCol=$this->fieldArray[0];
469                                                 $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.$theFile_R;
470                                                 $thumbData[$titleCol]='<img src="'.htmlspecialchars($href).'" hspace="2" border="0" title="'.htmlspecialchars(trim($theFile['file'])).'">';
471                                                 $out.=$this->addelement(4,'',$thumbData);
472                                         }
473                                 }
474                                 $this->eCounter++;
475                         }
476                 }
477                 return $out;
478         }
479
480         /**
481          * Returns true if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
482          * 
483          * @param       string          file extension
484          * @return      boolean         
485          */
486         function isImage($ext)  {
487                 return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
488         }
489
490         /**
491          * Wraps the directory-titles ($code) in a link to file_list.php (id=$path) and sorting commands...
492          * 
493          * @param       string          String to be wrapped
494          * @param       string          ID (path)
495          * @param       string          Sorting column
496          * @return      string          HTML
497          */
498         function linkWrapSort($code,$path,$col) {
499                 if ($this->sort==$col && !$this->sortRev)       {               // reverse sorting
500                         $params='&SET[sort]='.$col.'&SET[reverse]=1';
501                 } else {
502                         $params='&SET[sort]='.$col.'&SET[reverse]=0';
503                 }
504                 $href = $this->script.'?id='.rawurlencode($path).$params;
505                 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
506         }
507
508         /**
509          * Returns an array with file/dir items + a array with the sorted items
510          * 
511          * @param       string          Path
512          * @param       string          $type is the technical type; file,dir,link. empty is all kinds of stuff.
513          * @param       string          $extList: List of fileextensions to select. If empty, all are selected.
514          * @return      array           Array('files'=>array(), 'sorting'=>array());
515          */
516         function readDirectory($path,$type,$extList='') {
517                 $items = Array('files'=>array(), 'sorting'=>array());
518                 $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
519
520                 if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/'))       {
521                         $d = @dir($path);
522                         $tempArray=Array();
523                         if (is_object($d))      {
524                                 while($entry=$d->read()) {
525                                         if ($entry!='.' && $entry!='..')        {
526                                                 $wholePath = $path.'/'.$entry;          // Because of odd PHP-error where  <BR>-tag is sometimes placed after a filename!!
527                                                 if (@file_exists($wholePath) && (!$type || filetype($wholePath)==$type))        {
528                                                         if ($extList)   {
529                                                                 $fI = t3lib_div::split_fileref($entry);
530                                                                 if (t3lib_div::inList($extList,$fI['fileext'])) {
531                                                                         $tempArray[] = $wholePath;
532                                                                 }
533                                                         } else {
534                                                                 $tempArray[] = $wholePath;
535                                                         }
536                                                 }
537                                         }
538                                 }
539                                 $d->close();
540                         }
541                                 // Get fileinfo
542                         reset($tempArray);
543                         while (list(,$val)=each($tempArray))    {
544                                 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
545                                 $items['files'][] = $temp;
546                                 if ($this->sort)        {
547                                         $items['sorting'][] = strtoupper($temp[$this->sort]);
548                                 } else {
549                                         $items['sorting'][] = '';
550                                 }
551                         }
552                                 // Sort if required
553                         if ($this->sort)        {
554                                 if (!$this->sortRev)    {
555                                         asort($items['sorting']);
556                                 } else {
557                                         arsort($items['sorting']);
558                                 }
559                         }
560                 }
561                 return $items;
562         }
563
564         /**
565          * Creates the clipboard control pad
566          * 
567          * @param       array           
568          * @return      string          HTML-table
569          */
570         function makeClip($theData)     {
571                 $cells=array();
572                 $fullIdent = $theData['path'].$theData['file'];
573                 $md5=t3lib_div::shortmd5($fullIdent);
574
575                         // For normal clipboard, add copy/cut buttons:
576                 if ($this->clipObj->current=='normal')  {
577                         $isSel = $this->clipObj->isSelected('_FILE',$md5);
578                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
579                                                 '<img src="gfx/clip_copy'.($isSel=='copy'?'_h':'').'.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.copy'),1).' alt="" />'.
580                                                 '</a>';
581                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
582                                                 '<img src="gfx/clip_cut'.($isSel=='cut'?'_h':'').'.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.cut'),1).' alt="" />'.
583                                                 '</a>';
584                 } else {        // For numeric pads, add select checkboxes:
585                         $n='_FILE|'.$md5;
586                         $this->CBnames[]=$n;
587
588                         $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked':'');
589                         $cells[]='<input type="hidden" name="CBH['.$n.']" value="0">'.
590                                         '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" style="width:12;height:12;margin:0 0 0 0;"'.$checked.'>';   // NN 6.1
591                 }
592
593                         // Display PASTE button, if directory:
594                 $elFromTable = $this->clipObj->elFromTable('_FILE');
595                 if (@is_dir($fullIdent) && count($elFromTable)) {
596                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'">'.
597                                                 '<img src="gfx/clip_pasteinto.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->getLL('clip_pasteInto'),1).' alt="" />'.
598                                                 '</a>';
599                 }
600
601                 if ($GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']<5)    {
602                         $w100 = '';
603                         $w40 = '';
604                 } else {
605                         $w100 = ' width="100%"';
606                         $w40 = ' width="40%"';
607                 }
608                 return '<table border="0" cellpadding="1" cellspacing="0" bgcolor="'.$GLOBALS['SOBE']->doc->bgColor5.'"'.$w100.'>
609                         <tr>
610                         <td'.$w40.'></td>
611                         <td align="center">'.implode('</td><td>',$cells).'</td>
612                         <td'.$w40.'></td>
613                         </tr>
614                 </table>';
615         }
616 }
617
618
619
620 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc'])       {
621         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
622 }
623 ?>