Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (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 ***************************************************************/ 00051 $BACK_PATH = ''; 00052 require('init.php'); 00053 require('template.php'); 00054 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php'); 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00074 class SC_file_edit { 00075 var $content; // Module content accumulated. 00076 var $basicff; // File processing object loaded here. 00077 var $shortPath; 00078 var $title; 00079 var $icon; 00080 var $doc; // Document template object 00081 00082 // Internal, static: GPvar 00083 var $origTarget; // Original input target 00084 var $target; // The original target, but validated. 00085 var $returnUrl; // Return URL of list module. 00086 00087 00093 function init() { 00094 global $BACK_PATH,$TYPO3_CONF_VARS; 00095 00096 // Setting target, which must be a file reference to a file within the mounts. 00097 $this->target = $this->origTarget = t3lib_div::_GP('target'); 00098 $this->returnUrl = t3lib_div::_GP('returnUrl'); 00099 00100 // Creating file management object: 00101 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00102 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']); 00103 00104 00105 if (@file_exists($this->target)) { 00106 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir) 00107 } else { 00108 $this->target=''; 00109 } 00110 $key=$this->basicff->checkPathAgainstMounts($this->target.'/'); 00111 if (!$this->target || !$key) { 00112 t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!',''); 00113 exit; 00114 } 00115 // Finding the icon 00116 switch($GLOBALS['FILEMOUNTS'][$key]['type']) { 00117 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break; 00118 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break; 00119 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break; 00120 } 00121 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path'])); 00122 $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath; 00123 00124 // *************************** 00125 // Setting template object 00126 // *************************** 00127 $this->doc = t3lib_div::makeInstance('template'); 00128 $this->doc->docType = 'xhtml_trans'; 00129 $this->doc->backPath = $BACK_PATH; 00130 $this->doc->JScode=$this->doc->wrapScriptTags(' 00131 function backToList() { // 00132 top.goToModule("file_list"); 00133 } 00134 '); 00135 $this->doc->form='<form action="tce_file.php" method="post" name="editform">'; 00136 } 00137 00143 function main() { 00144 global $BE_USER, $LANG, $TYPO3_CONF_VARS; 00145 00146 $this->content=''; 00147 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle')); 00148 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle')); 00149 $this->content.=$this->doc->spacer(5); 00150 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon)); 00151 $this->content.=$this->doc->divider(5); 00152 00153 $fI = pathinfo($this->target); 00154 $extList=$TYPO3_CONF_VARS['SYS']['textfile_ext']; 00155 00156 if ($extList && t3lib_div::inList($extList,strtolower($fI['extension']))) { 00157 // Read file content to edit: 00158 $fileContent = t3lib_div::getUrl($this->target); 00159 00160 // making the formfields 00161 $hValue = 'file_edit.php?target='.rawurlencode($this->origTarget).'&returnUrl='.rawurlencode($this->returnUrl); 00162 $code = ''; 00163 $code.=' 00164 <div id="c-submit"> 00165 <input type="hidden" name="redirect" value="'.htmlspecialchars($hValue).'" /> 00166 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.submit',1).'" /> 00167 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.saveAndClose',1).'" onclick="document.editform.redirect.value=\''.htmlspecialchars($this->returnUrl).'\';" /> 00168 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" /> 00169 </div> 00170 '; 00171 00172 // Edit textarea: 00173 $code.=' 00174 <div id="c-edit"> 00175 <textarea rows="30" name="file[editfile][0][data]" wrap="off"'.$this->doc->formWidthText(48,'width:98%;height:80%','off').'>'. 00176 t3lib_div::formatForTextarea($fileContent). 00177 '</textarea> 00178 <input type="hidden" name="file[editfile][0][target]" value="'.$this->target.'" /> 00179 </div> 00180 <br />'; 00181 00182 // CSH: 00183 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_edit', $GLOBALS['BACK_PATH'],'|<br/>'); 00184 00185 // Make shortcut: 00186 if ($BE_USER->mayMakeShortcut()) { 00187 $this->MCONF['name']='xMOD_file_edit.php'; 00188 $code.= '<br />'.$this->doc->makeShortcutIcon('target','',$this->MCONF['name'],1); 00189 } 00190 } else { 00191 $code.=sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.coundNot'), $extList); 00192 } 00193 00194 // Ending of section and outputting editing form: 00195 $this->content.= $this->doc->sectionEnd(); 00196 $this->content.=$code; 00197 00198 $this->content.=$this->doc->endPage(); 00199 } 00200 00206 function printContent() { 00207 echo $this->content; 00208 } 00209 } 00210 00211 // Include extension? 00212 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_edit.php']) { 00213 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_edit.php']); 00214 } 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 // Make instance: 00228 $SOBE = t3lib_div::makeInstance('SC_file_edit'); 00229 $SOBE->init(); 00230 $SOBE->main(); 00231 $SOBE->printContent(); 00232 ?>