2 /***************************************************************
5 * (c) 1999-2005 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');
55 require_once(PATH_t3lib
.'class.t3lib_basicfilefunc.php');
68 * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
70 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
74 class SC_file_newfolder
{
81 * document template object
88 * File processing object
90 * @var t3lib_basicFileFunctions
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
97 // Internal, static (GPVar):
99 var $target; // Set with the target path inputted in &target
100 var $returnUrl; // Return URL of list module.
102 // Internal, dynamic:
103 var $content; // Accumulating content
108 * Constructor function for class
113 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
115 // Initialize GPvars:
116 $this->number
= t3lib_div
::_GP('number');
117 $this->target
= t3lib_div
::_GP('target');
118 $this->returnUrl
= t3lib_div
::_GP('returnUrl');
120 // Init basic-file-functions object:
121 $this->basicff
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
122 $this->basicff
->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
124 // Cleaning and checking target
125 $this->target
=$this->basicff
->is_directory($this->target
);
126 $key=$this->basicff
->checkPathAgainstMounts($this->target
.'/');
127 if (!$this->target ||
!$key) {
128 t3lib_BEfunc
::typo3PrintError ('Parameter Error','Target was not a directory!','');
133 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
134 case 'user': $this->icon
= 'gfx/i/_icon_ftp_user.gif'; break;
135 case 'group': $this->icon
= 'gfx/i/_icon_ftp_group.gif'; break;
136 default: $this->icon
= 'gfx/i/_icon_ftp.gif'; break;
139 // Relative path to filemount, $key:
140 $this->shortPath
= substr($this->target
,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
143 $this->title
= $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath
;
145 // Setting template object
146 $this->doc
= t3lib_div
::makeInstance('smallDoc');
147 $this->doc
->docType
= 'xhtml_trans';
148 $this->doc
->backPath
= $BACK_PATH;
149 $this->doc
->form
='<form action="tce_file.php" method="post" name="editform">';
150 $this->doc
->JScode
=$this->doc
->wrapScriptTags('
151 var path = "'.$this->target
.'";
153 function reload(a) { //
154 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).'))) {
155 var params = "&target="+escape(path)+"&number="+a;
156 window.location.href = "file_newfolder.php?"+params;
159 function backToList() { //
160 top.goToModule("file_list");
168 * Main function, rendering the main module content
177 $this->content
.=$this->doc
->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
178 $this->content
.=$this->doc
->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
179 $this->content
.=$this->doc
->spacer(5);
180 $this->content
.=$this->doc
->section('',$this->doc
->getFileheader($this->title
,$this->shortPath
,$this->icon
));
181 $this->content
.=$this->doc
->divider(5);
184 // Making the selector box for the number of concurrent folder-creations
185 $this->number
= t3lib_div
::intInRange($this->number
,1,10);
188 <select name="number" onchange="reload(this.options[this.selectedIndex].value);">';
189 for ($a=1;$a<=$this->folderNumber
;$a++
) {
191 <option value="'.$a.'"'.($this->number
==$a?
' selected="selected"':'').'>'.$a.' '.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.folders',1).'</option>';
198 // Making the number of new-folder boxes needed:
200 <div id="c-createFolders">
202 for ($a=0;$a<$this->number
;$a++
) {
204 <input'.$this->doc
->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
205 <input type="hidden" name="file[newfolder]['.$a.'][target]" value="'.htmlspecialchars($this->target
).'" />
212 // Making submit button for folder creation:
214 <div id="c-submitFolders">
215 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit',1).'" />
216 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
217 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
222 $code.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'],'<br/>');
224 $this->content
.= $this->doc
->section('',$code);
229 $this->content
.= $this->doc
->spacer(10);
231 // Switching form tags:
232 $this->content
.= $this->doc
->sectionEnd();
233 $this->content
.= '</form><form action="tce_file.php" method="post" name="editform2">';
235 // Add form fields for creation of a new, blank text file:
238 <p>['.htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']).']</p>
239 <input'.$this->doc
->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
240 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target
).'" />
244 // Submit button for creation of a new file:
246 <div id="c-submitFiles">
247 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit',1).'" />
248 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
249 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
254 $code.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'],'<br/>');
256 // Add the HTML as a section:
257 $this->content
.= $this->doc
->section($LANG->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'),$code);
262 * Outputting the accumulated content to screen
266 function printContent() {
267 $this->content
.= $this->doc
->endPage();
268 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
273 // Include extension?
274 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_newfolder.php']) {
275 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_newfolder.php']);
290 $SOBE = t3lib_div
::makeInstance('SC_file_newfolder');
293 $SOBE->printContent();