00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00075 class fileList extends t3lib_recordList {
00076 var $iLimit = 40;
00077 var $thumbs = 0;
00078 var $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
00079 var $fixedL = 30;
00080 var $script = 'file_list.php';
00081 var $clickMenus=1;
00082
00083 var $sort = '';
00084 var $sortRev = 1;
00085 var $firstElementNumber=0;
00086 var $clipBoard = 0;
00087
00088
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;
00096 var $totalItems='';
00097
00098 var $CBnames=array();
00099
00100
00101
00112 function start($path,$pointer,$sort,$sortRev,$clipBoard=0) {
00113 $this->counter=0;
00114 $this->totalbytes=0;
00115 $this->JScode='';
00116 $this->HTMLcode='';
00117 $this->path = $path;
00118 $this->sort=$sort;
00119 $this->sortRev=$sortRev;
00120 $this->firstElementNumber=$pointer;
00121 $this->clipBoard = $clipBoard;
00122
00123 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
00124 $this->thumbScript='gfx/notfound_thumb.gif';
00125 }
00126 }
00127
00133 function generateList() {
00134 $this->dirs = $this->readDirectory($this->path,'dir,link');
00135 $this->files = $this->readDirectory($this->path,'file');
00136 $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
00137 $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw,_REF_');
00138 }
00139
00146 function writeTop($path) {
00147
00148 $path = $GLOBALS['SOBE']->basicFF->is_directory($path);
00149
00150 if ($path) {
00151 $out='';
00152 $theFile = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($path);
00153 $root = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($theFile['path']);
00154 $titleCol='path';
00155 $this->fieldArray = Array($titleCol,'up');
00156
00157 list($title,$icon,$path) = $this->dirData($theFile);
00158
00159
00160 $theData = Array();
00161 $theData[$titleCol] = $this->widthGif;
00162
00163 $title = $GLOBALS['SOBE']->basicFF->blindPath($path);
00164 $theData['up']='<a href="'.htmlspecialchars($this->listURL()).'">'.
00165 '<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="" />'.
00166 '</a>';
00167
00168 if ($root) {
00169
00170 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00171 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
00172
00173 $theData[$titleCol].='<br />'.t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20));
00174 $theData['up'].=$this->linkWrapDir('<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/folder_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />',$theFile['path']);
00175 } else {
00176
00177 $theIcon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_ftp.gif','width="18" height="16"').' alt="" />';
00178 $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20)));
00179 }
00180
00181
00182 $out.=$this->addelement(1,'',$theData,'','',$theIcon);
00183
00184 $this->HTMLcode.='
00185
00186 <!--
00187 Page header for file list
00188 -->
00189 <table border="0" cellpadding="0" cellspacing="0" id="typo3-filelist-top">
00190 '.$out.'
00191 </table>';
00192 }
00193 }
00194
00204 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
00205 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.submit();';
00206 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
00207 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">'.$string.'</a>';
00208 }
00209
00218 function getTable($files,$dirs,$rowlist) {
00219
00220 $out='';
00221 $titleCol = 'file';
00222
00223
00224 $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
00225 $rowlist = t3lib_div::uniqueList($rowlist);
00226 $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
00227 if ($this->clipBoard) $rowlist.=',_CLIPBOARD_';
00228 $this->fieldArray = explode(',',$rowlist);
00229
00230
00231 $theData = Array();
00232 $theData[$titleCol] = $this->widthGif;
00233 $out.=$this->addelement(0,'',$theData,'');
00234
00235
00236
00237
00238 $iOut = '';
00239 $iOut.= $this->formatDirList($dirs);
00240
00241 if (count($dirs['sorting'])) {
00242
00243 $theData = Array();
00244 $theData[$titleCol] = '';
00245 $iOut.=$this->addelement(0,'',$theData);
00246 }
00247
00248
00249
00250
00251 $iOut.= $this->formatFileList($files,$titleCol);
00252
00253
00254 $theData = Array();
00255 reset($this->fieldArray);
00256 while(list(,$v)=each($this->fieldArray)) {
00257 if ($v=='_CLIPBOARD_') {
00258 $cells=array();
00259 $table='_FILE';
00260 $elFromTable = $this->clipObj->elFromTable($table);
00261 if (count($elFromTable)) {
00262 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$this->path)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$this->path,'into',$elFromTable)).'">'.
00263 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_paste',1).'" alt="" /></a>';
00264 }
00265 if ($this->clipObj->current!='normal' && $iOut) {
00266 $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');
00267 $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'));
00268 $onClick = 'checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;';
00269 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
00270 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_markRecords',1).'" alt="" />'.
00271 '</a>';
00272 }
00273
00274 $theData[$v] = implode('',$cells);
00275 } else {
00276 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
00277 $theData[$v] = $theT;
00278 }
00279 }
00280 $out.=$this->addelement(1,'',$theData,' class="c-headLine"','');
00281 $out.=$iOut;
00282
00283
00284 $theData = Array();
00285 $theData[$titleCol] = $this->counter.' File(s), '.t3lib_div::formatSize($this->totalbytes).'bytes';
00286 $out.=$this->addelement(1,'',$theData);
00287
00288
00289 return '
00290
00291
00292 <!--
00293 File list table:
00294 -->
00295 <table border="0" cellpadding="0" cellspacing="0" id="typo3-filelist">
00296 '.$out.'
00297 </table>';
00298 }
00299
00306 function formatDirList($items) {
00307 $out='';
00308
00309
00310 if (count($items['sorting'])) {
00311 reset($items['sorting']);
00312 while (list($key,) = each($items['sorting'])) {
00313 list($flag,$code) = $this->fwd_rwd_nav();
00314 $out.=$code;
00315 if ($flag) {
00316
00317 $theFile = $items['files'][$key];
00318 $this->counter++;
00319
00320 list($title,$icon,$path) = $this->dirData($theFile);
00321
00322
00323 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00324 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
00325
00326
00327 $theData = Array();
00328 reset($this->fieldArray);
00329 while(list(,$field)=each($this->fieldArray)) {
00330 switch($field) {
00331 case 'size':
00332
00333 break;
00334 case 'rw':
00335 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writable'])?'':'<span class="typo3-red"><b>W</b></span>');
00336 break;
00337 case 'fileext':
00338
00339 break;
00340 case 'tstamp':
00341 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile['tstamp']);
00342 break;
00343 case 'file':
00344 $theData[$field]= $this->linkWrapDir($title,$path);
00345 break;
00346 case '_CLIPBOARD_':
00347 $theData[$field]=$this->makeClip($theFile);
00348 break;
00349 case '_REF_':
00350 $theData[$field]=$this->makeRef($theFile);
00351 break;
00352 default:
00353 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
00354 break;
00355 }
00356 }
00357 $out.=$this->addelement(1,$theIcon,$theData);
00358 }
00359 $this->eCounter++;
00360 }
00361 }
00362 return $out;
00363 }
00364
00372 function linkWrapDir($code,$path) {
00373 $href = $this->script.'?id='.rawurlencode($path);
00374 $onclick = ' onclick="'.htmlspecialchars('top.content.nav_frame.hilight_row("file","folder'.t3lib_div::md5int($path).'_"+top.fsMod.currentBank)').'"';
00375
00376
00377 if(!strcmp($code,strip_tags($code))) {
00378 return '<a href="'.htmlspecialchars($href).'"'.$onclick.' title="'.htmlspecialchars($code).'">'.t3lib_div::fixed_lgd($code,$this->fixedL).'</a>';
00379 } else {
00380 return '<a href="'.htmlspecialchars($href).'"'.$onclick.'>'.$code.'</a>';
00381 }
00382 }
00383
00391 function linkWrapFile($code,$path) {
00392
00393 if (t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT'))) {
00394 $href = substr($path,strlen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')));
00395 $aOnClick = "return top.openUrlInWindow('".$href."','WebFile');";
00396 $code = '<a href="#" title="'.htmlspecialchars($code).'" onclick="'.htmlspecialchars($aOnClick).'">'.t3lib_div::fixed_lgd($code,$this->fixedL).'</a>';
00397 }
00398 return $code;
00399 }
00400
00406 function listURL() {
00407 return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
00408 }
00409
00416 function dirData($theFile) {
00417 $path = $theFile['path'].$theFile['file'].'/';
00418 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
00419
00420 $title=htmlspecialchars($theFile['file']);
00421 $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
00422 if ($title=='_temp_') {
00423 $icon = 'gfx/i/sysf.gif';
00424 $title='<b>TEMP</b>';
00425 }
00426 if ($title=='_recycler_') {
00427 $icon = 'gfx/i/recycler.gif';
00428 $title='<b>RECYCLER</b>';
00429 }
00430 $icon = $theFile['writable'] ? 'gfx/i/_icon_'.$webpath.'folders_ro.gif' : $icon;
00431
00432 return Array($title,$icon,$path);
00433 }
00434
00441 function formatFileList($items) {
00442 $out='';
00443
00444
00445 if (count($items['sorting'])) {
00446 reset($items['sorting']);
00447 while (list($key,) = each($items['sorting'])) {
00448 list($flag,$code) = $this->fwd_rwd_nav();
00449 $out.=$code;
00450 if ($flag) {
00451
00452 $theFile = $items['files'][$key];
00453 $this->counter++;
00454
00455 $this->totalbytes+=$theFile['size'];
00456 $ext = $items['files'][$key][fileext];
00457 $icon = t3lib_BEfunc::getFileIcon($ext);
00458
00459
00460 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00461 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
00462
00463
00464 $theData = Array();
00465 reset($this->fieldArray);
00466 while(list(,$field)=each($this->fieldArray)) {
00467 switch($field) {
00468 case 'size':
00469 $theData[$field]=t3lib_div::formatSize($theFile[$field]);
00470 break;
00471 case 'rw':
00472 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writable'])?'':'<span class="typo3-red"><b>W</b></span>');
00473 break;
00474 case 'fileext':
00475 $theData[$field]=strtoupper($theFile[$field]);
00476 break;
00477 case 'tstamp':
00478 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
00479 break;
00480 case '_CLIPBOARD_':
00481 $theData[$field]=$this->makeClip($theFile);
00482 break;
00483 case '_REF_':
00484 $theData[$field]=$this->makeRef($theFile);
00485 break;
00486 case 'file':
00487 $theData[$field] = $this->linkWrapFile($theFile[$field],$theFile['path'].$theFile['file']);
00488 break;
00489 default:
00490 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
00491 break;
00492 }
00493 }
00494 $out.=$this->addelement(1,$theIcon,$theData);
00495
00496
00497 if ($this->thumbs && $this->isImage($theFile['fileext'])) {
00498 $thumbData=Array();
00499 $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
00500 $titleCol=$this->fieldArray[0];
00501 $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.$theFile_R;
00502 $thumbData[$titleCol]='<img src="'.htmlspecialchars($href).'" hspace="2" title="'.htmlspecialchars(trim($theFile['file'])).'" alt="" />';
00503 $out.=$this->addelement(4,'',$thumbData);
00504 }
00505 }
00506 $this->eCounter++;
00507 }
00508 }
00509 return $out;
00510 }
00511
00518 function isImage($ext) {
00519 return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
00520 }
00521
00530 function linkWrapSort($code,$path,$col) {
00531 if ($this->sort==$col && !$this->sortRev) {
00532 $params='&SET[sort]='.$col.'&SET[reverse]=1';
00533 } else {
00534 $params='&SET[sort]='.$col.'&SET[reverse]=0';
00535 }
00536 $href = $this->script.'?id='.rawurlencode($path).$params;
00537 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
00538 }
00539
00548 function readDirectory($path,$type,$extList='') {
00549 $items = Array('files'=>array(), 'sorting'=>array());
00550 $path = $GLOBALS['SOBE']->basicFF->is_directory($path);
00551
00552 if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/')) {
00553 $d = @dir($path);
00554 $tempArray=Array();
00555 if (is_object($d)) {
00556 while($entry=$d->read()) {
00557 if ($entry!='.' && $entry!='..') {
00558 $wholePath = $path.'/'.$entry;
00559 if (@file_exists($wholePath) && (!$type || t3lib_div::inList($type,filetype($wholePath)))) {
00560 if ($extList) {
00561 $fI = t3lib_div::split_fileref($entry);
00562 if (t3lib_div::inList($extList,$fI['fileext'])) {
00563 $tempArray[] = $wholePath;
00564 }
00565 } else {
00566 $tempArray[] = $wholePath;
00567 }
00568 }
00569 }
00570 }
00571 $d->close();
00572 }
00573
00574 reset($tempArray);
00575 while (list(,$val)=each($tempArray)) {
00576 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
00577 $items['files'][] = $temp;
00578 if ($this->sort) {
00579 $items['sorting'][] = strtoupper($temp[$this->sort]);
00580 } else {
00581 $items['sorting'][] = '';
00582 }
00583 }
00584
00585 if ($this->sort) {
00586 if (!$this->sortRev) {
00587 asort($items['sorting']);
00588 } else {
00589 arsort($items['sorting']);
00590 }
00591 }
00592 }
00593 return $items;
00594 }
00595
00602 function makeClip($theData) {
00603 $cells=array();
00604 $fullIdent = $theData['path'].$theData['file'];
00605 $md5=t3lib_div::shortmd5($fullIdent);
00606
00607
00608 if ($this->clipObj->current=='normal') {
00609 $isSel = $this->clipObj->isSelected('_FILE',$md5);
00610 $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
00611 '<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="" />'.
00612 '</a>';
00613 $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
00614 '<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="" />'.
00615 '</a>';
00616 } else {
00617 $n='_FILE|'.$md5;
00618 $this->CBnames[]=$n;
00619
00620 $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked="checked"':'');
00621 $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" />'.
00622 '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" class="smallCheckboxes"'.$checked.' />';
00623 }
00624
00625
00626 $elFromTable = $this->clipObj->elFromTable('_FILE');
00627 if (@is_dir($fullIdent) && count($elFromTable)) {
00628 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'">'.
00629 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_pasteInto',1).'" alt="" />'.
00630 '</a>';
00631 }
00632
00633
00634 return ' <!-- CLIPBOARD PANEL: -->
00635 <div class="typo3-clipCtrl">
00636 '.implode('
00637 ',$cells).'
00638 </div>';
00639 }
00640
00647 function makeRef($theData) {
00648
00649
00650 $fullIdent = $theData['path'].$theData['file'];
00651
00652 if (t3lib_div::isFirstPartOfStr($fullIdent,PATH_site)) {
00653 $fullIdent = substr($fullIdent,strlen(PATH_site));
00654 }
00655
00656
00657 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00658 '*',
00659 'sys_refindex',
00660 'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr('_FILE','sys_refindex').
00661 ' AND ref_string='.$GLOBALS['TYPO3_DB']->fullQuoteStr($fullIdent,'sys_refindex').
00662 ' AND deleted=0'
00663 );
00664
00665
00666 $infoData=array();
00667 if (is_array($rows)) {
00668 foreach($rows as $row) {
00669 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
00670 }
00671 }
00672
00673 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>' : '';
00674 }
00675 }
00676
00677
00678
00679 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']) {
00680 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
00681 }
00682 ?>