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