Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00052 unset($MCONF); 00053 require ('mod/file/list/conf.php'); 00054 require ('init.php'); 00055 require ('template.php'); 00056 $LANG->includeLLFile('EXT:lang/locallang_mod_file_list.xml'); 00057 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php'); 00058 require_once (PATH_t3lib.'class.t3lib_extfilefunc.php'); 00059 require_once (PATH_t3lib.'class.t3lib_recordlist.php'); 00060 require_once (PATH_t3lib.'class.t3lib_clipboard.php'); 00061 require_once ('class.file_list.inc'); 00062 $BE_USER->modAccess($MCONF,1); 00063 00064 00065 00066 00067 00068 00069 00077 class SC_file_list { 00078 var $MCONF=array(); // Module configuration 00079 var $MOD_MENU=array(); 00080 var $MOD_SETTINGS=array(); 00081 00082 00083 // Internal: 00084 var $content; // Accumulated HTML output 00085 var $basicFF; // File operation object (t3lib_basicFileFunctions) 00086 var $doc; // Template object 00087 00088 // Internal, static: GPvars: 00089 var $id; // "id" -> the path to list. 00090 var $pointer; // Pointer to listing 00091 var $table; // "Table" 00092 var $imagemode; // Thumbnail mode. 00093 var $cmd; 00094 var $overwriteExistingFiles; 00095 00096 00103 function init() { 00104 global $TYPO3_CONF_VARS,$FILEMOUNTS; 00105 00106 // Setting GPvars: 00107 $this->id = t3lib_div::_GP('id'); 00108 $this->pointer = t3lib_div::_GP('pointer'); 00109 $this->table = t3lib_div::_GP('table'); 00110 $this->imagemode = t3lib_div::_GP('imagemode'); 00111 $this->cmd = t3lib_div::_GP('cmd'); 00112 $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles'); 00113 00114 // Setting module name: 00115 $this->MCONF = $GLOBALS['MCONF']; 00116 00117 // File operation object: 00118 $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00119 $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']); 00120 00121 // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc. 00122 $this->menuConfig(); 00123 } 00124 00130 function menuConfig() { 00131 // MENU-ITEMS: 00132 // If array, then it's a selector box menu 00133 // If empty string it's just a variable, that'll be saved. 00134 // Values NOT in this array will not be saved in the settings-array for the module. 00135 $this->MOD_MENU = array( 00136 'sort' => '', 00137 'reverse' => '', 00138 'displayThumbs' => '', 00139 'clipBoard' => '' 00140 ); 00141 00142 // CLEANSE SETTINGS 00143 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']); 00144 } 00145 00151 function main() { 00152 global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS; 00153 00154 // Initialize the template object 00155 $this->doc = t3lib_div::makeInstance('template'); 00156 $this->doc->backPath = $BACK_PATH; 00157 $this->doc->docType = 'xhtml_trans'; 00158 00159 // Validating the input "id" (the path, directory!) and checking it against the mounts of the user. 00160 $this->id = $this->basicFF->is_directory($this->id); 00161 $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/'); 00162 00163 // There there was access to this file path, continue, make the list 00164 if ($access) { 00165 00166 // Create filelisting object 00167 $filelist = t3lib_div::makeInstance('fileList'); 00168 $filelist->backPath = $BACK_PATH; 00169 $filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']?1:$BE_USER->uc['thumbnailsByDefault']; 00170 00171 // Create clipboard object and initialize that 00172 $filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); 00173 $filelist->clipObj->fileMode=1; 00174 $filelist->clipObj->initializeClipboard(); 00175 00176 $CB = t3lib_div::_GET('CB'); 00177 if ($this->cmd=='setCB') $CB['el'] = $filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),'_FILE'); 00178 if (!$this->MOD_SETTINGS['clipBoard']) $CB['setP']='normal'; 00179 $filelist->clipObj->setCmd($CB); 00180 $filelist->clipObj->cleanCurrent(); 00181 $filelist->clipObj->endClipboard(); // Saves 00182 00183 // If the "cmd" was to delete files from the list (clipboard thing), do that: 00184 if ($this->cmd=='delete') { 00185 $items = $filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1); 00186 if (count($items)) { 00187 // Make command array: 00188 $FILE=array(); 00189 reset($items); 00190 while(list(,$v)=each($items)) { 00191 $FILE['delete'][]=array('data'=>$v); 00192 } 00193 00194 // Init file processing object for deleting and pass the cmd array. 00195 $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions'); 00196 $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']); 00197 $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']); 00198 $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0; 00199 $fileProcessor->start($FILE); 00200 $fileProcessor->processData(); 00201 00202 $fileProcessor->printLogErrorMessages(); 00203 } 00204 } 00205 00206 if (!isset($this->MOD_SETTINGS['sort'])) { 00207 // Set default sorting 00208 $this->MOD_SETTINGS['sort'] = 'file'; 00209 $this->MOD_SETTINGS['reverse'] = 0; 00210 } 00211 00212 // Start up filelisting object, include settings. 00213 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000); 00214 $filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']); 00215 00216 // Write the header 00217 $filelist->writeTop($this->id); 00218 00219 // Generate the list 00220 $filelist->generateList(); 00221 00222 // Write the footer 00223 $filelist->writeBottom(); 00224 00225 // Set top JavaScript: 00226 $this->doc->JScode=$this->doc->wrapScriptTags(' 00227 00228 if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'"); 00229 function jumpToUrl(URL) { // 00230 window.location.href = URL; 00231 } 00232 00233 '.$filelist->CBfunctions() // ... and add clipboard JavaScript functions 00234 ); 00235 00236 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers. 00237 $CMparts=$this->doc->getContextMenuCode(); 00238 $this->doc->bodyTagAdditions = $CMparts[1]; 00239 $this->doc->JScode.=$CMparts[0]; 00240 $this->doc->postCode.= $CMparts[2]; 00241 00242 00243 // Create output 00244 $this->content=''; 00245 $this->content.=$this->doc->startPage($LANG->getLL('files')); 00246 $this->content.= '<form action="'.htmlspecialchars($filelist->listURL()).'" method="post" name="dblistForm">'; 00247 $this->content.= $filelist->HTMLcode; 00248 $this->content.= '<input type="hidden" name="cmd" /></form>'; 00249 00250 // FileList Module CSH: 00251 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'],'<br/>|'); 00252 00253 $this->content.=' 00254 <!-- 00255 "Upload" and "New" buttons 00256 --> 00257 <div id="typo3-filelist-buttons"> 00258 <table border="0" cellpadding="4" cellspacing="0"> 00259 <tr> 00260 <td> 00261 <form name="upload" action="'.$BACK_PATH.'file_upload.php"> 00262 <input type="hidden" name="target" value="'.htmlspecialchars($this->id).'" /> 00263 <input type="hidden" name="returnUrl" value="'.htmlspecialchars($filelist->listURL()).'" /> 00264 <input type="submit" value="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.upload',1)).'" /> 00265 </form> 00266 </td> 00267 <td> 00268 <form name="new" action="'.$BACK_PATH.'file_newfolder.php"> 00269 <input type="hidden" name="target" value="'.htmlspecialchars($this->id).'" /> 00270 <input type="hidden" name="returnUrl" value="'.htmlspecialchars($filelist->listURL()).'" /> 00271 <input type="submit" value="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:cm.new',1)).'" /> 00272 </form> 00273 </td> 00274 </tr> 00275 </table> 00276 </div> 00277 '; 00278 00279 if ($filelist->HTMLcode) { // Making listing options: 00280 00281 $this->content.=' 00282 00283 <!-- 00284 Listing options for clipboard and thumbnails 00285 --> 00286 <div id="typo3-listOptions"> 00287 '; 00288 00289 // Add "display thumbnails" checkbox: 00290 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[displayThumbs]',$this->MOD_SETTINGS['displayThumbs'],'file_list.php','','id="checkDisplayThumbs"').' <label for="checkDisplayThumbs">'.$LANG->getLL('displayThumbs',1).'</label><br />'; 00291 00292 // Add clipboard button 00293 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'file_list.php','','id="checkClipBoard"').' <label for="checkClipBoard">'.$LANG->getLL('clipBoard',1).'</label>'; 00294 00295 $this->content.=' 00296 </div> 00297 '; 00298 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_options', $GLOBALS['BACK_PATH']); 00299 00300 00301 // Set clipboard: 00302 if ($this->MOD_SETTINGS['clipBoard']) { 00303 $this->content.=$filelist->clipObj->printClipboard(); 00304 $this->content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']); 00305 } 00306 } 00307 00308 // Add shortcut 00309 if ($BE_USER->mayMakeShortcut()) { 00310 $this->content.='<br /><br />'.$this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']); 00311 } 00312 } else { 00313 // Create output - no access (no warning though) 00314 $this->content=''; 00315 $this->content.=$this->doc->startPage($LANG->getLL('files')); 00316 } 00317 00318 } 00319 00325 function printContent() { 00326 $this->content.= $this->doc->endPage(); 00327 $this->content = $this->doc->insertStylesAndJS($this->content); 00328 echo $this->content; 00329 } 00330 } 00331 00332 // Include extension? 00333 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']) { 00334 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']); 00335 } 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 // Make instance: 00349 $SOBE = t3lib_div::makeInstance('SC_file_list'); 00350 $SOBE->init(); 00351 $SOBE->main(); 00352 $SOBE->printContent(); 00353 00354 00355 if ($TYPO3_CONF_VARS['BE']['compressionLevel']) { 00356 new gzip_encode($TYPO3_CONF_VARS['BE']['compressionLevel']); 00357 } 00358 ?>