2 namespace TYPO3\CMS\Backend\Controller\File
;
4 /***************************************************************
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
30 use TYPO3\CMS\Backend\Utility\BackendUtility
;
31 use TYPO3\CMS\Core\Utility\GeneralUtility
;
34 * Script Class for display up to 10 upload fields
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 class FileUploadController
{
42 * Document template object
44 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
45 * @todo Define visibility
49 // Name of the filemount
51 * @todo Define visibility
55 // Internal, static (GPVar):
56 // Set with the target path inputted in &target
58 * @todo Define visibility
62 // Return URL of list module.
64 * @todo Define visibility
69 // Accumulating content
71 * @todo Define visibility
76 * The folder object which is the target directory for the upload
78 * @var \TYPO3\CMS\Core\Resource\Folder $folderObject
80 protected $folderObject;
83 * Constructor for initializing the class
86 * @todo Define visibility
88 public function init() {
90 $this->target
= GeneralUtility
::_GP('target');
91 $this->returnUrl
= GeneralUtility
::sanitizeLocalUrl(GeneralUtility
::_GP('returnUrl'));
92 if (!$this->returnUrl
) {
93 $this->returnUrl
= GeneralUtility
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
. BackendUtility
::getModuleUrl('file_list') . '&id=' . rawurlencode($this->target
);
95 // Create the folder object
97 $this->folderObject
= \TYPO3\CMS\Core\
Resource\ResourceFactory
::getInstance()->retrieveFileOrFolderObject($this->target
);
99 // Cleaning and checking target directory
100 if (!$this->folderObject
) {
101 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:paramError', TRUE);
102 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:targetNoDir', TRUE);
103 throw new \
RuntimeException($title . ': ' . $message, 1294586843);
105 // Setting the title and the icon
106 $icon = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('apps-filetree-root');
107 $this->title
= $icon . htmlspecialchars($this->folderObject
->getStorage()->getName()) . ': ' . htmlspecialchars($this->folderObject
->getIdentifier());
108 // Setting template object
109 $this->doc
= GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
110 $this->doc
->setModuleTemplate('EXT:backend/Resources/Private/Templates/file_upload.html');
111 $this->doc
->backPath
= $GLOBALS['BACK_PATH'];
112 $this->doc
->form
= '<form action="tce_file.php" method="post" name="editform" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '">';
116 * Main function, rendering the upload file form fields
119 * @todo Define visibility
121 public function main() {
123 $this->content
= $this->doc
->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle'));
124 $form = $this->renderUploadForm();
125 $pageContent = $this->doc
->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.pagetitle')) . $this->doc
->section('', $form);
127 $docHeaderButtons = array(
128 'csh' => BackendUtility
::cshItem('xMOD_csh_corebe', 'file_upload', $GLOBALS['BACK_PATH'])
130 $markerArray = array(
131 'CSH' => $docHeaderButtons['csh'],
132 'FUNC_MENU' => BackendUtility
::getFuncMenu($this->id
, 'SET[function]', $this->MOD_SETTINGS
['function'], $this->MOD_MENU
['function']),
133 'CONTENT' => $pageContent,
134 'PATH' => $this->title
136 $this->content
.= $this->doc
->moduleBody(array(), $docHeaderButtons, $markerArray);
137 $this->content
.= $this->doc
->endPage();
138 $this->content
= $this->doc
->insertStylesAndJS($this->content
);
142 * This function renders the upload form
144 * @return string the HTML form as a string, ready for outputting
145 * @todo Define visibility
147 public function renderUploadForm() {
148 // Make checkbox for "overwrite"
150 <div id="c-override">
151 <p><label for="overwriteExistingFiles"><input type="checkbox" class="checkbox" name="overwriteExistingFiles" id="overwriteExistingFiles" value="1" /> ' . $GLOBALS['LANG']->getLL('overwriteExistingFiles', 1) . '</label></p>
153 <p>' . $GLOBALS['LANG']->getLL('uploadMultipleFilesInfo', TRUE) . '</p>
156 // Produce the number of upload-fields needed:
160 // Adding 'size="50" ' for the sake of Mozilla!
162 <input type="file" multiple="true" name="upload_1[]" />
163 <input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($this->folderObject
->getCombinedIdentifier()) . '" />
164 <input type="hidden" name="file[upload][1][data]" value="1" /><br />
172 <input type="hidden" name="redirect" value="' . $this->returnUrl
. '" /><br />
173 <input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:file_upload.php.submit', 1) . '" />
180 * Outputting the accumulated content to screen
183 * @todo Define visibility
185 public function printContent() {