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