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
00074 class fileList extends t3lib_recordList {
00075 var $iLimit = 40;
00076 var $thumbs = 0;
00077 var $widthGif = '<img src="clear.gif" width="1" height="1" hspace="165" alt="" />';
00078 var $fixedL = 30;
00079 var $script = 'file_list.php';
00080 var $clickMenus=1;
00081
00082 var $sort = '';
00083 var $sortRev = 1;
00084 var $firstElementNumber=0;
00085 var $clipBoard = 0;
00086
00087
00088 var $JScode = '';
00089 var $HTMLcode = '';
00090 var $totalbytes=0;
00091 var $dirs = Array();
00092 var $files = Array();
00093 var $path = '';
00094 var $eCounter=0;
00095 var $totalItems='';
00096
00097 var $CBnames=array();
00098
00099
00100
00111 function start($path,$pointer,$sort,$sortRev,$clipBoard=0) {
00112 $this->counter=0;
00113 $this->totalbytes=0;
00114 $this->JScode='';
00115 $this->HTMLcode='';
00116 $this->path = $path;
00117 $this->sort=$sort;
00118 $this->sortRev=$sortRev;
00119 $this->firstElementNumber=$pointer;
00120 $this->clipBoard = $clipBoard;
00121
00122 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
00123 $this->thumbScript='gfx/notfound_thumb.gif';
00124 }
00125 }
00126
00132 function generateList() {
00133 $this->dirs = $this->readDirectory($this->path,'dir,link');
00134 $this->files = $this->readDirectory($this->path,'file');
00135 $this->totalItems=count($this->dirs['sorting'])+count($this->files['sorting']);
00136 $this->HTMLcode.=$this->getTable($this->files, $this->dirs, 'fileext,tstamp,size,rw');
00137 }
00138
00145 function writeTop($path) {
00146
00147 $path = $GLOBALS['SOBE']->basicFF->is_directory($path);
00148
00149 if ($path) {
00150 $out='';
00151 $theFile = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($path);
00152 $root = $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($theFile['path']);
00153 $titleCol='path';
00154 $this->fieldArray = Array($titleCol,'up');
00155
00156 list($title,$icon,$path) = $this->dirData($theFile);
00157
00158
00159 $theData = Array();
00160 $theData[$titleCol] = $this->widthGif;
00161
00162 $title = $GLOBALS['SOBE']->basicFF->blindPath($path);
00163 $theData['up']='<a href="'.htmlspecialchars($this->listURL()).'">'.
00164 '<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="" />'.
00165 '</a>';
00166
00167 if ($root) {
00168
00169 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00170 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
00171
00172 $theData[$titleCol].='<br />'.t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20));
00173 $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']);
00174 } else {
00175
00176 $theIcon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_ftp.gif','width="18" height="16"').' alt="" />';
00177 $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($title,-($this->fixedL+20)));
00178 }
00179
00180
00181 $out.=$this->addelement(1,'',$theData,'','',$theIcon);
00182
00183 $this->HTMLcode.='
00184
00185 <!--
00186 Page header for file list
00187 -->
00188 <table border="0" cellpadding="0" cellspacing="0" id="typo3-filelist-top">
00189 '.$out.'
00190 </table>';
00191 }
00192 }
00193
00203 function linkClipboardHeaderIcon($string,$table,$cmd,$warning='') {
00204 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.submit();';
00205 if ($warning) $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
00206 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent).'return false;">'.$string.'</a>';
00207 }
00208
00217 function getTable($files,$dirs,$rowlist) {
00218
00219 $out='';
00220 $titleCol = 'file';
00221
00222
00223 $rowlist = t3lib_div::rmFromList($titleCol,$rowlist);
00224 $rowlist = t3lib_div::uniqueList($rowlist);
00225 $rowlist = $rowlist ? $titleCol.','.$rowlist : $titleCol;
00226 if ($this->clipBoard) $rowlist.=',_CLIPBOARD_';
00227 $this->fieldArray = explode(',',$rowlist);
00228
00229
00230 $theData = Array();
00231 $theData[$titleCol] = $this->widthGif;
00232 $out.=$this->addelement(0,'',$theData,'');
00233
00234
00235
00236
00237 $iOut = '';
00238 $iOut.= $this->formatDirList($dirs,$titleCol);
00239
00240 if (count($dirs['sorting'])) {
00241
00242 $theData = Array();
00243 $theData[$titleCol] = '';
00244 $iOut.=$this->addelement(0,'',$theData);
00245 }
00246
00247
00248
00249
00250 $iOut.= $this->formatFileList($files,$titleCol);
00251
00252
00253 $theData = Array();
00254 reset($this->fieldArray);
00255 while(list(,$v)=each($this->fieldArray)) {
00256 if ($v=='_CLIPBOARD_') {
00257 $cells=array();
00258 $table='_FILE';
00259 $elFromTable = $this->clipObj->elFromTable($table);
00260 if (count($elFromTable)) {
00261 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$this->path)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$this->path,'into',$elFromTable)).'">'.
00262 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_paste',1).'" alt="" /></a>';
00263 }
00264 if ($this->clipObj->current!='normal' && $iOut) {
00265 $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');
00266 $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'));
00267 $onClick = 'checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;';
00268 $cells[]='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
00269 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_markRecords',1).'" alt="" />'.
00270 '</a>';
00271 }
00272
00273 $theData[$v] = implode('',$cells);
00274 } else {
00275 $theT = $this->linkWrapSort($GLOBALS['LANG']->getLL('c_'.$v,1), $this->path,$v);
00276 $theData[$v] = $theT;
00277 }
00278 }
00279 $out.=$this->addelement(1,'',$theData,' class="c-headLine"','');
00280 $out.=$iOut;
00281
00282
00283 $theData = Array();
00284 $theData[$titleCol] = $this->counter.' File(s), '.t3lib_div::formatSize($this->totalbytes).'bytes';
00285 $out.=$this->addelement(1,'',$theData);
00286
00287
00288 return '
00289
00290
00291 <!--
00292 File list table:
00293 -->
00294 <table border="0" cellpadding="0" cellspacing="0" id="typo3-filelist">
00295 '.$out.'
00296 </table>';
00297 }
00298
00305 function formatDirList($items) {
00306 $out='';
00307
00308
00309 if (count($items['sorting'])) {
00310 reset($items['sorting']);
00311 while (list($key,) = each($items['sorting'])) {
00312 list($flag,$code) = $this->fwd_rwd_nav();
00313 $out.=$code;
00314 if ($flag) {
00315
00316 $theFile = $items['files'][$key];
00317 $this->counter++;
00318
00319 list($title,$icon,$path) = $this->dirData($theFile);
00320
00321
00322 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00323 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$path);
00324
00325
00326 $theData = Array();
00327 reset($this->fieldArray);
00328 while(list(,$field)=each($this->fieldArray)) {
00329 switch($field) {
00330 case 'size':
00331
00332 break;
00333 case 'rw':
00334 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writable'])?'':'<span class="typo3-red"><b>W</b></span>');
00335 break;
00336 case 'fileext':
00337
00338 break;
00339 case 'tstamp':
00340 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile['tstamp']);
00341 break;
00342 case 'file':
00343 $theData[$field]= $this->linkWrapDir(t3lib_div::fixed_lgd($title,$this->fixedL),$path);
00344 break;
00345 case '_CLIPBOARD_':
00346 $theData[$field]=$this->makeClip($theFile);
00347 break;
00348 default:
00349 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
00350 break;
00351 }
00352 }
00353 $out.=$this->addelement(1,$theIcon,$theData);
00354 }
00355 $this->eCounter++;
00356 }
00357 }
00358 return $out;
00359 }
00360
00368 function linkWrapDir($code,$path) {
00369 $href = $this->script.'?id='.rawurlencode($path);
00370 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
00371 }
00372
00380 function linkWrapFile($code,$path) {
00381 if (t3lib_div::isFirstPartOfStr($path,t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT'))) {
00382 $href = substr($path,strlen(t3lib_div::getIndpEnv('TYPO3_DOCUMENT_ROOT')));
00383 $aOnClick = "return top.openUrlInWindow('".$href."','WebFile');";
00384 $code = '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$code.'</a>';
00385 }
00386 return $code;
00387 }
00388
00394 function listURL() {
00395 return $this->script.'?id='.rawurlencode($this->path).'&imagemode='.$this->thumbs;
00396 }
00397
00404 function dirData($theFile) {
00405 $path = $theFile['path'].$theFile['file'].'/';
00406 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
00407
00408 $title=htmlspecialchars($theFile['file']);
00409 $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
00410 if ($title=='_temp_') {
00411 $icon = 'gfx/i/sysf.gif';
00412 $title='<b>TEMP</b>';
00413 }
00414 if ($title=='_recycler_') {
00415 $icon = 'gfx/i/recycler.gif';
00416 $title='<b>RECYCLER</b>';
00417 }
00418 $icon = $theFile['writable'] ? 'gfx/i/_icon_'.$webpath.'folders_ro.gif' : $icon;
00419
00420 return Array($title,$icon,$path);
00421 }
00422
00429 function formatFileList($items) {
00430 $out='';
00431
00432
00433 if (count($items['sorting'])) {
00434 reset($items['sorting']);
00435 while (list($key,) = each($items['sorting'])) {
00436 list($flag,$code) = $this->fwd_rwd_nav();
00437 $out.=$code;
00438 if ($flag) {
00439
00440 $theFile = $items['files'][$key];
00441 $this->counter++;
00442
00443 $this->totalbytes+=$theFile['size'];
00444 $ext = $items['files'][$key][fileext];
00445 $icon = t3lib_BEfunc::getFileIcon($ext);
00446
00447
00448 $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/fileicons/'.$icon,'width="18" height="16"').' title="'.htmlspecialchars($theFile['file']).'" alt="" />';
00449 if ($this->clickMenus) $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($theIcon,$theFile['path'].$theFile['file']);
00450
00451
00452 $theData = Array();
00453 reset($this->fieldArray);
00454 while(list(,$field)=each($this->fieldArray)) {
00455 switch($field) {
00456 case 'size':
00457 $theData[$field]=t3lib_div::formatSize($theFile[$field]);
00458 break;
00459 case 'rw':
00460 $theData[$field]= (($theFile['readable'])?'':'<span class="typo3-red"><b>R</b></span>').(($theFile['writable'])?'':'<span class="typo3-red"><b>W</b></span>');
00461 break;
00462 case 'fileext':
00463 $theData[$field]=strtoupper($theFile[$field]);
00464 break;
00465 case 'tstamp':
00466 $theData[$field]=Date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $theFile[$field]);
00467 break;
00468 case '_CLIPBOARD_':
00469 $theData[$field]=$this->makeClip($theFile);
00470 break;
00471 case 'file':
00472 $theData[$field] = $this->linkWrapFile(t3lib_div::fixed_lgd($theFile[$field],$this->fixedL),$theFile['path'].$theFile['file']);
00473 break;
00474 default:
00475 $theData[$field]=t3lib_div::fixed_lgd($theFile[$field],$this->fixedL);
00476 break;
00477 }
00478 }
00479 $out.=$this->addelement(1,$theIcon,$theData);
00480
00481
00482 if ($this->thumbs && $this->isImage($theFile['fileext'])) {
00483 $thumbData=Array();
00484 $theFile_R = rawurlencode($theFile['path'].$theFile['file']);
00485 $titleCol=$this->fieldArray[0];
00486 $href = $this->backPath.$this->thumbScript.'?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.$theFile_R;
00487 $thumbData[$titleCol]='<img src="'.htmlspecialchars($href).'" hspace="2" title="'.htmlspecialchars(trim($theFile['file'])).'" alt="" />';
00488 $out.=$this->addelement(4,'',$thumbData);
00489 }
00490 }
00491 $this->eCounter++;
00492 }
00493 }
00494 return $out;
00495 }
00496
00503 function isImage($ext) {
00504 return t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],strtolower($ext));
00505 }
00506
00515 function linkWrapSort($code,$path,$col) {
00516 if ($this->sort==$col && !$this->sortRev) {
00517 $params='&SET[sort]='.$col.'&SET[reverse]=1';
00518 } else {
00519 $params='&SET[sort]='.$col.'&SET[reverse]=0';
00520 }
00521 $href = $this->script.'?id='.rawurlencode($path).$params;
00522 return '<a href="'.htmlspecialchars($href).'">'.$code.'</a>';
00523 }
00524
00533 function readDirectory($path,$type,$extList='') {
00534 $items = Array('files'=>array(), 'sorting'=>array());
00535 $path = $GLOBALS['SOBE']->basicFF->is_directory($path);
00536
00537 if($path && $GLOBALS['SOBE']->basicFF->checkPathAgainstMounts($path.'/')) {
00538 $d = @dir($path);
00539 $tempArray=Array();
00540 if (is_object($d)) {
00541 while($entry=$d->read()) {
00542 if ($entry!='.' && $entry!='..') {
00543 $wholePath = $path.'/'.$entry;
00544 if (@file_exists($wholePath) && (!$type || t3lib_div::inList($type,filetype($wholePath)))) {
00545 if ($extList) {
00546 $fI = t3lib_div::split_fileref($entry);
00547 if (t3lib_div::inList($extList,$fI['fileext'])) {
00548 $tempArray[] = $wholePath;
00549 }
00550 } else {
00551 $tempArray[] = $wholePath;
00552 }
00553 }
00554 }
00555 }
00556 $d->close();
00557 }
00558
00559 reset($tempArray);
00560 while (list(,$val)=each($tempArray)) {
00561 $temp = $GLOBALS['SOBE']->basicFF->getTotalFileInfo($val);
00562 $items['files'][] = $temp;
00563 if ($this->sort) {
00564 $items['sorting'][] = strtoupper($temp[$this->sort]);
00565 } else {
00566 $items['sorting'][] = '';
00567 }
00568 }
00569
00570 if ($this->sort) {
00571 if (!$this->sortRev) {
00572 asort($items['sorting']);
00573 } else {
00574 arsort($items['sorting']);
00575 }
00576 }
00577 }
00578 return $items;
00579 }
00580
00587 function makeClip($theData) {
00588 $cells=array();
00589 $fullIdent = $theData['path'].$theData['file'];
00590 $md5=t3lib_div::shortmd5($fullIdent);
00591
00592
00593 if ($this->clipObj->current=='normal') {
00594 $isSel = $this->clipObj->isSelected('_FILE',$md5);
00595 $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,1,($isSel=='copy'))).'">'.
00596 '<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="" />'.
00597 '</a>';
00598 $cells[]='<a href="'.htmlspecialchars($this->clipObj->selUrlFile($fullIdent,0,($isSel=='cut'))).'">'.
00599 '<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="" />'.
00600 '</a>';
00601 } else {
00602 $n='_FILE|'.$md5;
00603 $this->CBnames[]=$n;
00604
00605 $checked = ($this->clipObj->isSelected('_FILE',$md5)?' checked="checked"':'');
00606 $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" />'.
00607 '<input type="checkbox" name="CBC['.$n.']" value="'.htmlspecialchars($fullIdent).'" class="smallCheckboxes"'.$checked.' />';
00608 }
00609
00610
00611 $elFromTable = $this->clipObj->elFromTable('_FILE');
00612 if (@is_dir($fullIdent) && count($elFromTable)) {
00613 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('_FILE',$fullIdent)).'" onclick="return '.htmlspecialchars($this->clipObj->confirmMsg('_FILE',$fullIdent,'into',$elFromTable)).'">'.
00614 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->getLL('clip_pasteInto',1).'" alt="" />'.
00615 '</a>';
00616 }
00617
00618
00619 return ' <!-- CLIPBOARD PANEL: -->
00620 <div class="typo3-clipCtrl">
00621 '.implode('
00622 ',$cells).'
00623 </div>';
00624 }
00625 }
00626
00627
00628
00629 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']) {
00630 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.file_list.inc']);
00631 }
00632 ?>