2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (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
30 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 require('template.php');
43 * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
45 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
49 class SC_file_newfolder
{
56 * document template object
62 var $title; // Name of the filemount
64 // Internal, static (GPVar):
66 var $target; // Set with the target path inputted in &target
69 * the folder object which is the target directory
71 * @var t3lib_file_Folder $folderObject
73 protected $folderObject;
74 var $returnUrl; // Return URL of list module.
77 var $content; // Accumulating content
82 * Constructor function for class
88 $this->number
= t3lib_div
::_GP('number');
89 $this->target
= $combinedIdentifier = t3lib_div
::_GP('target');
90 $this->returnUrl
= t3lib_div
::sanitizeLocalUrl(t3lib_div
::_GP('returnUrl'));
92 // create the folder object
93 if ($combinedIdentifier) {
94 $this->folderObject
= t3lib_file_Factory
::getInstance()->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
97 // Cleaning and checking target directory
98 if (!$this->folderObject
) {
99 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
100 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
101 throw new RuntimeException($title . ': ' . $message, 1294586843);
104 // Setting the title and the icon
105 $icon = t3lib_iconWorks
::getSpriteIcon('apps-filetree-root');
106 $this->title
= $icon . htmlspecialchars($this->folderObject
->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject
->getIdentifier());
108 // Setting template object
109 $this->doc
= t3lib_div
::makeInstance('template');
110 $this->doc
->setModuleTemplate('templates/file_newfolder.html');
111 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
112 $this->doc
->JScode
=$this->doc
->wrapScriptTags('
113 var path = "' . $this->target
. '";
115 function reload(a) { //
116 if (!changed || (changed && confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')) . '))) {
117 var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . rawurlencode($this->returnUrl
) . '";
118 window.location.href = "file_newfolder.php?"+params;
121 function backToList() { //
122 top.goToModule("file_list");
130 * Main function, rendering the main module content
136 // start content compilation
137 $this->content
.= $this->doc
->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
142 $pageContent.=$this->doc
->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
143 $pageContent.=$this->doc
->spacer(5);
144 $pageContent.=$this->doc
->divider(5);
147 $code = '<form action="tce_file.php" method="post" name="editform">';
148 // Making the selector box for the number of concurrent folder-creations
149 $this->number
= t3lib_utility_Math
::forceIntegerInRange($this->number
,1,10);
152 <label for="number-of-new-folders">' .
153 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.number_of_folders') .
155 <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">';
156 for ($a=1;$a<=$this->folderNumber
;$a++
) {
157 $code .= '<option value="' . $a . '"' .
158 ($this->number
== $a ?
' selected="selected"' : '') .
159 '>' . $a . '</option>';
166 // Making the number of new-folder boxes needed:
168 <div id="c-createFolders">
170 for ($a=0;$a<$this->number
;$a++
) {
172 <input'.$this->doc
->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
173 <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target
) . '" /><br />
180 // Making submit button for folder creation:
182 <div id="c-submitFolders">
183 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit', 1) . '" />
184 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.cancel', 1) . '" onclick="backToList(); return false;" />
185 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
190 $code.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'], '<br />');
192 $pageContent.= $code;
197 $pageContent.= $this->doc
->spacer(10);
199 // Switching form tags:
200 $pageContent.= $this->doc
->sectionEnd();
201 $pageContent.= '</form><form action="tce_file.php" method="post" name="editform2">';
203 // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc.
204 $fileExtList = array();
205 $textfileExt = t3lib_div
::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE);
206 foreach ($textfileExt as $fileExt) {
207 if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) {
208 $fileExtList[] = '*.' . $fileExt;
211 // Add form fields for creation of a new, blank text file:
214 <p>[' . htmlspecialchars(implode(', ', $fileExtList)) . ']</p>
215 <input'.$this->doc
->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
216 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target
).'" />
220 // Submit button for creation of a new file:
222 <div id="c-submitFiles">
223 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit', 1) . '" />
224 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.cancel', 1) . '" onclick="backToList(); return false;" />
225 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
230 $code.= t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'], '<br />');
231 $pageContent .= $this->doc
->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'), $code);
232 $pageContent .= $this->doc
->sectionEnd();
233 $pageContent .= '</form>';
235 $docHeaderButtons = array();
237 // Add the HTML as a section:
238 $markerArray = array(
239 'CSH' => $docHeaderButtons['csh'],
240 'FUNC_MENU' => t3lib_BEfunc
::getFuncMenu($this->id
, 'SET[function]', $this->MOD_SETTINGS
['function'], $this->MOD_MENU
['function']),
241 'CONTENT' => $pageContent,
242 'PATH' => $this->title
,
245 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, $markerArray);
246 $this->content
.= $this->doc
->endPage();
248 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
252 * Outputting the accumulated content to screen
256 function printContent() {
262 $SOBE = t3lib_div
::makeInstance('SC_file_newfolder');
265 $SOBE->printContent();