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: Upload of files
30 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 require('template.php');
38 $LANG->includeLLFile('EXT:lang/locallang_misc.xml');
42 * Script Class for display up to 10 upload fields
44 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
48 class SC_file_upload
{
52 * Document template object
58 var $title; // Name of the filemount
60 // Internal, static (GPVar):
61 var $target; // Set with the target path inputted in &target
62 var $returnUrl; // Return URL of list module.
65 var $content; // Accumulating content
68 * the folder object which is the target directory for the upload
70 * @var t3lib_file_Folder $folderObject
72 protected $folderObject;
75 * Constructor for initializing the class
81 $this->target
= t3lib_div
::_GP('target');
82 $this->returnUrl
= t3lib_div
::sanitizeLocalUrl(t3lib_div
::_GP('returnUrl'));
83 if (!$this->returnUrl
) {
84 $this->returnUrl
= t3lib_div
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
. t3lib_extMgm
::extRelPath('filelist') . 'mod1/file_list.php?id=' . rawurlencode($this->target
);
87 // create the folder object
89 $this->folderObject
= t3lib_file_Factory
::getInstance()->retrieveFileOrFolderObject($this->target
);
92 // Cleaning and checking target directory
93 if (!$this->folderObject
) {
94 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
95 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
96 throw new RuntimeException($title . ': ' . $message, 1294586843);
99 // Setting the title and the icon
100 $icon = t3lib_iconWorks
::getSpriteIcon('apps-filetree-root');
101 $this->title
= $icon . htmlspecialchars($this->folderObject
->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject
->getIdentifier());
104 // Setting template object
105 $this->doc
= t3lib_div
::makeInstance('template');
106 $this->doc
->setModuleTemplate('templates/file_upload.html');
107 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
108 $this->doc
->form
= '<form action="tce_file.php" method="post" name="editform" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">';
113 * Main function, rendering the upload file form fields
119 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle'));
121 $form = $this->renderUploadForm();
124 $this->doc
->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.pagetitle')) .
125 $this->doc
->section('', $form);
129 $docHeaderButtons = array(
130 'csh' => t3lib_BEfunc
::cshItem('xMOD_csh_corebe', 'file_upload', $GLOBALS['BACK_PATH'])
133 $markerArray = array(
134 'CSH' => $docHeaderButtons['csh'],
135 'FUNC_MENU' => t3lib_BEfunc
::getFuncMenu($this->id
, 'SET[function]', $this->MOD_SETTINGS
['function'], $this->MOD_MENU
['function']),
136 'CONTENT' => $pageContent,
137 'PATH' => $this->title
,
140 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, $markerArray);
141 $this->content
.= $this->doc
->endPage();
142 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
147 * This function renders the upload form
149 * @return string the HTML form as a string, ready for outputting
151 function renderUploadForm() {
153 // Make checkbox for "overwrite"
155 <div id="c-override">
156 <p><label for="overwriteExistingFiles"><input type="checkbox" class="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> ' . $GLOBALS['LANG']->getLL('overwriteExistingFiles', 1) . '</label></p>
158 <p>' . $GLOBALS['LANG']->getLL('uploadMultipleFilesInfo', TRUE) . '</p>
163 // Produce the number of upload-fields needed:
167 // Adding 'size="50" ' for the sake of Mozilla!
169 <input type="file" multiple="true" name="upload_1[]" />
170 <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($this->folderObject
->getCombinedIdentifier()) . '" />
171 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
181 <input type="hidden" name="redirect" value="' . $this->returnUrl
. '" /><br />
182 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" />
191 * Outputting the accumulated content to screen
195 function printContent() {
201 $SOBE = t3lib_div
::makeInstance('SC_file_upload');
204 $SOBE->printContent();