a506c1e7e39b8189e043568e0daf6a4de2a4dd74
[Packages/TYPO3.CMS.git] / typo3 / sysext / tstemplate_info / class.tx_tstemplateinfo.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 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 * [CLASS/FUNCTION INDEX of SCRIPT]
29 *
30 *
31 *
32 * 49: class tx_tstemplateinfo extends t3lib_extobjbase
33 * 63: function tableRow($label, $data, $field)
34 * 77: function procesResources($resources, $func=false)
35 * 117: function resourceListForCopy($id, $template_uid)
36 * 143: function initialize_editor($pageId, $template_uid=0)
37 * 160: function main()
38 *
39 * TOTAL FUNCTIONS: 5
40 * (This index is automatically created/updated by the extension "extdeveval")
41 *
42 */
43
44 $GLOBALS['LANG']->includeLLFile('EXT:tstemplate_info/locallang.xml');
45
46 /**
47 * This class displays the Info/Modify screen of the Web > Template module
48 *
49 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
50 *
51 * $Id$
52 */
53 class tx_tstemplateinfo extends t3lib_extobjbase {
54
55 public $tce_processed = false; // indicator for t3editor, whether data is stored
56
57 /**
58 * Creates a row for a HTML table
59 *
60 * @param string $label: The label to be shown (e.g. 'Title:', 'Sitetitle:')
61 * @param string $data: The data/information to be shown (e.g. 'Template for my site')
62 * @param string $field: The field/variable to be sent on clicking the edit icon (e.g. 'title', 'sitetitle')
63 * @return string A row for a HTML table
64 */
65 function tableRow($label, $data, $field) {
66 $ret = '<tr><td>';
67 $ret.= '<a href="index.php?id=' . $this->pObj->id . '&e[' . $field . ']=1">' .
68 t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:editField', true))) . '<strong>' . $label . '&nbsp;&nbsp;</strong></a>';
69 $ret .= '</td><td width="80%" class="bgColor4">' . $data . '&nbsp;</td></tr>';
70 return $ret;
71 }
72
73 /**
74 * Renders HTML table with available template resources/files
75 *
76 * @param string $resources: List of resources/files to be shown (e.g. 'file_01.txt,file.txt')
77 * @param boolean $func: Whether to render functions like 'to top' or 'delete' for each resource (default: false)
78 * @return string HTML table with available template resources/files
79 */
80 function procesResources($resources, $func=false) {
81 $arr = t3lib_div::trimExplode(',', $resources.',,', 1);
82 $out = '';
83 $bgcol = ($func ? ' class="bgColor4"' : '');
84 foreach ($arr as $k => $v) {
85 $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v;
86 $functions = '';
87 if ($func) {
88 $functions = '<td bgcolor="red" nowrap="nowrap">' . $GLOBALS['LANG']->getLL('delete') . ' <input type="checkbox" name="data[remove_resource][' . $k . ']" value="' . htmlspecialchars($v) . '" /></td>';
89 $functions .= '<td' . $bgcol . ' nowrap="nowrap">' . $GLOBALS['LANG']->getLL('toTop') . ' <input type="checkbox" name="data[totop_resource][' . $k . ']" value="' . htmlspecialchars($v) . '" /></td>';
90 $functions .= '<td' . $bgcol . ' nowrap="nowrap">';
91 $fI = t3lib_div::split_fileref($v);
92 if (t3lib_div::inList($this->pObj->textExtensions,$fI['fileext'])) {
93 $functions.= '<a href="index.php?id='.$this->pObj->id.'&e[file]='.rawurlencode($v).'">'.t3lib_iconWorks::getSpriteIcon('actions-document-open',array('title'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:editFile', true))) . '</a>';
94 }
95 $functions.= '</td>';
96 }
97 $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], '');
98 $out .= '<tr><td' . $bgcol . ' nowrap="nowrap">' . $v . '&nbsp;&nbsp;</td><td' . $bgcol . ' nowrap="nowrap">&nbsp;' . t3lib_div::formatSize(@filesize($path)) . '&nbsp;</td>' . $functions . '<td' . $bgcol . '>' . trim($thumb) . '</td></tr>';
99 }
100 if ($out) {
101 if ($func) {
102 $out = '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . $out . '</table>';
103 $out = '<table border="0" cellpadding="0" cellspacing="0">
104 <tr><td class="bgColor2">' . $out . '<img src="clear.gif" width="465px" height="1px"></td></tr>
105 </table>';
106 } else {
107 $out = '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>';
108 }
109 }
110 return $out;
111 }
112
113 /**
114 * Renders HTML table with all available template resources/files in the current rootline that could be copied
115 *
116 * @param integer $id: The uid of the current page
117 * @param integer $template_uid: The uid of the template record to be rendered (only if more than one template on the current page)
118 * @return string HTML table with all available template resources/files in the current rootline that could be copied
119 */
120 function resourceListForCopy($id, $template_uid) {
121 global $tmpl;
122 $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
123 $rootLine = $sys_page->getRootLine($id);
124 $tmpl->runThroughTemplates($rootLine, $template_uid); // This generates the constants/config + hierarchy info for the template.
125 $theResources = t3lib_div::trimExplode(',', $tmpl->resources, 1);
126 foreach ($theResources as $k => $v) {
127 $fI = pathinfo($v);
128 if (t3lib_div::inList($this->pObj->textExtensions,strtolower($fI['extension']))) {
129 $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v;
130 $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], '');
131 $out .= '<tr><td' . $bgcol . ' nowrap="nowrap">' . $v . '&nbsp;&nbsp;</td><td' . $bgcol . ' nowrap="nowrap">&nbsp;' . t3lib_div::formatSize(@filesize($path)) . '&nbsp;</td><td' . $bgcol . '>' . trim($thumb) . '</td><td><input type="Checkbox" name="data[makecopy_resource][' . $k . ']" value="' . htmlspecialchars($v) . '"></td></tr>';
132 }
133 }
134 $out = ($out ? '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>' : '');
135 return $out;
136 }
137
138 /**
139 * Create an instance of t3lib_tsparser_ext in $GLOBALS['tmpl'] and looks for the first (visible) template
140 * record. If $template_uid was given and greater than zero, this record will be checked.
141 *
142 * @param integer $id: The uid of the current page
143 * @param integer $template_uid: The uid of the template record to be rendered (only if more than one template on the current page)
144 * @return boolean Returns true if a template record was found, otherwise false
145 */
146 function initialize_editor($pageId, $template_uid=0) {
147 // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
148 global $tmpl,$tplRow,$theConstants;
149
150 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here!
151 $tmpl->tt_track = 0; // Do not log time-performance information
152 $tmpl->init();
153
154 $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid); // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
155 $tplRow = $this->processTemplateRowAfterLoading($tplRow);
156 return (is_array($tplRow) ? true : false);
157 }
158
159 /**
160 * Process template row after loading
161 *
162 * @param array $tplRow: template row
163 * @return array preprocessed template row
164 * @author Fabrizio Branca <typo3@fabrizio-branca.de>
165 */
166 function processTemplateRowAfterLoading(array $tplRow) {
167 if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
168 // Let the recursion detection counter start at 91, so that only 10 recursive calls will be resolved
169 // Otherwise the editor will be bloated with way to many lines making it hard the break the cyclic recursion.
170 $tplRow['config'] = t3lib_TSparser::checkIncludeLines($tplRow['config'], 91);
171 $tplRow['constants'] = t3lib_TSparser::checkIncludeLines($tplRow['constants'], 91);
172 }
173 return $tplRow;
174 }
175
176 /**
177 * Process template row before saving
178 *
179 * @param array $tplRow: template row
180 * @return array preprocessed template row
181 * @author Fabrizio Branca <typo3@fabrizio-branca.de>
182 */
183 function processTemplateRowBeforeSaving(array $tplRow) {
184 if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
185 $tplRow = t3lib_TSparser::extractIncludes_array($tplRow);
186 }
187 return $tplRow;
188 }
189
190 /**
191 * The main processing method if this class
192 *
193 * @return string Information of the template status or the taken actions as HTML string
194 */
195 function main() {
196 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
197 global $tmpl,$tplRow,$theConstants;
198
199 $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = true;
200
201 $edit = $this->pObj->edit;
202 $e = $this->pObj->e;
203
204 t3lib_div::loadTCA('sys_template');
205
206
207
208
209 // **************************
210 // Checking for more than one template an if, set a menu...
211 // **************************
212 $manyTemplatesMenu = $this->pObj->templateMenu();
213 $template_uid = 0;
214 if ($manyTemplatesMenu) {
215 $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
216 }
217
218
219 // **************************
220 // Initialize
221 // **************************
222 $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize
223
224 if ($existTemplate) {
225 $saveId = ($tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']);
226 }
227 // **************************
228 // Create extension template
229 // **************************
230 $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
231 if($newId) {
232 // switch to new template
233 t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id. '&SET[templatesOnPage]=' . $newId);
234 }
235
236 if ($existTemplate) {
237 // Update template ?
238 $POST = t3lib_div::_POST();
239 if ($POST['submit'] || (t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']))
240 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
241 // Set the data to be saved
242 $recData = array();
243 $alternativeFileName = array();
244 $resList = $tplRow['resources'];
245
246 $tmp_upload_name = '';
247 $tmp_newresource_name = ''; // Set this to blank
248
249 if (is_array($POST['data'])) {
250 foreach ($POST['data'] as $field => $val) {
251 switch ($field) {
252 case 'constants':
253 case 'config':
254 case 'title':
255 case 'sitetitle':
256 case 'description':
257 $recData['sys_template'][$saveId][$field] = $val;
258 break;
259 case 'resources':
260 $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']); // If there is an uploaded file, move it for the sake of safe_mode.
261 if ($tmp_upload_name) {
262 if ($tmp_upload_name!='none' && $_FILES['resources']['name']) {
263 $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
264 $resList = $tmp_upload_name.','.$resList;
265 }
266 }
267 break;
268 case 'new_resource':
269 $newName = trim(t3lib_div::_GP('new_resource'));
270 if ($newName) {
271 $newName.= '.'.t3lib_div::_GP('new_resource_ext');
272 $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
273 $alternativeFileName[$tmp_newresource_name] = $newName;
274 $resList = $tmp_newresource_name.','.$resList;
275 }
276 break;
277 case 'makecopy_resource':
278 if (is_array($val)) {
279 $resList = ','.$resList.',';
280 foreach ($val as $k => $file) {
281 $tmp_name = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$file;
282 $resList = $tmp_name.','.$resList;
283 }
284 }
285 break;
286 case 'remove_resource':
287 if (is_array($val)) {
288 $resList = ','.$resList.',';
289 foreach ($val as $k => $file) {
290 $resList = str_replace(','.$file.',', ',', $resList);
291 }
292 }
293 break;
294 case 'totop_resource':
295 if (is_array($val)) {
296 $resList = ','.$resList.',';
297 foreach ($val as $k => $file) {
298 $resList = str_replace(','.$file.',', ',', $resList);
299 $resList = ','.$file.$resList;
300 }
301 }
302 break;
303 }
304 }
305 }
306 $resList=implode(',', t3lib_div::trimExplode(',', $resList, 1));
307 if (strcmp($resList, $tplRow['resources'])) {
308 $recData['sys_template'][$saveId]['resources'] = $resList;
309 }
310 if (count($recData)) {
311
312 $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
313
314 // Create new tce-object
315 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
316 $tce->stripslashes_values=0;
317 $tce->alternativeFileName = $alternativeFileName;
318 // Initialize
319 $tce->start($recData, array());
320 // Saved the stuff
321 $tce->process_datamap();
322 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
323 $tce->clear_cacheCmd('all');
324
325 // tce were processed successfully
326 $this->tce_processed = true;
327
328 // re-read the template ...
329 $this->initialize_editor($this->pObj->id, $template_uid);
330 }
331
332 // Unlink any uploaded/new temp files there was:
333 t3lib_div::unlink_tempfile($tmp_upload_name);
334 t3lib_div::unlink_tempfile($tmp_newresource_name);
335
336 // If files has been edited:
337 if (is_array($edit)) {
338 if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) { // Check if there are resources, and that the file is in the resourcelist.
339 $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$edit['filename'];
340 $fI = t3lib_div::split_fileref($edit['filename']);
341 if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) { // checks that have already been done.. Just to make sure
342 // @TODO: Check if the hardcorded value already has a config member, otherwise create one
343 if (filesize($path) < 30720) { // checks that have already been done.. Just to make sure
344 t3lib_div::writeFile($path, $edit['file']);
345
346 $theOutput.= $this->pObj->doc->spacer(10);
347 $theOutput.= $this->pObj->doc->section(
348 '<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>',
349 sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']),
350 0, 0, 0, 1
351 );
352
353 // Clear cache - the file has probably affected the template setup
354 // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
355 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
356 $tce->stripslashes_values = 0;
357 $tce->start(array(), array());
358 $tce->clear_cacheCmd('all');
359 }
360 }
361 }
362 }
363 }
364
365 // hook Post updating template/TCE processing
366 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
367 $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
368 if (is_array($postTCEProcessingHook)) {
369 $hookParameters = array(
370 'POST' => $POST,
371 'tce' => $tce,
372 );
373 foreach ($postTCEProcessingHook as $hookFunction) {
374 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
375 }
376 }
377 }
378
379 $theOutput.= $this->pObj->doc->spacer(5);
380 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow).'<strong>'.htmlspecialchars($tplRow['title']).'</strong>'.htmlspecialchars(trim($tplRow['sitetitle'])?' - ('.$tplRow['sitetitle'].')':''), 0, 1);
381 if ($manyTemplatesMenu) {
382 $theOutput.= $this->pObj->doc->section('', $manyTemplatesMenu);
383 $theOutput.= $this->pObj->doc->divider(5);
384 }
385
386 #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
387 #if (!$numberOfRows)
388 $numberOfRows = 35;
389
390 // If abort pressed, nothing should be edited:
391 if ($POST['abort'] || (t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']))
392 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
393 unset($e);
394 }
395
396 if ($e['title']) {
397 $outCode = '<input type="Text" name="data[title]" value="'.htmlspecialchars($tplRow['title']).'"'.$this->pObj->doc->formWidth().'>';
398 $outCode.= '<input type="Hidden" name="e[title]" value="1">';
399 $theOutput.= $this->pObj->doc->spacer(15);
400 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
401 }
402 if ($e['sitetitle']) {
403 $outCode = '<input type="Text" name="data[sitetitle]" value="'.htmlspecialchars($tplRow['sitetitle']).'"'.$this->pObj->doc->formWidth().'>';
404 $outCode.= '<input type="Hidden" name="e[sitetitle]" value="1">';
405 $theOutput.= $this->pObj->doc->spacer(15);
406 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
407 }
408 if ($e['description']) {
409 $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, '', '').'>'.t3lib_div::formatForTextarea($tplRow['description']).'</textarea>';
410 $outCode.= '<input type="Hidden" name="e[description]" value="1">';
411 $theOutput.= $this->pObj->doc->spacer(15);
412 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
413 }
414 if ($e['resources']) {
415 // Upload
416 $outCode = '<input type="File" name="resources"'.$this->pObj->doc->formWidth().' size="50">';
417 $outCode.= '<input type="Hidden" name="data[resources]" value="1">';
418 $outCode.= '<input type="Hidden" name="e[resources]" value="1">';
419 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
420 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size']*1024) . '</strong>';
421 $theOutput.= $this->pObj->doc->spacer(15);
422 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
423
424 // New
425 $opt = explode(',', $this->pObj->textExtensions);
426 $optTags = '';
427 foreach ($opt as $extVal) {
428 $optTags.= '<option value="'.$extVal.'">.'.$extVal.'</option>';
429 }
430 $outCode = '<input type="text" name="new_resource"'.$this->pObj->doc->formWidth(20).'>
431 <select name="new_resource_ext">'.$optTags.'</select>';
432 $outCode.= '<input type="Hidden" name="data[new_resource]" value="1">';
433 $theOutput.= $this->pObj->doc->spacer(15);
434 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
435
436 // Make copy
437 $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
438 if ($rL) {
439 $theOutput.= $this->pObj->doc->spacer(20);
440 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
441 }
442
443 // Update resource list
444 $rL = $this->procesResources($tplRow['resources'], 1);
445 if ($rL) {
446 $theOutput.= $this->pObj->doc->spacer(20);
447 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
448 }
449 }
450 if ($e['constants']) {
451 $outCode = '<textarea name="data[constants]" rows="'.$numberOfRows.'" wrap="off" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off').' class="fixed-font">'.t3lib_div::formatForTextarea($tplRow['constants']).'</textarea>';
452 $outCode.= '<input type="Hidden" name="e[constants]" value="1">';
453
454 // Display "Include TypoScript file content?" checkbox
455 $outCode .= t3lib_BEfunc::getFuncCheck(
456 $this->pObj->id,
457 'SET[includeTypoScriptFileContent]',
458 $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'],
459 'index.php',
460 '&e[constants]=1',
461 'id="checkIncludeTypoScriptFileContent"'
462 );
463 $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
464
465
466 $theOutput.= $this->pObj->doc->spacer(15);
467 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
468 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
469 }
470 if ($e['file']) {
471 $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$e[file];
472
473 $fI = t3lib_div::split_fileref($e[file]);
474 if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
475 if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size']*1024) {
476 $fileContent = t3lib_div::getUrl($path);
477 $outCode = $GLOBALS['LANG']->getLL('file'). ' <strong>' . $e[file] . '</strong><BR>';
478 $outCode.= '<textarea name="edit[file]" rows="'.$numberOfRows.'" wrap="off" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off').' class="fixed-font">'.t3lib_div::formatForTextarea($fileContent).'</textarea>';
479 $outCode.= '<input type="Hidden" name="edit[filename]" value="'.$e[file].'">';
480 $outCode.= '<input type="Hidden" name="e[file]" value="'.htmlspecialchars($e[file]).'">';
481 $theOutput.= $this->pObj->doc->spacer(15);
482 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
483 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
484 } else {
485 $theOutput.= $this->pObj->doc->spacer(15);
486 $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
487 $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
488 $theOutput.= $this->pObj->doc->section(
489 '<font color=red>' . $fileToBig . '</font>',
490 $filesizeNotAllowed,
491 0, 0, 0, 1
492 );
493 }
494 }
495 }
496 if ($e['config']) {
497 $outCode='<textarea name="data[config]" rows="'.$numberOfRows.'" wrap="off" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48,"width:98%;height:70%","off").' class="fixed-font">'.t3lib_div::formatForTextarea($tplRow["config"]).'</textarea>';
498 $outCode.= '<input type="Hidden" name="e[config]" value="1">';
499
500 // Display "Include TypoScript file content?" checkbox
501 $outCode .= t3lib_BEfunc::getFuncCheck(
502 $this->pObj->id,
503 'SET[includeTypoScriptFileContent]',
504 $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'],
505 'index.php',
506 '&e[config]=1',
507 'id="checkIncludeTypoScriptFileContent"'
508 );
509 $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
510
511 if (t3lib_extMgm::isLoaded('tsconfig_help')) {
512 $url = $BACK_PATH.'wizard_tsconfig.php?mode=tsref';
513 $params = array(
514 'formName' => 'editForm',
515 'itemName' => 'data[config]',
516 );
517 $outCode.= '<a href="#" onClick="vHWin=window.open(\''.$url.t3lib_div::implodeArrayForUrl('', array('P' => $params)).'\',\'popUp'.$md5ID.'\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">'.t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title'=> $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
518 }
519
520 $theOutput.= $this->pObj->doc->spacer(15);
521 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
522 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
523 }
524
525 // Processing:
526 $outCode = '';
527 $outCode.= $this->tableRow(
528 $GLOBALS['LANG']->getLL('title'),
529 htmlspecialchars($tplRow['title']),
530 'title'
531 );
532 $outCode.= $this->tableRow(
533 $GLOBALS['LANG']->getLL('sitetitle'),
534 htmlspecialchars($tplRow['sitetitle']),
535 'sitetitle'
536 );
537 $outCode.= $this->tableRow(
538 $GLOBALS['LANG']->getLL('description'),
539 nl2br(htmlspecialchars($tplRow['description'])),
540 'description'
541 );
542 $outCode.= $this->tableRow(
543 $GLOBALS['LANG']->getLL('resources'),
544 $this->procesResources($tplRow['resources']),
545 'resources'
546 );
547 $outCode.= $this->tableRow(
548 $GLOBALS['LANG']->getLL('constants'),
549 sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0)),
550 'constants'
551 );
552 $outCode.= $this->tableRow(
553 $GLOBALS['LANG']->getLL('setup'),
554 sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0)),
555 'config'
556 );
557 $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
558
559 // Edit all icon:
560 $outCode.= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') .
561 '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' .
562 t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title'=>
563 $GLOBALS['LANG']->getLL('editTemplateRecord') )) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
564 $theOutput.= $this->pObj->doc->section('', $outCode);
565
566
567 // hook after compiling the output
568 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
569 $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
570 if (is_array($postOutputProcessingHook)) {
571 $hookParameters = array(
572 'theOutput' => &$theOutput,
573 'POST' => $POST,
574 'e' => $e,
575 'tplRow' => $tplRow,
576 'numberOfRows' => $numberOfRows
577 );
578 foreach ($postOutputProcessingHook as $hookFunction) {
579 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
580 }
581 }
582 }
583
584 } else {
585 $theOutput.= $this->pObj->noTemplate(1);
586 }
587
588
589 return $theOutput;
590 }
591 }
592
593 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']) {
594 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']);
595 }
596
597 ?>