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
00057 require_once (PATH_t3lib.'class.t3lib_treeview.php');
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00081 class t3lib_folderTree extends t3lib_treeView {
00082
00088 function t3lib_folderTree() {
00089 parent::init();
00090
00091 $this->MOUNTS = $GLOBALS['FILEMOUNTS'];
00092
00093 $this->treeName='folder';
00094 $this->titleAttrib='';
00095 $this->domIdPrefix = 'folder';
00096 }
00097
00106 function wrapIcon($icon,$row) {
00107
00108 $theFolderIcon = $this->addTagAttributes($icon,($this->titleAttrib ? $this->titleAttrib.'="'.$this->getTitleAttrib($row).'"' : ''));
00109
00110
00111 if (!$this->ext_IconMode) {
00112 $theFolderIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theFolderIcon,$row['path'],'',0);
00113 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
00114 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'_'.$this->bank.'\');';
00115 $theFolderIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theFolderIcon.'</a>';
00116 }
00117 return $theFolderIcon;
00118 }
00119
00126 function getId($v) {
00127 return t3lib_div::md5Int($v['path']);
00128 }
00129
00136 function getJumpToParam($v) {
00137 return rawurlencode($v['path']);
00138 }
00139
00148 function getTitleStr($row,$titleLen=30) {
00149 return $row['_title'] ? $row['_title'] : parent::getTitleStr($row,$titleLen);
00150 }
00151
00158 function getBrowsableTree() {
00159
00160
00161 $this->initializePositionSaving();
00162
00163
00164 $titleLen=intval($this->BE_USER->uc['titleLen']);
00165 $treeArr=array();
00166
00167
00168 foreach($this->MOUNTS as $key => $val) {
00169 $md5_uid = md5($val['path']);
00170 $specUID=hexdec(substr($md5_uid,0,6));
00171 $this->specUIDmap[$specUID]=$val['path'];
00172
00173
00174 $this->bank=$val['nkey'];
00175 $isOpen = $this->stored[$val['nkey']][$specUID] || $this->expandFirst;
00176 $this->reset();
00177
00178
00179 $cmd=$this->bank.'_'.($isOpen?'0_':'1_').$specUID.'_'.$this->treeName;
00180 $icon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen?'minus':'plus').'only.gif','width="18" height="16"').' alt="" />';
00181 $firstHtml= $this->PM_ATagWrap($icon,$cmd);
00182
00183 switch($val['type']) {
00184 case 'user': $icon = 'gfx/i/_icon_ftp_user.gif'; break;
00185 case 'group': $icon = 'gfx/i/_icon_ftp_group.gif'; break;
00186 default: $icon = 'gfx/i/_icon_ftp.gif'; break;
00187 }
00188
00189
00190 $firstHtml.=$this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' alt="" />',$val);
00191 $row=array();
00192 $row['path']=$val['path'];
00193 $row['uid']=$specUID;
00194 $row['title']=$val['name'];
00195
00196
00197 $this->tree[]=array('HTML'=>$firstHtml,'row'=>$row,'bank'=>$this->bank);
00198
00199
00200 if ($isOpen) {
00201
00202 $depthD='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/blank.gif','width="18" height="16"').' alt="" />';
00203 $this->getFolderTree($val['path'],999,$depthD);
00204 }
00205
00206
00207 $treeArr=array_merge($treeArr,$this->tree);
00208 }
00209 return $this->printTree($treeArr);
00210 }
00211
00221 function getFolderTree($files_path, $depth=999, $depthData='') {
00222
00223
00224 $dirs = t3lib_div::get_dirs($files_path);
00225
00226 $c=0;
00227 if (is_array($dirs)) {
00228 $depth=intval($depth);
00229 $HTML='';
00230 $a=0;
00231 $c=count($dirs);
00232 sort($dirs);
00233
00234 foreach($dirs as $key => $val) {
00235 $a++;
00236 $this->tree[]=array();
00237 end($this->tree);
00238 $treeKey = key($this->tree);
00239 $LN = ($a==$c)?'blank':'line';
00240
00241 $val = ereg_replace('^\./','',$val);
00242 $title = $val;
00243 $path = $files_path.$val.'/';
00244 $webpath=t3lib_BEfunc::getPathType_web_nonweb($path);
00245
00246 $md5_uid = md5($path);
00247 $specUID=hexdec(substr($md5_uid,0,6));
00248 $this->specUIDmap[$specUID]=$path;
00249 $row=array();
00250 $row['path']=$path;
00251 $row['uid']=$specUID;
00252 $row['title']=$title;
00253
00254 if ($depth>1 && $this->expandNext($specUID)) {
00255 $nextCount=$this->getFolderTree(
00256 $path,
00257 $depth-1,
00258 $this->makeHTML ? $depthData.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$LN.'.gif','width="18" height="16"').' alt="" />' : ''
00259 );
00260 $exp=1;
00261 } else {
00262 $nextCount=$this->getCount($path);
00263 $exp=0;
00264 }
00265
00266
00267 if ($this->makeHTML) {
00268 $HTML=$depthData.$this->PMicon($row,$a,$c,$nextCount,$exp);
00269
00270 $icon = 'gfx/i/_icon_'.$webpath.'folders.gif';
00271 if ($val=='_temp_') {
00272 $icon = 'gfx/i/sysf.gif';
00273 $row['title']='TEMP';
00274 $row['_title']='<b>TEMP</b>';
00275 }
00276 if ($val=='_recycler_') {
00277 $icon = 'gfx/i/recycler.gif';
00278 $row['title']='RECYCLER';
00279 $row['_title']='<b>RECYCLER</b>';
00280 }
00281 $HTML.=$this->wrapIcon('<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' alt="" />',$row);
00282 }
00283
00284
00285 $this->tree[$treeKey] = Array(
00286 'row'=>$row,
00287 'HTML'=>$HTML,
00288 'bank'=>$this->bank
00289 );
00290 }
00291 }
00292 return $c;
00293 }
00294
00301 function getCount($files_path) {
00302
00303 $dirs = t3lib_div::get_dirs($files_path);
00304 $c=0;
00305 if (is_array($dirs)) {
00306 $c=count($dirs);
00307 }
00308 return $c;
00309 }
00310
00317 function initializePositionSaving() {
00318
00319 $this->stored=unserialize($this->BE_USER->uc['browseTrees'][$this->treeName]);
00320
00321
00322 $hashMap=array();
00323 foreach($this->MOUNTS as $key => $val) {
00324 $nkey = hexdec(substr($key,0,4));
00325 $hashMap[$nkey]=$key;
00326 $this->MOUNTS[$key]['nkey']=$nkey;
00327 }
00328
00329
00330
00331 $PM = explode('_',t3lib_div::_GP('PM'));
00332 if (count($PM)==4 && $PM[3]==$this->treeName) {
00333 if (isset($this->MOUNTS[$hashMap[$PM[0]]])) {
00334 if ($PM[1]) {
00335 $this->stored[$PM[0]][$PM[2]]=1;
00336 $this->savePosition($this->treeName);
00337 } else {
00338 unset($this->stored[$PM[0]][$PM[2]]);
00339 $this->savePosition($this->treeName);
00340 }
00341 }
00342 }
00343 }
00344 }
00345
00346 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']) {
00347 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_foldertree.php']);
00348 }
00349 ?>