2 /***************************************************************
5 * (c) 1999-2008 Kasper Skaarhoj (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
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
36 * [CLASS/FUNCTION INDEX of SCRIPT]
40 * 74: class SC_file_rename
42 * 149: function main()
43 * 192: function printContent()
46 * (This index is automatically created/updated by the extension "extdeveval")
54 require('template.php');
55 require_once(PATH_t3lib
.'class.t3lib_basicfilefunc.php');
56 require_once(PATH_t3lib
.'class.t3lib_parsehtml.php');
68 * Script Class for the rename-file form.
70 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
74 class SC_file_rename
{
78 * Document template object
85 * File processing object
87 * @var t3lib_basicFileFunctions
90 var $icon; // Will be set to the proper icon for the $target value.
91 var $shortPath; // Relative path to current found filemount
92 var $title; // Name of the filemount
94 // Internal, static (GPVar):
95 var $target; // Set with the target path inputted in &target
96 var $returnUrl; // Return URL of list module.
99 var $content; // Accumulating content
103 * Constructor function for class
109 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS;
111 // Initialize GPvars:
112 $this->target
= t3lib_div
::_GP('target');
113 $this->returnUrl
= t3lib_div
::_GP('returnUrl');
115 // Init basic-file-functions object:
116 $this->basicff
= t3lib_div
::makeInstance('t3lib_basicFileFunctions');
117 $this->basicff
->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
119 // Cleaning and checking target
120 if (file_exists($this->target
)) {
121 $this->target
=$this->basicff
->cleanDirectoryName($this->target
); // Cleaning and checking target (file or dir)
125 $key=$this->basicff
->checkPathAgainstMounts($this->target
.'/');
126 if (!$this->target ||
!$key) {
127 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
), '');
132 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
133 case 'user': $this->icon
= 'gfx/i/_icon_ftp_user.gif'; break;
134 case 'group': $this->icon
= 'gfx/i/_icon_ftp_group.gif'; break;
135 default: $this->icon
= 'gfx/i/_icon_ftp.gif'; break;
138 $this->icon
= '<img'.t3lib_iconWorks
::skinImg($this->backPath
,$this->icon
,'width="18" height="16"').' title="" alt="" />';
140 // Relative path to filemount, $key:
141 $this->shortPath
= substr($this->target
,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
144 $this->title
= $this->icon
.$GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath
;
146 // Setting template object
147 $this->doc
= t3lib_div
::makeInstance('template');
148 $this->doc
->setModuleTemplate('templates/file_rename.html');
149 $this->doc
->backPath
= $BACK_PATH;
150 $this->doc
->JScode
=$this->doc
->wrapScriptTags('
151 function backToList() { //
152 top.goToModule("file_list");
158 * Main function, rendering the content of the rename form
163 //TODO remove global, change $LANG into $GLOBALS['LANG'], change locallang*.php to locallang*.xml
168 $this->content
= $this->doc
->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
170 $pageContent = $this->doc
->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle'));
171 $pageContent .= $this->doc
->spacer(5);
172 $pageContent .= $this->doc
->divider(5);
175 $code = '<form action="tce_file.php" method="post" name="editform">';
176 // Making the formfields for renaming:
180 <input type="text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath
)).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' />
181 <input type="hidden" name="file[rename][0][target]" value="'.htmlspecialchars($this->target
).'" />
185 // Making submit button:
188 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.submit',1).'" />
189 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
190 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl
).'" />
195 // Add the HTML as a section:
196 $pageContent .= $code;
198 $docHeaderButtons = array();
199 $docHeaderButtons['csh'] = t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH']);
201 // Add the HTML as a section:
202 $markerArray = array(
203 'CSH' => $docHeaderButtons['csh'],
204 'FUNC_MENU' => t3lib_BEfunc
::getFuncMenu($this->id
, 'SET[function]', $this->MOD_SETTINGS
['function'], $this->MOD_MENU
['function']),
205 'CONTENT' => $pageContent,
206 'PATH' => $this->title
,
209 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, $markerArray);
210 $this->content
.= $this->doc
->endPage();
211 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
215 * Outputting the accumulated content to screen
219 function printContent() {
225 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_rename.php']) {
226 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/file_rename.php']);
232 $SOBE = t3lib_div
::makeInstance('SC_file_rename');
235 $SOBE->printContent();