[TASK] Separate ext:statictemplates code from core
[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 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('clear_all_cache')) {
93 $this->include_once[] = PATH_t3lib . 'class.t3lib_tcemain.php';
94 }
95 }
96
97 /**
98 * Clear cache
99 *
100 * @return void
101 * @todo Define visibility
102 */
103 public function clearCache() {
104 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('clear_all_cache')) {
105 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
106 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
107 $tce->stripslashes_values = 0;
108 $tce->start(array(), array());
109 $tce->clear_cacheCmd('all');
110 }
111 }
112
113 /**
114 * Main
115 *
116 * @return void
117 * @todo Define visibility
118 */
119 public function main() {
120 // Template markers
121 $markers = array(
122 'CSH' => '',
123 'FUNC_MENU' => '',
124 'CONTENT' => ''
125 );
126 // Access check...
127 // The page will show only if there is a valid page and if this page may be viewed by the user
128 $this->pageinfo = \TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess($this->id, $this->perms_clause);
129 $this->access = is_array($this->pageinfo) ? 1 : 0;
130 $this->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
131 $this->doc->backPath = $GLOBALS['BACK_PATH'];
132 $this->doc->setModuleTemplate('templates/tstemplate.html');
133 if ($this->id && $this->access) {
134 $urlParameters = array(
135 'id' => $this->id,
136 'template' => 'all'
137 );
138 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
139 $this->doc->form = '<form action="' . htmlspecialchars($aHref) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editForm">';
140 // JavaScript
141 $this->doc->JScode = '
142 <script language="javascript" type="text/javascript">
143 script_ended = 0;
144 function jumpToUrl(URL) {
145 window.location.href = URL;
146 }
147 function uFormUrl(aname) {
148 document.forms[0].action = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue(($aHref . '#'), TRUE) . '+aname;
149 }
150 function brPoint(lnumber,t) {
151 window.location.href = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue(($aHref . '&SET[function]=tx_tstemplateobjbrowser&SET[ts_browser_type]='), TRUE) . '+(t?"setup":"const")+"&breakPointLN="+lnumber;
152 return false;
153 }
154 </script>
155 ';
156 $this->doc->postCode = '
157 <script language="javascript" type="text/javascript">
158 script_ended = 1;
159 if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . ';
160 </script>
161 ';
162 $this->doc->inDocStylesArray[] = '
163 TABLE#typo3-objectBrowser { width: 100%; }
164 TABLE#typo3-objectBrowser A { text-decoration: none; }
165 TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
166 TABLE#ts-analyzer { width: 100% }
167 TABLE#ts-analyzer tr td {padding: 0 4px;}
168 TABLE#ts-analyzer tr.t3-row-header td { padding: 2px 4px; font-weight:bold; color: #fff; }
169 .ts-typoscript { width: 100%; }
170 .tsob-menu label, .tsob-menu-row2 label, .tsob-conditions label { padding: 0 5px 0 0; vertical-align: text-top;}
171 .tsob-menu-row2 {margin-top: 10px;}
172 .tsob-conditions {padding: 1px 2px;}
173 .tsob-search-submit {margin-left: 3px; margin-right: 3px;}
174 .tst-analyzer-options { margin:5px 0; }
175 .tst-analyzer-options label {padding-left:5px; vertical-align:text-top; }
176 .bgColor0 {background-color:#fff; color: #000; }
177 ';
178 // Setting up the context sensitive menu:
179 $this->doc->getContextMenuCode();
180 // Build the modulle content
181 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle'));
182 $this->extObjContent();
183 // Setting up the buttons and markers for docheader
184 $docHeaderButtons = $this->getButtons();
185 $markers['FUNC_MENU'] = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
186 $markers['CONTENT'] = $this->content;
187 } else {
188 // If no access or if ID == zero
189 $this->doc->inDocStylesArray[] = '
190 TABLE#ts-overview tr.t3-row-header { background-color: #A2AAB8; }
191 TABLE#ts-overview tr td {padding: 2px;}
192 TABLE#ts-overview tr.t3-row-header td { padding: 2px 4px; font-weight:bold; color: #fff; }
193 ';
194 // Template pages:
195 $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');
196 $templateArray = array();
197 $pArray = array();
198 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
199 $this->setInPageArray($pArray, \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($row['uid'], 'AND 1=1'), $row);
200 }
201 $GLOBALS['TYPO3_DB']->sql_free_result($res);
202 $lines = array();
203 $lines[] = '<tr class="t3-row-header">
204 <td nowrap>' . $GLOBALS['LANG']->getLL('pageName') . '</td>
205 <td nowrap>' . $GLOBALS['LANG']->getLL('templates') . '</td>
206 <td nowrap>' . $GLOBALS['LANG']->getLL('isRoot') . '</td>
207 <td nowrap>' . $GLOBALS['LANG']->getLL('isExt') . '</td>
208 </tr>';
209 $lines = array_merge($lines, $this->renderList($pArray));
210 $table = '<table border="0" cellpadding="0" cellspacing="1" id="ts-overview">' . implode('', $lines) . '</table>';
211 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('moduleTitle'));
212 $this->content .= $this->doc->section('', '
213 <br />
214 ' . $GLOBALS['LANG']->getLL('overview') . '
215 <br /><br />' . $table);
216 // RENDER LIST of pages with templates, END
217 // Setting up the buttons and markers for docheader
218 $docHeaderButtons = $this->getButtons();
219 $markers['CONTENT'] = $this->content;
220 }
221 // Build the <body> for the module
222 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
223 // Renders the module page
224 $this->content = $this->doc->render('Template Tools', $this->content);
225 }
226
227 /**
228 * Print content
229 *
230 * @return void
231 * @todo Define visibility
232 */
233 public function printContent() {
234 echo $this->content;
235 }
236
237 /**
238 * Create the panel of buttons for submitting the form or otherwise perform operations.
239 *
240 * @return array All available buttons as an assoc. array
241 */
242 protected function getButtons() {
243 $buttons = array(
244 'back' => '',
245 'close' => '',
246 'new' => '',
247 'save' => '',
248 'save_close' => '',
249 'view' => '',
250 'shortcut' => ''
251 );
252 if ($this->id && $this->access) {
253 // View page
254 $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.php:labels.showPage', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-view') . '</a>';
255 if ($this->extClassConf['name'] == 'tx_tstemplateinfo') {
256 // NEW button
257 $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.php:db_new.php.pagetitle', TRUE) . '" />';
258 if (!empty($this->e) && !\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('abort') && !\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('saveclose')) {
259 // no NEW-button while edit
260 $buttons['new'] = '';
261 // SAVE button
262 $buttons['save'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save', array(
263 'html' => '<input type="image" class="c-inputButton" name="submit" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', TRUE) . '" ' . '/>'
264 ));
265 // SAVE AND CLOSE button
266 $buttons['save_close'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-save-close', array(
267 'html' => '<input type="image" class="c-inputButton" name="saveclose" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc', TRUE) . '" ' . '/>'
268 ));
269 // CLOSE button
270 $buttons['close'] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-document-close', array(
271 'html' => '<input type="image" class="c-inputButton" name="abort" src="clear.gif" ' . 'title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc', TRUE) . '" ' . '/>'
272 ));
273 }
274 } elseif ($this->extClassConf['name'] == 'tx_tstemplateceditor' && count($this->MOD_MENU['constant_editor_cat'])) {
275 // SAVE button
276 $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.php:rm.saveDoc', TRUE) . '" ' . 'value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc', TRUE) . '" ' . '/>'));
277 } elseif ($this->extClassConf['name'] == 'tx_tstemplateobjbrowser') {
278 if (!empty($this->sObj)) {
279 // BACK
280 $urlParameters = array(
281 'id' => $this->id
282 );
283 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
284 $buttons['back'] = '<a href="' . htmlspecialchars($aHref) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.goBack', TRUE) . '">' . \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
285 }
286 }
287 // Shortcut
288 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
289 $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']);
290 }
291 } else {
292 // Shortcut
293 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
294 $buttons['shortcut'] = $this->doc->makeShortcutIcon('id', '', $this->MCONF['name']);
295 }
296 }
297 return $buttons;
298 }
299
300 // OTHER FUNCTIONS:
301 /**
302 * Wrap title for link in template
303 *
304 * @param string $title
305 * @param string $onlyKey
306 * @return string
307 * @todo Define visibility
308 */
309 public function linkWrapTemplateTitle($title, $onlyKey = '') {
310 $urlParameters = array(
311 'id' => $this->id
312 );
313 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
314 if ($onlyKey) {
315 $title = '<a href="' . htmlspecialchars(($aHref . '&e[' . $onlyKey . ']=1&SET[function]=tx_tstemplateinfo')) . '">' . htmlspecialchars($title) . '</a>';
316 } else {
317 $title = '<a href="' . htmlspecialchars(($aHref . '&e[constants]=1&e[config]=1&SET[function]=tx_tstemplateinfo')) . '">' . htmlspecialchars($title) . '</a>';
318 }
319 return $title;
320 }
321
322 /**
323 * No template
324 *
325 * @param integer $newStandardTemplate
326 * @return string
327 * @todo Define visibility
328 */
329 public function noTemplate($newStandardTemplate = 0) {
330 // Defined global here!
331 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
332 /** @var $tmpl \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService */
333 // Do not log time-performance information
334 $tmpl->tt_track = FALSE;
335 $tmpl->init();
336 $theOutput = '';
337 $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);
338 $theOutput .= $flashMessage->render();
339 // New standard?
340 if ($newStandardTemplate) {
341 // Hook to change output, implemented for statictemplates
342 if (isset(
343 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateView']
344 )) {
345 $selector = '';
346 $staticsText = '';
347 $reference = array(
348 'selectorHtml' => &$selector,
349 'staticsText' => &$staticsText
350 );
351 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction(
352 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateView'],
353 $reference,
354 $this
355 );
356 $selector = $reference['selectorHtml'];
357 $staticsText = $reference['staticsText'];
358 } else {
359 $selector = '<input type="hidden" name="createStandard" value="" />';
360 $staticsText = '';
361 }
362 // Extension?
363 $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);
364 }
365 // Extension?
366 $theOutput .= $this->doc->spacer(10);
367 $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);
368 // Go to first appearing...
369 $first = $tmpl->ext_prevPageWithTemplate($this->id, $this->perms_clause);
370 if ($first) {
371 $theOutput .= $this->doc->spacer(10);
372 $urlParameters = array(
373 'id' => $first['uid']
374 );
375 $aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
376 $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);
377 }
378 return $theOutput;
379 }
380
381 /**
382 * @todo Define visibility
383 */
384 public function templateMenu() {
385 // Defined global here!
386 $tmpl = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\ExtendedTemplateService');
387 /** @var $tmpl \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService */
388 // Do not log time-performance information
389 $tmpl->tt_track = FALSE;
390 $tmpl->init();
391 $all = $tmpl->ext_getAllTemplates($this->id, $this->perms_clause);
392 $menu = '';
393 if (count($all) > 1) {
394 $this->MOD_MENU['templatesOnPage'] = array();
395 foreach ($all as $d) {
396 $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
397 }
398 }
399 $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);
400 $menu = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->id, 'SET[templatesOnPage]', $this->MOD_SETTINGS['templatesOnPage'], $this->MOD_MENU['templatesOnPage']);
401 return $menu;
402 }
403
404 /**
405 * Create template
406 *
407 * @param integer $id
408 * @param integer $actTemplateId
409 * @return string
410 * @todo Define visibility
411 */
412 public function createTemplate($id, $actTemplateId = 0) {
413 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('createExtension') || \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('createExtension_x')) {
414 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
415 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
416 $tce->stripslashes_values = 0;
417 $recData = array();
418 $recData['sys_template']['NEW'] = array(
419 'pid' => $actTemplateId ? -1 * $actTemplateId : $id,
420 'title' => '+ext'
421 );
422 $tce->start($recData, array());
423 $tce->process_datamap();
424 return $tce->substNEWwithIDs['NEW'];
425 } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('newWebsite')) {
426 $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
427 /** @var $tce \TYPO3\CMS\Core\DataHandling\DataHandler */
428 $tce->stripslashes_values = 0;
429 $recData = array();
430 // Hook to handle row data, implemented for statictemplates
431 if (isset(
432 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateHandler']
433 )) {
434 $reference = array(
435 'recData' => &$recData,
436 'id' => $id,
437 );
438 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction(
439 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateModuleController']['newStandardTemplateHandler'],
440 $reference,
441 $this
442 );
443 $recData = $reference['recData'];
444 } else {
445 $recData['sys_template']['NEW'] = array(
446 'pid' => $id,
447 'title' => $GLOBALS['LANG']->getLL('titleNewSite'),
448 'sorting' => 0,
449 'root' => 1,
450 'clear' => 3,
451 'config' => '
452 # Default PAGE object:
453 page = PAGE
454 page.10 = TEXT
455 page.10.value = HELLO WORLD!
456 '
457 );
458 }
459 $tce->start($recData, array());
460 $tce->process_datamap();
461 $tce->clear_cacheCmd('all');
462 }
463 }
464
465 // RENDER LIST of pages with templates, BEGIN
466 /**
467 * Set page in array
468 *
469 * @param array $pArray
470 * @param array $rlArr
471 * @param array $row
472 * @return void
473 * @todo Define visibility
474 */
475 public function setInPageArray(&$pArray, $rlArr, $row) {
476 ksort($rlArr);
477 reset($rlArr);
478 if (!$rlArr[0]['uid']) {
479 array_shift($rlArr);
480 }
481 $cEl = current($rlArr);
482 $pArray[$cEl['uid']] = htmlspecialchars($cEl['title']);
483 array_shift($rlArr);
484 if (count($rlArr)) {
485 if (!isset($pArray[($cEl['uid'] . '.')])) {
486 $pArray[$cEl['uid'] . '.'] = array();
487 }
488 $this->setInPageArray($pArray[$cEl['uid'] . '.'], $rlArr, $row);
489 } else {
490 $pArray[$cEl['uid'] . '_'] = $row;
491 }
492 }
493
494 /**
495 * Render the list
496 *
497 * @param array $pArray
498 * @param array $lines
499 * @param integer $c
500 * @return array
501 * @todo Define visibility
502 */
503 public function renderList($pArray, $lines = array(), $c = 0) {
504 if (is_array($pArray)) {
505 reset($pArray);
506 static $i;
507 foreach ($pArray as $k => $v) {
508 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($k)) {
509 if (isset($pArray[$k . '_'])) {
510 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
511 <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>
512 <td align="center">' . $pArray[($k . '_')]['count'] . '</td>
513 <td align="center" class="bgColor5">' . ($pArray[$k . '_']['root_max_val'] > 0 ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '&nbsp;') . '</td>
514 <td align="center">' . ($pArray[$k . '_']['root_min_val'] == 0 ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('status-status-checked') : '&nbsp;') . '</td>
515 </tr>';
516 } else {
517 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
518 <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>
519 <td align="center"></td>
520 <td align="center" class="bgColor5"></td>
521 <td align="center"></td>
522 </tr>';
523 }
524 $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1);
525 }
526 }
527 }
528 return $lines;
529 }
530
531 }
532
533 ?>