TYPO3 API  SVNRelease
class.file_list.inc
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2009 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Include file extending t3lib_recordList
00029  *
00030  * $Id: class.file_list.inc 9758 2010-12-05 11:25:36Z stephenking $
00031  * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
00032  *
00033  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   75: class fileList extends t3lib_recordList
00041  *  112:     function start($path,$pointer,$sort,$sortRev,$clipBoard=0)
00042  *  133:     function generateList()
00043  *  146:     function writeTop($path)
00044  *  204:     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')
00045  *  218:     function getTable($files,$dirs,$rowlist)
00046  *  306:     function formatDirList($items)
00047  *  372:     function linkWrapDir($code,$path)
00048  *  391:     function linkWrapFile($code,$path)
00049  *  406:     function listURL()
00050  *  416:     function dirData($theFile)
00051  *  441:     function formatFileList($items)
00052  *  518:     function isImage($ext)
00053  *  530:     function linkWrapSort($code,$path,$col)
00054  *  548:     function readDirectory($path,$type,$extList='')
00055  *  602:     function makeClip($theData)
00056  *  647:     function makeRef($theData)
00057  *
00058  * TOTAL FUNCTIONS: 16
00059  * (This index is automatically created/updated by the extension "extdeveval")
00060  *
00061  */
00062 
00063 
00064 
00065 
00066 
00067 
00068 /**
00069  * Class for rendering of File>Filelist
00070  *
00071  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00072  * @package TYPO3
00073  * @subpackage core
00074  */
00075 class fileList extends t3lib_recordList {
00076     var $iLimit = 40;                   // default Max items shown
00077     var $thumbs = 0;                    // Boolean. Thumbnails on records containing files (pictures)
00078     var $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
00079     var $fixedL = 30;                   // Max length of strings
00080     var $script = 'file_list.php';
00081     var $clickMenus=1;                  // If true click menus are generated on files and folders
00082 
00083     var $sort = '';                     // The field to sort by...
00084     var $sortRev = 1;                   // Reverse sorting flag
00085     var $firstElementNumber=0;
00086     var $clipBoard = 0;
00087     var $bigControlPanel = 0;
00088 
00089         // internal
00090     var $JScode = '';
00091     var $HTMLcode = '';
00092     var $totalbytes=0;
00093     var $dirs = Array();
00094     var $files = Array();
00095     var $path = '';
00096     var $eCounter=0;                    // Counting the elements no matter what...
00097     var $dirCounter = 0;
00098     var $totalItems='';
00099 
00100     var $CBnames=array();
00101 
00102 
00103 
00104     /**
00105      * Initialization of class
00106      *
00107      * @param   string      The path to list
00108      * @param   integer     Pointer
00109      * @param   boolean     Sorting column
00110      * @param   boolean     Sorting direction
00111      * @param   boolean     Show clipboard flag
00112      * @return  void
00113      */
00114     function start($path, $pointer, $sort, $sortRev, $clipBoard=0, $bigControlPanel=0) {
00115         $this->counter=0;
00116         $this->totalbytes=0;
00117         $this->JScode='';
00118         $this->HTMLcode='';
00119         $this->path = $path;
00120         $this->sort=$sort;
00121         $this->sortRev=$sortRev;
00122         $this->firstElementNumber=$pointer;
00123         $this->clipBoard = $clipBoard;
00124         $this->bigControlPanel = $bigControlPanel;
00125             // setting the maximum length of the filenames to the user's settings or minimum 30 (= $this->fixedL)
00126         $this->fixedL = max($this->fixedL, $GLOBALS['BE_USER']->uc['titleLen']);
00127 
00128         if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
00129             $this->thumbScript='gfx/notfound_thumb.gif';
00130         }
00131         $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_common.xml');
00132     }
00133 
00134     /**
00135      * Reading files and directories, counting elements and generating the list in ->HTMLcode
00136      *
00137      * @return  void
00138      */
00139     function generateList() {
00140         $this->dirs = $this->readDirectory($this->path,'dir,link');
00141         $this->files = $this->readDirectory($this->path,'file');
00142         $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
00143         $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw,_REF_');
00144     }
00145 
00146     /**
00147      * Return the buttons used by the file list to include in the top header
00148      *
00149      * @return  array
00150      */
00151     function getButtonsAndOtherMarkers($path) {
00152 
00153             // Makes the code for the foldericon in the top
00154         $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
00155 
00156         if ($path)  {
00157             $otherMarkers = array(
00158                 'PAGE_ICON' => '',
00159                 'TITLE' => '',
00160             );
00161 
00162             $buttons = array(
00163                 'level_up' => '',
00164                 'refresh' => '',
00165                 'title' => '',
00166                 'page_icon' => '',
00167             );
00168 
00169             $theFile = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($path);
00170 
00171             list($title,$icon,$path) =  $this->dirData($theFile);
00172 
00173                 // Start compiling the HTML
00174             $title = $GLOBALS['SOBE']->basicFF->blindPath($path);
00175 
00176                 // if this is some subpage under the mount root....
00177             if ($GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($theFile['path'])) {
00178                     // The icon with link
00179                 $otherMarkers['PAGE_ICON'] = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="'.htmlspecialchars($theFile['file']).'" />';
00180                 if ($this->clickMenus) $otherMarkers['PAGE_ICON'] = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'],$path);
00181 
00182                 $buttons['level_up'] .= $this->linkWrapDir(t3lib_iconWorks::getSpriteIcon('actions-view-go-up', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.upOneLevel', 1))), $theFile['path']);
00183                 $otherMarkers['TITLE'] .= t3lib_div::removeXSS(t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20)));    // No HTML specialchars here - HTML like <strong> </strong> is allowed
00184 
00185                 // this is the root page
00186             } else {
00187                 $otherMarkers['PAGE_ICON'] = t3lib_iconWorks::getSpriteIcon('apps-filetree-root');
00188                 if ($this->clickMenus) $otherMarkers['PAGE_ICON'] = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'],$path);
00189                 $otherMarkers['TITLE'] .= htmlspecialchars(t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20)));
00190             }
00191         }
00192 
00193         $buttons['refresh'] = '<a href="'.htmlspecialchars($this->listURL()).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.reload', 1) . '">'.
00194                 t3lib_iconWorks::getSpriteIcon('actions-system-refresh')  .
00195             '</a>';
00196 
00197         return array($buttons, $otherMarkers);
00198     }
00199 
00200     /**
00201      * Wrapping input string in a link with clipboard command.
00202      *
00203      * @param   string      String to be linked - must be htmlspecialchar'ed / prepared before.
00204      * @param   string      table - NOT USED
00205      * @param   string      "cmd" value
00206      * @param   string      Warning for JS confirm message
00207      * @return  string      Linked string
00208      */
00209     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')   {
00210         $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.submit();';
00211         if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
00212         return '<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">'.$string.'</a>';
00213     }
00214 
00215     /**
00216      * Returns a table with directories and files listed.
00217      *
00218      * @param   array       Array of files from path
00219      * @param   array       Array of directories from path
00220      * @param   string      List of rows to display horizontallyh
00221      * @return  string      HTML-table
00222      */
00223     function getTable($files,$dirs,$rowlist)    {
00224             // Adds the code of files/dirs
00225         $out='';
00226         $titleCol = 'file';
00227         $upLevelDir = dirname(substr($files['files'][0]['path'], 0, -1)) . '/';
00228         $levelUp = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($upLevelDir) ? $this->linkWrapDir(t3lib_iconWorks::getSpriteIcon('actions-view-go-up', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel', TRUE))), $upLevelDir) : '';
00229 
00230             // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
00231         $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
00232         $rowlist = t3lib_div::uniqueList($rowlist);
00233         $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
00234         if ($this->bigControlPanel || $this->clipBoard) {
00235             $rowlist = str_replace('file,', 'file,_CLIPBOARD_,', $rowlist);
00236         }
00237         $this->fieldArray = explode(',',$rowlist);
00238 
00239             // Directories are added
00240         $iOut = '';
00241         $iOut.= $this->formatDirList($dirs);
00242 
00243         if (count($dirs['sorting']))    {
00244                 // half line is drawn
00245             $theData = Array();
00246             $theData[$titleCol] = '';
00247         }
00248 
00249 
00250 
00251             // Files are added
00252         $iOut.= $this->formatFileList($files,$titleCol);
00253 
00254             // Header line is drawn
00255         $theData = Array();
00256 
00257         foreach ($this->fieldArray as $v)   {
00258             if ($v == '_CLIPBOARD_' && $this->clipBoard) {
00259                 $cells=array();
00260                 $table='_FILE';
00261                 $elFromTable = $this->clipObj->elFromTable($table);
00262                 if (count($elFromTable))    {
00263                     $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$this->path)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$this->path,'into',$elFromTable)).'" title="' . $GLOBALS['LANG']->getLL('clip_paste', 1) . '">' .
00264                         t3lib_iconWorks::getSpriteIcon('actions-document-paste-after') .
00265                     '</a>';
00266                 }
00267                 if ($this->clipObj->current!='normal' && $iOut) {
00268                     $cells[]=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-copy', array('title' => $GLOBALS['LANG']->getLL('clip_selectMarked', 1))), $table,'setCB');
00269                     $cells[]=$this->linkClipboardHeaderIcon(t3lib_iconWorks::getSpriteIcon('actions-edit-delete', array('title' => $GLOBALS['LANG']->getLL('clip_deleteMarked'))), $table,'delete',$GLOBALS['LANG']->getLL('clip_deleteMarkedWarning'));
00270                     $onClick = 'checkOffCB(\'' . implode(',', $this->CBnames) . '\', this); return false;';
00271                     $cells[] = '<a class="cbcCheckAll" rel="" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('clip_markRecords', TRUE) . '">' .
00272                             t3lib_iconWorks::getSpriteIcon('actions-document-select').
00273                         '</a>';
00274                 }
00275                 $theData[$v] = implode('',$cells);
00276             } else {    // Normal row:
00277                 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
00278                 $theData[$v] = $theT;
00279             }
00280         }
00281         $out .= '<thead>' . $this->addelement(1, $levelUp, $theData, ' class="t3-row-header"', '') . '</thead>';
00282         $out .= '<tbody>' . $iOut . '</tbody>';
00283 
00284             // half line is drawn
00285 
00286             // finish
00287         return '
00288 
00289 
00290         <!--
00291             File list table:
00292         -->
00293             <table cellpadding="0" cellspacing="0" id="typo3-filelist">
00294                 '.$out.'
00295             </table>';
00296     }
00297 
00298     /**
00299      * Gets the number of files and total size of a folder
00300      *
00301      * @return string
00302      **/
00303     function getFolderInfo() {
00304         if($this->counter == 1) {
00305             $fileLabel = $GLOBALS['LANG']->getLL('file', true);
00306         } else {
00307             $fileLabel = $GLOBALS['LANG']->getLL('files', true);
00308         }
00309         return $this->counter . ' ' . $fileLabel . ', ' . t3lib_div::formatSize($this->totalbytes, $GLOBALS['LANG']->getLL('byteSizeUnits', true));
00310     }
00311 
00312     /**
00313      * This returns tablerows for the directories in the array $items['sorting'].
00314      *
00315      * @param   array       Directory items
00316      * @return  string      HTML table rows.
00317      */
00318     function formatDirList($items)  {
00319         $out='';
00320 
00321         // Folders:
00322         if (count($items['sorting']))   {
00323             foreach ($items['sorting'] as $key => $value) {
00324                 list($flag,$code) = $this->fwd_rwd_nav();
00325                 $out.=$code;
00326                 if ($flag)  {
00327                         // Initialization
00328                     $theFile = $items['files'][$key];
00329                     $this->counter++;
00330 
00331                     list($title,$icon,$path) =  $this->dirData($theFile);
00332 
00333                         // The icon with link
00334                     $theIcon = t3lib_iconWorks::getSpriteIconForFile( ($theFile['type'] == 'dir' ? 'folder' : $theFile['fileext']), array('title' => htmlspecialchars($theFile['file'])));
00335                     if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
00336 
00337                         //  Preparing and getting the data-array
00338                     $theData = Array();
00339                     foreach ($this->fieldArray as $field) {
00340                         switch($field)  {
00341                             case 'size':
00342                                 $theData[$field] = t3lib_div::formatSize($theFile[$field], $GLOBALS['LANG']->getLL('byteSizeUnits', true));
00343                             break;
00344                             case 'rw':
00345                                 $theData[$field] = (($theFile['readable']) ? '' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('read', true) . '</strong></span>') . (($theFile['writable']) ? '' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('write', true) . '</strong></span>');
00346                             break;
00347                             case 'fileext':
00348                                 $theData[$field]=strtoupper($theFile['fileext']);
00349                             break;
00350                             case 'tstamp':
00351                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile['tstamp']);
00352                             break;
00353                             case 'file':
00354                                 $theData[$field]= $this->linkWrapDir($title,$path);
00355                             break;
00356                             case '_CLIPBOARD_':
00357                                 $temp = '';
00358                                 if ($this->bigControlPanel) {
00359                                     $temp .= $this->makeEdit($theFile);
00360                                 }
00361                                 $temp .= $this->makeClip($theFile);
00362                                 $theData[$field] = $temp;
00363                             break;
00364                             case '_REF_':
00365                                 $theData[$field]=$this->makeRef($theFile);
00366                             break;
00367                             default:
00368                                 $theData[$field]=t3lib_div::fixed_lgd_cs($theFile[$field],$this->fixedL);
00369                             break;
00370                         }
00371                     }
00372                     $altRows = 'class="' . ($i++ % 2 == 0 ? 'bgColor6' : 'bgColor4') . '"';
00373 
00374                     $out .= $this->addelement(1, $theIcon, $theData, $altRows);
00375                 }
00376                 $this->eCounter++;
00377                 $this->dirCounter = $this->eCounter;
00378             }
00379         }
00380         return $out;
00381     }
00382 
00383     /**
00384      * Wraps the directory-titles
00385      *
00386      * @param   string      String to be wrapped in links
00387      * @param   string      ID (path)
00388      * @return  string      HTML
00389      */
00390     function linkWrapDir($code,$path)   {
00391         $href = $this->script.'?id='.rawurlencode($path);
00392         $onclick = ' onclick="'.htmlspecialchars('top.content.nav_frame.hilight_row("file","folder'.t3lib_div::md5int($path).'_"+top.fsMod.currentBank)').'"';
00393 
00394             // Sometimes $code contains plain HTML tags. In such a case the string should not be modified!
00395         if(!strcmp($code,strip_tags($code)))    {
00396             return '<a href="'.htmlspecialchars($href).'"'.$onclick.' title="'.htmlspecialchars($code).'">'.t3lib_div::fixed_lgd_cs($code,$this->fixedL).'</a>';
00397         } else  {
00398             return '<a href="'.htmlspecialchars($href).'"'.$onclick.'>'.$code.'</a>';
00399         }
00400     }
00401 
00402     /**
00403      * Wraps filenames in links which opens them in a window IF they are in web-path.
00404      *
00405      * @param   string      String to be wrapped in links
00406      * @param   string      ID (path)
00407      * @return  string      HTML
00408      */
00409     function linkWrapFile($code,$path)  {
00410 
00411         if (t3lib_div::isFirstPartOfStr($path, PATH_site)) {
00412             $href = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . substr($path, strlen(PATH_site));
00413             $aOnClick = "return top.openUrlInWindow('".$href."','WebFile');";
00414             $code = '<a href="#" title="'.htmlspecialchars($code).'" onclick="'.htmlspecialchars($aOnClick).'">'.t3lib_div::fixed_lgd_cs($code,$this->fixedL).'</a>';
00415         }
00416         return $code;
00417     }
00418 
00419     /**
00420      * Returns list URL; This is the URL of the current script with id and imagemode parameters, thats all.
00421      *
00422      * @return  string      URL
00423      */
00424     function listURL()  {
00425         return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
00426     }
00427 
00428     /**
00429      * Returns some data specific for the directories...
00430      *
00431      * @param   array       File information array
00432      * @return  array       (title, icon, path)
00433      */
00434     function dirData($theFile)  {
00435         $path = $theFile['path'] . $theFile['file'] . '/';
00436         $webpath = t3lib_BEfunc::getPathType_web_nonweb($path);
00437 
00438         $title = htmlspecialchars($theFile['file']);
00439         $icon = 'gfx/i/_icon_' . $webpath . 'folders.gif';
00440         if ($title == '_temp_') {
00441             $icon = 'gfx/i/sysf.gif';
00442             $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', true) . '</strong>';
00443         }
00444         if ($title == '_recycler_') {
00445             $icon = 'gfx/i/recycler.gif';
00446             $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', true) . '</strong>';
00447         }
00448         $icon = $theFile['writable'] ? 'gfx/i/_icon_' . $webpath . 'folders_ro.gif' : $icon;
00449 
00450         return array($title, $icon, $path);
00451     }
00452 
00453     /**
00454      * This returns tablerows for the files in the array $items['sorting'].
00455      *
00456      * @param   array       File items
00457      * @return  string      HTML table rows.
00458      */
00459     function formatFileList($items) {
00460         $out='';
00461 
00462             // Files:
00463         if (count($items['sorting']))   {
00464             foreach ($items['sorting'] as $key => $value) {
00465                 list($flag,$code) = $this->fwd_rwd_nav();
00466                 $out.=$code;
00467                 if ($flag)  {
00468                         // Initialization
00469                     $theFile = $items['files'][$key];
00470                     $this->counter++;
00471 
00472                     $this->totalbytes+=$theFile['size'];
00473                     $ext = $items['files'][$key][fileext];
00474                     $icon = t3lib_BEfunc::getFileIcon($ext);
00475 
00476                         // The icon with link
00477                     $theIcon = t3lib_iconWorks::getSpriteIconForFile($theFile['fileext'], array('title' => htmlspecialchars($theFile['file'])));
00478 
00479                     if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
00480 
00481                         //  Preparing and getting the data-array
00482                     $theData = Array();
00483                     foreach ($this->fieldArray as $field) {
00484                         switch($field)  {
00485                             case 'size':
00486                                 $theData[$field] = t3lib_div::formatSize($theFile[$field], $GLOBALS['LANG']->getLL('byteSizeUnits', true));
00487                             break;
00488                             case 'rw':
00489                                 $theData[$field] = (($theFile['readable']) ? '' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('read', true) . '</strong></span>') . (($theFile['writable']) ? '' : '<span class="typo3-red"><strong>' . $GLOBALS['LANG']->getLL('write', true) . '</strong></span>');
00490                             break;
00491                             case 'fileext':
00492                                 $theData[$field]=strtoupper($theFile[$field]);
00493                             break;
00494                             case 'tstamp':
00495                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
00496                             break;
00497                             case '_CLIPBOARD_':
00498                                 $temp = '';
00499                                 if ($this->bigControlPanel) {
00500                                     $temp .= $this->makeEdit($theFile);
00501                                 }
00502                                 $temp .= $this->makeClip($theFile);
00503                                 $theData[$field] = $temp;
00504                             break;
00505                             case '_REF_':
00506                                 $theData[$field]=$this->makeRef($theFile);
00507                             break;
00508                             case 'file':
00509                                 $theData[$field] = $this->linkWrapFile($theFile[$field],$theFile['path'].$theFile['file']);
00510                                     // Thumbsnails?
00511                                 if ($this->thumbs && $this->isImage($theFile['fileext']))   {
00512                                     $thumbData = array();
00513                                     $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
00514                                     $titleCol = $this->fieldArray[0];
00515 
00516                                     $theFile_abs = $theFile['path'].$theFile['file'];
00517                                     $check = basename($theFile_abs).':'.filemtime($theFile_abs).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
00518                                     $params = '&file='.$theFile_R;
00519                                     $params.= '&md5sum='.t3lib_div::shortMD5($check);
00520                                     $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
00521 
00522                                     $theData[$field] .= '<br /><img src="'.htmlspecialchars($href).'" hspace="2" title="'.htmlspecialchars(trim($theFile['file'])).'" alt="'.htmlspecialchars(trim($theFile['file'])).'" />';
00523                                 }
00524                             break;
00525                             default:
00526                                 $theData[$field]=t3lib_div::fixed_lgd_cs($theFile[$field],$this->fixedL);
00527                             break;
00528                         }
00529                     }
00530                     if ($this->dirCounter % 2 == 0) {
00531                         $altRows = 'class="' . ($i++ % 2 == 0 ? 'bgColor6' : 'bgColor4') . '"';
00532                     } else {
00533                         $altRows = 'class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '"';
00534                     }
00535 
00536                     $out .= $this->addelement(1, $theIcon, $theData, $altRows);
00537                 }
00538                 $this->eCounter++;
00539             }
00540         }
00541         return $out;
00542     }
00543 
00544     /**
00545      * Returns true if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
00546      *
00547      * @param   string      file extension
00548      * @return  boolean
00549      */
00550     function isImage($ext)  {
00551         return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
00552     }
00553 
00554     /**
00555      * Wraps the directory-titles ($code) in a link to file_list.php (id=$path) and sorting commands...
00556      *
00557      * @param   string      String to be wrapped
00558      * @param   string      ID (path)
00559      * @param   string      Sorting column
00560      * @return  string      HTML
00561      */
00562     function linkWrapSort($code,$path,$col) {
00563         if ($this->sort==$col && !$this->sortRev)   {       // reverse sorting
00564             $params='&SET[sort]='.$col.'&SET[reverse]=1';
00565         } else {
00566             $params='&SET[sort]='.$col.'&SET[reverse]=0';
00567         }
00568         $href = $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('filelist') . 'mod1/' . $this->script . '?id=' . rawurlencode($path) . $params;
00569         return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
00570     }
00571 
00572     /**
00573      * Returns an array with file/dir items + an array with the sorted items
00574      *
00575      * @param   string      Path (absolute) to read
00576      * @param   string      $type is the technical type; file,dir,link. empty is all kinds of stuff.
00577      * @param   string      $extList: List of fileextensions to select. If empty, all are selected.
00578      * @return  array       Array('files'=>array(), 'sorting'=>array());
00579      */
00580     function readDirectory($path,$type,$extList='') {
00581         $items = Array('files'=>array(), 'sorting'=>array());
00582         $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
00583 
00584         if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/'))   {
00585             $d = @dir($path);
00586             $tempArray=Array();
00587             if (is_object($d))  {
00588                 while(false !== ($entry=$d->read())) {
00589                     if ($entry!='.' && $entry!='..')    {
00590                         $wholePath = $path.'/'.$entry;      // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
00591                         if (@file_exists($wholePath) && (!$type || t3lib_div::inList($type,filetype($wholePath))))  {
00592                             if ($extList)   {
00593                                 $fI = t3lib_div::split_fileref($entry);
00594                                 if (t3lib_div::inList($extList,$fI['fileext'])) {
00595                                     $tempArray[] = $wholePath;
00596                                 }
00597                             } else {
00598                                 $tempArray[] = $wholePath;
00599                             }
00600                         }
00601                     }
00602                 }
00603                 $d->close();
00604             }
00605                 // Get fileinfo
00606             foreach ($tempArray as $val) {
00607                 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
00608                 $items['files'][] = $temp;
00609                 if ($this->sort)    {
00610                     $items['sorting'][] = strtoupper($temp[$this->sort]);
00611                 } else {
00612                     $items['sorting'][] = '';
00613                 }
00614             }
00615                 // Sort if required
00616             if ($this->sort)    {
00617                 if (!$this->sortRev)    {
00618                     asort($items['sorting']);
00619                 } else {
00620                     arsort($items['sorting']);
00621                 }
00622             }
00623         }
00624         return $items;
00625     }
00626 
00627     /**
00628      * Creates the clipboard control pad
00629      *
00630      * @param   array       Array with information about the file/directory for which to make the clipboard panel for the listing.
00631      * @return  string      HTML-table
00632      */
00633     function makeClip($theData) {
00634         $cells=array();
00635         $fullIdent = $theData['path'].$theData['file'];
00636         $md5=t3lib_div::shortmd5($fullIdent);
00637 
00638             // For normal clipboard, add copy/cut buttons:
00639         if ($this->clipObj->current=='normal')  {
00640             $isSel = $this->clipObj->isSelected('_FILE',$md5);
00641             $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
00642                         t3lib_iconWorks::getSpriteIcon('actions-edit-copy'.($isSel=='copy'?'-release':''),array('title'=>$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.copy',1))).
00643                         '</a>';
00644             $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
00645                         t3lib_iconWorks::getSpriteIcon('actions-edit-cut'.($isSel=='cut'?'-release':''),array('title'=>$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.cut',1))).
00646                         '</a>';
00647         } else {    // For numeric pads, add select checkboxes:
00648             $n='_FILE|'.$md5;
00649             $this->CBnames[]=$n;
00650 
00651             $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked="checked"':'');
00652             $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" />'.
00653                     '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" class="smallCheckboxes"'.$checked.' />';
00654         }
00655 
00656             // Display PASTE button, if directory:
00657         $elFromTable = $this->clipObj->elFromTable('_FILE');
00658         if (@is_dir($fullIdent) && count($elFromTable)) {
00659             $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'" title="' . $GLOBALS['LANG']->getLL('clip_pasteInto', TRUE) . '">'.
00660               t3lib_iconWorks::getSpriteIcon('actions-document-paste-into') .
00661             '</a>';
00662         }
00663 
00664             // Compile items into a DIV-element:
00665         return '                            <!-- CLIPBOARD PANEL: -->
00666                                             <div class="typo3-clipCtrl">
00667                                                 '.implode('
00668                                                 ',$cells).'
00669                                             </div>';
00670     }
00671 
00672     /**
00673     * Creates the edit control section
00674     *
00675     * @param    array       Array with information about the file/directory for which to make the edit control section for the listing.
00676     * @return   string      HTML-table
00677     */
00678     function makeEdit($theData) {
00679         $cells = array();
00680         $fullIdent = $theData['path'].$theData['file'];
00681         $canEdit = t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], $theData['realFileext']);
00682 
00683             // prepare space icon
00684         $iconWidth  = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeWidth']  ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeWidth']  : 12;
00685         $iconHeight = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeHeight'] ? $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['iconSizeHeight'] : 12;
00686         $spaceIcon = '<img src="' . $this->backPath . 'clear.gif" width="' . $iconWidth . '" height="' . $iconHeight . '" title="" alt="" />';
00687 
00688 
00689             //edit
00690         if ($theData['type'] == 'dir' || !$canEdit) {
00691             $cells['edit'] = $spaceIcon;
00692         } else {
00693             $editOnClick = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'file_edit.php?target=' .
00694                 rawurlencode($fullIdent) .
00695                 '&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location);return false;';
00696             $cells['edit'] = '<a href="#" onclick="' . $editOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.edit') . '">' . t3lib_iconWorks::getSpriteIcon('actions-page-open') . '</a>';
00697         }
00698             //rename
00699         $renameOnClick = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'file_rename.php?target=' .
00700             rawurlencode($fullIdent) .
00701             '&returnUrl=\'+top.rawurlencode(top.content.list_frame.document.location);return false;';
00702         $cells['rename'] = '<a href="#" onclick="' . $renameOnClick . '"  title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.rename') . '">' . t3lib_iconWorks::getSpriteIcon('actions-edit-rename') . '</a>';
00703 
00704             //info
00705         $infoOnClick = 'top.launchView(\'' . $fullIdent . '\', \'\');return false;';
00706         $cells['info'] = '<a href="#" onclick="' . $infoOnClick . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.info') . '">' . t3lib_iconWorks::getSpriteIcon('status-dialog-information') . '</a>';
00707 
00708             // Hook for manipulating edit icons.
00709         if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'])) {
00710             foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fileList']['editIconsHook'] as $classData) {
00711                 $hookObject = t3lib_div::getUserObj($classData);
00712 
00713                 if(!($hookObject instanceof fileList_editIconHook)) {
00714                     throw new UnexpectedValueException('$hookObject must implement interface fileList_editIconHook', 1235225797);
00715                 }
00716 
00717                 $hookObject->manipulateEditIcons($cells, $this);
00718             }
00719         }
00720 
00721             // Compile items into a DIV-element:
00722         return '                            <!-- EDIT CONTROLS: -->
00723                                             <div class="typo3-editCtrl">
00724                                                 ' . implode('
00725                                                 ', $cells).'
00726                                             </div>';
00727     }
00728 
00729     /**
00730      * Make reference count
00731      *
00732      * @param   array       Array with information about the file/directory for which to make the clipboard panel for the listing.
00733      * @return  string      HTML
00734      */
00735     function makeRef($theData)  {
00736 
00737             // First, fit path to match what is stored in the refindex:
00738         $fullIdent = $theData['path'].$theData['file'];
00739 
00740         if (t3lib_div::isFirstPartOfStr($fullIdent,PATH_site))  {
00741             $fullIdent = substr($fullIdent,strlen(PATH_site));
00742         }
00743 
00744             // Look up the path:
00745         $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00746             '*',
00747             'sys_refindex',
00748             'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE','sys_refindex').
00749                 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($fullIdent,'sys_refindex').
00750                 ' AND deleted=0'
00751         );
00752 
00753             // Compile information for title tag:
00754         $infoData=array();
00755         if (is_array($rows)) {
00756             foreach($rows as $row)  {
00757                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
00758             }
00759         }
00760 
00761         return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$theData['path'].$theData['file'].'\', \'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd_cs(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
00762     }
00763 }
00764 
00765 
00766 
00767 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc'])) {
00768     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
00769 }
00770 ?>