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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 require_once (PATH_t3lib.'class.t3lib_treeview.php');
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 class t3lib_folderTree extends t3lib_treeView {
00083
00084
00085
00086
00087
00088
00089 function t3lib_folderTree() {
00090 parent::init();
00091
00092 $this->MOUNTS = $GLOBALS['FILEMOUNTS'];
00093
00094 $this->treeName='folder';
00095 $this->titleAttrib='';
00096 $this->domIdPrefix = 'folder';
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 function wrapIcon($icon,$row) {
00108
00109 $theFolderIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"' : ''));
00110
00111
00112 if (!$this->ext_IconMode) {
00113 $theFolderIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theFolderIcon,$row['path'],'',0);
00114 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
00115 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$this->bank.');';
00116 $theFolderIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theFolderIcon.'</a>';
00117 }
00118 return $theFolderIcon;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130 function wrapTitle($title,$row,$bank=0) {
00131 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
00132 $CSM = '';
00133 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
00134 $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('',$row['path'],'',0,'','',TRUE)).'"';
00135 }
00136 return '<a href="#" title="'.htmlspecialchars($row['title']).'" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
00137 }
00138
00139
00140
00141
00142
00143
00144
00145 function getId($v) {
00146 return t3lib_div::md5Int($v['path']);
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 function getJumpToParam($v) {
00156 return rawurlencode($v['path']);
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 function getTitleStr($row,$titleLen=30) {
00168 return $row['_title'] ? $row['_title'] : parent::getTitleStr($row,$titleLen);
00169 }
00170
00171
00172
00173
00174
00175
00176
00177 function getBrowsableTree() {
00178
00179
00180 $this->initializePositionSaving();
00181
00182
00183 $titleLen=intval($this->BE_USER->uc['titleLen']);
00184 $treeArr=array();
00185
00186
00187 foreach($this->MOUNTS as $key => $val) {
00188 $md5_uid = md5($val['path']);
00189 $specUID=hexdec(substr($md5_uid,0,6));
00190 $this->specUIDmap[$specUID]=$val['path'];
00191
00192
00193 $this->bank=$val['nkey'];
00194 $isOpen = $this->stored[$val['nkey']][$specUID] || $this->expandFirst;
00195 $this->reset();
00196
00197
00198 $cmd=$this->bank.'_'.($isOpen?'0_':'1_').$specUID.'_'.$this->treeName;
00199 $icon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif','width="18" height="16"').' alt="" />';
00200 $firstHtml= $this->PM_ATagWrap($icon,$cmd);
00201
00202 switch ($val['type']) {
00203 case 'user':
00204 $icon = 'gfx/i/_icon_ftp_user.gif';
00205 break;
00206 case 'group':
00207 $icon = 'gfx/i/_icon_ftp_group.gif';
00208 break;
00209 case 'readonly':
00210 $icon = 'gfx/i/_icon_ftp_readonly.gif';
00211 break;
00212 default:
00213 $icon = 'gfx/i/_icon_ftp.gif';
00214 break;
00215 }
00216
00217
00218 $firstHtml.=$this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' alt="" />',$val);
00219 $row=array();
00220 $row['path']=$val['path'];
00221 $row['uid']=$specUID;
00222 $row['title']=$val['name'];
00223
00224
00225 $this->tree[]=array('HTML'=>$firstHtml,'row'=>$row,'bank'=>$this->bank);
00226
00227
00228 if ($isOpen) {
00229
00230 $depthD='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/blank.gif','width="18" height="16"').' alt="" />';
00231 $this->getFolderTree($val['path'], 999, $depthD, $val['type']);
00232 }
00233
00234
00235 $treeArr=array_merge($treeArr,$this->tree);
00236 }
00237 return $this->printTree($treeArr);
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 function getFolderTree($files_path, $depth=999, $depthData='', $type='') {
00250
00251
00252 $dirs = t3lib_div::get_dirs($files_path);
00253
00254 $c=0;
00255 if (is_array($dirs)) {
00256 $depth=intval($depth);
00257 $HTML='';
00258 $a=0;
00259 $c=count($dirs);
00260 sort($dirs);
00261
00262 foreach($dirs as $key => $val) {
00263 $a++;
00264 $this->tree[]=array();
00265 end($this->tree);
00266 $treeKey = key($this->tree);
00267 $LN = ($a==$c)?'blank':'line';
00268
00269 $val = ereg_replace('^\./','',$val);
00270 $title = $val;
00271 $path = $files_path.$val.'/';
00272 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
00273
00274 $md5_uid = md5($path);
00275 $specUID=hexdec(substr($md5_uid,0,6));
00276 $this->specUIDmap[$specUID]=$path;
00277 $row=array();
00278 $row['path']=$path;
00279 $row['uid']=$specUID;
00280 $row['title']=$title;
00281
00282 if ($depth>1 && $this->expandNext($specUID)) {
00283 $nextCount=$this->getFolderTree(
00284 $path,
00285 $depth-1,
00286 $this->makeHTML ? $depthData.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$LN.'.gif','width="18" height="16"').' alt="" />' : '',
00287 $type
00288 );
00289 $exp=1;
00290 } else {
00291 $nextCount=$this->getCount($path);
00292 $exp=0;
00293 }
00294
00295
00296 if ($this->makeHTML) {
00297 $HTML=$depthData.$this->PMicon($row,$a,$c,$nextCount,$exp);
00298
00299 $icon = 'gfx/i/_icon_' .$webpath . 'folders' . ($type == 'readonly' ? '_ro' : '') . '.gif';
00300 if ($val=='_temp_') {
00301 $icon = 'gfx/i/sysf.gif';
00302 $row['title'] = $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true);
00303 $row['_title'] = '<strong>' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true) . '</strong>';
00304 }
00305 if ($val=='_recycler_') {
00306 $icon = 'gfx/i/recycler.gif';
00307 $row['title'] = $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true);
00308 $row['_title'] = '<strong>' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true) . '</strong>';
00309 }
00310 $HTML.=$this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' alt="" />',$row);
00311 }
00312
00313
00314 $this->tree[$treeKey] = Array(
00315 'row'=>$row,
00316 'HTML'=>$HTML,
00317 'bank'=>$this->bank
00318 );
00319 }
00320 }
00321 return $c;
00322 }
00323
00324
00325
00326
00327
00328
00329
00330 function getCount($files_path) {
00331
00332 $dirs = t3lib_div::get_dirs($files_path);
00333 $c=0;
00334 if (is_array($dirs)) {
00335 $c=count($dirs);
00336 }
00337 return $c;
00338 }
00339
00340
00341
00342
00343
00344
00345
00346 function initializePositionSaving() {
00347
00348 $this->stored=unserialize($this->BE_USER->uc['browseTrees'][$this->treeName]);
00349
00350
00351 $hashMap=array();
00352 foreach($this->MOUNTS as $key => $val) {
00353 $nkey = hexdec(substr($key,0,4));
00354 $hashMap[$nkey]=$key;
00355 $this->MOUNTS[$key]['nkey']=$nkey;
00356 }
00357
00358
00359
00360 $PM = explode('_',t3lib_div::_GP('PM'));
00361 if (count($PM)==4 && $PM[3]==$this->treeName) {
00362 if (isset($this->MOUNTS[$hashMap[$PM[0]]])) {
00363 if ($PM[1]) {
00364 $this->stored[$PM[0]][$PM[2]]=1;
00365 $this->savePosition($this->treeName);
00366 } else {
00367 unset($this->stored[$PM[0]][$PM[2]]);
00368 $this->savePosition($this->treeName);
00369 }
00370 }
00371 }
00372 }
00373 }
00374
00375 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']) {
00376 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']);
00377 }
00378
00379 ?>