class.file_list.inc

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (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 4637 2009-01-01 16:49:13Z benni $
00031  * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
00032  *
00033  * @author  Kasper Skaarhoj <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 Skaarhoj <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 
00088         // internal
00089     var $JScode = '';
00090     var $HTMLcode = '';
00091     var $totalbytes=0;
00092     var $dirs = Array();
00093     var $files = Array();
00094     var $path = '';
00095     var $eCounter=0;                    // Counting the elements no matter what...
00096     var $dirCounter = 0;
00097     var $totalItems='';
00098 
00099     var $CBnames=array();
00100 
00101 
00102 
00103     /**
00104      * Initialization of class
00105      *
00106      * @param   string      The path to list
00107      * @param   integer     Pointer
00108      * @param   boolean     Sorting column
00109      * @param   boolean     Sorting direction
00110      * @param   boolean     Show clipboard flag
00111      * @return  void
00112      */
00113     function start($path,$pointer,$sort,$sortRev,$clipBoard=0)  {
00114         $this->counter=0;
00115         $this->totalbytes=0;
00116         $this->JScode='';
00117         $this->HTMLcode='';
00118         $this->path = $path;
00119         $this->sort=$sort;
00120         $this->sortRev=$sortRev;
00121         $this->firstElementNumber=$pointer;
00122         $this->clipBoard = $clipBoard;
00123             // setting the maximum length of the filenames to the user's settings or minimum 30 (= $this->fixedL)
00124         $this->fixedL = max($this->fixedL, $GLOBALS['BE_USER']->uc['titleLen']);
00125 
00126         if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])  {
00127             $this->thumbScript='gfx/notfound_thumb.gif';
00128         }
00129         $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_common.xml');
00130     }
00131 
00132     /**
00133      * Reading files and directories, counting elements and generating the list in ->HTMLcode
00134      *
00135      * @return  void
00136      */
00137     function generateList() {
00138         $this->dirs = $this->readDirectory($this->path,'dir,link');
00139         $this->files = $this->readDirectory($this->path,'file');
00140         $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
00141         $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw,_REF_');
00142     }
00143 
00144     /**
00145      * Return the buttons used by the file list to include in the top header
00146      *
00147      * @return  array
00148      */
00149     function getButtonsAndOtherMarkers($path) {
00150 
00151             // Makes the code for the foldericon in the top
00152         $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
00153 
00154         if ($path)  {
00155             $otherMarkers = array(
00156                 'PAGE_ICON' => '',
00157                 'TITLE' => '',
00158             );
00159 
00160             $buttons = array(
00161                 'level_up' => '',
00162                 'refresh' => '',
00163                 'title' => '',
00164                 'page_icon' => '',
00165             );
00166 
00167             $theFile = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($path);
00168 
00169             list($title,$icon,$path) =  $this->dirData($theFile);
00170 
00171                 // Start compiling the HTML
00172             $title = $GLOBALS['SOBE']->basicFF->blindPath($path);
00173 
00174                 // if this is some subpage under the mount root....
00175             if ($GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($theFile['path'])) {
00176                     // The icon with link
00177                 $otherMarkers['PAGE_ICON'] = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00178                 if ($this->clickMenus) $otherMarkers['PAGE_ICON'] = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'],$path);
00179 
00180                 $buttons['level_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']);
00181                 $otherMarkers['TITLE'] .= t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20));  // No HTML specialchars here - HTML like <b> </b> is allowed
00182 
00183                 // this is the root page
00184             } else {
00185                 $otherMarkers['PAGE_ICON'] = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_ftp.gif','width="18" height="16"').' alt="" />';
00186                 if ($this->clickMenus) $otherMarkers['PAGE_ICON'] = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($otherMarkers['PAGE_ICON'],$path);
00187                 $otherMarkers['TITLE'] .= htmlspecialchars(t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20)));
00188             }
00189         }
00190 
00191         $buttons['refresh'] = '<a href="'.htmlspecialchars($this->listURL()).'">'.
00192                 '<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="" />'.
00193                 '</a>';
00194 
00195         return array($buttons, $otherMarkers);
00196     }
00197 
00198     /**
00199      * Wrapping input string in a link with clipboard command.
00200      *
00201      * @param   string      String to be linked - must be htmlspecialchar'ed / prepared before.
00202      * @param   string      table - NOT USED
00203      * @param   string      "cmd" value
00204      * @param   string      Warning for JS confirm message
00205      * @return  string      Linked string
00206      */
00207     function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')   {
00208         $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.submit();';
00209         if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
00210         return '<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">'.$string.'</a>';
00211     }
00212 
00213     /**
00214      * Returns a table with directories and files listed.
00215      *
00216      * @param   array       Array of files from path
00217      * @param   array       Array of directories from path
00218      * @param   string      List of rows to display horizontallyh
00219      * @return  string      HTML-table
00220      */
00221     function getTable($files,$dirs,$rowlist)    {
00222             // Adds the code of files/dirs
00223         $out='';
00224         $titleCol = 'file';
00225 
00226             // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
00227         $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
00228         $rowlist = t3lib_div::uniqueList($rowlist);
00229         $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
00230         if ($this->clipBoard)   $rowlist.=',_CLIPBOARD_';
00231         $this->fieldArray = explode(',',$rowlist);
00232 
00233             // Directories are added
00234         $iOut = '';
00235         $iOut.= $this->formatDirList($dirs);
00236 
00237         if (count($dirs['sorting']))    {
00238                 // half line is drawn
00239             $theData = Array();
00240             $theData[$titleCol] = '';
00241         }
00242 
00243 
00244 
00245             // Files are added
00246         $iOut.= $this->formatFileList($files,$titleCol);
00247 
00248             // Header line is drawn
00249         $theData = Array();
00250         reset($this->fieldArray);
00251         while(list(,$v)=each($this->fieldArray))    {
00252             if ($v=='_CLIPBOARD_')  {
00253                 $cells=array();
00254                 $table='_FILE';
00255                 $elFromTable = $this->clipObj->elFromTable($table);
00256                 if (count($elFromTable))    {
00257                     $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$this->path)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$this->path,'into',$elFromTable)).'">'.
00258                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_paste',1).'" alt="" /></a>';
00259                 }
00260                 if ($this->clipObj->current!='normal' && $iOut) {
00261                     $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');
00262                     $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'));
00263                     $onClick = 'checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;';
00264                     $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
00265                             '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_markRecords',1).'" alt="" />'.
00266                             '</a>';
00267                 }
00268 
00269                 $theData[$v] = implode('',$cells);
00270             } else {    // Normal row:
00271                 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
00272                 $theData[$v] = $theT;
00273             }
00274         }
00275         $out.=$this->addelement(1,'',$theData,' class="c-headLine"','');
00276         $out.=$iOut;
00277 
00278             // half line is drawn
00279 
00280             // finish
00281         return '
00282 
00283 
00284         <!--
00285             File list table:
00286         -->
00287             <table border="0" cellpadding="0" cellspacing="1" id="typo3-filelist">
00288                 '.$out.'
00289             </table>';
00290     }
00291 
00292     /**
00293      * Gets the number of files and total size of a folder
00294      *
00295      * @return string
00296      **/
00297     function getFolderInfo() {
00298         if($this->counter == 1) {
00299             $fileLabel = $GLOBALS['LANG']->getLL('file', true);
00300         } else {
00301             $fileLabel = $GLOBALS['LANG']->getLL('files', true);
00302         }
00303         return $this->counter . ' ' . $fileLabel . ', ' . t3lib_div::formatSize($this->totalbytes, $GLOBALS['LANG']->getLL('byteSizeUnits', true));
00304     }
00305 
00306     /**
00307      * This returns tablerows for the directories in the array $items['sorting'].
00308      *
00309      * @param   array       Directory items
00310      * @return  string      HTML table rows.
00311      */
00312     function formatDirList($items)  {
00313         $out='';
00314 
00315         // Folders:
00316         if (count($items['sorting']))   {
00317             reset($items['sorting']);
00318             while (list($key,) = each($items['sorting']))   {
00319                 list($flag,$code) = $this->fwd_rwd_nav();
00320                 $out.=$code;
00321                 if ($flag)  {
00322                         // Initialization
00323                     $theFile = $items['files'][$key];
00324                     $this->counter++;
00325 
00326                     list($title,$icon,$path) =  $this->dirData($theFile);
00327 
00328                         // The icon with link
00329                     $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00330                     if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
00331 
00332                         //  Preparing and getting the data-array
00333                     $theData = Array();
00334                     reset($this->fieldArray);
00335                     while(list(,$field)=each($this->fieldArray))    {
00336                         switch($field)  {
00337                             case 'size':
00338                                 $theData[$field] = t3lib_div::formatSize($theFile[$field], $GLOBALS['LANG']->getLL('byteSizeUnits', true));
00339                             break;
00340                             case 'rw':
00341                                 $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>');
00342                             break;
00343                             case 'fileext':
00344                                 $theData[$field]=strtoupper($theFile['fileext']);
00345                             break;
00346                             case 'tstamp':
00347                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile['tstamp']);
00348                             break;
00349                             case 'file':
00350                                 $theData[$field]= $this->linkWrapDir($title,$path);
00351                             break;
00352                             case '_CLIPBOARD_':
00353                                 $theData[$field]=$this->makeClip($theFile);
00354                             break;
00355                             case '_REF_':
00356                                 $theData[$field]=$this->makeRef($theFile);
00357                             break;
00358                             default:
00359                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
00360                             break;
00361                         }
00362                     }
00363                     $altRows = 'class="' . ($i++ % 2 == 0 ? 'bgColor6' : 'bgColor4') . '"';
00364 
00365                     $out .= $this->addelement(1, $theIcon, $theData, $altRows);
00366                 }
00367                 $this->eCounter++;
00368                 $this->dirCounter = $this->eCounter;
00369             }
00370         }
00371         return $out;
00372     }
00373 
00374     /**
00375      * Wraps the directory-titles
00376      *
00377      * @param   string      String to be wrapped in links
00378      * @param   string      ID (path)
00379      * @return  string      HTML
00380      */
00381     function linkWrapDir($code,$path)   {
00382         $href = $this->script.'?id='.rawurlencode($path);
00383         $onclick = ' onclick="'.htmlspecialchars('top.content.nav_frame.hilight_row("file","folder'.t3lib_div::md5int($path).'_"+top.fsMod.currentBank)').'"';
00384 
00385             // Sometimes $code contains plain HTML tags. In such a case the string should not be modified!
00386         if(!strcmp($code,strip_tags($code)))    {
00387             return '<a href="'.htmlspecialchars($href).'"'.$onclick.' title="'.htmlspecialchars($code).'">'.t3lib_div::fixed_lgd($code,$this->fixedL).'</a>';
00388         } else  {
00389             return '<a href="'.htmlspecialchars($href).'"'.$onclick.'>'.$code.'</a>';
00390         }
00391     }
00392 
00393     /**
00394      * Wraps filenames in links which opens them in a window IF they are in web-path.
00395      *
00396      * @param   string      String to be wrapped in links
00397      * @param   string      ID (path)
00398      * @return  string      HTML
00399      */
00400     function linkWrapFile($code,$path)  {
00401 
00402         if (t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')))    {
00403             $href = substr($path,strlen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')));
00404             $aOnClick = "return top.openUrlInWindow('".$href."','WebFile');";
00405             $code = '<a href="#" title="'.htmlspecialchars($code).'" onclick="'.htmlspecialchars($aOnClick).'">'.t3lib_div::fixed_lgd($code,$this->fixedL).'</a>';
00406         }
00407         return $code;
00408     }
00409 
00410     /**
00411      * Returns list URL; This is the URL of the current script with id and imagemode parameters, thats all.
00412      *
00413      * @return  string      URL
00414      */
00415     function listURL()  {
00416         return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
00417     }
00418 
00419     /**
00420      * Returns some data specific for the directories...
00421      *
00422      * @param   array       File information array
00423      * @return  array       (title, icon, path)
00424      */
00425     function dirData($theFile)  {
00426         $path = $theFile['path'] . $theFile['file'] . '/';
00427         $webpath = t3lib_BEfunc::getPathType_web_nonweb($path);
00428 
00429         $title = htmlspecialchars($theFile['file']);
00430         $icon = 'gfx/i/_icon_' . $webpath . 'folders.gif';
00431         if ($title == '_temp_') {
00432             $icon = 'gfx/i/sysf.gif';
00433             $title = '<strong>' . $GLOBALS['LANG']->getLL('temp', true) . '</strong>';
00434         }
00435         if ($title == '_recycler_') {
00436             $icon = 'gfx/i/recycler.gif';
00437             $title = '<strong>' . $GLOBALS['LANG']->getLL('recycler', true) . '</strong>';
00438         }
00439         $icon = $theFile['writable'] ? 'gfx/i/_icon_' . $webpath . 'folders_ro.gif' : $icon;
00440 
00441         return array($title, $icon, $path);
00442     }
00443 
00444     /**
00445      * This returns tablerows for the files in the array $items['sorting'].
00446      *
00447      * @param   array       File items
00448      * @return  string      HTML table rows.
00449      */
00450     function formatFileList($items) {
00451         $out='';
00452 
00453             // Files:
00454         if (count($items['sorting']))   {
00455             reset($items['sorting']);
00456             while (list($key,) = each($items['sorting']))   {
00457                 list($flag,$code) = $this->fwd_rwd_nav();
00458                 $out.=$code;
00459                 if ($flag)  {
00460                         // Initialization
00461                     $theFile = $items['files'][$key];
00462                     $this->counter++;
00463 
00464                     $this->totalbytes+=$theFile['size'];
00465                     $ext = $items['files'][$key][fileext];
00466                     $icon = t3lib_BEfunc::getFileIcon($ext);
00467 
00468                         // The icon with link
00469                     $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00470                     if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
00471 
00472                         //  Preparing and getting the data-array
00473                     $theData = Array();
00474                     reset($this->fieldArray);
00475                     while(list(,$field)=each($this->fieldArray))    {
00476                         switch($field)  {
00477                             case 'size':
00478                                 $theData[$field] = t3lib_div::formatSize($theFile[$field], $GLOBALS['LANG']->getLL('byteSizeUnits', true));
00479                             break;
00480                             case 'rw':
00481                                 $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>');
00482                             break;
00483                             case 'fileext':
00484                                 $theData[$field]=strtoupper($theFile[$field]);
00485                             break;
00486                             case 'tstamp':
00487                                 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
00488                             break;
00489                             case '_CLIPBOARD_':
00490                                 $theData[$field]=$this->makeClip($theFile);
00491                             break;
00492                             case '_REF_':
00493                                 $theData[$field]=$this->makeRef($theFile);
00494                             break;
00495                             case 'file':
00496                                 $theData[$field] = $this->linkWrapFile($theFile[$field],$theFile['path'].$theFile['file']);
00497                             break;
00498                             default:
00499                                 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
00500                             break;
00501                         }
00502                     }
00503                     if ($this->dirCounter % 2 == 0) {
00504                         $altRows = 'class="' . ($i++ % 2 == 0 ? 'bgColor6' : 'bgColor4') . '"';
00505                     } else {
00506                         $altRows = 'class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '"';
00507                     }
00508 
00509                     $out .= $this->addelement(1, $theIcon, $theData, $altRows);
00510 
00511                         // Thumbsnails?
00512                     if ($this->thumbs && $this->isImage($theFile['fileext']))   {
00513                         $thumbData = array();
00514                         $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
00515                         $titleCol = $this->fieldArray[0];
00516 
00517                         $theFile_abs = $theFile['path'].$theFile['file'];
00518                         $check = basename($theFile_abs).':'.filemtime($theFile_abs).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
00519                         $params = '&file='.$theFile_R;
00520                         $params.= '&md5sum='.t3lib_div::shortMD5($check);
00521                         $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].$params;
00522 
00523                         $thumbData[$titleCol]='<img src="'.htmlspecialchars($href).'" hspace="2" title="'.htmlspecialchars(trim($theFile['file'])).'" alt="" />';
00524                         $out.= $this->addelement(4,'',$thumbData);
00525                     }
00526                 }
00527                 $this->eCounter++;
00528             }
00529         }
00530         return $out;
00531     }
00532 
00533     /**
00534      * Returns true if $ext is an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
00535      *
00536      * @param   string      file extension
00537      * @return  boolean
00538      */
00539     function isImage($ext)  {
00540         return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
00541     }
00542 
00543     /**
00544      * Wraps the directory-titles ($code) in a link to file_list.php (id=$path) and sorting commands...
00545      *
00546      * @param   string      String to be wrapped
00547      * @param   string      ID (path)
00548      * @param   string      Sorting column
00549      * @return  string      HTML
00550      */
00551     function linkWrapSort($code,$path,$col) {
00552         if ($this->sort==$col && !$this->sortRev)   {       // reverse sorting
00553             $params='&SET[sort]='.$col.'&SET[reverse]=1';
00554         } else {
00555             $params='&SET[sort]='.$col.'&SET[reverse]=0';
00556         }
00557         $href = $this->script.'?id='.rawurlencode($path).$params;
00558         return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
00559     }
00560 
00561     /**
00562      * Returns an array with file/dir items + an array with the sorted items
00563      *
00564      * @param   string      Path (absolute) to read
00565      * @param   string      $type is the technical type; file,dir,link. empty is all kinds of stuff.
00566      * @param   string      $extList: List of fileextensions to select. If empty, all are selected.
00567      * @return  array       Array('files'=>array(), 'sorting'=>array());
00568      */
00569     function readDirectory($path,$type,$extList='') {
00570         $items = Array('files'=>array(), 'sorting'=>array());
00571         $path = $GLOBALS['SOBE']->basicFF->is_directory($path); // Cleaning name...
00572 
00573         if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/'))   {
00574             $d = @dir($path);
00575             $tempArray=Array();
00576             if (is_object($d))  {
00577                 while(false !== ($entry=$d->read())) {
00578                     if ($entry!='.' && $entry!='..')    {
00579                         $wholePath = $path.'/'.$entry;      // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
00580                         if (@file_exists($wholePath) && (!$type || t3lib_div::inList($type,filetype($wholePath))))  {
00581                             if ($extList)   {
00582                                 $fI = t3lib_div::split_fileref($entry);
00583                                 if (t3lib_div::inList($extList,$fI['fileext'])) {
00584                                     $tempArray[] = $wholePath;
00585                                 }
00586                             } else {
00587                                 $tempArray[] = $wholePath;
00588                             }
00589                         }
00590                     }
00591                 }
00592                 $d->close();
00593             }
00594                 // Get fileinfo
00595             reset($tempArray);
00596             while (list(,$val)=each($tempArray))    {
00597                 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
00598                 $items['files'][] = $temp;
00599                 if ($this->sort)    {
00600                     $items['sorting'][] = strtoupper($temp[$this->sort]);
00601                 } else {
00602                     $items['sorting'][] = '';
00603                 }
00604             }
00605                 // Sort if required
00606             if ($this->sort)    {
00607                 if (!$this->sortRev)    {
00608                     asort($items['sorting']);
00609                 } else {
00610                     arsort($items['sorting']);
00611                 }
00612             }
00613         }
00614         return $items;
00615     }
00616 
00617     /**
00618      * Creates the clipboard control pad
00619      *
00620      * @param   array       Array with information about the file/directory for which to make the clipboard panel for the listing.
00621      * @return  string      HTML-table
00622      */
00623     function makeClip($theData) {
00624         $cells=array();
00625         $fullIdent = $theData['path'].$theData['file'];
00626         $md5=t3lib_div::shortmd5($fullIdent);
00627 
00628             // For normal clipboard, add copy/cut buttons:
00629         if ($this->clipObj->current=='normal')  {
00630             $isSel = $this->clipObj->isSelected('_FILE',$md5);
00631             $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
00632                         '<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="" />'.
00633                         '</a>';
00634             $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
00635                         '<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="" />'.
00636                         '</a>';
00637         } else {    // For numeric pads, add select checkboxes:
00638             $n='_FILE|'.$md5;
00639             $this->CBnames[]=$n;
00640 
00641             $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked="checked"':'');
00642             $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" />'.
00643                     '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" class="smallCheckboxes"'.$checked.' />';
00644         }
00645 
00646             // Display PASTE button, if directory:
00647         $elFromTable = $this->clipObj->elFromTable('_FILE');
00648         if (@is_dir($fullIdent) && count($elFromTable)) {
00649             $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'">'.
00650                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_pasteInto',1).'" alt="" />'.
00651                         '</a>';
00652         }
00653 
00654             // Compile items into a DIV-element:
00655         return '                            <!-- CLIPBOARD PANEL: -->
00656                                             <div class="typo3-clipCtrl">
00657                                                 '.implode('
00658                                                 ',$cells).'
00659                                             </div>';
00660     }
00661 
00662     /**
00663      * Make reference count
00664      *
00665      * @param   array       Array with information about the file/directory for which to make the clipboard panel for the listing.
00666      * @return  string      HTML
00667      */
00668     function makeRef($theData)  {
00669 
00670             // First, fit path to match what is stored in the refindex:
00671         $fullIdent = $theData['path'].$theData['file'];
00672 
00673         if (t3lib_div::isFirstPartOfStr($fullIdent,PATH_site))  {
00674             $fullIdent = substr($fullIdent,strlen(PATH_site));
00675         }
00676 
00677             // Look up the path:
00678         $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00679             '*',
00680             'sys_refindex',
00681             'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE','sys_refindex').
00682                 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($fullIdent,'sys_refindex').
00683                 ' AND deleted=0'
00684         );
00685 
00686             // Compile information for title tag:
00687         $infoData=array();
00688         if (is_array($rows)) {
00689             foreach($rows as $row)  {
00690                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
00691             }
00692         }
00693 
00694         return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$theData['path'].$theData['file'].'\', \'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
00695     }
00696 }
00697 
00698 
00699 
00700 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc'])   {
00701     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
00702 }
00703 ?>

Generated on Sat Jan 3 04:23:28 2009 for TYPO3 API by  doxygen 1.4.7