Added feature #14247: Add a concatenator for CSS and JS (thanks to Steffen Gebert)
[Packages/TYPO3.CMS.git] / typo3 / file_rename.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (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 * Web>File: Renaming files and folders
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 74: class SC_file_rename
41 * 96: function init()
42 * 149: function main()
43 * 192: function printContent()
44 *
45 * TOTAL FUNCTIONS: 3
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
56
57
58
59
60
61
62
63
64
65 /**
66 * Script Class for the rename-file form.
67 *
68 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
69 * @package TYPO3
70 * @subpackage core
71 */
72 class SC_file_rename {
73
74 // Internal, static:
75 /**
76 * Document template object
77 *
78 * @var smallDoc
79 */
80 var $doc;
81
82 /**
83 * File processing object
84 *
85 * @var t3lib_basicFileFunctions
86 */
87 var $basicff;
88 var $icon; // Will be set to the proper icon for the $target value.
89 var $shortPath; // Relative path to current found filemount
90 var $title; // Name of the filemount
91
92 // Internal, static (GPVar):
93 var $target; // Set with the target path inputted in &target
94 var $returnUrl; // Return URL of list module.
95
96 // Internal, dynamic:
97 var $content; // Accumulating content
98
99
100 /**
101 * Constructor function for class
102 *
103 * @return void
104 */
105 function init() {
106 //TODO remove global
107 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
108
109 // Initialize GPvars:
110 $this->target = t3lib_div::_GP('target');
111 $this->returnUrl = t3lib_div::_GP('returnUrl');
112
113 // Init basic-file-functions object:
114 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
115 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
116
117 // Cleaning and checking target
118 if (file_exists($this->target)) {
119 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir)
120 } else {
121 $this->target='';
122 }
123 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
124 if (!$this->target || !$key) {
125 t3lib_BEfunc::typo3PrintError ($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', true), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', true), '');
126 exit;
127 }
128
129 // Finding the icon
130 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
131 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break;
132 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break;
133 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break;
134 }
135
136 $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />';
137
138 // Relative path to filemount, $key:
139 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
140
141 // Setting title:
142 $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath;
143
144 // Setting template object
145 $this->doc = t3lib_div::makeInstance('template');
146 $this->doc->setModuleTemplate('templates/file_rename.html');
147 $this->doc->backPath = $BACK_PATH;
148 $this->doc->JScode=$this->doc->wrapScriptTags('
149 function backToList() { //
150 top.goToModule("file_list");
151 }
152 ');
153 }
154
155 /**
156 * Main function, rendering the content of the rename form
157 *
158 * @return void
159 */
160 function main() {
161 //TODO remove global, change $LANG into $GLOBALS['LANG'], change locallang*.php to locallang*.xml
162
163 global $LANG;
164
165 // Make page header:
166 $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
167
168 $pageContent = $this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
169 $pageContent .= $this->doc->spacer(5);
170 $pageContent .= $this->doc->divider(5);
171
172
173 $code = '<form action="tce_file.php" method="post" name="editform">';
174 // Making the formfields for renaming:
175 $code .= '
176
177 <div id="c-rename">
178 <input type="text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />
179 <input type="hidden" name="file[rename][0][target]" value="'.htmlspecialchars($this->target).'" />
180 </div>
181 ';
182
183 // Making submit button:
184 $code.='
185 <div id="c-submit">
186 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.submit',1).'" />
187 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
188 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" />
189 </div>
190 ';
191
192 $code .= '</form>';
193
194 // Add the HTML as a section:
195 $pageContent .= $code;
196
197 $docHeaderButtons = array();
198 $docHeaderButtons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH']);
199
200 // Add the HTML as a section:
201 $markerArray = array(
202 'CSH' => $docHeaderButtons['csh'],
203 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
204 'CONTENT' => $pageContent,
205 'PATH' => $this->title,
206 );
207
208 $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
209 $this->content.= $this->doc->endPage();
210 $this->content = $this->doc->insertStylesAndJS($this->content);
211 }
212
213 /**
214 * Outputting the accumulated content to screen
215 *
216 * @return void
217 */
218 function printContent() {
219 echo $this->content;
220 }
221 }
222
223
224 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php']) {
225 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_rename.php']);
226 }
227
228
229
230 // Make instance:
231 $SOBE = t3lib_div::makeInstance('SC_file_rename');
232 $SOBE->init();
233 $SOBE->main();
234 $SOBE->printContent();
235
236 ?>