db878dda23d35c207643255956b35d3f67bf9582
[Packages/TYPO3.CMS.git] / typo3 / sysext / tstemplate / Classes / Controller / TypoScriptTemplateModuleController.php
1 <?php
2 namespace TYPO3\CMS\Tstemplate\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 /**
31 * Module: TypoScript Tools
32 *
33 * $TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"] = Directory of default resources. Eg. "fileadmin/res/" or so.
34 *
35 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
36 */
37 class TypoScriptTemplateModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
38
39 /**
40 * @todo Define visibility
41 */
42 public $perms_clause;
43
44 /**
45 * @todo Define visibility
46 */
47 public $e;
48
49 /**
50 * @todo Define visibility
51 */
52 public $sObj;
53
54 /**
55 * @todo Define visibility
56 */
57 public $edit;
58
59 /**
60 * @todo Define visibility
61 */
62 public $textExtensions = 'html,htm,txt,css,tmpl,inc,js';
63
64 /**
65 * @todo Define visibility
66 */
67 public $modMenu_type = '';
68
69 /**
70 * @todo Define visibility
71 */
72 public $modMenu_dontValidateList = '';
73
74 /**
75 * @todo Define visibility
76 */
77 public $modMenu_setDefaultList = '';
78
79 /**
80 * Init
81 *
82 * @return void
83 * @todo Define visibility
84 */
85 public function init() {
86 parent::init();
87 $this->id = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'));
88 $this->e = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('e');
89 $this->sObj = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('sObj');
90 $this->edit = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('edit');
91 $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
92 }
93
94 /**
95 * Clear cache
96 *
97 * @return void
98 * @todo Define visibility
99 */
100 public function clearCache() {
101 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('clear_all_cache')) {
102 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
103 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
104 $tce->stripslashes_values = 0;
105 $tce->start(array(), array());
106 $tce->clear_cacheCmd('all');
107 }
108 }
109
110 /**
111 * Main
112 *
113 * @return void
114 * @todo Define visibility
115 */
116 public function main() {
117 // Template markers
118 $markers = array(
119 'CSH' => '',
120 'FUNC_MENU' => '',
121 'CONTENT' => ''
122 );
123 // Access check...
124 // The page will show only if there is a valid page and if this page may be viewed by the user
125 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
126 $this->access = is_array($this->pageinfo) ? 1 : 0;
127 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
128 $this->doc->backPath = $GLOBALS['BACK_PATH'];
129 $this->doc->setModuleTemplate('EXT:tstemplate/Resources/Private/Templates/tstemplate.html');
130 if ($this->id && $this->access) {
131 $urlParameters = array(
132 'id' => $this->id,
133 'template' => 'all'
134 );
135 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
136 $this->doc->form = '<form action="' . htmlspecialchars($aHref) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editForm">';
137 // JavaScript
138 $this->doc->JScode = '
139 <script language="javascript" type="text/javascript">
140 script_ended = 0;
141 function jumpToUrl(URL) {
142 window.location.href = URL;
143 }
144 function uFormUrl(aname) {
145 document.forms[0].action = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue(($aHref . '#'), TRUE) . '+aname;
146 }
147 function brPoint(lnumber,t) {
148 window.location.href = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue(($aHref . '&SET[function]=TYPO3\\CMS\\TstemplateObjbrowser\\Controller\\TypoScriptTemplateObjectBrowserModuleFunctionController&SET[ts_browser_type]='), TRUE) . '+(t?"setup":"const")+"&breakPointLN="+lnumber;
149 return false;
150 }
151 </script>
152 ';
153 $this->doc->postCode = '
154 <script language="javascript" type="text/javascript">
155 script_ended = 1;
156 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
157 </script>
158 ';
159 $this->doc->inDocStylesArray[] = '
160 TABLE#typo3-objectBrowser { width: 100%; margin-bottom: 24px; }
161 TABLE#typo3-objectBrowser A { text-decoration: none; }
162 TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
163 TABLE#ts-analyzer { width: 100% }
164 TABLE#ts-analyzer tr td {padding: 0 4px;}
165 TABLE#ts-analyzer tr.t3-row-header td { padding: 2px 4px; font-weight:bold; color: #fff; }
166 .ts-typoscript { width: 100%; }
167 .tsob-menu label, .tsob-menu-row2 label, .tsob-conditions label { padding: 0 5px 0 0; vertical-align: text-top;}
168 .tsob-menu-row2 {margin-top: 10px;}
169 .tsob-conditions {padding: 1px 2px;}
170 .tsob-search-submit {margin-left: 3px; margin-right: 3px;}
171 .tst-analyzer-options { margin:5px 0; }
172 .tst-analyzer-options label {padding-left:5px; vertical-align:text-top; }
173 .bgColor0 {background-color:#fff; color: #000; }
174 ';
175 // Setting up the context sensitive menu:
176 $this->doc->getContextMenuCode();
177 // Build the modulle content
178 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle'));
179 $this->extObjContent();
180 // Setting up the buttons and markers for docheader
181 $docHeaderButtons = $this->getButtons();
182 $markers['FUNC_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
183 $markers['CONTENT'] = $this->content;
184 } else {
185 // If no access or if ID == zero
186 $this->doc->inDocStylesArray[] = '
187 TABLE#ts-overview tr.t3-row-header { background-color: #A2AAB8; }
188 TABLE#ts-overview tr td {padding: 2px;}
189 TABLE#ts-overview tr.t3-row-header td { padding: 2px 4px; font-weight:bold; color: #fff; }
190 ';
191 // Template pages:
192 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val', 'pages,sys_template', 'pages.uid=sys_template.pid' . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('pages') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('pages') . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('sys_template') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('sys_template'), 'pages.uid');
193 $templateArray = array();
194 $pArray = array();
195 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
196 $this->setInPageArray($pArray, \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($row['uid'], 'AND 1=1'), $row);
197 }
198 $GLOBALS['TYPO3_DB']->sql_free_result($res);
199 $lines = array();
200 $lines[] = '<tr class="t3-row-header">
201 <td nowrap>' . $GLOBALS['LANG']->getLL('pageName') . '</td>
202 <td nowrap>' . $GLOBALS['LANG']->getLL('templates') . '</td>
203 <td nowrap>' . $GLOBALS['LANG']->getLL('isRoot') . '</td>
204 <td nowrap>' . $GLOBALS['LANG']->getLL('isExt') . '</td>
205 </tr>';
206 $lines = array_merge($lines, $this->renderList($pArray));
207 $table = '<table border="0" cellpadding="0" cellspacing="1" id="ts-overview">' . implode('', $lines) . '</table>';
208 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle'));
209 $this->content .= $this->doc->section('', '
210 <br />
211 ' . $GLOBALS['LANG']->getLL('overview') . '
212 <br /><br />' . $table);
213 // RENDER LIST of pages with templates, END
214 // Setting up the buttons and markers for docheader
215 $docHeaderButtons = $this->getButtons();
216 $markers['CONTENT'] = $this->content;
217 }
218 // Build the <body> for the module
219 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
220 // Renders the module page
221 $this->content = $this->doc->render('Template Tools', $this->content);
222 }
223
224 /**
225 * Print content
226 *
227 * @return void
228 * @todo Define visibility
229 */
230 public function printContent() {
231 echo $this->content;
232 }
233
234 /**
235 * Create the panel of buttons for submitting the form or otherwise perform operations.
236 *
237 * @return array All available buttons as an assoc. array
238 */
239 protected function getButtons() {
240 $buttons = array(
241 'back' => '',
242 'close' => '',
243 'new' => '',
244 'save' => '',
245 'save_close' => '',
246 'view' => '',
247 'shortcut' => ''
248 );
249 if ($this->id && $this->access) {
250 // View page
251 $buttons['view'] = '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick($this->pageinfo['uid'], $GLOBALS['BACK_PATH'], \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($this->pageinfo['uid']))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
252 if ($this->extClassConf['name'] == 'TYPO3\CMS\TstemplateInfo\Controller\TypoScriptTemplateInformationModuleFunctionController') {
253 // NEW button
254 $buttons['new'] = '<input type="image" class="c-inputButton" name="createExtension" value="New"' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/new_el.gif', '') . ' title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:db_new.php.pagetitle', TRUE) . '" />';
255 if (!empty($this->e) && !\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('abort') && !\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('saveclose')) {
256 // no NEW-button while edit
257 $buttons['new'] = '';
258 // SAVE button
259 $buttons['save'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save', array(
260 'html' => '<input type="image" class="c-inputButton" name="submit" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . '/>'
261 ));
262 // SAVE AND CLOSE button
263 $buttons['save_close'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save-close', array(
264 'html' => '<input type="image" class="c-inputButton" name="saveclose" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', TRUE) . '" ' . '/>'
265 ));
266 // CLOSE button
267 $buttons['close'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-close', array(
268 'html' => '<input type="image" class="c-inputButton" name="abort" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '" ' . '/>'
269 ));
270 }
271 } elseif ($this->extClassConf['name'] == 'TYPO3\CMS\TstemplateCeditor\Controller\TypoScriptTemplateConstantEditorModuleFunctionController' && count($this->MOD_MENU['constant_editor_cat'])) {
272 // SAVE button
273 $buttons['save'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save', array('html' => '<input type="image" class="c-inputButton" name="submit" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', TRUE) . '" ' . '/>'));
274 } elseif ($this->extClassConf['name'] == 'TYPO3\CMS\TstemplateObjbrowser\Controller\TypoScriptTemplateObjectBrowserModuleFunctionController') {
275 if (!empty($this->sObj)) {
276 // BACK
277 $urlParameters = array(
278 'id' => $this->id
279 );
280 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
281 $buttons['back'] = '<a href="' . htmlspecialchars($aHref) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
282 }
283 }
284 // Shortcut
285 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
286 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
287 }
288 } else {
289 // Shortcut
290 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
291 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id', '', $this->MCONF['name']);
292 }
293 }
294 return $buttons;
295 }
296
297 // OTHER FUNCTIONS:
298 /**
299 * Wrap title for link in template
300 *
301 * @param string $title
302 * @param string $onlyKey
303 * @return string
304 * @todo Define visibility
305 */
306 public function linkWrapTemplateTitle($title, $onlyKey = '') {
307 $urlParameters = array(
308 'id' => $this->id
309 );
310 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
311 if ($onlyKey) {
312 $title = '<a href="' . htmlspecialchars(($aHref . '&e[' . $onlyKey . ']=1&SET[function]=TYPO3\\CMS\\TstemplateInfo\\Controller\\TypoScriptTemplateInformationModuleFunctionController')) . '">' . htmlspecialchars($title) . '</a>';
313 } else {
314 $title = '<a href="' . htmlspecialchars(($aHref . '&e[constants]=1&e[config]=1&SET[function]=TYPO3\\CMS\\TstemplateInfo\\Controller\\TypoScriptTemplateInformationModuleFunctionController')) . '">' . htmlspecialchars($title) . '</a>';
315 }
316 return $title;
317 }
318
319 /**
320 * No template
321 *
322 * @param integer $newStandardTemplate
323 * @return string
324 * @todo Define visibility
325 */
326 public function noTemplate($newStandardTemplate = 0) {
327 // Defined global here!
328 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
329 /** @var $tmpl \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService */
330 // Do not log time-performance information
331 $tmpl->tt_track = FALSE;
332 $tmpl->init();
333 $theOutput = '';
334 $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('noTemplateDescription') . '<br />' . $GLOBALS['LANG']->getLL('createTemplateToEditConfiguration'), $GLOBALS['LANG']->getLL('noTemplate'), \TYPO3\CMS\Core\Messaging\FlashMessage::INFO);
335 $theOutput .= $flashMessage->render();
336 // New standard?
337 if ($newStandardTemplate) {
338 // Hook to change output, implemented for statictemplates
339 if (isset(
340 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateView']
341 )) {
342 $selector = '';
343 $staticsText = '';
344 $reference = array(
345 'selectorHtml' => &$selector,
346 'staticsText' => &$staticsText
347 );
348 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction(
349 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateView'],
350 $reference,
351 $this
352 );
353 $selector = $reference['selectorHtml'];
354 $staticsText = $reference['staticsText'];
355 } else {
356 $selector = '<input type="hidden" name="createStandard" value="" />';
357 $staticsText = '';
358 }
359 // Extension?
360 $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('newWebsite') . $staticsText, $GLOBALS['LANG']->getLL('newWebsiteDescription') . '<br /><br />' . $selector . '<input type="Submit" name="newWebsite" value="' . $GLOBALS['LANG']->getLL('newWebsiteAction') . '" />', 0, 1);
361 }
362 // Extension?
363 $theOutput .= $this->doc->spacer(10);
364 $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('extTemplate'), $GLOBALS['LANG']->getLL('extTemplateDescription') . '<br /><br />' . '<input type="submit" name="createExtension" value="' . $GLOBALS['LANG']->getLL('extTemplateAction') . '" />', 0, 1);
365 // Go to first appearing...
366 $first = $tmpl->ext_prevPageWithTemplate($this->id, $this->perms_clause);
367 if ($first) {
368 $theOutput .= $this->doc->spacer(10);
369 $urlParameters = array(
370 'id' => $first['uid']
371 );
372 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
373 $theOutput .= $this->doc->section($GLOBALS['LANG']->getLL('goToClosest'), sprintf($GLOBALS['LANG']->getLL('goToClosestDescription') . '<br /><br />%s<strong>' . $GLOBALS['LANG']->getLL('goToClosestAction') . '</strong>%s', htmlspecialchars($first['title']), $first['uid'], '<a href="' . htmlspecialchars($aHref) . '">', '</a>'), 0, 1);
374 }
375 return $theOutput;
376 }
377
378 /**
379 * @todo Define visibility
380 */
381 public function templateMenu() {
382 // Defined global here!
383 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
384 /** @var $tmpl \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService */
385 // Do not log time-performance information
386 $tmpl->tt_track = FALSE;
387 $tmpl->init();
388 $all = $tmpl->ext_getAllTemplates($this->id, $this->perms_clause);
389 $menu = '';
390 if (count($all) > 1) {
391 $this->MOD_MENU['templatesOnPage'] = array();
392 foreach ($all as $d) {
393 $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
394 }
395 }
396 $this->MOD_SETTINGS = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData($this->MOD_MENU, \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
397 $menu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[templatesOnPage]', $this->MOD_SETTINGS['templatesOnPage'], $this->MOD_MENU['templatesOnPage']);
398 return $menu;
399 }
400
401 /**
402 * Create template
403 *
404 * @param integer $id
405 * @param integer $actTemplateId
406 * @return string
407 * @todo Define visibility
408 */
409 public function createTemplate($id, $actTemplateId = 0) {
410 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('createExtension') || \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('createExtension_x')) {
411 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
412 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
413 $tce->stripslashes_values = 0;
414 $recData = array();
415 $recData['sys_template']['NEW'] = array(
416 'pid' => $actTemplateId ? -1 * $actTemplateId : $id,
417 'title' => '+ext'
418 );
419 $tce->start($recData, array());
420 $tce->process_datamap();
421 return $tce->substNEWwithIDs['NEW'];
422 } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('newWebsite')) {
423 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
424 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
425 $tce->stripslashes_values = 0;
426 $recData = array();
427 // Hook to handle row data, implemented for statictemplates
428 if (isset(
429 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateHandler']
430 )) {
431 $reference = array(
432 'recData' => &$recData,
433 'id' => $id,
434 );
435 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction(
436 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateHandler'],
437 $reference,
438 $this
439 );
440 $recData = $reference['recData'];
441 } else {
442 $recData['sys_template']['NEW'] = array(
443 'pid' => $id,
444 'title' => $GLOBALS['LANG']->getLL('titleNewSite'),
445 'sorting' => 0,
446 'root' => 1,
447 'clear' => 3,
448 'config' => '
449 # Default PAGE object:
450 page = PAGE
451 page.10 = TEXT
452 page.10.value = HELLO WORLD!
453 '
454 );
455 }
456 $tce->start($recData, array());
457 $tce->process_datamap();
458 $tce->clear_cacheCmd('all');
459 }
460 }
461
462 // RENDER LIST of pages with templates, BEGIN
463 /**
464 * Set page in array
465 *
466 * @param array $pArray
467 * @param array $rlArr
468 * @param array $row
469 * @return void
470 * @todo Define visibility
471 */
472 public function setInPageArray(&$pArray, $rlArr, $row) {
473 ksort($rlArr);
474 reset($rlArr);
475 if (!$rlArr[0]['uid']) {
476 array_shift($rlArr);
477 }
478 $cEl = current($rlArr);
479 $pArray[$cEl['uid']] = htmlspecialchars($cEl['title']);
480 array_shift($rlArr);
481 if (count($rlArr)) {
482 if (!isset($pArray[($cEl['uid'] . '.')])) {
483 $pArray[$cEl['uid'] . '.'] = array();
484 }
485 $this->setInPageArray($pArray[$cEl['uid'] . '.'], $rlArr, $row);
486 } else {
487 $pArray[$cEl['uid'] . '_'] = $row;
488 }
489 }
490
491 /**
492 * Render the list
493 *
494 * @param array $pArray
495 * @param array $lines
496 * @param integer $c
497 * @return array
498 * @todo Define visibility
499 */
500 public function renderList($pArray, $lines = array(), $c = 0) {
501 if (is_array($pArray)) {
502 reset($pArray);
503 static $i;
504 foreach ($pArray as $k => $v) {
505 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
506 if (isset($pArray[$k . '_'])) {
507 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
508 <td nowrap><img src="clear.gif" width="1" height="1" hspace=' . $c * 10 . ' align="top">' . '<a href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::linkThisScript(array('id' => $k)) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $k), array('title' => ('ID: ' . $k))) . \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($pArray[$k], 30) . '</a></td>
509 <td align="center">' . $pArray[($k . '_')]['count'] . '</td>
510 <td align="center" class="bgColor5">' . ($pArray[$k . '_']['root_max_val'] > 0 ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '&nbsp;') . '</td>
511 <td align="center">' . ($pArray[$k . '_']['root_min_val'] == 0 ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '&nbsp;') . '</td>
512 </tr>';
513 } else {
514 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
515 <td nowrap ><img src="clear.gif" width="1" height="1" hspace=' . $c * 10 . ' align=top>' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordWSOL('pages', $k)) . \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($pArray[$k], 30) . '</td>
516 <td align="center"></td>
517 <td align="center" class="bgColor5"></td>
518 <td align="center"></td>
519 </tr>';
520 }
521 $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1);
522 }
523 }
524 }
525 return $lines;
526 }
527
528 }
529
530 ?>