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