|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Web>File: Renaming files and folders 00029 * 00030 * $Id: file_rename.php 10121 2011-01-18 20:15:30Z ohader $ 00031 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj 00032 * 00033 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00034 */ 00035 /** 00036 * [CLASS/FUNCTION INDEX of SCRIPT] 00037 * 00038 * 00039 * 00040 * 74: class SC_file_rename 00041 * 96: function init() 00042 * 149: function main() 00043 * 192: function printContent() 00044 * 00045 * TOTAL FUNCTIONS: 3 00046 * (This index is automatically created/updated by the extension "extdeveval") 00047 * 00048 */ 00049 00050 00051 00052 $BACK_PATH = ''; 00053 require('init.php'); 00054 require('template.php'); 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 /** 00066 * Script Class for the rename-file form. 00067 * 00068 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00069 * @package TYPO3 00070 * @subpackage core 00071 */ 00072 class SC_file_rename { 00073 00074 // Internal, static: 00075 /** 00076 * Document template object 00077 * 00078 * @var smallDoc 00079 */ 00080 var $doc; 00081 00082 /** 00083 * File processing object 00084 * 00085 * @var t3lib_basicFileFunctions 00086 */ 00087 var $basicff; 00088 var $icon; // Will be set to the proper icon for the $target value. 00089 var $shortPath; // Relative path to current found filemount 00090 var $title; // Name of the filemount 00091 00092 // Internal, static (GPVar): 00093 var $target; // Set with the target path inputted in &target 00094 var $returnUrl; // Return URL of list module. 00095 00096 // Internal, dynamic: 00097 var $content; // Accumulating content 00098 00099 00100 /** 00101 * Constructor function for class 00102 * 00103 * @return void 00104 */ 00105 function init() { 00106 //TODO remove global 00107 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS; 00108 00109 // Initialize GPvars: 00110 $this->target = t3lib_div::_GP('target'); 00111 $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl')); 00112 00113 // Init basic-file-functions object: 00114 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00115 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']); 00116 00117 // Cleaning and checking target 00118 if (file_exists($this->target)) { 00119 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir) 00120 } else { 00121 $this->target=''; 00122 } 00123 $key=$this->basicff->checkPathAgainstMounts($this->target.'/'); 00124 if (!$this->target || !$key) { 00125 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE); 00126 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE); 00127 throw new RuntimeException($title . ': ' . $message); 00128 } 00129 00130 // Finding the icon 00131 switch($GLOBALS['FILEMOUNTS'][$key]['type']) { 00132 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break; 00133 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break; 00134 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break; 00135 } 00136 00137 $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />'; 00138 00139 // Relative path to filemount, $key: 00140 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path'])); 00141 00142 // Setting title: 00143 $this->title = $this->icon . htmlspecialchars($GLOBALS['FILEMOUNTS'][$key]['name']) . ': ' . $this->shortPath; 00144 00145 // Setting template object 00146 $this->doc = t3lib_div::makeInstance('template'); 00147 $this->doc->setModuleTemplate('templates/file_rename.html'); 00148 $this->doc->backPath = $BACK_PATH; 00149 $this->doc->JScode=$this->doc->wrapScriptTags(' 00150 function backToList() { // 00151 top.goToModule("file_list"); 00152 } 00153 '); 00154 } 00155 00156 /** 00157 * Main function, rendering the content of the rename form 00158 * 00159 * @return void 00160 */ 00161 function main() { 00162 //TODO remove global, change $LANG into $GLOBALS['LANG'], change locallang*.php to locallang*.xml 00163 00164 global $LANG; 00165 00166 // Make page header: 00167 $this->content = $this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle')); 00168 00169 $pageContent = $this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.pagetitle')); 00170 $pageContent .= $this->doc->spacer(5); 00171 $pageContent .= $this->doc->divider(5); 00172 00173 00174 $code = '<form action="tce_file.php" method="post" name="editform">'; 00175 // Making the formfields for renaming: 00176 $code .= ' 00177 00178 <div id="c-rename"> 00179 <input type="text" name="file[rename][0][data]" value="'.htmlspecialchars(basename($this->shortPath)).'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(20).' /> 00180 <input type="hidden" name="file[rename][0][target]" value="'.htmlspecialchars($this->target).'" /> 00181 </div> 00182 '; 00183 00184 // Making submit button: 00185 $code.=' 00186 <div id="c-submit"> 00187 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_rename.php.submit',1).'" /> 00188 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" /> 00189 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" /> 00190 </div> 00191 '; 00192 00193 $code .= '</form>'; 00194 00195 // Add the HTML as a section: 00196 $pageContent .= $code; 00197 00198 $docHeaderButtons = array(); 00199 $docHeaderButtons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH']); 00200 00201 // Add the HTML as a section: 00202 $markerArray = array( 00203 'CSH' => $docHeaderButtons['csh'], 00204 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 00205 'CONTENT' => $pageContent, 00206 'PATH' => $this->title, 00207 ); 00208 00209 $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray); 00210 $this->content.= $this->doc->endPage(); 00211 $this->content = $this->doc->insertStylesAndJS($this->content); 00212 } 00213 00214 /** 00215 * Outputting the accumulated content to screen 00216 * 00217 * @return void 00218 */ 00219 function printContent() { 00220 echo $this->content; 00221 } 00222 } 00223 00224 00225 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_rename.php'])) { 00226 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_rename.php']); 00227 } 00228 00229 00230 00231 // Make instance: 00232 $SOBE = t3lib_div::makeInstance('SC_file_rename'); 00233 $SOBE->init(); 00234 $SOBE->main(); 00235 $SOBE->printContent(); 00236 00237 ?>
1.8.0