0597f81daa76861313f0f026dd7be9d1856db004
[Packages/TYPO3.CMS.git] / typo3 / sysext / tstemplate / Classes / Controller / TypoScriptTemplateModuleController.php
1 <?php
2 namespace TYPO3\CMS\Tstemplate\Controller;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Backend\Module\BaseScriptClass;
20 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
21 use TYPO3\CMS\Backend\Template\DocumentTemplate;
22 use TYPO3\CMS\Backend\Template\ModuleTemplate;
23 use TYPO3\CMS\Core\DataHandling\DataHandler;
24 use TYPO3\CMS\Core\Imaging\Icon;
25 use TYPO3\CMS\Core\Imaging\IconFactory;
26 use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
27 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
28 use TYPO3\CMS\Core\Utility\GeneralUtility;
29 use TYPO3\CMS\Backend\Utility\BackendUtility;
30 use TYPO3\CMS\Core\Utility\MathUtility;
31 use TYPO3\CMS\Fluid\View\StandaloneView;
32 use TYPO3\CMS\Fluid\ViewHelpers\Be\InfoboxViewHelper;
33
34 /**
35 * Module: TypoScript Tools
36 *
37 * $TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"] = Directory of default resources. Eg. "fileadmin/res/" or so.
38 */
39 class TypoScriptTemplateModuleController extends BaseScriptClass
40 {
41 /**
42 * @var string
43 */
44 public $perms_clause;
45
46 /**
47 * @var string
48 */
49 public $e;
50
51 /**
52 * @var string
53 */
54 public $sObj;
55
56 /**
57 * @var string
58 */
59 public $edit;
60
61 /**
62 * @var string
63 */
64 public $textExtensions = 'html,htm,txt,css,tmpl,inc,js';
65
66 /**
67 * @var string
68 */
69 public $modMenu_type = '';
70
71 /**
72 * @var string
73 */
74 public $modMenu_dontValidateList = '';
75
76 /**
77 * @var string
78 */
79 public $modMenu_setDefaultList = '';
80
81 /**
82 * @var array
83 */
84 public $pageinfo = array();
85
86 /**
87 * @var bool
88 */
89 public $access = false;
90
91 /**
92 * The name of the module
93 *
94 * @var string
95 */
96 protected $moduleName = 'web_ts';
97
98 /**
99 * @var IconFactory
100 */
101 protected $iconFactory;
102
103 /**
104 * ModuleTemplate Container
105 *
106 * @var ModuleTemplate
107 */
108 protected $moduleTemplate;
109
110 /**
111 * Constructor
112 */
113 public function __construct()
114 {
115 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
116 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
117 $this->getLanguageService()->includeLLFile('EXT:tstemplate/Resources/Private/Language/locallang.xlf');
118
119 $this->MCONF = array(
120 'name' => $this->moduleName
121 );
122 $this->moduleTemplate->addJavaScriptCode(
123 'jumpToUrl',
124 '
125 function jumpToUrl(URL) {
126 window.location.href = URL;
127 return false;
128 }
129 '
130 );
131 }
132
133 /**
134 * Init
135 *
136 * @return void
137 */
138 public function init()
139 {
140 parent::init();
141 $this->id = (int)GeneralUtility::_GP('id');
142 $this->e = GeneralUtility::_GP('e');
143 $this->sObj = GeneralUtility::_GP('sObj');
144 $this->edit = GeneralUtility::_GP('edit');
145 $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
146 }
147
148 /**
149 * Clear cache
150 *
151 * @return void
152 */
153 public function clearCache()
154 {
155 if (GeneralUtility::_GP('clear_all_cache')) {
156 /** @var DataHandler $tce */
157 $tce = GeneralUtility::makeInstance(DataHandler::class);
158 $tce->stripslashes_values = false;
159 $tce->start(array(), array());
160 $tce->clear_cacheCmd('all');
161 }
162 }
163
164 /**
165 * Main
166 *
167 * @return void
168 */
169 public function main()
170 {
171 // Template markers
172 $markers = array(
173 'CSH' => '',
174 'FUNC_MENU' => '',
175 'CONTENT' => ''
176 );
177
178 // Access check...
179 // The page will show only if there is a valid page and if this page may be viewed by the user
180 $this->pageinfo = BackendUtility::readPageAccess($this->id, $this->perms_clause);
181 $this->access = is_array($this->pageinfo);
182
183 /** @var DocumentTemplate doc */
184 $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
185 $this->moduleTemplate->getPageRenderer()->addCssFile(ExtensionManagementUtility::extRelPath('tstemplate') . 'Resources/Public/Css/styles.css');
186
187 $lang = $this->getLanguageService();
188
189 if ($this->id && $this->access) {
190 $urlParameters = array(
191 'id' => $this->id,
192 'template' => 'all'
193 );
194 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
195 $this->moduleTemplate->setForm('<form action="' . htmlspecialchars($aHref) . '" method="post" enctype="multipart/form-data" name="editForm" class="form">');
196
197 // JavaScript
198 $this->moduleTemplate->addJavaScriptCode(
199 'TSTemplateInlineJS', '
200 function uFormUrl(aname) {
201 document.forms[0].action = ' . GeneralUtility::quoteJSvalue(($aHref . '#')) . '+aname;
202 }
203 function brPoint(lnumber,t) {
204 window.location.href = ' . GeneralUtility::quoteJSvalue(($aHref . '&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateObjectBrowserModuleFunctionController&SET[ts_browser_type]=')) . '+(t?"setup":"const")+"&breakPointLN="+lnumber;
205 return false;
206 }
207 if (top.fsMod) top.fsMod.recentIds["web"] = ' . $this->id . ';
208 ');
209 $this->moduleTemplate->getPageRenderer()->addCssInlineBlock(
210 'TSTemplateInlineStyle', '
211 TABLE#typo3-objectBrowser { width: 100%; margin-bottom: 24px; }
212 TABLE#typo3-objectBrowser A { text-decoration: none; }
213 TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
214 .ts-typoscript { width: 100%; }
215 .tsob-search-submit {margin-left: 3px; margin-right: 3px;}
216 .tst-analyzer-options { margin:5px 0; }
217 ');
218 // Setting up the context sensitive menu:
219 $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ClickMenu');
220 // Build the module content
221 $this->content = $this->doc->header($lang->getLL('moduleTitle'));
222 $this->extObjContent();
223 // Setting up the buttons and markers for docheader
224 $this->getButtons();
225 $this->generateMenu();
226 } else {
227 // Template pages:
228 $records = $this->getDatabaseConnection()->exec_SELECTgetRows(
229 'pages.uid, count(*) AS count, max(sys_template.root) AS root_max_val, min(sys_template.root) AS root_min_val',
230 'pages,sys_template',
231 'pages.uid=sys_template.pid'
232 . BackendUtility::deleteClause('pages')
233 . BackendUtility::versioningPlaceholderClause('pages')
234 . BackendUtility::deleteClause('sys_template')
235 . BackendUtility::versioningPlaceholderClause('sys_template'),
236 'pages.uid',
237 'pages.pid, pages.sorting'
238 );
239 $pArray = array();
240 foreach ($records as $record) {
241 $this->setInPageArray($pArray, BackendUtility::BEgetRootLine($record['uid'], 'AND 1=1'), $record);
242 }
243
244 $table = '<div class="table-fit"><table class="table table-striped table-hover" id="ts-overview">' .
245 '<thead>' .
246 '<tr>' .
247 '<th>' . $lang->getLL('pageName') . '</th>' .
248 '<th>' . $lang->getLL('templates') . '</th>' .
249 '<th>' . $lang->getLL('isRoot') . '</th>' .
250 '<th>' . $lang->getLL('isExt') . '</th>' .
251 '</tr>' .
252 '</thead>' .
253 '<tbody>' . implode('', $this->renderList($pArray)) . '</tbody>' .
254 '</table></div>';
255
256 $this->content = $this->doc->header($lang->getLL('moduleTitle'));
257 $this->content .= $this->moduleTemplate->section('', '<p class="lead">' . $lang->getLL('overview') . '</p>' . $table);
258
259 // RENDER LIST of pages with templates, END
260 // Setting up the buttons and markers for docheader
261 $this->getButtons();
262 }
263 }
264
265 /**
266 * Generates the menu based on $this->MOD_MENU
267 *
268 * @return void
269 * @throws \InvalidArgumentException
270 */
271 protected function generateMenu()
272 {
273 $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
274 $menu->setIdentifier('WebFuncJumpMenu');
275 foreach ($this->MOD_MENU['function'] as $controller => $title) {
276 $item = $menu
277 ->makeMenuItem()
278 ->setHref(
279 BackendUtility::getModuleUrl(
280 $this->moduleName,
281 [
282 'id' => $this->id,
283 'SET' => [
284 'function' => $controller
285 ]
286 ]
287 )
288 )
289 ->setTitle($title);
290 if ($controller === $this->MOD_SETTINGS['function']) {
291 $item->setActive(true);
292 }
293 $menu->addMenuItem($item);
294 }
295 $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
296 }
297
298 /**
299 * Injects the request object for the current request or subrequest
300 * Then checks for module functions that have hooked in, and renders menu etc.
301 *
302 * @param ServerRequestInterface $request the current request
303 * @param ResponseInterface $response
304 * @return ResponseInterface the response with the content
305 */
306 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
307 {
308 $GLOBALS['SOBE'] = $this;
309 $this->init();
310
311 // Checking for first level external objects
312 $this->checkExtObj();
313
314 $this->clearCache();
315 $this->main();
316
317 $this->moduleTemplate->setContent($this->content);
318 $response->getBody()->write($this->moduleTemplate->renderContent());
319 return $response;
320 }
321
322 /**
323 * Print content
324 *
325 * @return void
326 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
327 */
328 public function printContent()
329 {
330 GeneralUtility::logDeprecatedFunction();
331 echo $this->content;
332 }
333
334 /**
335 * Create the panel of buttons for submitting the form or otherwise perform operations.
336 *
337 * @return array All available buttons as an assoc. array
338 */
339 protected function getButtons()
340 {
341 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
342 $lang = $this->getLanguageService();
343
344 if ($this->id && $this->access) {
345 // View page
346 $viewButton = $buttonBar->makeLinkButton()
347 ->setHref('#')
348 ->setOnClick(BackendUtility::viewOnClick($this->pageinfo['uid'], '', BackendUtility::BEgetRootLine($this->pageinfo['uid'])))
349 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', true))
350 ->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL));
351 $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 99);
352 if ($this->extClassConf['name'] === TypoScriptTemplateInformationModuleFunctionController::class) {
353 // NEW button
354 $urlParameters = array(
355 'id' => $this->id,
356 'template' => 'all',
357 'createExtension' => 'new'
358 );
359
360 if (!empty($this->e) && !GeneralUtility::_POST('_saveandclosedok')) {
361 $saveButton = $buttonBar->makeInputButton()
362 ->setName('_savedok')
363 ->setValue('1')
364 ->setIcon($this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL))
365 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', true));
366
367 $saveAndCloseButton = $buttonBar->makeInputButton()
368 ->setName('_saveandclosedok')
369 ->setValue('1')
370 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveCloseDoc', true))
371 ->setIcon($this->iconFactory->getIcon('actions-document-save-close', Icon::SIZE_SMALL));
372
373 $splitButtonElement = $buttonBar->makeSplitButton()
374 ->addItem($saveButton)
375 ->addItem($saveAndCloseButton);
376
377 $buttonBar->addButton($splitButtonElement, ButtonBar::BUTTON_POSITION_LEFT, 3);
378
379 // CLOSE button
380 $closeButton = $buttonBar->makeLinkButton()
381 ->setHref(BackendUtility::getModuleUrl('web_ts', array('id' => $this->id)))
382 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', true))
383 ->setIcon($this->iconFactory->getIcon('actions-document-close', Icon::SIZE_SMALL));
384 $buttonBar->addButton($closeButton);
385 } else {
386 $newButton = $buttonBar->makeLinkButton()
387 ->setHref(BackendUtility::getModuleUrl('web_ts', $urlParameters))
388 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:db_new.php.pagetitle', true))
389 ->setIcon($this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL));
390 $buttonBar->addButton($newButton);
391 }
392 } elseif ($this->extClassConf['name'] === TypoScriptTemplateConstantEditorModuleFunctionController::class && !empty($this->MOD_MENU['constant_editor_cat'])) {
393 // SAVE button
394 $saveButton = $buttonBar->makeInputButton()
395 ->setName('_savedok')
396 ->setValue('1')
397 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDoc', true))
398 ->setIcon($this->iconFactory->getIcon('actions-document-save', Icon::SIZE_SMALL))
399 ->setShowLabelText(true);
400 $buttonBar->addButton($saveButton);
401 } elseif ($this->extClassConf['name'] === TypoScriptTemplateObjectBrowserModuleFunctionController::class) {
402 if (!empty($this->sObj)) {
403 // BACK
404 $urlParameters = array(
405 'id' => $this->id
406 );
407 $backButton = $buttonBar->makeLinkButton()
408 ->setHref(BackendUtility::getModuleUrl('web_ts', $urlParameters))
409 ->setClasses('typo3-goBack')
410 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', true))
411 ->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
412 $buttonBar->addButton($backButton);
413 }
414 }
415 }
416 // Shortcut
417 $shortcutButton = $buttonBar->makeShortcutButton()
418 ->setModuleName($this->MCONF['name'])
419 ->setGetVariables(['id']);
420 $buttonBar->addButton($shortcutButton);
421 }
422
423 // OTHER FUNCTIONS:
424 /**
425 * Wrap title for link in template
426 *
427 * @param string $title
428 * @param string $onlyKey
429 * @return string
430 */
431 public function linkWrapTemplateTitle($title, $onlyKey = '')
432 {
433 $urlParameters = array(
434 'id' => $this->id
435 );
436 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
437 if ($onlyKey) {
438 $title = '<a href="' . htmlspecialchars(($aHref . '&e[' . $onlyKey . ']=1&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController')) . '">' . htmlspecialchars($title) . '</a>';
439 } else {
440 $title = '<a href="' . htmlspecialchars(($aHref . '&e[constants]=1&e[config]=1&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController')) . '">' . htmlspecialchars($title) . '</a>';
441 }
442 return $title;
443 }
444
445 /**
446 * No template
447 *
448 * @param int $newStandardTemplate
449 * @return string
450 */
451 public function noTemplate($newStandardTemplate = 0)
452 {
453 // Defined global here!
454 /** @var ExtendedTemplateService $tmpl */
455 $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
456 $GLOBALS['tmpl'] = $tmpl;
457
458 // Do not log time-performance information
459 $tmpl->tt_track = false;
460 $tmpl->init();
461
462 $lang = $this->getLanguageService();
463
464 $title = $lang->getLL('noTemplate');
465 $message = '<p>' . $lang->getLL('noTemplateDescription') . '<br />' . $lang->getLL('createTemplateToEditConfiguration') . '</p>';
466
467 $view = GeneralUtility::makeInstance(StandaloneView::class);
468 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html'));
469 $view->assignMultiple(array(
470 'title' => $title,
471 'message' => $message,
472 'state' => InfoboxViewHelper::STATE_INFO
473 ));
474 $theOutput = $view->render();
475
476 // New standard?
477 if ($newStandardTemplate) {
478 // Hook to change output, implemented for statictemplates
479 if (isset(
480 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateView']
481 )) {
482 $selector = '';
483 $staticsText = '';
484 $reference = array(
485 'selectorHtml' => &$selector,
486 'staticsText' => &$staticsText
487 );
488 GeneralUtility::callUserFunction(
489 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateView'],
490 $reference,
491 $this
492 );
493 $selector = $reference['selectorHtml'];
494 $staticsText = $reference['staticsText'];
495 } else {
496 $selector = '<input type="hidden" name="createStandard" value="" />';
497 $staticsText = '';
498 }
499 // Extension?
500 $theOutput .= $this->moduleTemplate->section(
501 $lang->getLL('newWebsite') . $staticsText,
502 '<p>' . $lang->getLL('newWebsiteDescription') . '</p>' . $selector . '<input class="btn btn-primary" type="submit" name="newWebsite" value="' . $lang->getLL('newWebsiteAction') . '" />',
503 0, 1);
504 }
505 // Extension?
506 $theOutput .= $this->moduleTemplate->section(
507 $lang->getLL('extTemplate'),
508 '<p>' . $lang->getLL('extTemplateDescription') . '</p>' . '<input class="btn btn-default" type="submit" name="createExtension" value="' . $lang->getLL('extTemplateAction') . '" />',
509 0, 1);
510 // Go to first appearing...
511 $first = $tmpl->ext_prevPageWithTemplate($this->id, $this->perms_clause);
512 if ($first) {
513 $urlParameters = array(
514 'id' => $first['uid']
515 );
516 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
517 $theOutput .= $this->moduleTemplate->section(
518 $lang->getLL('goToClosest'),
519 sprintf('<p>' . $lang->getLL('goToClosestDescription') . '</p>%s' . $lang->getLL('goToClosestAction') . '%s', htmlspecialchars($first['title']), $first['uid'], '<a class="btn btn-default" href="' . htmlspecialchars($aHref) . '">', '</a>'),
520 0, 1);
521 }
522 return $theOutput;
523 }
524
525 /**
526 * Render template menu
527 *
528 * @return string
529 */
530 public function templateMenu()
531 {
532 /** @var ExtendedTemplateService $tmpl */
533 $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
534 $GLOBALS['tmpl'] = $tmpl;
535
536 // Do not log time-performance information
537 $tmpl->tt_track = false;
538 $tmpl->init();
539
540 $all = $tmpl->ext_getAllTemplates($this->id, $this->perms_clause);
541 if (count($all) > 1) {
542 $this->MOD_MENU['templatesOnPage'] = array();
543 foreach ($all as $d) {
544 $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
545 }
546 }
547 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
548 return BackendUtility::getFuncMenu($this->id, 'SET[templatesOnPage]', $this->MOD_SETTINGS['templatesOnPage'], $this->MOD_MENU['templatesOnPage']);
549 }
550
551 /**
552 * Create template
553 *
554 * @param int $id
555 * @param int $actTemplateId
556 * @return string
557 */
558 public function createTemplate($id, $actTemplateId = 0)
559 {
560 $recData = array();
561 /** @var DataHandler $tce */
562 $tce = GeneralUtility::makeInstance(DataHandler::class);
563 $tce->stripslashes_values = false;
564
565 if (GeneralUtility::_GP('createExtension')) {
566 $recData['sys_template']['NEW'] = array(
567 'pid' => $actTemplateId ? -1 * $actTemplateId : $id,
568 'title' => '+ext'
569 );
570 $tce->start($recData, array());
571 $tce->process_datamap();
572 } elseif (GeneralUtility::_GP('newWebsite')) {
573 // Hook to handle row data, implemented for statictemplates
574 if (isset(
575 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateHandler']
576 )) {
577 $reference = array(
578 'recData' => &$recData,
579 'id' => $id,
580 );
581 GeneralUtility::callUserFunction(
582 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateHandler'],
583 $reference,
584 $this
585 );
586 $recData = $reference['recData'];
587 } else {
588 $recData['sys_template']['NEW'] = array(
589 'pid' => $id,
590 'title' => $this->getLanguageService()->getLL('titleNewSite'),
591 'sorting' => 0,
592 'root' => 1,
593 'clear' => 3,
594 'config' => '
595 # Default PAGE object:
596 page = PAGE
597 page.10 = TEXT
598 page.10.value = HELLO WORLD!
599 '
600 );
601 }
602 $tce->start($recData, array());
603 $tce->process_datamap();
604 $tce->clear_cacheCmd('all');
605 }
606 return $tce->substNEWwithIDs['NEW'];
607 }
608
609 // RENDER LIST of pages with templates, BEGIN
610 /**
611 * Set page in array
612 *
613 * @param array $pArray
614 * @param array $rlArr
615 * @param array $row
616 * @return void
617 */
618 public function setInPageArray(&$pArray, $rlArr, $row)
619 {
620 ksort($rlArr);
621 reset($rlArr);
622 if (!$rlArr[0]['uid']) {
623 array_shift($rlArr);
624 }
625 $cEl = current($rlArr);
626 $pArray[$cEl['uid']] = htmlspecialchars($cEl['title']);
627 array_shift($rlArr);
628 if (!empty($rlArr)) {
629 if (!isset($pArray[($cEl['uid'] . '.')])) {
630 $pArray[$cEl['uid'] . '.'] = array();
631 }
632 $this->setInPageArray($pArray[$cEl['uid'] . '.'], $rlArr, $row);
633 } else {
634 $pArray[$cEl['uid'] . '_'] = $row;
635 }
636 }
637
638 /**
639 * Render the list
640 *
641 * @param array $pArray
642 * @param array $lines
643 * @param int $c
644 * @return array
645 */
646 public function renderList($pArray, $lines = array(), $c = 0)
647 {
648 static $i;
649
650 if (!is_array($pArray)) {
651 return $lines;
652 }
653
654 $statusCheckedIcon = $this->iconFactory->getIcon('status-status-checked', Icon::SIZE_SMALL)->render();
655 foreach ($pArray as $k => $v) {
656 if (MathUtility::canBeInterpretedAsInteger($k)) {
657 if (isset($pArray[$k . '_'])) {
658 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
659 <td nowrap><span style="width: 1px; height: 1px; display:inline-block; margin-left: ' . $c * 20 . 'px"></span>' . '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('id' => $k))) . '" title="' . htmlspecialchars('ID: ' . $k) . '">' . $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $k), Icon::SIZE_SMALL)->render() . GeneralUtility::fixed_lgd_cs($pArray[$k], 30) . '</a></td>
660 <td>' . $pArray[($k . '_')]['count'] . '</td>
661 <td>' . ($pArray[$k . '_']['root_max_val'] > 0 ? $statusCheckedIcon : '&nbsp;') . '</td>
662 <td>' . ($pArray[$k . '_']['root_min_val'] == 0 ? $statusCheckedIcon : '&nbsp;') . '</td>
663 </tr>';
664 } else {
665 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
666 <td nowrap><span style="width: 1px; height: 1px; display:inline-block; margin-left: ' . $c * 20 . 'px"></span>' . $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $k), Icon::SIZE_SMALL)->render() . GeneralUtility::fixed_lgd_cs($pArray[$k], 30) . '</td>
667 <td></td>
668 <td></td>
669 <td></td>
670 </tr>';
671 }
672 $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1);
673 }
674 }
675 return $lines;
676 }
677 }