Initial revision
[Packages/TYPO3.CMS.git] / typo3 / file_rename.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: Renaming files and folders
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 // ***************************
46 // Script Classes
47 // ***************************
48 class SC_file_rename {
49 var $content;
50
51 var $basicff;
52 var $shortPath;
53 var $title;
54 var $icon;
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->target = t3lib_div::GPvar("target");
63 $this->basicff = t3lib_div::makeInstance("t3lib_basicFileFunctions");
64 $this->basicff->init($GLOBALS["FILEMOUNTS"],$TYPO3_CONF_VARS["BE"]["fileExtensions"]);
65
66 if (@file_exists($this->target)) {
67 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir)
68 } else {
69 $this->target="";
70 }
71 $key=$this->basicff->checkPathAgainstMounts($this->target."/");
72 if (!$this->target || !$key) {
73 t3lib_BEfunc::typo3PrintError ("Parameter Error","Target was not a directory!","");
74 exit;
75 }
76 // Finding the icon
77 switch($GLOBALS["FILEMOUNTS"][$key]["type"]) {
78 case "user": $this->icon = "gfx/i/_icon_ftp_user.gif"; break;
79 case "group": $this->icon = "gfx/i/_icon_ftp_group.gif"; break;
80 default: $this->icon = "gfx/i/_icon_ftp.gif"; break;
81 }
82 $this->shortPath = substr($this->target,strlen($GLOBALS["FILEMOUNTS"][$key]["path"]));
83 $this->title = $GLOBALS["FILEMOUNTS"][$key]["name"].": ".$this->shortPath;
84
85
86
87 // ***************************
88 // Setting template object
89 // ***************************
90 $this->doc = t3lib_div::makeInstance("smallDoc");
91 $this->doc->backPath = $BACK_PATH;
92
93 $this->doc->JScode='
94 <script language="javascript" type="text/javascript">
95 function backToList() {
96 top.goToModule("file_list");
97 }
98 </script>
99 ';
100 $this->doc->form='<form action="tce_file.php" method="POST" name="editform">';
101 }
102 function main() {
103 global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$HTTP_GET_VARS,$HTTP_POST_VARS,$CLIENT,$TYPO3_CONF_VARS;
104
105 $this->content="";
106 $this->content.=$this->doc->startPage($LANG->sL("LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle"));
107 $this->content.=$this->doc->header($LANG->sL("LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle"));
108 $this->content.=$this->doc->spacer(5);
109 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
110 $this->content.=$this->doc->divider(5);
111
112
113 // making the formfields
114 $code='<br>
115 <input type="Text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(20).'>
116 <input type="Hidden" name="file[rename][0][target]" value="'.$this->target.'"><br>';
117
118 $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;">';
119
120
121 $this->content.= $this->doc->section("",$code);
122 }
123 function printContent() {
124 global $SOBE;
125
126 $this->content.= $this->doc->spacer(10);
127 $this->content.= $this->doc->middle();
128 $this->content.= $this->doc->endPage();
129 echo $this->content;
130 }
131 }
132
133 // Include extension?
134 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_rename.php"]) {
135 include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/file_rename.php"]);
136 }
137
138
139
140
141
142
143
144
145
146
147
148
149 // Make instance:
150 $SOBE = t3lib_div::makeInstance("SC_file_rename");
151 $SOBE->init();
152 $SOBE->main();
153 $SOBE->printContent();
154 ?>