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