Added more comments, $Id$ keywords etc for the whole core of TYPO3.
[Packages/TYPO3.CMS.git] / typo3 / file_rename.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: Renaming files and folders
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_rename
40 * 90: function init()
41 * 126: function backToList()
42 * 139: function main()
43 * 166: function printContent()
44 *
45 * TOTAL FUNCTIONS: 4
46 * (This index is automatically created/updated by the extension "extdeveval")
47 *
48 */
49
50
51
52 $BACK_PATH='';
53 require ('init.php');
54 require ('template.php');
55 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
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_rename {
76 var $content;
77
78 var $basicff;
79 var $shortPath;
80 var $title;
81 var $icon;
82 var $target;
83 var $doc;
84
85 /**
86 * Constructor:
87 *
88 * @return [type] ...
89 */
90 function init() {
91 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
92
93 $this->target = t3lib_div::GPvar("target");
94 $this->basicff = t3lib_div::makeInstance("t3lib_basicFileFunctions");
95 $this->basicff->init($GLOBALS["FILEMOUNTS"],$TYPO3_CONF_VARS["BE"]["fileExtensions"]);
96
97 if (@file_exists($this->target)) {
98 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir)
99 } else {
100 $this->target="";
101 }
102 $key=$this->basicff->checkPathAgainstMounts($this->target."/");
103 if (!$this->target || !$key) {
104 t3lib_BEfunc::typo3PrintError ("Parameter Error","Target was not a directory!","");
105 exit;
106 }
107 // Finding the icon
108 switch($GLOBALS["FILEMOUNTS"][$key]["type"]) {
109 case "user": $this->icon = "gfx/i/_icon_ftp_user.gif"; break;
110 case "group": $this->icon = "gfx/i/_icon_ftp_group.gif"; break;
111 default: $this->icon = "gfx/i/_icon_ftp.gif"; break;
112 }
113 $this->shortPath = substr($this->target,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
114 $this->title = $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath;
115
116
117
118 // ***************************
119 // Setting template object
120 // ***************************
121 $this->doc = t3lib_div::makeInstance("smallDoc");
122 $this->doc->backPath = $BACK_PATH;
123
124 $this->doc->JScode='
125 <script language="javascript" type="text/javascript">
126 function backToList() {
127 top.goToModule("file_list");
128 }
129 </script>
130 ';
131 $this->doc->form='<form action="tce_file.php" method="POST" name="editform">';
132 }
133
134 /**
135 * [Describe function...]
136 *
137 * @return [type] ...
138 */
139 function main() {
140 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
141
142 $this->content="";
143 $this->content.=$this->doc->startPage($LANG->sL("LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle"));
144 $this->content.=$this->doc->header($LANG->sL("LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle"));
145 $this->content.=$this->doc->spacer(5);
146 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
147 $this->content.=$this->doc->divider(5);
148
149
150 // making the formfields
151 $code='<br>
152 <input type="Text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'>
153 <input type="Hidden" name="file[rename][0][target]" value="'.$this->target.'"><br>';
154
155 $code.='<BR><input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:file_rename.php.submit").'">&nbsp;&nbsp;<input type="Submit" value="'.$LANG->sL("LLL:EXT:lang/locallang_core.php:labels.cancel").'" onClick="backToList(); return false;">';
156
157
158 $this->content.= $this->doc->section("",$code);
159 }
160
161 /**
162 * [Describe function...]
163 *
164 * @return [type] ...
165 */
166 function printContent() {
167 global $SOBE;
168
169 $this->content.= $this->doc->spacer(10);
170 $this->content.= $this->doc->middle();
171 $this->content.= $this->doc->endPage();
172 echo $this->content;
173 }
174 }
175
176 // Include extension?
177 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_rename.php"]) {
178 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_rename.php"]);
179 }
180
181
182
183
184
185
186
187
188
189
190
191
192 // Make instance:
193 $SOBE = t3lib_div::makeInstance("SC_file_rename");
194 $SOBE->init();
195 $SOBE->main();
196 $SOBE->printContent();
197 ?>