[TASK] Remove old login labels
[Packages/TYPO3.CMS.git] / typo3 / file_edit.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
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.
13 *
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.
18 *
19 *
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.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Web>File: Editing documents
29 *
30 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
31 * XHTML compliant (except textarea field)
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36 $GLOBALS['BACK_PATH'] = '';
37 require('init.php');
38 require('template.php');
39
40
41 /**
42 * Script Class for rendering the file editing screen
43 *
44 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
45 * @package TYPO3
46 * @subpackage core
47 */
48 class SC_file_edit {
49 var $content; // Module content accumulated.
50
51 /**
52 * File processing object
53 *
54 * @var t3lib_basicFileFunctions
55 */
56 var $basicff;
57 var $shortPath;
58 var $title;
59 var $icon;
60
61 /**
62 * Document template object
63 *
64 * @var template
65 */
66 var $doc;
67
68 // Internal, static: GPvar
69 var $origTarget; // Original input target
70 var $target; // The original target, but validated.
71 var $returnUrl; // Return URL of list module.
72
73
74 /**
75 * Initialize script class
76 *
77 * @return void
78 */
79 function init() {
80 // Setting target, which must be a file reference to a file within the mounts.
81 $this->target = $this->origTarget = t3lib_div::_GP('target');
82 $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'));
83
84 // Creating file management object:
85 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
86 $this->basicff->init($GLOBALS['FILEMOUNTS'],$GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
87
88
89 if (file_exists($this->target)) {
90 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir)
91 } else {
92 $this->target='';
93 }
94 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
95 if (!$this->target || !$key) {
96 $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:paramError', TRUE);
97 $message = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:targetNoDir', TRUE);
98 throw new RuntimeException($title . ': ' . $message, 1294586841);
99 }
100 // Finding the icon
101 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
102 case 'user':
103 $this->icon = 'gfx/i/_icon_ftp_user.gif';
104 break;
105 case 'group':
106 $this->icon = 'gfx/i/_icon_ftp_group.gif';
107 break;
108 default:
109 $this->icon = 'gfx/i/_icon_ftp.gif';
110 }
111
112 $this->icon = '<img'.t3lib_iconWorks::skinImg($this->backPath,$this->icon,'width="18" height="16"').' title="" alt="" />';
113
114 // Relative path to filemount, $key:
115 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
116
117 // Setting title:
118 $this->title = $this->icon.$GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
119
120 // ***************************
121 // Setting template object
122 // ***************************
123 $this->doc = t3lib_div::makeInstance('template');
124 $this->doc->setModuleTemplate('templates/file_edit.html');
125 $this->doc->backPath = $GLOBALS['BACK_PATH'];
126 $this->doc->JScode=$this->doc->wrapScriptTags('
127 function backToList() { //
128 top.goToModule("file_list");
129 }
130 ');
131 $this->doc->form='<form action="tce_file.php" method="post" name="editform">';
132 }
133
134 /**
135 * Main function, redering the actual content of the editing page
136 *
137 * @return void
138 */
139 function main() {
140 //TODO: change locallang*.php to locallang*.xml
141 $docHeaderButtons = $this->getButtons();
142
143 $this->content = $this->doc->startPage($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
144
145 // hook before compiling the output
146 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'])) {
147 $preOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['preOutputProcessingHook'];
148 if (is_array($preOutputProcessingHook)) {
149 $hookParameters = array(
150 'content' => &$this->content,
151 'target' => &$this->target,
152 );
153 foreach ($preOutputProcessingHook as $hookFunction) {
154 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
155 }
156 }
157 }
158
159 $pageContent = $this->doc->header($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
160 $pageContent .= $this->doc->spacer(2);
161
162 $fI = pathinfo($this->target);
163 $extList = $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext'];
164
165 if ($extList && t3lib_div::inList($extList,strtolower($fI['extension']))) {
166 // Read file content to edit:
167 $fileContent = t3lib_div::getUrl($this->target);
168
169 // making the formfields
170 $hValue = 'file_edit.php?target='.rawurlencode($this->origTarget).'&returnUrl='.rawurlencode($this->returnUrl);
171
172 // Edit textarea:
173 $code.='
174 <div id="c-edit">
175 <textarea rows="30" name="file[editfile][0][data]" wrap="off"'.$this->doc->formWidthText(48,'width:98%;height:80%','off').' class="fixed-font enable-tab">'.
176 t3lib_div::formatForTextarea($fileContent).
177 '</textarea>
178 <input type="hidden" name="file[editfile][0][target]" value="'.$this->target.'" />
179 <input type="hidden" name="redirect" value="'.htmlspecialchars($hValue).'" />
180 </div>
181 <br />';
182
183 // Make shortcut:
184 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
185 $this->MCONF['name']='xMOD_file_edit.php';
186 $docHeaderButtons['shortcut'] = $this->doc->makeShortcutIcon('target','',$this->MCONF['name'],1);
187 } else {
188 $docHeaderButtons['shortcut'] = '';
189 }
190 } else {
191 $code .= sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.coundNot'), $extList);
192 }
193
194 // Ending of section and outputting editing form:
195 $pageContent.= $this->doc->sectionEnd();
196 $pageContent.=$code;
197
198 // hook after compiling the output
199 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'])) {
200 $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/file_edit.php']['postOutputProcessingHook'];
201 if (is_array($postOutputProcessingHook)) {
202 $hookParameters = array(
203 'pageContent' => &$pageContent,
204 'target' => &$this->target,
205 );
206 foreach ($postOutputProcessingHook as $hookFunction) {
207 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
208 }
209 }
210 }
211
212 // Add the HTML as a section:
213 $markerArray = array(
214 'CSH' => $docHeaderButtons['csh'],
215 'FUNC_MENU' => t3lib_BEfunc::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']),
216 'BUTTONS' => $docHeaderButtons,
217 'PATH' => $this->title,
218 'CONTENT' => $pageContent,
219 );
220
221 $this->content.= $this->doc->moduleBody(array(), $docHeaderButtons, $markerArray);
222 $this->content.= $this->doc->endPage();
223 $this->content = $this->doc->insertStylesAndJS($this->content);
224
225
226 }
227
228 /**
229 * Outputting the accumulated content to screen
230 *
231 * @return void
232 */
233 function printContent() {
234 echo $this->content;
235 }
236
237 /**
238 * Builds the buttons for the docheader and returns them as an array
239 *
240 * @return array
241 **/
242 function getButtons() {
243
244 $buttons = array();
245
246 // CSH button
247 $buttons['csh'] = t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_edit', $GLOBALS['BACK_PATH'], '', TRUE);
248
249 // Save button
250 $theIcon = t3lib_iconWorks::getSpriteIcon('actions-document-save');
251 $buttons['SAVE'] = '<a href="#" onclick="document.editform.submit();" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.submit', TRUE)).'">' . $theIcon . '</a>';
252
253 // Save and Close button
254 $theIcon = t3lib_iconWorks::getSpriteIcon('actions-document-save-close');
255 $buttons['SAVE_CLOSE'] = '<a href="#" onclick="document.editform.redirect.value=\''.htmlspecialchars($this->returnUrl).'\'; document.editform.submit();" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.saveAndClose', TRUE)).'">' . $theIcon . '</a>';
256
257 // Cancel button
258 $theIcon = t3lib_iconWorks::getSpriteIcon('actions-document-close');
259 $buttons['CANCEL'] = '<a href="#" onclick="backToList(); return false;" title="' . $GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.cancel', TRUE)) . '">' . $theIcon . '</a>';
260
261 return $buttons;
262 }
263 }
264
265
266 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_edit.php'])) {
267 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/file_edit.php']);
268 }
269
270
271
272 // Make instance:
273 $SOBE = t3lib_div::makeInstance('SC_file_edit');
274 $SOBE->init();
275 $SOBE->main();
276 $SOBE->printContent();
277
278 ?>