Initial revision
[Packages/TYPO3.CMS.git] / typo3 / file_newfolder.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (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 * @author Kasper Skårhøj <kasper@typo3.com>
31 * @package TYPO3
32 * @subpackage core
33 *
34 */
35
36
37 $BACK_PATH="";
38 require ("init.php");
39 require ("template.php");
40 require_once (PATH_t3lib."class.t3lib_basicfilefunc.php");
41
42
43
44 // ***************************
45 // Script Classes
46 // ***************************
47 class SC_file_newfolder {
48 var $content;
49 var $number;
50 var $basicff;
51 var $shortPath;
52 var $title;
53 var $icon;
54 var $folderNumber=10;
55 var $target;
56 var $doc;
57
58 // Constructor:
59 function init() {
60 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
61
62 $this->number = t3lib_div::GPvar("number");
63 $this->target = t3lib_div::GPvar("target");
64 $this->basicff = t3lib_div::makeInstance("t3lib_basicFileFunctions");
65 $this->basicff->init($GLOBALS["FILEMOUNTS"],$TYPO3_CONF_VARS["BE"]["fileExtensions"]);
66
67 $this->target=$this->basicff->is_directory($this->target); // Cleaning and checking target
68 $key=$this->basicff->checkPathAgainstMounts($this->target."/");
69 if (!$this->target || !$key) {
70 t3lib_BEfunc::typo3PrintError ("Parameter Error","Target was not a directory!","");
71 exit;
72 }
73 // Finding the icon
74 switch($GLOBALS["FILEMOUNTS"][$key]["type"]) {
75 case "user": $this->icon = "gfx/i/_icon_ftp_user.gif"; break;
76 case "group": $this->icon = "gfx/i/_icon_ftp_group.gif"; break;
77 default: $this->icon = "gfx/i/_icon_ftp.gif"; break;
78 }
79 $this->shortPath = substr($this->target,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
80 $this->title = $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath;
81
82 // ***************************
83 // Setting template object
84 // ***************************
85 $this->doc = t3lib_div::makeInstance("smallDoc");
86 $this->doc->backPath = $BACK_PATH;
87 $this->doc->JScode='
88 <script language="javascript" type="text/javascript">
89 var path = "'.$this->target.'";
90
91 function reload(a) {
92 if (!changed || (changed && confirm("'.$LANG->sL("LLL:EXT:lang/locallang_core.php:mess.redraw").'"))) {
93 var params = "&target="+escape(path)+"&number="+a;
94 document.location = "file_newfolder.php?"+params;
95 }
96 }
97 function backToList() {
98 top.goToModule("file_list");
99 }
100
101 var changed = 0;
102
103 </script>
104 ';
105 $this->doc->form='<form action="tce_file.php" method="POST" name="editform">';
106 }
107 function main() {
108 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
109
110 $this->content="";
111 $this->content.=$this->doc->startPage($LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle"));
112 $this->content.=$this->doc->header($LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.pagetitle"));
113 $this->content.=$this->doc->spacer(5);
114 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
115 $this->content.=$this->doc->divider(5);
116
117
118 // making the selector box
119 $this->number = t3lib_div::intInRange($this->number,1,10);
120 $code='<select name="number" onChange="reload(this.options[this.selectedIndex].value);">';
121 for ($a=1;$a<=$this->folderNumber;$a++) {
122 $code.='<option value="'.$a.'"'.($this->number==$a?' selected':'').'>'.$a.' '.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.folders").'</option>';
123 }
124 $code.='</select><BR><BR>';
125
126 for ($a=0;$a<$this->number;$a++) {
127 $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>';
128 }
129 $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;">';
130 $this->content.= $this->doc->section("",$code);
131
132
133 $this->content.= $this->doc->spacer(10);
134 $this->content.= $this->doc->middle();
135
136 // new file:
137 $code='</form><form action="tce_file.php" method="POST" name="editform2">';
138 $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>';
139 $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;">';
140 $this->content.= $this->doc->section($LANG->sL("LLL:EXT:lang/locallang_core.php:file_newfolder.php.newfile"),$code);
141 }
142 function printContent() {
143 global $SOBE;
144
145 $this->content.= $this->doc->middle();
146 $this->content.= $this->doc->endPage();
147 echo $this->content;
148 }
149 }
150
151 // Include extension?
152 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_newfolder.php"]) {
153 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_newfolder.php"]);
154 }
155
156
157
158
159
160
161
162
163
164
165
166
167 // Make instance:
168 $SOBE = t3lib_div::makeInstance("SC_file_newfolder");
169 $SOBE->init();
170 $SOBE->main();
171 $SOBE->printContent();
172 ?>