[FEATURE] Add XLIFF translation support (l10n)
[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 class tx_tstemplateinfo extends t3lib_extobjbase {
52
53 public $tce_processed = FALSE; // indicator for t3editor, whether data is stored
54
55 /**
56 * Creates a row for a HTML table
57 *
58 * @param string $label: The label to be shown (e.g. 'Title:', 'Sitetitle:')
59 * @param string $data: The data/information to be shown (e.g. 'Template for my site')
60 * @param string $field: The field/variable to be sent on clicking the edit icon (e.g. 'title', 'sitetitle')
61 * @return string A row for a HTML table
62 */
63 function tableRow($label, $data, $field) {
64 $ret = '<tr><td>';
65 $ret.= '<a href="index.php?id=' . $this->pObj->id . '&e[' . $field . ']=1">' .
66 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>';
67 $ret .= '</td><td width="80%" class="bgColor4">' . $data . '&nbsp;</td></tr>';
68 return $ret;
69 }
70
71 /**
72 * Renders HTML table with available template resources/files
73 *
74 * @param string $resources: List of resources/files to be shown (e.g. 'file_01.txt,file.txt')
75 * @param boolean $func: Whether to render functions like 'to top' or 'delete' for each resource (default: FALSE)
76 * @return string HTML table with available template resources/files
77 */
78 function procesResources($resources, $func=FALSE) {
79 $arr = t3lib_div::trimExplode(',', $resources.',,', 1);
80 $out = '';
81 $bgcol = ($func ? ' class="bgColor4"' : '');
82 foreach ($arr as $k => $v) {
83 $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v;
84 $functions = '';
85 if ($func) {
86 $functions = '<td bgcolor="red" nowrap="nowrap">' . $GLOBALS['LANG']->getLL('delete') . ' <input type="checkbox" name="data[remove_resource][' . $k . ']" value="' . htmlspecialchars($v) . '" /></td>';
87 $functions .= '<td' . $bgcol . ' nowrap="nowrap">' . $GLOBALS['LANG']->getLL('toTop') . ' <input type="checkbox" name="data[totop_resource][' . $k . ']" value="' . htmlspecialchars($v) . '" /></td>';
88 $functions .= '<td' . $bgcol . ' nowrap="nowrap">';
89 $fI = t3lib_div::split_fileref($v);
90 if (t3lib_div::inList($this->pObj->textExtensions,$fI['fileext'])) {
91 $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>';
92 }
93 $functions.= '</td>';
94 }
95 $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], '');
96 $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>';
97 }
98 if ($out) {
99 if ($func) {
100 $out = '<table border="0" cellpadding="1" cellspacing="1" width="100%">' . $out . '</table>';
101 $out = '<table border="0" cellpadding="0" cellspacing="0">
102 <tr><td class="bgColor2">' . $out . '<img src="clear.gif" width="465px" height="1px"></td></tr>
103 </table>';
104 } else {
105 $out = '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>';
106 }
107 }
108 return $out;
109 }
110
111 /**
112 * Renders HTML table with all available template resources/files in the current rootline that could be copied
113 *
114 * @param integer $id: The uid of the current page
115 * @param integer $template_uid: The uid of the template record to be rendered (only if more than one template on the current page)
116 * @return string HTML table with all available template resources/files in the current rootline that could be copied
117 */
118 function resourceListForCopy($id, $template_uid) {
119 global $tmpl;
120 $sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
121 $rootLine = $sys_page->getRootLine($id);
122 $tmpl->runThroughTemplates($rootLine, $template_uid); // This generates the constants/config + hierarchy info for the template.
123 $theResources = t3lib_div::trimExplode(',', $tmpl->resources, 1);
124 foreach ($theResources as $k => $v) {
125 $fI = pathinfo($v);
126 if (t3lib_div::inList($this->pObj->textExtensions,strtolower($fI['extension']))) {
127 $path = PATH_site.$GLOBALS['TCA']['sys_template']['columns']['resources']['config']['uploadfolder'].'/'.$v;
128 $thumb = t3lib_BEfunc::thumbCode(array('resources' => $v), 'sys_template', 'resources', $GLOBALS['BACK_PATH'], '');
129 $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>';
130 }
131 }
132 $out = ($out ? '<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>' : '');
133 return $out;
134 }
135
136 /**
137 * Create an instance of t3lib_tsparser_ext in $GLOBALS['tmpl'] and looks for the first (visible) template
138 * record. If $template_uid was given and greater than zero, this record will be checked.
139 *
140 * @param integer $id: The uid of the current page
141 * @param integer $template_uid: The uid of the template record to be rendered (only if more than one template on the current page)
142 * @return boolean Returns TRUE if a template record was found, otherwise FALSE
143 */
144 function initialize_editor($pageId, $template_uid=0) {
145 // Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
146 global $tmpl,$tplRow,$theConstants;
147
148 $tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext'); // Defined global here!
149 $tmpl->tt_track = 0; // Do not log time-performance information
150 $tmpl->init();
151
152 // Get the row of the first VISIBLE template of the page. whereclause like the frontend.
153 $tplRow = $tmpl->ext_getFirstTemplate($pageId, $template_uid);
154 if (is_array($tplRow)) {
155 $tplRow = $this->processTemplateRowAfterLoading($tplRow);
156 return TRUE;
157 }
158 return FALSE;
159 }
160
161 /**
162 * Process template row after loading
163 *
164 * @param array $tplRow: template row
165 * @return array preprocessed template row
166 * @author Fabrizio Branca <typo3@fabrizio-branca.de>
167 */
168 function processTemplateRowAfterLoading(array $tplRow) {
169 if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
170 // Let the recursion detection counter start at 91, so that only 10 recursive calls will be resolved
171 // Otherwise the editor will be bloated with way to many lines making it hard the break the cyclic recursion.
172 $tplRow['config'] = t3lib_TSparser::checkIncludeLines($tplRow['config'], 91);
173 $tplRow['constants'] = t3lib_TSparser::checkIncludeLines($tplRow['constants'], 91);
174 }
175 return $tplRow;
176 }
177
178 /**
179 * Process template row before saving
180 *
181 * @param array $tplRow: template row
182 * @return array preprocessed template row
183 * @author Fabrizio Branca <typo3@fabrizio-branca.de>
184 */
185 function processTemplateRowBeforeSaving(array $tplRow) {
186 if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
187 $tplRow = t3lib_TSparser::extractIncludes_array($tplRow);
188 }
189 return $tplRow;
190 }
191
192 /**
193 * The main processing method if this class
194 *
195 * @return string Information of the template status or the taken actions as HTML string
196 */
197 function main() {
198 global $BACK_PATH;
199 global $tmpl,$tplRow,$theConstants;
200
201 $this->pObj->MOD_MENU['includeTypoScriptFileContent'] = TRUE;
202
203 $edit = $this->pObj->edit;
204 $e = $this->pObj->e;
205
206 t3lib_div::loadTCA('sys_template');
207
208
209
210
211 // **************************
212 // Checking for more than one template an if, set a menu...
213 // **************************
214 $manyTemplatesMenu = $this->pObj->templateMenu();
215 $template_uid = 0;
216 if ($manyTemplatesMenu) {
217 $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
218 }
219
220
221 // **************************
222 // Initialize
223 // **************************
224 $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid); // initialize
225
226 if ($existTemplate) {
227 $saveId = ($tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']);
228 }
229 // **************************
230 // Create extension template
231 // **************************
232 $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
233 if($newId) {
234 // switch to new template
235 t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id. '&SET[templatesOnPage]=' . $newId);
236 }
237
238 if ($existTemplate) {
239 // Update template ?
240 $POST = t3lib_div::_POST();
241 if ($POST['submit'] || (t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']))
242 || $POST['saveclose'] || (t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y']))) {
243 // Set the data to be saved
244 $recData = array();
245 $alternativeFileName = array();
246 $resList = $tplRow['resources'];
247
248 $tmp_upload_name = '';
249 $tmp_newresource_name = ''; // Set this to blank
250
251 if (is_array($POST['data'])) {
252 foreach ($POST['data'] as $field => $val) {
253 switch ($field) {
254 case 'constants':
255 case 'config':
256 case 'title':
257 case 'sitetitle':
258 case 'description':
259 $recData['sys_template'][$saveId][$field] = $val;
260 break;
261 case 'resources':
262 // If there is an uploaded file, move it.
263 $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']);
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 . $GLOBALS['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 . $GLOBALS['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 /** @var $tce t3lib_TCEmain */
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>' . $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
424 $outCode.= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($GLOBALS['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 . $GLOBALS['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) < $GLOBALS['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'), $GLOBALS['TCA']['sys_template']['columns']['resources']['config']['max_size']);
491 $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $GLOBALS['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 ?>