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