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