Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / file_newfolder.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 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 *
32 * @author Kasper Skaarhoj <kasper@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 75: class SC_file_newfolder
40 * 91: function init()
41 * 145: function main()
42 * 186: function printContent()
43 *
44 * TOTAL FUNCTIONS: 3
45 * (This index is automatically created/updated by the extension "extdeveval")
46 *
47 */
48
49
50
51 $BACK_PATH='';
52 require ('init.php');
53 require ('template.php');
54 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
55
56
57
58
59
60
61
62
63
64
65
66
67
68 /**
69 * Script Class
70 *
71 * @author Kasper Skaarhoj <kasper@typo3.com>
72 * @package TYPO3
73 * @subpackage core
74 */
75 class SC_file_newfolder {
76 var $content;
77 var $number;
78 var $basicff;
79 var $shortPath;
80 var $title;
81 var $icon;
82 var $folderNumber=10;
83 var $target;
84 var $doc;
85
86 /**
87 * Constructor:
88 *
89 * @return [type] ...
90 */
91 function init() {
92 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
93
94 $this->number = t3lib_div::GPvar("number");
95 $this->target = t3lib_div::GPvar("target");
96 $this->basicff = t3lib_div::makeInstance("t3lib_basicFileFunctions");
97 $this->basicff->init($GLOBALS["FILEMOUNTS"],$TYPO3_CONF_VARS["BE"]["fileExtensions"]);
98
99 $this->target=$this->basicff->is_directory($this->target); // Cleaning and checking target
100 $key=$this->basicff->checkPathAgainstMounts($this->target."/");
101 if (!$this->target || !$key) {
102 t3lib_BEfunc::typo3PrintError ("Parameter Error","Target was not a directory!","");
103 exit;
104 }
105 // Finding the icon
106 switch($GLOBALS["FILEMOUNTS"][$key]["type"]) {
107 case "user": $this->icon = "gfx/i/_icon_ftp_user.gif"; break;
108 case "group": $this->icon = "gfx/i/_icon_ftp_group.gif"; break;
109 default: $this->icon = "gfx/i/_icon_ftp.gif"; break;
110 }
111 $this->shortPath = substr($this->target,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
112 $this->title = $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath;
113
114 // ***************************
115 // Setting template object
116 // ***************************
117 $this->doc = t3lib_div::makeInstance("smallDoc");
118 $this->doc->backPath = $BACK_PATH;
119 $this->doc->JScode='
120 <script language="javascript" type="text/javascript">
121 var path = "'.$this->target.'";
122
123 function reload(a) { //
124 if (!changed || (changed && confirm("'.$LANG->sL("LLL:EXT:lang/locallang_core.php:mess.redraw").'"))) {
125 var params = "&target="+escape(path)+"&number="+a;
126 document.location = "file_newfolder.php?"+params;
127 }
128 }
129 function backToList() { //
130 top.goToModule("file_list");
131 }
132
133 var changed = 0;
134
135 </script>
136 ';
137 $this->doc->form='<form action="tce_file.php" method="POST" name="editform">';
138 }
139
140 /**
141 * [Describe function...]
142 *
143 * @return [type] ...
144 */
145 function main() {
146 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
147
148 $this->content="";
149 $this->content.=$this->doc->startPage($LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle"));
150 $this->content.=$this->doc->header($LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle"));
151 $this->content.=$this->doc->spacer(5);
152 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
153 $this->content.=$this->doc->divider(5);
154
155
156 // making the selector box
157 $this->number = t3lib_div::intInRange($this->number,1,10);
158 $code='<select name="number" onChange="reload(this.options[this.selectedIndex].value);">';
159 for ($a=1;$a<=$this->folderNumber;$a++) {
160 $code.='<option value="'.$a.'"'.($this->number==$a?' selected':'').'>'.$a.' '.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.folders").'</option>';
161 }
162 $code.='</select><BR><BR>';
163
164 for ($a=0;$a<$this->number;$a++) {
165 $code.='<input'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).' type="Text" name="file[newfolder]['.$a.'][data]" onChange="changed=true;"><input type="Hidden" name="file[newfolder]['.$a.'][target]" value="'.$this->target.'"><BR>';
166 }
167 $code.='<BR><input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.submit").'">&nbsp;&nbsp;<input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.cancel").'" onClick="backToList(); return false;">';
168 $this->content.= $this->doc->section("",$code);
169
170
171 $this->content.= $this->doc->spacer(10);
172 $this->content.= $this->doc->middle();
173
174 // new file:
175 $code='</form><form action="tce_file.php" method="POST" name="editform2">';
176 $code.='<input'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).' type="Text" name="file[newfile][0][data]" onChange="changed=true;"><input type="Hidden" name="file[newfile][0][target]" value="'.$this->target.'"><BR>';
177 $code.='<BR><input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile_submit").'">&nbsp;&nbsp;<input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.cancel").'" onClick="backToList(); return false;">';
178 $this->content.= $this->doc->section($LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile"),$code);
179 }
180
181 /**
182 * [Describe function...]
183 *
184 * @return [type] ...
185 */
186 function printContent() {
187 global $SOBE;
188
189 $this->content.= $this->doc->middle();
190 $this->content.= $this->doc->endPage();
191 echo $this->content;
192 }
193 }
194
195 // Include extension?
196 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_newfolder.php"]) {
197 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_newfolder.php"]);
198 }
199
200
201
202
203
204
205
206
207
208
209
210
211 // Make instance:
212 $SOBE = t3lib_div::makeInstance("SC_file_newfolder");
213 $SOBE->init();
214 $SOBE->main();
215 $SOBE->printContent();
216 ?>