2 /***************************************************************
5 * (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Web>File: File listing
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 77: class SC_file_list
41 * 103: function init()
42 * 130: function menuConfig()
43 * 151: function main()
44 * 325: function printContent()
47 * (This index is automatically created/updated by the extension "extdeveval")
53 require ('mod/file/list/conf.php');
55 require ('template.php');
56 $LANG->includeLLFile('EXT:lang/locallang_mod_file_list.xml');
57 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
58 require_once ('class.file_list.inc');
59 $BE_USER->modAccess($MCONF,1);
68 * Script Class for creating the list of files in the File > Filelist module
70 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
75 var $MCONF=array(); // Module configuration
76 var $MOD_MENU=array();
77 var $MOD_SETTINGS=array();
81 var $content; // Accumulated HTML output
84 * File processing object
86 * @var t3lib_basicFileFunctions
91 * Document template object
97 // Internal, static: GPvars:
98 var $id; // "id" -> the path to list.
99 var $pointer; // Pointer to listing
100 var $table; // "Table"
101 var $imagemode; // Thumbnail mode.
103 var $overwriteExistingFiles;
107 * Initialize variables, file object
108 * Incoming GET vars include id, pointer, table, imagemode
113 global $TYPO3_CONF_VARS,$FILEMOUNTS;
116 $this->id
= t3lib_div
::_GP('id');
117 $this->pointer
= t3lib_div
::_GP('pointer');
118 $this->table
= t3lib_div
::_GP('table');
119 $this->imagemode
= t3lib_div
::_GP('imagemode');
120 $this->cmd
= t3lib_div
::_GP('cmd');
121 $this->overwriteExistingFiles
= t3lib_div
::_GP('overwriteExistingFiles');
123 // Setting module name:
124 $this->MCONF
= $GLOBALS['MCONF'];
126 // File operation object:
127 $this->basicFF
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
128 $this->basicFF
->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']);
130 // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
135 * Setting the menu/session variables
139 function menuConfig() {
141 // If array, then it's a selector box menu
142 // If empty string it's just a variable, that'll be saved.
143 // Values NOT in this array will not be saved in the settings-array for the module.
144 $this->MOD_MENU
= array(
147 'displayThumbs' => '',
149 'bigControlPanel' => ''
153 $this->MOD_SETTINGS
= t3lib_BEfunc
::getModuleData($this->MOD_MENU
, t3lib_div
::_GP('SET'), $this->MCONF
['name']);
157 * Main function, creating the listing
162 global $BE_USER,$LANG,$BACK_PATH,$TYPO3_CONF_VARS,$FILEMOUNTS;
164 // Initialize the template object
165 $this->doc
= t3lib_div
::makeInstance('template');
166 $this->doc
->backPath
= $BACK_PATH;
167 $this->doc
->setModuleTemplate('templates/file_list.html');
168 $this->doc
->getPageRenderer()->loadPrototype();
170 // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
171 $this->id
= $this->basicFF
->is_directory($this->id
);
172 $access = $this->id
&& $this->basicFF
->checkPathAgainstMounts($this->id
.'/');
174 // There there was access to this file path, continue, make the list
176 // include the initialization for the flash uploader
177 if ($GLOBALS['BE_USER']->uc
['enableFlashUploader']) {
179 $this->doc
->JScodeArray
['flashUploader'] = '
180 if (top.TYPO3.FileUploadWindow.isFlashAvailable()) {
181 document.observe("dom:loaded", function() {
182 // monitor the button
183 $("button-upload").observe("click", initFlashUploader);
185 function initFlashUploader(event) {
186 // set the page specific options for the flashUploader
187 var flashUploadOptions = {
188 uploadURL: top.TS.PATH_typo3 + "ajax.php",
189 uploadFileSizeLimit: "' . t3lib_div
::getMaxUploadFileSize() . '",
191 allow: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow'] . '",
192 deny: "' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny'] . '"
194 uploadFilePostName: "upload_1",
196 "file[upload][1][target]": "' . $this->id
. '",
197 "file[upload][1][data]": 1,
198 "file[upload][1][charset]": "utf-8",
199 "ajaxID": "TYPO3_tcefile::process"
203 // get the flashUploaderWindow instance from the parent frame
204 var flashUploader = top.TYPO3.FileUploadWindow.getInstance(flashUploadOptions);
205 // add an additional function inside the container to show the checkbox option
206 var infoComponent = new top.Ext.Panel({
207 autoEl: { tag: "div" },
212 cls: "t3-upload-window-infopanel",
213 id: "t3-upload-window-infopanel-addition",
214 html: \'<label for="overrideExistingFilesCheckbox"><input id="overrideExistingFilesCheckbox" type="checkbox" onclick="setFlashPostOptionOverwriteExistingFiles(this);" />\' + top.String.format(top.TYPO3.LLL.fileUpload.infoComponentOverrideFiles) + \'</label>\'
216 flashUploader.add(infoComponent);
218 // do a reload of this frame once all uploads are done
219 flashUploader.on("totalcomplete", function() {
220 window.location.reload();
223 // this is the callback function that delivers the additional post parameter to the flash application
224 top.setFlashPostOptionOverwriteExistingFiles = function(checkbox) {
225 var uploader = top.TYPO3.getInstance("FileUploadWindow");
226 if (uploader.isVisible()) {
227 uploader.swf.addPostParam("overwriteExistingFiles", (checkbox.checked == true ? 1 : 0));
237 // Create filelisting object
238 $this->filelist
= t3lib_div
::makeInstance('fileList');
239 $this->filelist
->backPath
= $BACK_PATH;
241 // if user never opened the list module, set the value for displayThumbs
242 if (!isset($this->MOD_SETTINGS
['displayThumbs'])) {
243 $this->MOD_SETTINGS
['displayThumbs'] = $BE_USER->uc
['thumbnailsByDefault'];
245 $this->filelist
->thumbs
= $this->MOD_SETTINGS
['displayThumbs'];
247 // Create clipboard object and initialize that
248 $this->filelist
->clipObj
= t3lib_div
::makeInstance('t3lib_clipboard');
249 $this->filelist
->clipObj
->fileMode
=1;
250 $this->filelist
->clipObj
->initializeClipboard();
252 $CB = t3lib_div
::_GET('CB');
253 if ($this->cmd
=='setCB') $CB['el'] = $this->filelist
->clipObj
->cleanUpCBC(array_merge(t3lib_div
::_POST('CBH'),t3lib_div
::_POST('CBC')),'_FILE');
254 if (!$this->MOD_SETTINGS
['clipBoard']) $CB['setP']='normal';
255 $this->filelist
->clipObj
->setCmd($CB);
256 $this->filelist
->clipObj
->cleanCurrent();
257 $this->filelist
->clipObj
->endClipboard(); // Saves
259 // If the "cmd" was to delete files from the list (clipboard thing), do that:
260 if ($this->cmd
=='delete') {
261 $items = $this->filelist
->clipObj
->cleanUpCBC(t3lib_div
::_POST('CBC'),'_FILE',1);
263 // Make command array:
265 foreach ($items as $v) {
266 $FILE['delete'][]=array('data'=>$v);
269 // Init file processing object for deleting and pass the cmd array.
270 $fileProcessor = t3lib_div
::makeInstance('t3lib_extFileFunctions');
271 $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
272 $fileProcessor->init_actionPerms($GLOBALS['BE_USER']->getFileoperationPermissions());
273 $fileProcessor->dontCheckForUnique
= $this->overwriteExistingFiles ?
1 : 0;
274 $fileProcessor->start($FILE);
275 $fileProcessor->processData();
277 $fileProcessor->printLogErrorMessages();
281 if (!isset($this->MOD_SETTINGS
['sort'])) {
282 // Set default sorting
283 $this->MOD_SETTINGS
['sort'] = 'file';
284 $this->MOD_SETTINGS
['reverse'] = 0;
287 // Start up filelisting object, include settings.
288 $this->pointer
= t3lib_div
::intInRange($this->pointer
,0,100000);
289 $this->filelist
->start($this->id
, $this->pointer
, $this->MOD_SETTINGS
['sort'], $this->MOD_SETTINGS
['reverse'], $this->MOD_SETTINGS
['clipBoard'], $this->MOD_SETTINGS
['bigControlPanel']);
292 $this->filelist
->generateList();
295 $this->filelist
->writeBottom();
297 // Set top JavaScript:
298 $this->doc
->JScode
=$this->doc
->wrapScriptTags('
300 if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id
).'");
301 function jumpToUrl(URL) { //
302 window.location.href = URL;
305 '.$this->filelist
->CBfunctions() // ... and add clipboard JavaScript functions
308 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
309 $this->doc
->getContextMenuCode();
311 // Setting up the buttons and markers for docheader
312 list($buttons, $otherMarkers) = $this->filelist
->getButtonsAndOtherMarkers($this->id
);
314 // add the folder info to the marker array
315 $otherMarkers['FOLDER_INFO'] = $this->filelist
->getFolderInfo();
317 $docHeaderButtons = array_merge($this->getButtons(), $buttons);
319 // Build the <body> for the module
320 $this->content
= $this->doc
->startPage($LANG->getLL('files'));
324 $pageContent.= '<form action="'.htmlspecialchars($this->filelist
->listURL()).'" method="post" name="dblistForm">';
325 $pageContent.= $this->filelist
->HTMLcode
;
326 $pageContent.= '<input type="hidden" name="cmd" /></form>';
329 if ($this->filelist
->HTMLcode
) { // Making listing options:
334 Listing options for clipboard and thumbnails
336 <div id="typo3-listOptions">
339 // Add "display bigControlPanel" checkbox:
340 $pageContent.=t3lib_BEfunc
::getFuncCheck($this->id
, 'SET[bigControlPanel]', $this->MOD_SETTINGS
['bigControlPanel'], 'file_list.php', '', 'id="bigControlPanel"') . '<label for="bigControlPanel"> ' .$LANG->getLL('bigControlPanel', 1) . '</label><br />';
342 // Add "display thumbnails" checkbox:
343 $pageContent.=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 />';
345 // Add clipboard button
346 $pageContent.=t3lib_BEfunc
::getFuncCheck($this->id
,'SET[clipBoard]',$this->MOD_SETTINGS
['clipBoard'],'file_list.php','','id="checkClipBoard"').' <label for="checkClipBoard">'.$LANG->getLL('clipBoard',1).'</label>';
354 if ($this->MOD_SETTINGS
['clipBoard']) {
355 $pageContent.=$this->filelist
->clipObj
->printClipboard();
356 $pageContent.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'filelist_clipboard', $GLOBALS['BACK_PATH']);
360 $markerArray = array(
361 'CSH' => $docHeaderButtons['csh'],
362 'FUNC_MENU' => t3lib_BEfunc
::getFuncMenu($this->id
, 'SET[function]', $this->MOD_SETTINGS
['function'], $this->MOD_MENU
['function']),
363 'CONTENT' => $pageContent
366 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, array_merge($markerArray, $otherMarkers));
367 $this->content
.= $this->doc
->endPage();
368 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
371 // Create output - no access (no warning though)
373 $this->content
.= $this->doc
->startPage($LANG->getLL('files'));
374 $this->content
.= $this->doc
->endPage();
375 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
382 * Outputting the accumulated content to screen
386 function printContent() {
391 * Create the panel of buttons for submitting the form or otherwise perform operations.
393 * @return array all available buttons as an assoc. array
395 function getButtons() {
396 global $TCA, $LANG, $BACK_PATH, $BE_USER;
406 if ($BE_USER->mayMakeShortcut()) {
407 $buttons['shortcut'] = $this->doc
->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU
)),$this->MCONF
['name']);
410 // FileList Module CSH:
411 $buttons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'filelist_module', $GLOBALS['BACK_PATH'], '', TRUE
);
414 $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)).'">' .
415 t3lib_iconWorks
::getSpriteIcon('actions-edit-upload') .
418 $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)).'">' .
419 t3lib_iconWorks
::getSpriteIcon('actions-document-new') .
428 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_list.php']) {
429 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_list.php']);
435 $SOBE = t3lib_div
::makeInstance('SC_file_list');
438 $SOBE->printContent();