Tons of changes made to the CORE. All scripts has more a less been modified. Primaril...
[Packages/TYPO3.CMS.git] / typo3 / file_list.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Web>File: File listing
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasper@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 77: class SC_file_list
41 * 103: function init()
42 * 130: function menuConfig()
43 * 151: function main()
44 * 274: function printContent()
45 *
46 * TOTAL FUNCTIONS: 4
47 * (This index is automatically created/updated by the extension "extdeveval")
48 *
49 */
50
51
52 unset($MCONF);
53 require ('mod/file/list/conf.php');
54 require ('init.php');
55 require ('template.php');
56 require ('sysext/lang/locallang_mod_file_list.php');
57 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
58 require_once (PATH_t3lib.'class.t3lib_extfilefunc.php');
59 require_once (PATH_t3lib.'class.t3lib_recordlist.php');
60 require_once (PATH_t3lib.'class.t3lib_clipboard.php');
61 require_once ('class.file_list.inc');
62 $BE_USER->modAccess($MCONF,1);
63
64
65
66
67
68
69
70 /**
71 * Script Class for creating the list of files in the File > Filelist module
72 *
73 * @author Kasper Skaarhoj <kasper@typo3.com>
74 * @package TYPO3
75 * @subpackage core
76 */
77 class SC_file_list {
78 var $MCONF=array(); // Module configuration
79 var $MOD_MENU=array();
80 var $MOD_SETTINGS=array();
81
82
83 // Internal:
84 var $content; // Accumulated HTML output
85 var $basicFF; // File operation object (t3lib_basicFileFunctions)
86 var $doc; // Template object
87
88 // Internal, static: GPvars:
89 var $id; // "id" -> the path to list.
90 var $pointer; // Pointer to listing
91 var $table; // "Table"
92 var $imagemode; // Thumbnail mode.
93 var $cmd;
94 var $overwriteExistingFiles;
95
96
97 /**
98 * Initialize variables, file object
99 * Incoming GET vars include id, pointer, table, imagemode
100 *
101 * @return void
102 */
103 function init() {
104 global $TYPO3_CONF_VARS,$FILEMOUNTS;
105
106 // Setting GPvars:
107 $this->id = t3lib_div::GPvar('id');
108 $this->pointer = t3lib_div::GPvar('pointer');
109 $this->table = t3lib_div::GPvar('table');
110 $this->imagemode = t3lib_div::GPvar('imagemode');
111 $this->cmd = t3lib_div::GPvar('cmd');
112 $this->overwriteExistingFiles = t3lib_div::GPvar('overwriteExistingFiles');
113
114 // Setting module name:
115 $this->MCONF = $GLOBALS['MCONF'];
116
117 // File operation object:
118 $this->basicFF = t3lib_div::makeInstance('t3lib_basicFileFunctions');
119 $this->basicFF->init($FILEMOUNTS,$TYPO3_CONF_VARS['BE']['fileExtensions']);
120
121 // Configure the "menu" - which is used internally to save the values of sorting, displayThumbs etc.
122 $this->menuConfig();
123 }
124
125 /**
126 * Setting the menu/session variables
127 *
128 * @return void
129 */
130 function menuConfig() {
131 // MENU-ITEMS:
132 // If array, then it's a selector box menu
133 // If empty string it's just a variable, that'll be saved.
134 // Values NOT in this array will not be saved in the settings-array for the module.
135 $this->MOD_MENU = array(
136 'sort' => '',
137 'reverse' => '',
138 'displayThumbs' => '',
139 'clipBoard' => ''
140 );
141
142 // CLEANSE SETTINGS
143 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::GPvar('SET'), $this->MCONF['name']);
144 }
145
146 /**
147 * Main function, creating the listing
148 *
149 * @return void
150 */
151 function main() {
152 global $BE_USER,$LANG,$BACK_PATH,$HTTP_GET_VARS,$HTTP_POST_VARS,$TYPO3_CONF_VARS,$FILEMOUNTS;
153
154 // Initialize the template object
155 $this->doc = t3lib_div::makeInstance('template');
156 $this->doc->backPath = $BACK_PATH;
157 $this->doc->docType = 'xhtml_trans';
158
159 // Validating the input "id" (the path, directory!) and checking it against the mounts of the user.
160 $this->id = $this->basicFF->is_directory($this->id);
161 $access = $this->id && $this->basicFF->checkPathAgainstMounts($this->id.'/');
162
163 // There there was access to this file path, continue, make the list
164 if ($access) {
165
166 // Create filelisting object
167 $filelist = t3lib_div::makeInstance('fileList');
168 $filelist->backPath = $BACK_PATH;
169 $filelist->thumbs = $this->MOD_SETTINGS['displayThumbs']?1:$BE_USER->uc['thumbnailsByDefault'];
170
171 // Create clipboard object and initialize that
172 $filelist->clipObj = t3lib_div::makeInstance('t3lib_clipboard');
173 $filelist->clipObj->fileMode=1;
174 $filelist->clipObj->initializeClipboard();
175
176 $CB = $HTTP_GET_VARS['CB'];
177 if ($this->cmd=='setCB') $CB['el'] = $filelist->clipObj->cleanUpCBC(array_merge($HTTP_POST_VARS['CBH'],$HTTP_POST_VARS['CBC']),'_FILE');
178 if (!$this->MOD_SETTINGS['clipBoard']) $CB['setP']='normal';
179 $filelist->clipObj->setCmd($CB);
180 $filelist->clipObj->cleanCurrent();
181 $filelist->clipObj->endClipboard(); // Saves
182
183 // If the "cmd" was to delete files from the list (clipboard thing), do that:
184 if ($this->cmd=='delete') {
185 $items = $filelist->clipObj->cleanUpCBC($HTTP_POST_VARS['CBC'],'_FILE',1);
186 if (count($items)) {
187 // Make command array:
188 $FILE=array();
189 reset($items);
190 while(list(,$v)=each($items)) {
191 $FILE['delete'][]=array('data'=>$v);
192 }
193
194 // Init file processing object for deleting and pass the cmd array.
195 $fileProcessor = t3lib_div::makeInstance('t3lib_extFileFunctions');
196 $fileProcessor->init($FILEMOUNTS, $TYPO3_CONF_VARS['BE']['fileExtensions']);
197 $fileProcessor->init_actionPerms($BE_USER->user['fileoper_perms']);
198 $fileProcessor->dontCheckForUnique = $this->overwriteExistingFiles ? 1 : 0;
199 $fileProcessor->start($FILE);
200 $fileProcessor->processData();
201
202 $fileProcessor->printLogErrorMessages();
203 }
204 }
205
206 // Start up filelisting object, include settings.
207 $this->pointer = t3lib_div::intInRange($this->pointer,0,100000);
208 $filelist->start($this->id,$this->pointer,$this->MOD_SETTINGS['sort'],$this->MOD_SETTINGS['reverse'],$this->MOD_SETTINGS['clipBoard']);
209
210 // Write the header
211 $filelist->writeTop($this->id);
212
213 // Generate the list
214 $filelist->generateList($this->id,$this->table);
215
216 // Write the footer
217 $filelist->writeBottom();
218
219 // Set top JavaScript:
220 $this->doc->JScode=$this->doc->wrapScriptTags('
221
222 if (top.fsMod) top.fsMod.recentIds["file"] = unescape("'.rawurlencode($this->id).'");
223 function jumpToUrl(URL) { //
224 document.location = URL;
225 }
226
227 '.$filelist->CBfunctions() // ... and add clipboard JavaScript functions
228 );
229
230 // This will return content necessary for the context sensitive clickmenus to work: bodytag events, JavaScript functions and DIV-layers.
231 $CMparts=$this->doc->getContextMenuCode();
232 $this->doc->bodyTagAdditions = $CMparts[1];
233 $this->doc->JScode.=$CMparts[0];
234 $this->doc->postCode.= $CMparts[2];
235
236
237 // Create output
238 $this->content='';
239 $this->content.=$this->doc->startPage($LANG->getLL('files'));
240 $this->content.= '<form action="'.htmlspecialchars($filelist->listURL()).'" method="post" name="dblistForm">';
241 $this->content.= $filelist->HTMLcode;
242 $this->content.= '<input type="hidden" name="cmd" /></form>';
243
244 if ($filelist->HTMLcode) { // Making search form:
245 // Add "display thumbnails" checkbox:
246 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[displayThumbs]',$this->MOD_SETTINGS['displayThumbs'],'file_list.php','').' '.$LANG->getLL('displayThumbs',1).'<br />';
247
248 // Add clipboard button
249 $this->content.=t3lib_BEfunc::getFuncCheck($this->id,'SET[clipBoard]',$this->MOD_SETTINGS['clipBoard'],'file_list.php','').' '.$LANG->getLL('clipBoard',1);
250
251 // Set clipboard:
252 if ($this->MOD_SETTINGS['clipBoard']) $this->content.=$filelist->clipObj->printClipboard();
253 }
254
255 // Add shortcut
256 if ($BE_USER->mayMakeShortcut()) {
257 $this->content.='<br /><br />'.$this->doc->makeShortcutIcon('pointer,id,target,table',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']);
258 }
259 } else {
260 // Create output - no access (no warning though)
261 $this->content='';
262 $this->content.=$this->doc->startPage($LANG->getLL('files'));
263 }
264
265 // Ending page:
266 $this->content.= $this->doc->endPage();
267 }
268
269 /**
270 * Outputting the accumulated content to screen
271 *
272 * @return void
273 */
274 function printContent() {
275
276 echo $this->content;
277 }
278 }
279
280 // Include extension?
281 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']) {
282 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_list.php']);
283 }
284
285
286
287
288
289
290
291
292
293
294
295
296 // Make instance:
297 $SOBE = t3lib_div::makeInstance('SC_file_list');
298 $SOBE->init();
299 $SOBE->main();
300 $SOBE->printContent();
301
302
303 if ($TYPO3_CONF_VARS['BE']['compressionLevel']) {
304 new gzip_encode($TYPO3_CONF_VARS['BE']['compressionLevel']);
305 }
306 ?>