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
00059
00060
00061
00062 class filelistFolderTree extends t3lib_folderTree {
00063
00064 var $ext_IconMode;
00065 var $ajaxStatus = false;
00066
00067
00068
00069
00070
00071
00072 function filelistFolderTree() {
00073 parent::t3lib_folderTree();
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083 function wrapIcon($theFolderIcon, &$row) {
00084
00085
00086 if (!$this->ext_IconMode) {
00087 $theFolderIcon = $GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon($theFolderIcon,$row['path'],'',0);
00088 } elseif (!strcmp($this->ext_IconMode,'titlelink')) {
00089 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$this->bank.');';
00090 $theFolderIcon='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.$theFolderIcon.'</a>';
00091 }
00092
00093 return '<span class="dragIcon" id="dragIconID_'.$this->getJumpToParam($row).'">'.$theFolderIcon.'</span>';
00094 }
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 function wrapTitle($title,$row,$bank=0) {
00107 $aOnClick = 'return jumpTo(\''.$this->getJumpToParam($row).'\',this,\''.$this->domIdPrefix.$this->getId($row).'\','.$bank.');';
00108 $CSM = '';
00109 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler']) {
00110 $CSM = ' oncontextmenu="'.htmlspecialchars($GLOBALS['TBE_TEMPLATE']->wrapClickMenuOnIcon('',$row['path'],'',0,'&bank='.$this->bank,'',TRUE)).'"';
00111 }
00112 $theFolderTitle='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"'.$CSM.'>'.$title.'</a>';
00113
00114
00115 return '<span class="dragTitle" id="dragTitleID_'.$this->getJumpToParam($row).'">'.$theFolderTitle.'</span>';
00116 }
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 function printTree($treeArr='') {
00128 $titleLen = intval($this->BE_USER->uc['titleLen']);
00129 if (!is_array($treeArr)) $treeArr = $this->tree;
00130
00131 $out = '
00132 <!-- TYPO3 folder tree structure. -->
00133 <ul class="tree" id="treeRoot">
00134 ';
00135 $titleLen=intval($this->BE_USER->uc['titleLen']);
00136 if (!is_array($treeArr)) $treeArr=$this->tree;
00137
00138
00139
00140 $PM = t3lib_div::_GP('PM');
00141 if(($PMpos = strpos($PM, '#')) !== false) { $PM = substr($PM, 0, $PMpos); }
00142 $PM = explode('_', $PM);
00143 if((TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) && is_array($PM) && count($PM)==4) {
00144 if($PM[1]) {
00145 $expandedFolderUid = $PM[2];
00146 $ajaxOutput = '';
00147 $invertedDepthOfAjaxRequestedItem = 0;
00148 $doExpand = true;
00149 } else {
00150 $expandedFolderUid = $PM[2];
00151 $doCollapse = true;
00152 }
00153 }
00154
00155
00156
00157
00158 $closeDepth = array();
00159
00160 foreach($treeArr as $k => $v) {
00161 $classAttr = $v['row']['_CSSCLASS'];
00162 $uid = $v['row']['uid'];
00163 $idAttr = htmlspecialchars($this->domIdPrefix.$this->getId($v['row']).'_'.$v['bank']);
00164 $itemHTML = '';
00165
00166
00167
00168 if($v['isFirst'] && !($doCollapse) && !($doExpand && $expandedFolderUid == $uid)) {
00169 $itemHTML = "<ul>\n";
00170 }
00171
00172
00173 if($v['hasSub']) { $classAttr = ($classAttr) ? ' expanded': 'expanded'; }
00174 if($v['isLast']) { $classAttr = ($classAttr) ? ' last' : 'last'; }
00175
00176 $itemHTML .='
00177 <li id="'.$idAttr.'"'.($classAttr ? ' class="'.$classAttr.'"' : '').'><div class="treeLinkItem">'.
00178 $v['HTML'].
00179 $this->wrapTitle($this->getTitleStr($v['row'],$titleLen),$v['row'],$v['bank']) . '</div>';
00180
00181
00182 if(!$v['hasSub']) { $itemHTML .= "</li>\n"; }
00183
00184
00185
00186 if($v['isLast'] && !($doExpand && $expandedFolderUid == $uid)) { $closeDepth[$v['invertedDepth']] = 1; }
00187
00188
00189
00190
00191 if($v['isLast'] && !$v['hasSub'] && !$doCollapse && !($doExpand && $expandedFolderUid == $uid)) {
00192 for ($i = $v['invertedDepth']; $closeDepth[$i] == 1; $i++) {
00193 $closeDepth[$i] = 0;
00194 $itemHTML .= "</ul></li>\n";
00195 }
00196 }
00197
00198
00199 if($doCollapse && $expandedFolderUid == $uid) {
00200 $this->ajaxStatus = true;
00201 return $itemHTML;
00202 }
00203
00204
00205 if($doExpand && $expandedFolderUid == $uid) {
00206 $ajaxOutput .= $itemHTML;
00207 $invertedDepthOfAjaxRequestedItem = $v['invertedDepth'];
00208 } elseif($invertedDepthOfAjaxRequestedItem) {
00209 if($v['invertedDepth'] < $invertedDepthOfAjaxRequestedItem) {
00210 $ajaxOutput .= $itemHTML;
00211 } else {
00212 $this->ajaxStatus = true;
00213 return $ajaxOutput;
00214 }
00215 }
00216
00217 $out .= $itemHTML;
00218 }
00219
00220 if($ajaxOutput) {
00221 $this->ajaxStatus = true;
00222 return $ajaxOutput;
00223 }
00224
00225
00226 $out .= "</ul>\n";
00227 return $out;
00228 }
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243 function PMicon($row,$a,$c,$nextCount,$exp) {
00244 $PM = $nextCount ? ($exp ? 'minus' : 'plus') : 'join';
00245 $BTM = ($a == $c) ? 'bottom' : '';
00246 $icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.$PM.$BTM.'.gif','width="18" height="16"').' alt="" />';
00247
00248 if ($nextCount) {
00249 $cmd = $this->bank.'_'.($exp?'0_':'1_').$row['uid'].'_'.$this->treeName;
00250 $icon = $this->PMiconATagWrap($icon,$cmd,!$exp);
00251 }
00252 return $icon;
00253 }
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264 function PMiconATagWrap($icon, $cmd, $isExpand = true) {
00265 if ($this->thisScript) {
00266
00267 $js = htmlspecialchars('Tree.load(\''.$cmd.'\', '.intval($isExpand).', this);');
00268 return '<a class="pm" onclick="'.$js.'">'.$icon.'</a>';
00269 } else {
00270 return $icon;
00271 }
00272 }
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 function getBrowsableTree() {
00283
00284
00285 $this->initializePositionSaving();
00286
00287
00288 $titleLen = intval($this->BE_USER->uc['titleLen']);
00289 $treeArr = array();
00290
00291
00292 foreach($this->MOUNTS as $key => $val) {
00293 $hasSub = false;
00294 $specUID = t3lib_div::md5int($val['path']);
00295 $this->specUIDmap[$specUID] = $val['path'];
00296
00297
00298 $this->bank = $val['nkey'];
00299 $isOpen = $this->stored[$val['nkey']][$specUID] || $this->expandFirst;
00300 $this->reset();
00301
00302
00303 $cmd = $this->bank.'_'.($isOpen ? '0_' : '1_').$specUID.'_'.$this->treeName;
00304 $icon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($isOpen? 'minus':'plus').'only.gif').' alt="" />';
00305 $firstHtml= $this->PM_ATagWrap($icon,$cmd);
00306
00307 switch ($val['type']) {
00308 case 'user':
00309 $icon = 'apps-filetree-folder-user';
00310 break;
00311 case 'group':
00312 $icon = 'apps-filetree-folder-user';
00313 break;
00314 case 'readonly':
00315 $icon = 'apps-filetree-folder-locked';
00316 break;
00317 default:
00318 $icon = 'apps-filetree-mount';
00319 break;
00320 }
00321
00322
00323 $firstHtml.=$this->wrapIcon(t3lib_iconWorks::getSpriteIcon($icon),$val);
00324 $row=array();
00325 $row['uid'] = $specUID;
00326 $row['path'] = $val['path'];
00327 $row['title'] = $val['name'];
00328
00329
00330 if ($isOpen) {
00331 $hasSub = true;
00332 }
00333
00334 $this->tree[] = array('HTML' => $firstHtml, 'row' => $row, 'bank' => $this->bank, 'hasSub' => $hasSub);
00335
00336
00337 if ($isOpen)
00338 $this->getFolderTree($val['path'], 999, $val['type']);
00339
00340
00341 $treeArr = array_merge($treeArr, $this->tree);
00342
00343
00344
00345 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
00346 break;
00347 }
00348 }
00349 return $this->printTree($treeArr);
00350 }
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362 function getFolderTree($files_path, $depth=999, $type='') {
00363
00364
00365 $dirs = t3lib_div::get_dirs($files_path);
00366 if (!is_array($dirs)) return 0;
00367
00368 sort($dirs);
00369 $c = count($dirs);
00370
00371 $depth = intval($depth);
00372 $HTML = '';
00373 $a = 0;
00374
00375 foreach($dirs as $key => $val) {
00376 $a++;
00377 $this->tree[] = array();
00378 end($this->tree);
00379 $treeKey = key($this->tree);
00380
00381 $val = preg_replace('/^\.\
00382 $title = $val;
00383 $path = $files_path.$val.'/';
00384
00385 $specUID = t3lib_div::md5int($path);
00386 $this->specUIDmap[$specUID] = $path;
00387
00388 $row = array();
00389 $row['path'] = $path;
00390 $row['uid'] = $specUID;
00391 $row['title'] = $title;
00392
00393
00394 if ($depth > 1 && $this->expandNext($specUID)) {
00395 $nextCount = $this->getFolderTree(
00396 $path,
00397 $depth-1,
00398 $this->makeHTML ? '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($a == $c ? 'blank' : 'line').'.gif','width="18" height="16"').' alt="" />' : '',
00399 $type
00400 );
00401 $exp = 1;
00402 } else {
00403 $nextCount = $this->getCount($path);
00404 $exp = 0;
00405 }
00406
00407
00408 if ($this->makeHTML) {
00409 $HTML = $this->PMicon($row,$a,$c,$nextCount,$exp);
00410
00411 $webpath = t3lib_BEfunc::getPathType_web_nonweb($path);
00412
00413 if (is_writable($path)) {
00414 $type = '';
00415 $overlays = array();
00416 } else {
00417 $type = 'readonly';
00418 $overlays= array('status-overlay-locked'=>array());
00419
00420 }
00421
00422 if($webpath == 'web') {
00423 $icon = 'apps-filetree-folder-default';
00424 } else {
00425 $icon = 'apps-filetree-folder-default';
00426 }
00427 if ($val == '_temp_') {
00428 $icon = 'apps-filetree-folder-temp';
00429 $row['title'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true);
00430 $row['_title'] = '<strong>' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:temp', true) . '</strong>';
00431 }
00432 if ($val == '_recycler_') {
00433 $icon = 'apps-filetree-folder-recycler';
00434 $row['title'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true);
00435 $row['_title'] = '<strong>' .$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:recycler', true) . '</strong>';
00436 }
00437 $HTML .= $this->wrapIcon(t3lib_iconWorks::getSpriteIcon($icon,array('title'=>$row['title']),$overlays),$row);
00438 }
00439
00440
00441 $this->tree[$treeKey] = Array(
00442 'row' => $row,
00443 'HTML' => $HTML,
00444 'hasSub' => $nextCount && $this->expandNext($specUID),
00445 'isFirst'=> ($a == 1),
00446 'isLast' => false,
00447 'invertedDepth'=> $depth,
00448 'bank' => $this->bank
00449 );
00450 }
00451
00452 if($a) { $this->tree[$treeKey]['isLast'] = true; }
00453 return $c;
00454 }
00455 }
00456
00457 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.filelistfoldertree.php']) {
00458 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.filelistfoldertree.php']);
00459 }
00460
00461 ?>