2 /***************************************************************
5 * (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Web>File: Create new folders in the filemounts
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 74: class SC_file_newfolder
41 * 101: function init()
42 * 161: function main()
43 * 255: function printContent()
46 * (This index is automatically created/updated by the extension "extdeveval")
54 require('template.php');
66 * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
68 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
72 class SC_file_newfolder
{
79 * document template object
86 * File processing object
88 * @var t3lib_basicFileFunctions
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
96 * Charset processing object
100 protected $charsetConversion;
102 // Internal, static (GPVar):
104 var $target; // Set with the target path inputted in &target
105 var $returnUrl; // Return URL of list module.
107 // Internal, dynamic:
108 var $content; // Accumulating content
113 * Constructor function for class
118 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
120 // Initialize GPvars:
121 $this->number
= t3lib_div
::_GP('number');
122 $this->target
= t3lib_div
::_GP('target');
123 $this->returnUrl
= t3lib_div
::_GP('returnUrl');
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']);
129 // Init basic-charset-functions object:
130 $this->charsetConversion
= t3lib_div
::makeInstance('t3lib_cs');
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 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), '');
142 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
143 case 'user': $this->icon
= 'gfx/i/_icon_ftp_user.gif'; break;
144 case 'group': $this->icon
= 'gfx/i/_icon_ftp_group.gif'; break;
145 default: $this->icon
= 'gfx/i/_icon_ftp.gif'; break;
148 $this->icon
= '<img'.t3lib_iconWorks
::skinImg($this->backPath
,$this->icon
,'width="18" height="16"').' title="" alt="" />';
150 // Relative path to filemount, $key:
151 $this->shortPath
= substr($this->target
,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
154 $this->title
= $this->icon
. htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath
;
156 // Setting template object
157 $this->doc
= t3lib_div
::makeInstance('template');
158 $this->doc
->setModuleTemplate('templates/file_newfolder.html');
159 $this->doc
->backPath
= $BACK_PATH;
160 $this->doc
->JScode
=$this->doc
->wrapScriptTags('
161 var path = "'.$this->target
.'";
163 function reload(a) { //
164 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).'))) {
165 var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl='
166 . urlencode($this->charsetConversion
->conv($this->returnUrl
, $GLOBALS['LANG']->charSet
, 'utf-8'))
168 window.location.href = "file_newfolder.php?"+params;
171 function backToList() { //
172 top.goToModule("file_list");
180 * Main function, rendering the main module content
187 // start content compilation
188 $this->content
.=$this->doc
->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
193 $pageContent.=$this->doc
->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
194 $pageContent.=$this->doc
->spacer(5);
195 $pageContent.=$this->doc
->divider(5);
198 $code = '<form action="tce_file.php" method="post" name="editform">';
199 // Making the selector box for the number of concurrent folder-creations
200 $this->number
= t3lib_div
::intInRange($this->number
,1,10);
203 <label for="number-of-new-folders">' .
204 $LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.number_of_folders') .
206 <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">';
207 for ($a=1;$a<=$this->folderNumber
;$a++
) {
208 $code .= '<option value="' . $a . '"' .
209 ($this->number
== $a ?
' selected="selected"' : '') .
210 '>' . $a . '</option>';
217 // Making the number of new-folder boxes needed:
219 <div id="c-createFolders">
221 for ($a=0;$a<$this->number
;$a++
) {
223 <input'.$this->doc
->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
224 <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target
) . '" /><br />
231 // Making submit button for folder creation:
233 <div id="c-submitFolders">
234 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
235 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
236 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
241 $code.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'], '<br />');
243 $pageContent.= $code;
248 $pageContent.= $this->doc
->spacer(10);
250 // Switching form tags:
251 $pageContent.= $this->doc
->sectionEnd();
252 $pageContent.= '</form><form action="tce_file.php" method="post" name="editform2">';
254 // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc.
255 $fileExtList = array();
256 $textfileExt = t3lib_div
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE);
257 foreach ($textfileExt as $fileExt) {
258 if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) {
259 $fileExtList[] = '*.' . $fileExt;
262 // Add form fields for creation of a new, blank text file:
265 <p>[' . htmlspecialchars(implode(', ', $fileExtList)) . ']</p>
266 <input'.$this->doc
->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
267 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target
).'" />
271 // Submit button for creation of a new file:
273 <div id="c-submitFiles">
274 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit',1).'" />
275 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
276 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
281 $code.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'], '<br />');
282 $pageContent.= $this->doc
->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
283 $pageContent .= $this->doc
->sectionEnd();
284 $pageContent .= '</form>';
286 $docHeaderButtons = array();
288 // Add the HTML as a section:
289 $markerArray = array(
290 'CSH' => $docHeaderButtons['csh'],
291 'FUNC_MENU' => t3lib_BEfunc
::getFuncMenu($this->id
, 'SET[function]', $this->MOD_SETTINGS
['function'], $this->MOD_MENU
['function']),
292 'CONTENT' => $pageContent,
293 'PATH' => $this->title
,
296 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, $markerArray);
297 $this->content
.= $this->doc
->endPage();
299 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
303 * Outputting the accumulated content to screen
307 function printContent() {
313 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_newfolder.php']) {
314 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_newfolder.php']);
320 $SOBE = t3lib_div
::makeInstance('SC_file_newfolder');
323 $SOBE->printContent();