Fixed bug #13294: IRRE deleted combo records are still validated by TBE_EDITOR (Thank...
[Packages/TYPO3.CMS.git] / typo3 / file_newfolder.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@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: Create new folders in the filemounts
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 74: class SC_file_newfolder
41 * 101: function init()
42 * 161: function main()
43 * 255: function printContent()
44 *
45 * TOTAL FUNCTIONS: 3
46 * (This index is automatically created/updated by the extension "extdeveval")
47 *
48 */
49
50
51
52 $BACK_PATH = '';
53 require('init.php');
54 require('template.php');
55
56
57
58
59
60
61
62
63
64
65 /**
66 * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
67 *
68 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
69 * @package TYPO3
70 * @subpackage core
71 */
72 class SC_file_newfolder {
73
74 // External, static:
75 var $folderNumber=10;
76
77 // Internal, static:
78 /**
79 * document template object
80 *
81 * @var smallDoc
82 */
83 var $doc;
84
85 /**
86 * File processing object
87 *
88 * @var t3lib_basicFileFunctions
89 */
90 var $basicff;
91 var $icon; // Will be set to the proper icon for the $target value.
92 var $shortPath; // Relative path to current found filemount
93 var $title; // Name of the filemount
94
95 /**
96 * Charset processing object
97 *
98 * @var t3lib_cs
99 */
100 protected $charsetConversion;
101
102 // Internal, static (GPVar):
103 var $number;
104 var $target; // Set with the target path inputted in &target
105 var $returnUrl; // Return URL of list module.
106
107 // Internal, dynamic:
108 var $content; // Accumulating content
109
110
111
112 /**
113 * Constructor function for class
114 *
115 * @return void
116 */
117 function init() {
118 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
119
120 // Initialize GPvars:
121 $this->number = t3lib_div::_GP('number');
122 $this->target = t3lib_div::_GP('target');
123 $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
124
125 // Init basic-file-functions object:
126 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
127 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
128
129 // Init basic-charset-functions object:
130 $this->charsetConversion = t3lib_div::makeInstance('t3lib_cs');
131
132 // Cleaning and checking target
133 $this->target = $this->charsetConversion->conv($this->target, 'utf-8', $GLOBALS['LANG']->charSet);
134 $this->target = $this->basicff->is_directory($this->target);
135 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
136 if (!$this->target || !$key) {
137 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
138 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
139 throw new RuntimeException($title . ': ' . $message);
140 }
141
142 // Finding the icon
143 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
144 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break;
145 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break;
146 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break;
147 }
148
149 $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />';
150
151 // Relative path to filemount, $key:
152 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
153
154 // Setting title:
155 $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
156
157 // Setting template object
158 $this->doc = t3lib_div::makeInstance('template');
159 $this->doc->setModuleTemplate('templates/file_newfolder.html');
160 $this->doc->backPath = $BACK_PATH;
161 $this->doc->JScode=$this->doc->wrapScriptTags('
162 var path = "'.$this->target.'";
163
164 function reload(a) { //
165 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).'))) {
166 var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl='
167 . urlencode($this->charsetConversion->conv($this->returnUrl, $GLOBALS['LANG']->charSet, 'utf-8'))
168 . '";
169 window.location.href = "file_newfolder.php?"+params;
170 }
171 }
172 function backToList() { //
173 top.goToModule("file_list");
174 }
175
176 var changed = 0;
177 ');
178 }
179
180 /**
181 * Main function, rendering the main module content
182 *
183 * @return void
184 */
185 function main() {
186 global $LANG;
187
188 // start content compilation
189 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
190
191
192 // Make page header:
193 $pageContent='';
194 $pageContent.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
195 $pageContent.=$this->doc->spacer(5);
196 $pageContent.=$this->doc->divider(5);
197
198
199 $code = '<form action="tce_file.php" method="post" name="editform">';
200 // Making the selector box for the number of concurrent folder-creations
201 $this->number = t3lib_div::intInRange($this->number,1,10);
202 $code .= '
203 <div id="c-select">
204 <label for="number-of-new-folders">' .
205 $LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.number_of_folders') .
206 '</label>
207 <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">';
208 for ($a=1;$a<=$this->folderNumber;$a++) {
209 $code .= '<option value="' . $a . '"' .
210 ($this->number == $a ? ' selected="selected"' : '') .
211 '>' . $a . '</option>';
212 }
213 $code.='
214 </select>
215 </div>
216 ';
217
218 // Making the number of new-folder boxes needed:
219 $code.='
220 <div id="c-createFolders">
221 ';
222 for ($a=0;$a<$this->number;$a++) {
223 $code.='
224 <input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
225 <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target) . '" /><br />
226 ';
227 }
228 $code.='
229 </div>
230 ';
231
232 // Making submit button for folder creation:
233 $code.='
234 <div id="c-submitFolders">
235 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
236 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
237 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
238 </div>
239 ';
240
241 // CSH:
242 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'], '<br />');
243
244 $pageContent.= $code;
245
246
247
248 // Add spacer:
249 $pageContent.= $this->doc->spacer(10);
250
251 // Switching form tags:
252 $pageContent.= $this->doc->sectionEnd();
253 $pageContent.= '</form><form action="tce_file.php" method="post" name="editform2">';
254
255 // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc.
256 $fileExtList = array();
257 $textfileExt = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE);
258 foreach ($textfileExt as $fileExt) {
259 if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) {
260 $fileExtList[] = '*.' . $fileExt;
261 }
262 }
263 // Add form fields for creation of a new, blank text file:
264 $code='
265 <div id="c-newFile">
266 <p>[' . htmlspecialchars(implode(', ', $fileExtList)) . ']</p>
267 <input'.$this->doc->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
268 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target).'" />
269 </div>
270 ';
271
272 // Submit button for creation of a new file:
273 $code.='
274 <div id="c-submitFiles">
275 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit',1).'" />
276 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
277 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
278 </div>
279 ';
280
281 // CSH:
282 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'], '<br />');
283 $pageContent.= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
284 $pageContent .= $this->doc->sectionEnd();
285 $pageContent .= '</form>';
286
287 $docHeaderButtons = array();
288
289 // Add the HTML as a section:
290 $markerArray = array(
291 'CSH' => $docHeaderButtons['csh'],
292 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
293 'CONTENT' => $pageContent,
294 'PATH' => $this->title,
295 );
296
297 $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
298 $this->content.= $this->doc->endPage();
299
300 $this->content = $this->doc->insertStylesAndJS($this->content);
301 }
302
303 /**
304 * Outputting the accumulated content to screen
305 *
306 * @return void
307 */
308 function printContent() {
309 echo $this->content;
310 }
311 }
312
313
314 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']) {
315 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']);
316 }
317
318
319
320 // Make instance:
321 $SOBE = t3lib_div::makeInstance('SC_file_newfolder');
322 $SOBE->init();
323 $SOBE->main();
324 $SOBE->printContent();
325
326 ?>