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 ***************************************************************/ 00052 $BACK_PATH = ''; 00053 require('init.php'); 00054 require('template.php'); 00055 $LANG->includeLLFile('EXT:lang/locallang_misc.xml'); 00056 require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php'); 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00077 class SC_file_upload { 00078 00079 // External, static: 00080 var $uploadNumber=10; 00081 00082 // Internal, static: 00083 var $doc; // Template object. 00084 var $basicff; // Instance of "t3lib_basicFileFunctions" 00085 var $icon; // Will be set to the proper icon for the $target value. 00086 var $shortPath; // Relative path to current found filemount 00087 var $title; // Name of the filemount 00088 00089 // Internal, static (GPVar): 00090 var $number; 00091 var $target; // Set with the target path inputted in &target 00092 var $returnUrl; // Return URL of list module. 00093 00094 // Internal, dynamic: 00095 var $content; // Accumulating content 00096 00097 00103 function init() { 00104 global $LANG,$BACK_PATH,$TYPO3_CONF_VARS; 00105 00106 // Initialize GPvars: 00107 $this->number = t3lib_div::_GP('number'); 00108 $this->target = t3lib_div::_GP('target'); 00109 $this->returnUrl = t3lib_div::_GP('returnUrl'); 00110 00111 // Init basic-file-functions object: 00112 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions'); 00113 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']); 00114 00115 // Cleaning and checking target 00116 $this->target=$this->basicff->is_directory($this->target); // Cleaning and checking target 00117 $key=$this->basicff->checkPathAgainstMounts($this->target.'/'); 00118 if (!$this->target || !$key) { 00119 t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!',''); 00120 exit; 00121 } 00122 00123 // Finding the icon 00124 switch($GLOBALS['FILEMOUNTS'][$key]['type']) { 00125 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break; 00126 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break; 00127 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break; 00128 } 00129 00130 // Relative path to filemount, $key: 00131 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path'])); 00132 00133 // Setting title: 00134 $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath; 00135 00136 // Setting template object 00137 $this->doc = t3lib_div::makeInstance('smallDoc'); 00138 $this->doc->docType = 'xhtml_trans'; 00139 $this->doc->backPath = $BACK_PATH; 00140 $this->doc->form='<form action="tce_file.php" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">'; 00141 $this->doc->JScode=$this->doc->wrapScriptTags(' 00142 var path = "'.$this->target.'"; 00143 00144 function reload(a) { // 00145 if (!changed || (changed && confirm('.$LANG->JScharCode($LANG->sL('LLL:EXT:lang/locallang_core.php:mess.redraw')).'))) { 00146 var params = "&target="+escape(path)+"&number="+a+"&returnUrl='.htmlspecialchars($this->returnUrl).'"; 00147 document.location = "file_upload.php?"+params; 00148 } 00149 } 00150 function backToList() { // 00151 top.goToModule("file_list"); 00152 } 00153 var changed = 0; 00154 '); 00155 } 00156 00162 function main() { 00163 global $LANG; 00164 00165 // Make page header: 00166 $this->content=''; 00167 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle')); 00168 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle')); 00169 $this->content.=$this->doc->spacer(5); 00170 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon)); 00171 $this->content.=$this->doc->divider(5); 00172 00173 00174 // Making the selector box for the number of concurrent uploads 00175 $this->number = t3lib_div::intInRange($this->number,1,10); 00176 $code=' 00177 <div id="c-select"> 00178 <select name="number" onchange="reload(this.options[this.selectedIndex].value);">'; 00179 for ($a=1;$a<=$this->uploadNumber;$a++) { 00180 $code.=' 00181 <option value="'.$a.'"'.($this->number==$a?' selected="selected"':'').'>'.$a.' '.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.files',1).'</option>'; 00182 } 00183 $code.=' 00184 </select> 00185 </div> 00186 '; 00187 00188 // Make checkbox for "overwrite" 00189 $code.=' 00190 <div id="c-override"> 00191 <input type="checkbox" name="overwriteExistingFiles" value="1" /> '.$LANG->getLL('overwriteExistingFiles',1).' 00192 </div> 00193 '; 00194 00195 // Produce the number of upload-fields needed: 00196 $code.=' 00197 <div id="c-upload"> 00198 '; 00199 for ($a=0;$a<$this->number;$a++) { 00200 // Adding 'size="50" ' for the sake of Mozilla! 00201 $code.=' 00202 <input type="file" name="upload_'.$a.'"'.$this->doc->formWidth(35).' size="50" onclick="changed=1;" /> 00203 <input type="hidden" name="file[upload]['.$a.'][target]" value="'.htmlspecialchars($this->target).'" /> 00204 <input type="hidden" name="file[upload]['.$a.'][data]" value="'.$a.'" /><br /> 00205 '; 00206 } 00207 $code.=' 00208 </div> 00209 '; 00210 00211 // Submit button: 00212 $code.=' 00213 <div id="c-submit"> 00214 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit',1).'" /> 00215 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" /> 00216 <input type="hidden" name="redirect" value="'.htmlspecialchars($this->returnUrl).'" /> 00217 </div> 00218 '; 00219 00220 // CSH: 00221 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_upload', $GLOBALS['BACK_PATH'],'<br/>'); 00222 00223 // Add the HTML as a section: 00224 $this->content.= $this->doc->section('',$code); 00225 00226 // Ending page 00227 $this->content.= $this->doc->endPage(); 00228 } 00229 00235 function printContent() { 00236 00237 echo $this->content; 00238 } 00239 } 00240 00241 // Include extension? 00242 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_upload.php']) { 00243 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_upload.php']); 00244 } 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 // Make instance: 00258 $SOBE = t3lib_div::makeInstance('SC_file_upload'); 00259 $SOBE->init(); 00260 $SOBE->main(); 00261 $SOBE->printContent(); 00262 ?>