[BUGFIX] Add jumpToUrl Javascript in TyposcriptTemplateModule
[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 if ($this->getBackendUser()->mayMakeShortcut()) {
418 $shortcutButton = $buttonBar->makeFullyRenderedButton()
419 ->setHtmlSource($this->moduleTemplate->makeShortcutIcon('id', '', $this->MCONF['name']));
420 $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT, 99);
421 }
422 }
423
424 // OTHER FUNCTIONS:
425 /**
426 * Wrap title for link in template
427 *
428 * @param string $title
429 * @param string $onlyKey
430 * @return string
431 */
432 public function linkWrapTemplateTitle($title, $onlyKey = '')
433 {
434 $urlParameters = array(
435 'id' => $this->id
436 );
437 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
438 if ($onlyKey) {
439 $title = '<a href="' . htmlspecialchars(($aHref . '&e[' . $onlyKey . ']=1&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController')) . '">' . htmlspecialchars($title) . '</a>';
440 } else {
441 $title = '<a href="' . htmlspecialchars(($aHref . '&e[constants]=1&e[config]=1&SET[function]=TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController')) . '">' . htmlspecialchars($title) . '</a>';
442 }
443 return $title;
444 }
445
446 /**
447 * No template
448 *
449 * @param int $newStandardTemplate
450 * @return string
451 */
452 public function noTemplate($newStandardTemplate = 0)
453 {
454 // Defined global here!
455 /** @var ExtendedTemplateService $tmpl */
456 $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
457 $GLOBALS['tmpl'] = $tmpl;
458
459 // Do not log time-performance information
460 $tmpl->tt_track = false;
461 $tmpl->init();
462
463 $lang = $this->getLanguageService();
464
465 $title = $lang->getLL('noTemplate');
466 $message = '<p>' . $lang->getLL('noTemplateDescription') . '<br />' . $lang->getLL('createTemplateToEditConfiguration') . '</p>';
467
468 $view = GeneralUtility::makeInstance(StandaloneView::class);
469 $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:tstemplate/Resources/Private/Templates/InfoBox.html'));
470 $view->assignMultiple(array(
471 'title' => $title,
472 'message' => $message,
473 'state' => InfoboxViewHelper::STATE_INFO
474 ));
475 $theOutput = $view->render();
476
477 // New standard?
478 if ($newStandardTemplate) {
479 // Hook to change output, implemented for statictemplates
480 if (isset(
481 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateView']
482 )) {
483 $selector = '';
484 $staticsText = '';
485 $reference = array(
486 'selectorHtml' => &$selector,
487 'staticsText' => &$staticsText
488 );
489 GeneralUtility::callUserFunction(
490 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateView'],
491 $reference,
492 $this
493 );
494 $selector = $reference['selectorHtml'];
495 $staticsText = $reference['staticsText'];
496 } else {
497 $selector = '<input type="hidden" name="createStandard" value="" />';
498 $staticsText = '';
499 }
500 // Extension?
501 $theOutput .= $this->moduleTemplate->section(
502 $lang->getLL('newWebsite') . $staticsText,
503 '<p>' . $lang->getLL('newWebsiteDescription') . '</p>' . $selector . '<input class="btn btn-primary" type="submit" name="newWebsite" value="' . $lang->getLL('newWebsiteAction') . '" />',
504 0, 1);
505 }
506 // Extension?
507 $theOutput .= $this->moduleTemplate->section(
508 $lang->getLL('extTemplate'),
509 '<p>' . $lang->getLL('extTemplateDescription') . '</p>' . '<input class="btn btn-default" type="submit" name="createExtension" value="' . $lang->getLL('extTemplateAction') . '" />',
510 0, 1);
511 // Go to first appearing...
512 $first = $tmpl->ext_prevPageWithTemplate($this->id, $this->perms_clause);
513 if ($first) {
514 $urlParameters = array(
515 'id' => $first['uid']
516 );
517 $aHref = BackendUtility::getModuleUrl('web_ts', $urlParameters);
518 $theOutput .= $this->moduleTemplate->section(
519 $lang->getLL('goToClosest'),
520 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>'),
521 0, 1);
522 }
523 return $theOutput;
524 }
525
526 /**
527 * Render template menu
528 *
529 * @return string
530 */
531 public function templateMenu()
532 {
533 /** @var ExtendedTemplateService $tmpl */
534 $tmpl = GeneralUtility::makeInstance(ExtendedTemplateService::class);
535 $GLOBALS['tmpl'] = $tmpl;
536
537 // Do not log time-performance information
538 $tmpl->tt_track = false;
539 $tmpl->init();
540
541 $all = $tmpl->ext_getAllTemplates($this->id, $this->perms_clause);
542 if (count($all) > 1) {
543 $this->MOD_MENU['templatesOnPage'] = array();
544 foreach ($all as $d) {
545 $this->MOD_MENU['templatesOnPage'][$d['uid']] = $d['title'];
546 }
547 }
548 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
549 return BackendUtility::getFuncMenu($this->id, 'SET[templatesOnPage]', $this->MOD_SETTINGS['templatesOnPage'], $this->MOD_MENU['templatesOnPage']);
550 }
551
552 /**
553 * Create template
554 *
555 * @param int $id
556 * @param int $actTemplateId
557 * @return string
558 */
559 public function createTemplate($id, $actTemplateId = 0)
560 {
561 $recData = array();
562 /** @var DataHandler $tce */
563 $tce = GeneralUtility::makeInstance(DataHandler::class);
564 $tce->stripslashes_values = false;
565
566 if (GeneralUtility::_GP('createExtension')) {
567 $recData['sys_template']['NEW'] = array(
568 'pid' => $actTemplateId ? -1 * $actTemplateId : $id,
569 'title' => '+ext'
570 );
571 $tce->start($recData, array());
572 $tce->process_datamap();
573 } elseif (GeneralUtility::_GP('newWebsite')) {
574 // Hook to handle row data, implemented for statictemplates
575 if (isset(
576 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateHandler']
577 )) {
578 $reference = array(
579 'recData' => &$recData,
580 'id' => $id,
581 );
582 GeneralUtility::callUserFunction(
583 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][TypoScriptTemplateModuleController::class]['newStandardTemplateHandler'],
584 $reference,
585 $this
586 );
587 $recData = $reference['recData'];
588 } else {
589 $recData['sys_template']['NEW'] = array(
590 'pid' => $id,
591 'title' => $this->getLanguageService()->getLL('titleNewSite'),
592 'sorting' => 0,
593 'root' => 1,
594 'clear' => 3,
595 'config' => '
596 # Default PAGE object:
597 page = PAGE
598 page.10 = TEXT
599 page.10.value = HELLO WORLD!
600 '
601 );
602 }
603 $tce->start($recData, array());
604 $tce->process_datamap();
605 $tce->clear_cacheCmd('all');
606 }
607 return $tce->substNEWwithIDs['NEW'];
608 }
609
610 // RENDER LIST of pages with templates, BEGIN
611 /**
612 * Set page in array
613 *
614 * @param array $pArray
615 * @param array $rlArr
616 * @param array $row
617 * @return void
618 */
619 public function setInPageArray(&$pArray, $rlArr, $row)
620 {
621 ksort($rlArr);
622 reset($rlArr);
623 if (!$rlArr[0]['uid']) {
624 array_shift($rlArr);
625 }
626 $cEl = current($rlArr);
627 $pArray[$cEl['uid']] = htmlspecialchars($cEl['title']);
628 array_shift($rlArr);
629 if (!empty($rlArr)) {
630 if (!isset($pArray[($cEl['uid'] . '.')])) {
631 $pArray[$cEl['uid'] . '.'] = array();
632 }
633 $this->setInPageArray($pArray[$cEl['uid'] . '.'], $rlArr, $row);
634 } else {
635 $pArray[$cEl['uid'] . '_'] = $row;
636 }
637 }
638
639 /**
640 * Render the list
641 *
642 * @param array $pArray
643 * @param array $lines
644 * @param int $c
645 * @return array
646 */
647 public function renderList($pArray, $lines = array(), $c = 0)
648 {
649 static $i;
650
651 if (!is_array($pArray)) {
652 return $lines;
653 }
654
655 $statusCheckedIcon = $this->iconFactory->getIcon('status-status-checked', Icon::SIZE_SMALL)->render();
656 foreach ($pArray as $k => $v) {
657 if (MathUtility::canBeInterpretedAsInteger($k)) {
658 if (isset($pArray[$k . '_'])) {
659 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
660 <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>
661 <td>' . $pArray[($k . '_')]['count'] . '</td>
662 <td>' . ($pArray[$k . '_']['root_max_val'] > 0 ? $statusCheckedIcon : '&nbsp;') . '</td>
663 <td>' . ($pArray[$k . '_']['root_min_val'] == 0 ? $statusCheckedIcon : '&nbsp;') . '</td>
664 </tr>';
665 } else {
666 $lines[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
667 <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>
668 <td></td>
669 <td></td>
670 <td></td>
671 </tr>';
672 }
673 $lines = $this->renderList($pArray[$k . '.'], $lines, $c + 1);
674 }
675 }
676 return $lines;
677 }
678 }