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