Updated years from 2004 to 2005 + all function indexes. NO actual code changes done!
[Packages/TYPO3.CMS.git] / typo3 / file_edit.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2005 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 * 206: 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
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 var $basicff; // File processing object loaded here.
77 var $shortPath;
78 var $title;
79 var $icon;
80 var $doc; // Document template object
81
82 // Internal, static: GPvar
83 var $origTarget; // Original input target
84 var $target; // The original target, but validated.
85 var $returnUrl; // Return URL of list module.
86
87
88 /**
89 * Initialize script class
90 *
91 * @return void
92 */
93 function init() {
94 global $BACK_PATH,$TYPO3_CONF_VARS;
95
96 // Setting target, which must be a file reference to a file within the mounts.
97 $this->target = $this->origTarget = t3lib_div::_GP('target');
98 $this->returnUrl = t3lib_div::_GP('returnUrl');
99
100 // Creating file management object:
101 $this->basicff = t3lib_div::makeInstance('t3lib_basicFileFunctions');
102 $this->basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);
103
104
105 if (@file_exists($this->target)) {
106 $this->target=$this->basicff->cleanDirectoryName($this->target); // Cleaning and checking target (file or dir)
107 } else {
108 $this->target='';
109 }
110 $key=$this->basicff->checkPathAgainstMounts($this->target.'/');
111 if (!$this->target || !$key) {
112 t3lib_BEfunc::typo3PrintError ('Parameter Error','Target was not a directory!','');
113 exit;
114 }
115 // Finding the icon
116 switch($GLOBALS['FILEMOUNTS'][$key]['type']) {
117 case 'user': $this->icon = 'gfx/i/_icon_ftp_user.gif'; break;
118 case 'group': $this->icon = 'gfx/i/_icon_ftp_group.gif'; break;
119 default: $this->icon = 'gfx/i/_icon_ftp.gif'; break;
120 }
121 $this->shortPath = substr($this->target,strlen($GLOBALS['FILEMOUNTS'][$key]['path']));
122 $this->title = $GLOBALS['FILEMOUNTS'][$key]['name'].': '.$this->shortPath;
123
124 // ***************************
125 // Setting template object
126 // ***************************
127 $this->doc = t3lib_div::makeInstance('template');
128 $this->doc->docType = 'xhtml_trans';
129 $this->doc->backPath = $BACK_PATH;
130 $this->doc->JScode=$this->doc->wrapScriptTags('
131 function backToList() { //
132 top.goToModule("file_list");
133 }
134 ');
135 $this->doc->form='<form action="tce_file.php" method="post" name="editform">';
136 }
137
138 /**
139 * Main function, redering the actual content of the editing page
140 *
141 * @return void
142 */
143 function main() {
144 global $BE_USER, $LANG, $TYPO3_CONF_VARS;
145
146 $this->content='';
147 $this->content.=$this->doc->startPage($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
148 $this->content.=$this->doc->header($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.pagetitle'));
149 $this->content.=$this->doc->spacer(5);
150 $this->content.=$this->doc->section('',$this->doc->getFileheader($this->title,$this->shortPath,$this->icon));
151 $this->content.=$this->doc->divider(5);
152
153 $fI = pathinfo($this->target);
154 $extList=$TYPO3_CONF_VARS['SYS']['textfile_ext'];
155
156 if ($extList && t3lib_div::inList($extList,strtolower($fI['extension']))) {
157 // Read file content to edit:
158 $fileContent = t3lib_div::getUrl($this->target);
159
160 // making the formfields
161 $hValue = 'file_edit.php?target='.rawurlencode($this->origTarget).'&returnUrl='.rawurlencode($this->returnUrl);
162 $code = '';
163 $code.='
164 <div id="c-submit">
165 <input type="hidden" name="redirect" value="'.htmlspecialchars($hValue).'" />
166 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.submit',1).'" />
167 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.saveAndClose',1).'" onclick="document.editform.redirect.value=\''.htmlspecialchars($this->returnUrl).'\';" />
168 <input type="submit" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.cancel',1).'" onclick="backToList(); return false;" />
169 </div>
170 ';
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').'>'.
176 t3lib_div::formatForTextarea($fileContent).
177 '</textarea>
178 <input type="hidden" name="file[editfile][0][target]" value="'.$this->target.'" />
179 </div>
180 <br />';
181
182 // CSH:
183 $code.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_edit', $GLOBALS['BACK_PATH'],'|<br/>');
184
185 // Make shortcut:
186 if ($BE_USER->mayMakeShortcut()) {
187 $this->MCONF['name']='xMOD_file_edit.php';
188 $code.= '<br />'.$this->doc->makeShortcutIcon('target','',$this->MCONF['name'],1);
189 }
190 } else {
191 $code.=sprintf($LANG->sL('LLL:EXT:lang/locallang_core.php:file_edit.php.coundNot'), $extList);
192 }
193
194 // Ending of section and outputting editing form:
195 $this->content.= $this->doc->sectionEnd();
196 $this->content.=$code;
197
198 $this->content.=$this->doc->endPage();
199 }
200
201 /**
202 * Outputting the accumulated content to screen
203 *
204 * @return void
205 */
206 function printContent() {
207 echo $this->content;
208 }
209 }
210
211 // Include extension?
212 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_edit.php']) {
213 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/file_edit.php']);
214 }
215
216
217
218
219
220
221
222
223
224
225
226
227 // Make instance:
228 $SOBE = t3lib_div::makeInstance('SC_file_edit');
229 $SOBE->init();
230 $SOBE->main();
231 $SOBE->printContent();
232 ?>