[TASK] Clean up phpDoc comments in typo3/
[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 /**
29 * Web>File: Create new folders in the filemounts
30 *
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36 $BACK_PATH = '';
37 require('init.php');
38 require('template.php');
39
40 /**
41 * Script Class for the create-new script; Displays a form for creating up to 10 folders or one new text file
42 *
43 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
44 * @package TYPO3
45 * @subpackage core
46 */
47 class SC_file_newfolder {
48
49 // External, static:
50 var $folderNumber = 10;
51
52 // Internal, static:
53 /**
54 * document template object
55 *
56 * @var smallDoc
57 */
58 var $doc;
59 // Name of the filemount
60 var $title;
61
62 // Internal, static (GPVar):
63 var $number;
64 // Set with the target path inputted in &target
65 var $target;
66
67 /**
68 * The folder object which is the target directory
69 *
70 * @var t3lib_file_Folder $folderObject
71 */
72 protected $folderObject;
73 // Return URL of list module.
74 var $returnUrl;
75
76 // Internal, dynamic:
77 // Accumulating content
78 var $content;
79
80 /**
81 * Constructor function for class
82 *
83 * @return void
84 */
85 function init() {
86 // Initialize GPvars:
87 $this->number = t3lib_div::_GP('number');
88 $this->target = $combinedIdentifier = t3lib_div::_GP('target');
89 $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
90
91 // create the folder object
92 if ($combinedIdentifier) {
93 $this->folderObject = t3lib_file_Factory::getInstance()->getFolderObjectFromCombinedIdentifier($combinedIdentifier);
94 }
95
96 // Cleaning and checking target directory
97 if (!$this->folderObject) {
98 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
99 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
100 throw new RuntimeException($title . ': ' . $message, 1294586843);
101 }
102
103 // Setting the title and the icon
104 $icon = t3lib_iconWorks::getSpriteIcon('apps-filetree-root');
105 $this->title = $icon . htmlspecialchars($this->folderObject->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject->getIdentifier());
106
107 // Setting template object
108 $this->doc = t3lib_div::makeInstance('template');
109 $this->doc->setModuleTemplate('templates/file_newfolder.html');
110 $this->doc->backPath = $GLOBALS['BACK_PATH'];
111 $this->doc->JScode = $this->doc->wrapScriptTags('
112 var path = "' . $this->target . '";
113
114 function reload(a) { //
115 if (!changed || (changed && confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')) . '))) {
116 var params = "&target="+encodeURIComponent(path)+"&number="+a+"&returnUrl=' . rawurlencode($this->returnUrl) . '";
117 window.location.href = "file_newfolder.php?"+params;
118 }
119 }
120 function backToList() { //
121 top.goToModule("file_list");
122 }
123
124 var changed = 0;
125 ');
126 }
127
128 /**
129 * Main function, rendering the main module content
130 *
131 * @return void
132 */
133 function main() {
134
135 // Start content compilation
136 $this->content .= $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
137
138 // Make page header:
139 $pageContent = '';
140 $pageContent .= $this->doc->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle'));
141 $pageContent .= $this->doc->spacer(5);
142 $pageContent.=$this->doc->divider(5);
143
144
145 $code = '<form action="tce_file.php" method="post" name="editform">';
146 // Making the selector box for the number of concurrent folder-creations
147 $this->number = t3lib_utility_Math::forceIntegerInRange($this->number, 1, 10);
148 $code .= '
149 <div id="c-select">
150 <label for="number-of-new-folders">' .
151 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.number_of_folders') .
152 '</label>
153 <select name="number" id="number-of-new-folders" onchange="reload(this.options[this.selectedIndex].value);">';
154 for ($a = 1; $a <= $this->folderNumber; $a++) {
155 $code .= '<option value="' . $a . '"' .
156 ($this->number == $a ? ' selected="selected"' : '') .
157 '>' . $a . '</option>';
158 }
159 $code .= '
160 </select>
161 </div>
162 ';
163
164 // Making the number of new-folder boxes needed:
165 $code .= '
166 <div id="c-createFolders">
167 ';
168 for ($a = 0; $a < $this->number; $a++) {
169 $code .= '
170 <input'.$this->doc->formWidth(20).' type="text" name="file[newfolder]['.$a.'][data]" onchange="changed=true;" />
171 <input type="hidden" name="file[newfolder][' . $a . '][target]" value="' . htmlspecialchars($this->target) . '" /><br />
172 ';
173 }
174 $code .= '
175 </div>
176 ';
177
178 // Making submit button for folder creation:
179 $code .= '
180 <div id="c-submitFolders">
181 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit', 1) . '" />
182 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.cancel', 1) . '" onclick="backToList(); return false;" />
183 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
184 </div>
185 ';
186
187 // CSH:
188 $code .= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfolder', $GLOBALS['BACK_PATH'], '<br />');
189
190 $pageContent .= $code;
191
192 // Add spacer:
193 $pageContent .= $this->doc->spacer(10);
194
195 // Switching form tags:
196 $pageContent .= $this->doc->sectionEnd();
197 $pageContent .= '</form><form action="tce_file.php" method="post" name="editform2">';
198
199 // Create a list of allowed file extensions with the nice format "*.jpg, *.gif" etc.
200 $fileExtList = array();
201 $textfileExt = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'], TRUE);
202 foreach ($textfileExt as $fileExt) {
203 if (!preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', '.' . $fileExt)) {
204 $fileExtList[] = '*.' . $fileExt;
205 }
206 }
207 // Add form fields for creation of a new, blank text file:
208 $code = '
209 <div id="c-newFile">
210 <p>[' . htmlspecialchars(implode(', ', $fileExtList)) . ']</p>
211 <input'.$this->doc->formWidth(20).' type="text" name="file[newfile][0][data]" onchange="changed=true;" />
212 <input type="hidden" name="file[newfile][0][target]" value="'.htmlspecialchars($this->target).'" />
213 </div>
214 ';
215
216 // Submit button for creation of a new file:
217 $code .= '
218 <div id="c-submitFiles">
219 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit', 1) . '" />
220 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.cancel', 1) . '" onclick="backToList(); return false;" />
221 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
222 </div>
223 ';
224
225 // CSH:
226 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_newfile', $GLOBALS['BACK_PATH'], '<br />');
227 $pageContent .= $this->doc->section($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile'), $code);
228 $pageContent .= $this->doc->sectionEnd();
229 $pageContent .= '</form>';
230
231 $docHeaderButtons = array();
232
233 // Add the HTML as a section:
234 $markerArray = array(
235 'CSH' => $docHeaderButtons['csh'],
236 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
237 'CONTENT' => $pageContent,
238 'PATH' => $this->title,
239 );
240
241 $this->content .= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
242 $this->content .= $this->doc->endPage();
243
244 $this->content = $this->doc->insertStylesAndJS($this->content);
245 }
246
247 /**
248 * Outputting the accumulated content to screen
249 *
250 * @return void
251 */
252 function printContent() {
253 echo $this->content;
254 }
255 }
256
257 // Make instance:
258 $SOBE = t3lib_div::makeInstance('SC_file_newfolder');
259 $SOBE->init();
260 $SOBE->main();
261 $SOBE->printContent();
262
263 ?>