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