2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Web>File: Renaming files and folders
30 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
39 require('template.php');
51 * Script Class for the rename-file form.
53 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
57 class SC_file_rename
{
61 * Document template object
68 * File processing object
70 * @var t3lib_basicFileFunctions
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
77 // Internal, static (GPVar):
78 var $target; // Set with the target path inputted in &target
79 var $returnUrl; // Return URL of list module.
82 var $content; // Accumulating content
86 * Constructor function for class
92 $this->target
= t3lib_div
::_GP('target');
93 $this->returnUrl
= t3lib_div
::sanitizeLocalUrl(t3lib_div
::_GP('returnUrl'));
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']);
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)
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);
113 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
115 $this->icon
= 'gfx/i/_icon_ftp_user.gif';
118 $this->icon
= 'gfx/i/_icon_ftp_group.gif';
121 $this->icon
= 'gfx/i/_icon_ftp.gif';
124 $this->icon
= '<img'.t3lib_iconWorks
::skinImg($this->backPath
,$this->icon
,'width="18" height="16"').' title="" alt="" />';
126 // Relative path to filemount, $key:
127 $this->shortPath
= substr($this->target
,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
130 $this->title
= $this->icon
. htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath
;
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");
144 * Main function, rendering the content of the rename form
149 //TODO: change locallang*.php to locallang*.xml
152 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
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);
159 $code = '<form action="tce_file.php" method="post" name="editform">';
160 // Making the formfields for renaming:
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
).'" />
169 // Making submit button:
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
).'" />
180 // Add the HTML as a section:
181 $pageContent .= $code;
183 $docHeaderButtons = array();
184 $docHeaderButtons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH']);
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
,
194 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, $markerArray);
195 $this->content
.= $this->doc
->endPage();
196 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
200 * Outputting the accumulated content to screen
204 function printContent() {
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']);
217 $SOBE = t3lib_div
::makeInstance('SC_file_rename');
220 $SOBE->printContent();