Fixed bug #16302: Template module crashes, if no template exists on a page (Thanks...
[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 if(is_array($tplRow)) {
156 $this->processTemplateRowAfterLoading($tplRow);
157 return TRUE;
158 }
159 return FALSE;
160 }
161
162 /**
163 * Process template row after loading
164 *
165 * @param array $tplRow: template row
166 * @return array preprocessed template row
167 * @author Fabrizio Branca <typo3@fabrizio-branca.de>
168 */
169 function processTemplateRowAfterLoading(array $tplRow) {
170 if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
171 // Let the recursion detection counter start at 91, so that only 10 recursive calls will be resolved
172 // Otherwise the editor will be bloated with way to many lines making it hard the break the cyclic recursion.
173 $tplRow['config'] = t3lib_TSparser::checkIncludeLines($tplRow['config'], 91);
174 $tplRow['constants'] = t3lib_TSparser::checkIncludeLines($tplRow['constants'], 91);
175 }
176 return $tplRow;
177 }
178
179 /**
180 * Process template row before saving
181 *
182 * @param array $tplRow: template row
183 * @return array preprocessed template row
184 * @author Fabrizio Branca <typo3@fabrizio-branca.de>
185 */
186 function processTemplateRowBeforeSaving(array $tplRow) {
187 if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
188 $tplRow = t3lib_TSparser::extractIncludes_array($tplRow);
189 }
190 return $tplRow;
191 }
192
193 /**
194 * The main processing method if this class
195 *
196 * @return string Information of the template status or the taken actions as HTML string
197 */
198 function main() {
199 global $SOBE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
200 global $tmpl,$tplRow,$theConstants;
201
202 $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = true;
203
204 $edit = $this->pObj->edit;
205 $e = $this->pObj->e;
206
207 t3lib_div::loadTCA('sys_template');
208
209
210
211
212 // **************************
213 // Checking for more than one template an if, set a menu...
214 // **************************
215 $manyTemplatesMenu = $this->pObj->templateMenu();
216 $template_uid = 0;
217 if ($manyTemplatesMenu) {
218 $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
219 }
220
221
222 // **************************
223 // Initialize
224 // **************************
225 $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize
226
227 if ($existTemplate) {
228 $saveId = ($tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']);
229 }
230 // **************************
231 // Create extension template
232 // **************************
233 $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
234 if($newId) {
235 // switch to new template
236 t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id. '&SET[templatesOnPage]=' . $newId);
237 }
238
239 if ($existTemplate) {
240 // Update template ?
241 $POST = t3lib_div::_POST();
242 if ($POST['submit'] || (t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']))
243 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
244 // Set the data to be saved
245 $recData = array();
246 $alternativeFileName = array();
247 $resList = $tplRow['resources'];
248
249 $tmp_upload_name = '';
250 $tmp_newresource_name = ''; // Set this to blank
251
252 if (is_array($POST['data'])) {
253 foreach ($POST['data'] as $field => $val) {
254 switch ($field) {
255 case 'constants':
256 case 'config':
257 case 'title':
258 case 'sitetitle':
259 case 'description':
260 $recData['sys_template'][$saveId][$field] = $val;
261 break;
262 case 'resources':
263 $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.
264 if ($tmp_upload_name) {
265 if ($tmp_upload_name!='none' && $_FILES['resources']['name']) {
266 $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
267 $resList = $tmp_upload_name.','.$resList;
268 }
269 }
270 break;
271 case 'new_resource':
272 $newName = trim(t3lib_div::_GP('new_resource'));
273 if ($newName) {
274 $newName.= '.'.t3lib_div::_GP('new_resource_ext');
275 $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
276 $alternativeFileName[$tmp_newresource_name] = $newName;
277 $resList = $tmp_newresource_name.','.$resList;
278 }
279 break;
280 case 'makecopy_resource':
281 if (is_array($val)) {
282 $resList = ','.$resList.',';
283 foreach ($val as $k => $file) {
284 $tmp_name = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$file;
285 $resList = $tmp_name.','.$resList;
286 }
287 }
288 break;
289 case 'remove_resource':
290 if (is_array($val)) {
291 $resList = ','.$resList.',';
292 foreach ($val as $k => $file) {
293 $resList = str_replace(','.$file.',', ',', $resList);
294 }
295 }
296 break;
297 case 'totop_resource':
298 if (is_array($val)) {
299 $resList = ','.$resList.',';
300 foreach ($val as $k => $file) {
301 $resList = str_replace(','.$file.',', ',', $resList);
302 $resList = ','.$file.$resList;
303 }
304 }
305 break;
306 }
307 }
308 }
309 $resList=implode(',', t3lib_div::trimExplode(',', $resList, 1));
310 if (strcmp($resList, $tplRow['resources'])) {
311 $recData['sys_template'][$saveId]['resources'] = $resList;
312 }
313 if (count($recData)) {
314
315 $recData['sys_template'][$saveId] = $this->processTemplateRowBeforeSaving($recData['sys_template'][$saveId]);
316
317 // Create new tce-object
318 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
319 $tce->stripslashes_values=0;
320 $tce->alternativeFileName = $alternativeFileName;
321 // Initialize
322 $tce->start($recData, array());
323 // Saved the stuff
324 $tce->process_datamap();
325 // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
326 $tce->clear_cacheCmd('all');
327
328 // tce were processed successfully
329 $this->tce_processed = true;
330
331 // re-read the template ...
332 $this->initialize_editor($this->pObj->id, $template_uid);
333 }
334
335 // Unlink any uploaded/new temp files there was:
336 t3lib_div::unlink_tempfile($tmp_upload_name);
337 t3lib_div::unlink_tempfile($tmp_newresource_name);
338
339 // If files has been edited:
340 if (is_array($edit)) {
341 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.
342 $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$edit['filename'];
343 $fI = t3lib_div::split_fileref($edit['filename']);
344 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
345 // @TODO: Check if the hardcorded value already has a config member, otherwise create one
346 if (filesize($path) < 30720) { // checks that have already been done.. Just to make sure
347 t3lib_div::writeFile($path, $edit['file']);
348
349 $theOutput.= $this->pObj->doc->spacer(10);
350 $theOutput.= $this->pObj->doc->section(
351 '<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>',
352 sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']),
353 0, 0, 0, 1
354 );
355
356 // Clear cache - the file has probably affected the template setup
357 // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
358 $tce = t3lib_div::makeInstance('t3lib_TCEmain');
359 $tce->stripslashes_values = 0;
360 $tce->start(array(), array());
361 $tce->clear_cacheCmd('all');
362 }
363 }
364 }
365 }
366 }
367
368 // hook Post updating template/TCE processing
369 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
370 $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
371 if (is_array($postTCEProcessingHook)) {
372 $hookParameters = array(
373 'POST' => $POST,
374 'tce' => $tce,
375 );
376 foreach ($postTCEProcessingHook as $hookFunction) {
377 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
378 }
379 }
380 }
381
382 $theOutput.= $this->pObj->doc->spacer(5);
383 $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);
384 if ($manyTemplatesMenu) {
385 $theOutput.= $this->pObj->doc->section('', $manyTemplatesMenu);
386 $theOutput.= $this->pObj->doc->divider(5);
387 }
388
389 #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
390 #if (!$numberOfRows)
391 $numberOfRows = 35;
392
393 // If abort pressed, nothing should be edited:
394 if ($POST['abort'] || (t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']))
395 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
396 unset($e);
397 }
398
399 if ($e['title']) {
400 $outCode = '<input type="Text" name="data[title]" value="'.htmlspecialchars($tplRow['title']).'"'.$this->pObj->doc->formWidth().'>';
401 $outCode.= '<input type="Hidden" name="e[title]" value="1">';
402 $theOutput.= $this->pObj->doc->spacer(15);
403 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
404 }
405 if ($e['sitetitle']) {
406 $outCode = '<input type="Text" name="data[sitetitle]" value="'.htmlspecialchars($tplRow['sitetitle']).'"'.$this->pObj->doc->formWidth().'>';
407 $outCode.= '<input type="Hidden" name="e[sitetitle]" value="1">';
408 $theOutput.= $this->pObj->doc->spacer(15);
409 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
410 }
411 if ($e['description']) {
412 $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"'.$this->pObj->doc->formWidthText(48, '', '').'>'.t3lib_div::formatForTextarea($tplRow['description']).'</textarea>';
413 $outCode.= '<input type="Hidden" name="e[description]" value="1">';
414 $theOutput.= $this->pObj->doc->spacer(15);
415 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
416 }
417 if ($e['resources']) {
418 // Upload
419 $outCode = '<input type="File" name="resources"'.$this->pObj->doc->formWidth().' size="50">';
420 $outCode.= '<input type="Hidden" name="data[resources]" value="1">';
421 $outCode.= '<input type="Hidden" name="e[resources]" value="1">';
422 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
423 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size']*1024) . '</strong>';
424 $theOutput.= $this->pObj->doc->spacer(15);
425 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
426
427 // New
428 $opt = explode(',', $this->pObj->textExtensions);
429 $optTags = '';
430 foreach ($opt as $extVal) {
431 $optTags.= '<option value="'.$extVal.'">.'.$extVal.'</option>';
432 }
433 $outCode = '<input type="text" name="new_resource"'.$this->pObj->doc->formWidth(20).'>
434 <select name="new_resource_ext">'.$optTags.'</select>';
435 $outCode.= '<input type="Hidden" name="data[new_resource]" value="1">';
436 $theOutput.= $this->pObj->doc->spacer(15);
437 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
438
439 // Make copy
440 $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
441 if ($rL) {
442 $theOutput.= $this->pObj->doc->spacer(20);
443 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
444 }
445
446 // Update resource list
447 $rL = $this->procesResources($tplRow['resources'], 1);
448 if ($rL) {
449 $theOutput.= $this->pObj->doc->spacer(20);
450 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
451 }
452 }
453 if ($e['constants']) {
454 $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>';
455 $outCode.= '<input type="Hidden" name="e[constants]" value="1">';
456
457 // Display "Include TypoScript file content?" checkbox
458 $outCode .= t3lib_BEfunc::getFuncCheck(
459 $this->pObj->id,
460 'SET[includeTypoScriptFileContent]',
461 $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'],
462 'index.php',
463 '&e[constants]=1',
464 'id="checkIncludeTypoScriptFileContent"'
465 );
466 $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
467
468
469 $theOutput.= $this->pObj->doc->spacer(15);
470 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
471 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
472 }
473 if ($e['file']) {
474 $path = PATH_site.$TCA['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$e[file];
475
476 $fI = t3lib_div::split_fileref($e[file]);
477 if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
478 if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size']*1024) {
479 $fileContent = t3lib_div::getUrl($path);
480 $outCode = $GLOBALS['LANG']->getLL('file'). ' <strong>' . $e[file] . '</strong><BR>';
481 $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>';
482 $outCode.= '<input type="Hidden" name="edit[filename]" value="'.$e[file].'">';
483 $outCode.= '<input type="Hidden" name="e[file]" value="'.htmlspecialchars($e[file]).'">';
484 $theOutput.= $this->pObj->doc->spacer(15);
485 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
486 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
487 } else {
488 $theOutput.= $this->pObj->doc->spacer(15);
489 $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
490 $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
491 $theOutput.= $this->pObj->doc->section(
492 '<font color=red>' . $fileToBig . '</font>',
493 $filesizeNotAllowed,
494 0, 0, 0, 1
495 );
496 }
497 }
498 }
499 if ($e['config']) {
500 $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>';
501 $outCode.= '<input type="Hidden" name="e[config]" value="1">';
502
503 // Display "Include TypoScript file content?" checkbox
504 $outCode .= t3lib_BEfunc::getFuncCheck(
505 $this->pObj->id,
506 'SET[includeTypoScriptFileContent]',
507 $this->pObj->MOD_SETTINGS['includeTypoScriptFileContent'],
508 'index.php',
509 '&e[config]=1',
510 'id="checkIncludeTypoScriptFileContent"'
511 );
512 $outCode .= '<label for="checkIncludeTypoScriptFileContent">' . $GLOBALS['LANG']->getLL('includeTypoScriptFileContent') . '</label><br />';
513
514 if (t3lib_extMgm::isLoaded('tsconfig_help')) {
515 $url = $BACK_PATH.'wizard_tsconfig.php?mode=tsref';
516 $params = array(
517 'formName' => 'editForm',
518 'itemName' => 'data[config]',
519 );
520 $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>';
521 }
522
523 $theOutput.= $this->pObj->doc->spacer(15);
524 $theOutput.= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
525 $theOutput.= $this->pObj->doc->sectionEnd().$outCode;
526 }
527
528 // Processing:
529 $outCode = '';
530 $outCode.= $this->tableRow(
531 $GLOBALS['LANG']->getLL('title'),
532 htmlspecialchars($tplRow['title']),
533 'title'
534 );
535 $outCode.= $this->tableRow(
536 $GLOBALS['LANG']->getLL('sitetitle'),
537 htmlspecialchars($tplRow['sitetitle']),
538 'sitetitle'
539 );
540 $outCode.= $this->tableRow(
541 $GLOBALS['LANG']->getLL('description'),
542 nl2br(htmlspecialchars($tplRow['description'])),
543 'description'
544 );
545 $outCode.= $this->tableRow(
546 $GLOBALS['LANG']->getLL('resources'),
547 $this->procesResources($tplRow['resources']),
548 'resources'
549 );
550 $outCode.= $this->tableRow(
551 $GLOBALS['LANG']->getLL('constants'),
552 sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0)),
553 'constants'
554 );
555 $outCode.= $this->tableRow(
556 $GLOBALS['LANG']->getLL('setup'),
557 sprintf($GLOBALS['LANG']->getLL('editToView'), (trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0)),
558 'config'
559 );
560 $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
561
562 // Edit all icon:
563 $outCode.= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') .
564 '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' .
565 t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title'=>
566 $GLOBALS['LANG']->getLL('editTemplateRecord') )) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
567 $theOutput.= $this->pObj->doc->section('', $outCode);
568
569
570 // hook after compiling the output
571 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
572 $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
573 if (is_array($postOutputProcessingHook)) {
574 $hookParameters = array(
575 'theOutput' => &$theOutput,
576 'POST' => $POST,
577 'e' => $e,
578 'tplRow' => $tplRow,
579 'numberOfRows' => $numberOfRows
580 );
581 foreach ($postOutputProcessingHook as $hookFunction) {
582 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
583 }
584 }
585 }
586
587 } else {
588 $theOutput.= $this->pObj->noTemplate(1);
589 }
590
591
592 return $theOutput;
593 }
594 }
595
596 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']) {
597 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']);
598 }
599
600 ?>