See four lines in changelog, 2004-05-18. Basically a lot of fixes for character set...
[Packages/TYPO3.CMS.git] / typo3 / file_newfolder.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 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: 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 <kasper@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 76: class SC_file_newfolder
41 * 102: function init()
42 * 161: function main()
43 * 248: 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
57
58
59
60
61
62
63
64
65
66
67
68
69 /**
70 * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
71 *
72 * @author Kasper Skaarhoj <kasper@typo3.com>
73 * @package TYPO3
74 * @subpackage core
75 */
76 class SC_file_newfolder {
77
78 // External, static:
79 var $folderNumber=10;
80
81 // Internal, static:
82 var $doc; // Template object.
83 var $basicff; // Instance of "t3lib_basicFileFunctions"
84 var $icon; // Will be set to the proper icon for the $target value.
85 var $shortPath; // Relative path to current found filemount
86 var $title; // Name of the filemount
87
88 // Internal, static (GPVar):
89 var $number;
90 var $target; // Set with the target path inputted in &target
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 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
104
105 // Initialize GPvars:
106 $this->number = t3lib_div::_GP('number');
107 $this->target = t3lib_div::_GP('target');
108
109 // Init basic-file-functions object:
110 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
111 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
112
113 // Cleaning and checking target
114 $this->target=$this->basicff->is_directory($this->target);
115 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
116 if (!$this->target || !$key) {
117 t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
118 exit;
119 }
120
121 // Finding the icon
122 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
123 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break;
124 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break;
125 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break;
126 }
127
128 // Relative path to filemount, $key:
129 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
130
131 // Setting title:
132 $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
133
134 // Setting template object
135 $this->doc = t3lib_div::makeInstance('smallDoc');
136 $this->doc->docType = 'xhtml_trans';
137 $this->doc->backPath = $BACK_PATH;
138 $this->doc->form='<form action="tce_file.php" method="post" name="editform">';
139 $this->doc->JScode=$this->doc->wrapScriptTags('
140 var path = "'.$this->target.'";
141
142 function reload(a) { //
143 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).'))) {
144 var params = "&target="+escape(path)+"&number="+a;
145 document.location = "file_newfolder.php?"+params;
146 }
147 }
148 function backToList() { //
149 top.goToModule("file_list");
150 }
151
152 var changed = 0;
153 ');
154 }
155
156 /**
157 * Main function, rendering the main module content
158 *
159 * @return void
160 */
161 function main() {
162 global $LANG;
163
164 // Make page header:
165 $this->content='';
166 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
167 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
168 $this->content.=$this->doc->spacer(5);
169 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
170 $this->content.=$this->doc->divider(5);
171
172
173 // Making the selector box for the number of concurrent folder-creations
174 $this->number = t3lib_div::intInRange($this->number,1,10);
175 $code='
176 <div id="c-select">
177 <select name="number" onchange="reload(this.options[this.selectedIndex].value);">';
178 for ($a=1;$a<=$this->folderNumber;$a++) {
179 $code.='
180 <option value="'.$a.'"'.($this->number==$a?' selected="selected"':'').'>'.$a.' '.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.folders',1).'</option>';
181 }
182 $code.='
183 </select>
184 </div>
185 ';
186
187 // Making the number of new-folder boxes needed:
188 $code.='
189 <div id="c-createFolders">
190 ';
191 for ($a=0;$a<$this->number;$a++) {
192 $code.='
193 <input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
194 <input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($this->target).'" />
195 ';
196 }
197 $code.='
198 </div>
199 ';
200
201 // Making submit button for folder creation:
202 $code.='
203 <div id="c-submitFolders">
204 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
205 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
206 </div>
207 ';
208 $this->content.= $this->doc->section('',$code);
209
210
211
212 // Add spacer:
213 $this->content.= $this->doc->spacer(10);
214
215 // Switching form tags:
216 $this->content.= $this->doc->sectionEnd();
217 $this->content.= '</form><form action="tce_file.php" method="post" name="editform2">';
218
219 // Add form fields for creation of a new, blank text file:
220 $code='
221 <div id="c-newFile">
222 <p>['.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']).']</p>
223 <input'.$this->doc->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
224 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target).'" />
225 </div>
226 ';
227
228 // Submit button for creation of a new file:
229 $code.='
230 <div id="c-submitFiles">
231 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit',1).'" />
232 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
233 </div>
234 ';
235
236 // Add the HTML as a section:
237 $this->content.= $this->doc->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
238
239 // Ending page
240 $this->content.= $this->doc->endPage();
241 }
242
243 /**
244 * Outputting the accumulated content to screen
245 *
246 * @return void
247 */
248 function printContent() {
249
250 echo $this->content;
251 }
252 }
253
254 // Include extension?
255 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']) {
256 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_newfolder.php']);
257 }
258
259
260
261
262
263
264
265
266
267
268
269
270 // Make instance:
271 $SOBE = t3lib_div::makeInstance('SC_file_newfolder');
272 $SOBE->init();
273 $SOBE->main();
274 $SOBE->printContent();
275 ?>