|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (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 ***************************************************************/ 00027 /** 00028 * Web>File: File listing 00029 * 00030 * $Id: file_list.php 10237 2011-01-22 00:47:03Z baschny $ 00031 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj 00032 * 00033 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00034 */ 00035 /** 00036 * [CLASS/FUNCTION INDEX of SCRIPT] 00037 * 00038 * 00039 * 00040 * 77: class SC_file_list 00041 * 103: function init() 00042 * 130: function menuConfig() 00043 * 151: function main() 00044 * 325: function printContent() 00045 * 00046 * TOTAL FUNCTIONS: 4 00047 * (This index is automatically created/updated by the extension "extdeveval") 00048 * 00049 */ 00050 00051 00052 unset($MCONF); 00053 require ('conf.php'); 00054 require ($BACK_PATH . 'init.php'); 00055 require ($BACK_PATH . 'template.php'); 00056 $LANG->includeLLFile('EXT:lang/locallang_mod_file_list.xml'); 00057 $LANG->includeLLFile('EXT:lang/locallang_misc.xml'); 00058 require_once ($BACK_PATH . 'class.file_list.inc'); 00059 $BE_USER->modAccess($MCONF,1); 00060 00061 00062 00063 00064 00065 00066 00067 /** 00068 * Script Class for creating the list of files in the File > Filelist module 00069 * 00070 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00071 * @package TYPO3 00072 * @subpackage core 00073 */ 00074 class SC_file_list { 00075 var $MCONF=array(); // Module configuration 00076 var $MOD_MENU=array(); 00077 var $MOD_SETTINGS=array(); 00078 00079 00080 // Internal: 00081 var $content; // Accumulated HTML output 00082 00083 /** 00084 * File processing object 00085 * 00086 * @var t3lib_basicFileFunctions 00087 */ 00088 var $basicFF; 00089 00090 /** 00091 * Document template object 00092 * 00093 * @var template 00094 */ 00095 var $doc; 00096 00097 // Internal, static: GPvars: 00098 var $id; // "id" -> the path to list. 00099 var $pointer; // Pointer to listing 00100 var $table; // "Table" 00101 var $imagemode; // Thumbnail mode. 00102 var $cmd; 00103 var $overwriteExistingFiles; 00104 00105 00106 /** 00107 * Initialize variables, file object 00108 * Incoming GET vars include id, pointer, table, imagemode 00109 * 00110 * @return void 00111 */ 00112 function init() { 00113 global $TYPO3_CONF_VARS,$FILEMOUNTS; 00114 00115 // Setting GPvars: 00116 $this->id = t3lib_div::_GP('id'); 00117 $this->pointer = t3lib_div::_GP('pointer'); 00118 $this->table = t3lib_div::_GP('table'); 00119 $this->imagemode = t3lib_div::_GP('imagemode'); 00120 $this->cmd = t3lib_div::_GP('cmd'); 00121 $this->overwriteExistingFiles = t3lib_div::_GP('overwriteExistingFiles'); 00122 00123 // Setting module name: 00124 $this->MCONF = $GLOBALS['MCONF']; 00125 00126 // File operation object: 00127 $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00128 $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']); 00129 00130 // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc. 00131 $this->menuConfig(); 00132 } 00133 00134 /** 00135 * Setting the menu/session variables 00136 * 00137 * @return void 00138 */ 00139 function menuConfig() { 00140 // MENU-ITEMS: 00141 // If array, then it's a selector box menu 00142 // If empty string it's just a variable, that'll be saved. 00143 // Values NOT in this array will not be saved in the settings-array for the module. 00144 $this->MOD_MENU = array( 00145 'sort' => '', 00146 'reverse' => '', 00147 'displayThumbs' => '', 00148 'clipBoard' => '', 00149 'bigControlPanel' => '' 00150 ); 00151 00152 // CLEANSE SETTINGS 00153 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']); 00154 } 00155 00156 /** 00157 * Main function, creating the listing 00158 * 00159 * @return void 00160 */ 00161 function main() { 00162 global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS; 00163 00164 // Initialize the template object 00165 $this->doc = t3lib_div::makeInstance('template'); 00166 $this->doc->backPath = $BACK_PATH; 00167 $this->doc->setModuleTemplate('templates/file_list.html'); 00168 $this->doc->getPageRenderer()->loadPrototype(); 00169 00170 // Validating the input "id" (the path, directory!) and checking it against the mounts of the user. 00171 $this->id = $this->basicFF->is_directory($this->id); 00172 $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/'); 00173 00174 // There there was access to this file path, continue, make the list 00175 if ($access) { 00176 // include the initialization for the flash uploader 00177 if ($GLOBALS['BE_USER']->uc['enableFlashUploader']) { 00178 00179 $this->doc->JScodeArray['flashUploader'] = ' 00180 if (top.TYPO3.FileUploadWindow.isFlashAvailable()) { 00181 document.observe("dom:loaded", function() { 00182 // monitor the button 00183 $("button-upload").observe("click", initFlashUploader); 00184 00185 function initFlashUploader(event) { 00186 // set the page specific options for the flashUploader 00187 var flashUploadOptions = { 00188 uploadURL: top.TS.PATH_typo3 + "ajax.php", 00189 uploadFileSizeLimit: "' . t3lib_div::getMaxUploadFileSize() . '", 00190 uploadFileTypes: { 00191 allow: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '", 00192 deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '" 00193 }, 00194 uploadFilePostName: "upload_1", 00195 uploadPostParams: { 00196 "file[upload][1][target]": "' . $this->id . '", 00197 "file[upload][1][data]": 1, 00198 "file[upload][1][charset]": "utf-8", 00199 "ajaxID": "TYPO3_tcefile::process" 00200 } 00201 }; 00202 00203 // get the flashUploaderWindow instance from the parent frame 00204 var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions); 00205 // add an additional function inside the container to show the checkbox option 00206 var infoComponent = new top.Ext.Panel({ 00207 autoEl: { tag: "div" }, 00208 height: "auto", 00209 bodyBorder: false, 00210 border: false, 00211 hideBorders: true, 00212 cls: "t3-upload-window-infopanel", 00213 id: "t3-upload-window-infopanel-addition", 00214 html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\' 00215 }); 00216 flashUploader.add(infoComponent); 00217 00218 // do a reload of this frame once all uploads are done 00219 flashUploader.on("totalcomplete", function() { 00220 window.location.reload(); 00221 }); 00222 00223 // this is the callback function that delivers the additional post parameter to the flash application 00224 top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) { 00225 var uploader = top.TYPO3.getInstance("FileUploadWindow"); 00226 if (uploader.isVisible()) { 00227 uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0)); 00228 } 00229 }; 00230 00231 event.stop(); 00232 }; 00233 }); 00234 } 00235 '; 00236 } 00237 // Create filelisting object 00238 $this->filelist = t3lib_div::makeInstance('fileList'); 00239 $this->filelist->backPath = $BACK_PATH; 00240 00241 // Apply predefined values for hidden checkboxes 00242 // Set predefined value for DisplayBigControlPanel: 00243 if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'activated') { 00244 $this->MOD_SETTINGS['bigControlPanel'] = TRUE; 00245 } elseif ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'deactivated') { 00246 $this->MOD_SETTINGS['bigControlPanel'] = FALSE; 00247 } 00248 00249 // Set predefined value for DisplayThumbnails: 00250 if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'activated') { 00251 $this->MOD_SETTINGS['displayThumbs'] = TRUE; 00252 } elseif ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'deactivated') { 00253 $this->MOD_SETTINGS['displayThumbs'] = FALSE; 00254 } 00255 00256 // Set predefined value for Clipboard: 00257 if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableClipBoard') === 'activated') { 00258 $this->MOD_SETTINGS['clipBoard'] = TRUE; 00259 } elseif ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableClipBoard') === 'deactivated') { 00260 $this->MOD_SETTINGS['clipBoard'] = FALSE; 00261 } 00262 00263 // if user never opened the list module, set the value for displayThumbs 00264 if (!isset($this->MOD_SETTINGS['displayThumbs'])) { 00265 $this->MOD_SETTINGS['displayThumbs'] = $BE_USER->uc['thumbnailsByDefault']; 00266 } 00267 $this->filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']; 00268 00269 // Create clipboard object and initialize that 00270 $this->filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard'); 00271 $this->filelist->clipObj->fileMode=1; 00272 $this->filelist->clipObj->initializeClipboard(); 00273 00274 $CB = t3lib_div::_GET('CB'); 00275 if ($this->cmd=='setCB') $CB['el'] = $this->filelist->clipObj->cleanUpCBC(array_merge(t3lib_div::_POST('CBH'),t3lib_div::_POST('CBC')),'_FILE'); 00276 if (!$this->MOD_SETTINGS['clipBoard']) $CB['setP']='normal'; 00277 $this->filelist->clipObj->setCmd($CB); 00278 $this->filelist->clipObj->cleanCurrent(); 00279 $this->filelist->clipObj->endClipboard(); // Saves 00280 00281 // If the "cmd" was to delete files from the list (clipboard thing), do that: 00282 if ($this->cmd=='delete') { 00283 $items = $this->filelist->clipObj->cleanUpCBC(t3lib_div::_POST('CBC'),'_FILE',1); 00284 if (count($items)) { 00285 // Make command array: 00286 $FILE=array(); 00287 foreach ($items as $v) { 00288 $FILE['delete'][]=array('data'=>$v); 00289 } 00290 00291 // Init file processing object for deleting and pass the cmd array. 00292 $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions'); 00293 $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']); 00294 $fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions()); 00295 $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0; 00296 $fileProcessor->start($FILE); 00297 $fileProcessor->processData(); 00298 00299 $fileProcessor->printLogErrorMessages(); 00300 } 00301 } 00302 00303 if (!isset($this->MOD_SETTINGS['sort'])) { 00304 // Set default sorting 00305 $this->MOD_SETTINGS['sort'] = 'file'; 00306 $this->MOD_SETTINGS['reverse'] = 0; 00307 } 00308 00309 // Start up filelisting object, include settings. 00310 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000); 00311 $this->filelist->start($this->id, $this->pointer, $this->MOD_SETTINGS['sort'], $this->MOD_SETTINGS['reverse'], $this->MOD_SETTINGS['clipBoard'], $this->MOD_SETTINGS['bigControlPanel']); 00312 00313 // Generate the list 00314 $this->filelist->generateList(); 00315 00316 // Write the footer 00317 $this->filelist->writeBottom(); 00318 00319 // Set top JavaScript: 00320 $this->doc->JScode=$this->doc->wrapScriptTags(' 00321 00322 if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'"); 00323 function jumpToUrl(URL) { // 00324 window.location.href = URL; 00325 } 00326 00327 '.$this->filelist->CBfunctions() // ... and add clipboard JavaScript functions 00328 ); 00329 00330 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers. 00331 $this->doc->getContextMenuCode(); 00332 00333 // Setting up the buttons and markers for docheader 00334 list($buttons, $otherMarkers) = $this->filelist->getButtonsAndOtherMarkers($this->id); 00335 00336 // add the folder info to the marker array 00337 $otherMarkers['FOLDER_INFO'] = $this->filelist->getFolderInfo(); 00338 00339 $docHeaderButtons = array_merge($this->getButtons(), $buttons); 00340 00341 // Build the <body> for the module 00342 00343 // Create output 00344 $pageContent=''; 00345 $pageContent.= '<form action="'.htmlspecialchars($this->filelist->listURL()).'" method="post" name="dblistForm">'; 00346 $pageContent.= $this->filelist->HTMLcode; 00347 $pageContent.= '<input type="hidden" name="cmd" /></form>'; 00348 00349 00350 if ($this->filelist->HTMLcode) { // Making listing options: 00351 00352 $pageContent.=' 00353 00354 <!-- 00355 Listing options for extended view, clipboard and thumbnails 00356 --> 00357 <div id="typo3-listOptions"> 00358 '; 00359 00360 // Add "display bigControlPanel" checkbox: 00361 if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayBigControlPanel') === 'selectable') { 00362 $pageContent .= t3lib_BEfunc::getFuncCheck( 00363 $this->id, 00364 'SET[bigControlPanel]', 00365 $this->MOD_SETTINGS['bigControlPanel'], 00366 'file_list.php', 00367 '', 00368 'id="bigControlPanel"' 00369 ) . '<label for="bigControlPanel"> ' . $GLOBALS['LANG']->getLL('bigControlPanel', TRUE) . '</label><br />'; 00370 } 00371 00372 // Add "display thumbnails" checkbox: 00373 if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableDisplayThumbnails') === 'selectable') { 00374 $pageContent .= t3lib_BEfunc::getFuncCheck( 00375 $this->id, 00376 'SET[displayThumbs]', 00377 $this->MOD_SETTINGS['displayThumbs'], 00378 'file_list.php', 00379 '', 00380 'id="checkDisplayThumbs"' 00381 ) . ' <label for="checkDisplayThumbs">' . $GLOBALS['LANG']->getLL('displayThumbs', TRUE) . '</label><br />'; 00382 } 00383 00384 // Add "clipboard" checkbox: 00385 if ($GLOBALS['BE_USER']->getTSConfigVal('options.file_list.enableClipBoard') === 'selectable') { 00386 $pageContent .= t3lib_BEfunc::getFuncCheck( 00387 $this->id, 00388 'SET[clipBoard]', 00389 $this->MOD_SETTINGS['clipBoard'], 00390 'file_list.php', 00391 '', 00392 'id="checkClipBoard"' 00393 ) . ' <label for="checkClipBoard">' . $GLOBALS['LANG']->getLL('clipBoard', TRUE) . '</label>'; 00394 } 00395 00396 $pageContent.=' 00397 </div> 00398 '; 00399 00400 00401 // Set clipboard: 00402 if ($this->MOD_SETTINGS['clipBoard']) { 00403 $pageContent.=$this->filelist->clipObj->printClipboard(); 00404 $pageContent.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']); 00405 } 00406 } 00407 00408 $markerArray = array( 00409 'CSH' => $docHeaderButtons['csh'], 00410 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 00411 'CONTENT' => $pageContent 00412 ); 00413 00414 $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers)); 00415 // Renders the module page 00416 $this->content = $this->doc->render( 00417 $LANG->getLL('files'), 00418 $this->content 00419 ); 00420 00421 } else { 00422 // Create output - no access (no warning though) 00423 $this->content = $this->doc->render( 00424 $LANG->getLL('files'), 00425 '' 00426 ); 00427 } 00428 00429 00430 } 00431 00432 /** 00433 * Outputting the accumulated content to screen 00434 * 00435 * @return void 00436 */ 00437 function printContent() { 00438 echo $this->content; 00439 } 00440 00441 /** 00442 * Create the panel of buttons for submitting the form or otherwise perform operations. 00443 * 00444 * @return array all available buttons as an assoc. array 00445 */ 00446 function getButtons() { 00447 global $TCA, $LANG, $BACK_PATH, $BE_USER; 00448 00449 $buttons = array( 00450 'csh' => '', 00451 'shortcut' => '', 00452 'upload' => '', 00453 'new' => '', 00454 ); 00455 00456 // Add shortcut 00457 if ($BE_USER->mayMakeShortcut()) { 00458 $buttons['shortcut'] = $this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']); 00459 } 00460 00461 // FileList Module CSH: 00462 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'], '', TRUE); 00463 00464 // upload button 00465 $buttons['upload'] = '<a href="' . $BACK_PATH . 'file_upload.php?target=' . rawurlencode($this->id) . '&returnUrl=' . rawurlencode($this->filelist->listURL()) . '" id="button-upload" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.upload',1)).'">' . 00466 t3lib_iconWorks::getSpriteIcon('actions-edit-upload') . 00467 '</a>'; 00468 00469 $buttons['new'] = '<a href="' . $BACK_PATH . 'file_newfolder.php?target=' . rawurlencode($this->id) . '&returnUrl=' . rawurlencode($this->filelist->listURL()) . '" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.new',1)).'">' . 00470 t3lib_iconWorks::getSpriteIcon('actions-document-new') . 00471 '</a>'; 00472 00473 return $buttons; 00474 } 00475 00476 } 00477 00478 00479 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_list.php'])) { 00480 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_list.php']); 00481 } 00482 00483 00484 00485 // Make instance: 00486 $SOBE = t3lib_div::makeInstance('SC_file_list'); 00487 $SOBE->init(); 00488 $SOBE->main(); 00489 $SOBE->printContent(); 00490 00491 ?>
1.8.0