5468bc3f338da2edfce970364447fd256e70b0e2
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / PageLayoutView.php
1 <?php
2
3 namespace TYPO3\CMS\Backend\View;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use Doctrine\DBAL\Driver\Statement;
19 use Psr\Log\LoggerAwareInterface;
20 use Psr\Log\LoggerAwareTrait;
21 use TYPO3\CMS\Backend\Controller\Page\LocalizationController;
22 use TYPO3\CMS\Backend\Controller\PageLayoutController;
23 use TYPO3\CMS\Backend\Routing\UriBuilder;
24 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
25 use TYPO3\CMS\Backend\Utility\BackendUtility;
26 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
27 use TYPO3\CMS\Core\Database\Connection;
28 use TYPO3\CMS\Core\Database\ConnectionPool;
29 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
30 use TYPO3\CMS\Core\Database\Query\QueryHelper;
31 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
32 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
33 use TYPO3\CMS\Core\Database\ReferenceIndex;
34 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
35 use TYPO3\CMS\Core\Imaging\Icon;
36 use TYPO3\CMS\Core\Imaging\IconFactory;
37 use TYPO3\CMS\Core\Localization\LanguageService;
38 use TYPO3\CMS\Core\Messaging\FlashMessage;
39 use TYPO3\CMS\Core\Messaging\FlashMessageService;
40 use TYPO3\CMS\Core\Page\PageRenderer;
41 use TYPO3\CMS\Core\Service\DependencyOrderingService;
42 use TYPO3\CMS\Core\Service\FlexFormService;
43 use TYPO3\CMS\Core\Site\Entity\NullSite;
44 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
45 use TYPO3\CMS\Core\Site\SiteFinder;
46 use TYPO3\CMS\Core\Type\Bitmask\Permission;
47 use TYPO3\CMS\Core\Utility\GeneralUtility;
48 use TYPO3\CMS\Core\Utility\HttpUtility;
49 use TYPO3\CMS\Core\Utility\MathUtility;
50 use TYPO3\CMS\Core\Utility\StringUtility;
51 use TYPO3\CMS\Core\Versioning\VersionState;
52 use TYPO3\CMS\Fluid\View\StandaloneView;
53
54 /**
55 * Child class for the Web > Page module
56 * @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API.
57 */
58 class PageLayoutView implements LoggerAwareInterface
59 {
60 use LoggerAwareTrait;
61
62 /**
63 * If TRUE, users/groups are shown in the page info box.
64 *
65 * @var bool
66 */
67 public $pI_showUser = false;
68
69 /**
70 * The number of successive records to edit when showing content elements.
71 *
72 * @var int
73 */
74 public $nextThree = 3;
75
76 /**
77 * If TRUE, disables the edit-column icon for tt_content elements
78 *
79 * @var bool
80 */
81 public $pages_noEditColumns = false;
82
83 /**
84 * If TRUE, new-wizards are linked to rather than the regular new-element list.
85 *
86 * @var bool
87 */
88 public $option_newWizard = true;
89
90 /**
91 * If set to "1", will link a big button to content element wizard.
92 *
93 * @var int
94 */
95 public $ext_function = 0;
96
97 /**
98 * If TRUE, elements will have edit icons (probably this is whether the user has permission to edit the page content). Set externally.
99 *
100 * @var bool
101 */
102 public $doEdit = true;
103
104 /**
105 * Age prefixes for displaying times. May be set externally to localized values.
106 *
107 * @var string
108 */
109 public $agePrefixes = ' min| hrs| days| yrs| min| hour| day| year';
110
111 /**
112 * Array of tables to be listed by the Web > Page module in addition to the default tables.
113 *
114 * @var array
115 */
116 public $externalTables = [];
117
118 /**
119 * "Pseudo" Description -table name
120 *
121 * @var string
122 */
123 public $descrTable;
124
125 /**
126 * If set TRUE, the language mode of tt_content elements will be rendered with hard binding between
127 * default language content elements and their translations!
128 *
129 * @var bool
130 */
131 public $defLangBinding = false;
132
133 /**
134 * External, static: Configuration of tt_content element display:
135 *
136 * @var array
137 */
138 public $tt_contentConfig = [
139 // Boolean: Display info-marks or not
140 'showInfo' => 1,
141 // Boolean: Display up/down arrows and edit icons for tt_content records
142 'showCommands' => 1,
143 'languageCols' => 0,
144 'languageMode' => 0,
145 'languageColsPointer' => 0,
146 'showHidden' => 1,
147 // Displays hidden records as well
148 'sys_language_uid' => 0,
149 // Which language
150 'cols' => '1,0,2,3',
151 'activeCols' => '1,0,2,3'
152 // Which columns can be accessed by current BE user
153 ];
154
155 /**
156 * Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
157 *
158 * @var array
159 */
160 public $activeTables = [];
161
162 /**
163 * @var array
164 */
165 public $tt_contentData = [
166 'nextThree' => [],
167 'prev' => [],
168 'next' => []
169 ];
170
171 /**
172 * Used to store labels for CTypes for tt_content elements
173 *
174 * @var array
175 */
176 public $CType_labels = [];
177
178 /**
179 * Used to store labels for the various fields in tt_content elements
180 *
181 * @var array
182 */
183 public $itemLabels = [];
184
185 /**
186 * Indicates if all available fields for a user should be selected or not.
187 *
188 * @var int
189 */
190 public $allFields = 0;
191
192 /**
193 * Number of records to show
194 *
195 * @var int
196 */
197 public $showLimit = 0;
198
199 /**
200 * Shared module configuration, used by localization features
201 *
202 * @var array
203 */
204 public $modSharedTSconfig = [];
205
206 /**
207 * Tables which should not get listed
208 *
209 * @var string
210 */
211 public $hideTables = '';
212
213 /**
214 * Containing which fields to display in extended mode
215 *
216 * @var string[]
217 */
218 public $displayFields;
219
220 /**
221 * Tables which should not list their translations
222 *
223 * @var string
224 */
225 public $hideTranslations = '';
226
227 /**
228 * If set, csvList is outputted.
229 *
230 * @var bool
231 */
232 public $csvOutput = false;
233
234 /**
235 * Cache for record path
236 *
237 * @var mixed[]
238 */
239 public $recPath_cache = [];
240
241 /**
242 * Field, to sort list by
243 *
244 * @var string
245 */
246 public $sortField;
247
248 /**
249 * default Max items shown per table in "multi-table mode", may be overridden by tables.php
250 *
251 * @var int
252 */
253 public $itemsLimitPerTable = 20;
254
255 /**
256 * Page select permissions
257 *
258 * @var string
259 */
260 public $perms_clause = '';
261
262 /**
263 * Page id
264 *
265 * @var int
266 */
267 public $id;
268
269 /**
270 * Return URL
271 *
272 * @var string
273 */
274 public $returnUrl = '';
275
276 /**
277 * Tablename if single-table mode
278 *
279 * @var string
280 */
281 public $table = '';
282
283 /**
284 * Some permissions...
285 *
286 * @var int
287 */
288 public $calcPerms = 0;
289
290 /**
291 * Mode for what happens when a user clicks the title of a record.
292 *
293 * @var string
294 */
295 public $clickTitleMode = '';
296
297 /**
298 * Levels to search down.
299 *
300 * @var int
301 */
302 public $searchLevels = '';
303
304 /**
305 * "LIMIT " in SQL...
306 *
307 * @var int
308 */
309 public $iLimit = 0;
310
311 /**
312 * Set to the total number of items for a table when selecting.
313 *
314 * @var string
315 */
316 public $totalItems = '';
317
318 /**
319 * TSconfig which overwrites TCA-Settings
320 *
321 * @var mixed[][]
322 */
323 public $tableTSconfigOverTCA = [];
324
325 /**
326 * Loaded with page record with version overlay if any.
327 *
328 * @var string[]
329 */
330 public $pageRecord = [];
331
332 /**
333 * Used for tracking duplicate values of fields
334 *
335 * @var string[]
336 */
337 public $duplicateStack = [];
338
339 /**
340 * Fields to display for the current table
341 *
342 * @var string[]
343 */
344 public $setFields = [];
345
346 /**
347 * Current script name
348 *
349 * @var string
350 */
351 public $script = 'index.php';
352
353 /**
354 * If TRUE, records are listed only if a specific table is selected.
355 *
356 * @var bool
357 */
358 public $listOnlyInSingleTableMode = false;
359
360 /**
361 * JavaScript code accumulation
362 *
363 * @var string
364 */
365 public $JScode = '';
366
367 /**
368 * Pointer for browsing list
369 *
370 * @var int
371 */
372 public $firstElementNumber = 0;
373
374 /**
375 * Counting the elements no matter what...
376 *
377 * @var int
378 */
379 public $eCounter = 0;
380
381 /**
382 * Search string
383 *
384 * @var string
385 */
386 public $searchString = '';
387
388 /**
389 * default Max items shown per table in "single-table mode", may be overridden by tables.php
390 *
391 * @var int
392 */
393 public $itemsLimitSingleTable = 100;
394
395 /**
396 * Field, indicating to sort in reverse order.
397 *
398 * @var bool
399 */
400 public $sortRev;
401
402 /**
403 * String, can contain the field name from a table which must have duplicate values marked.
404 *
405 * @var string
406 */
407 public $duplicateField;
408
409 /**
410 * Specify a list of tables which are the only ones allowed to be displayed.
411 *
412 * @var string
413 */
414 public $tableList = '';
415
416 /**
417 * Array of collapsed / uncollapsed tables in multi table view
418 *
419 * @var int[][]
420 */
421 public $tablesCollapsed = [];
422
423 /**
424 * @var array[] Module configuration
425 */
426 public $modTSconfig;
427
428 /**
429 * HTML output
430 *
431 * @var string
432 */
433 public $HTMLcode = '';
434
435 /**
436 * Thumbnails on records containing files (pictures)
437 *
438 * @var bool
439 */
440 public $thumbs = 0;
441
442 /**
443 * Used for tracking next/prev uids
444 *
445 * @var int[][]
446 */
447 public $currentTable = [];
448
449 /**
450 * OBSOLETE - NOT USED ANYMORE. leftMargin
451 *
452 * @var int
453 */
454 public $leftMargin = 0;
455
456 /**
457 * Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
458 *
459 * @var array
460 */
461 public $fieldArray = [];
462
463 /**
464 * Set to zero, if you don't want a left-margin with addElement function
465 *
466 * @var int
467 */
468 public $setLMargin = 1;
469
470 /**
471 * Contains page translation languages
472 *
473 * @var array
474 */
475 public $pageOverlays = [];
476
477 /**
478 * Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
479 *
480 * @var int
481 */
482 public $counter = 0;
483
484 /**
485 * Contains site languages for this page ID
486 *
487 * @var SiteLanguage[]
488 */
489 protected $siteLanguages = [];
490
491 /**
492 * Script URL
493 *
494 * @var string
495 */
496 public $thisScript = '';
497
498 /**
499 * If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
500 *
501 * @var string
502 */
503 public $oddColumnsCssClass = '';
504
505 /**
506 * Not used in this class - but maybe extension classes...
507 * Max length of strings
508 *
509 * @var int
510 */
511 public $fixedL = 30;
512
513 /**
514 * Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
515 *
516 * @var array
517 */
518 public $addElement_tdParams = [];
519
520 /**
521 * @var int
522 */
523 public $no_noWrap = 0;
524
525 /**
526 * @var int
527 */
528 public $showIcon = 1;
529
530 /**
531 * Keys are fieldnames and values are td-css-classes to add in addElement();
532 *
533 * @var array
534 */
535 public $addElement_tdCssClass = [];
536
537 /**
538 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
539 */
540 protected $clipboard;
541
542 /**
543 * User permissions
544 *
545 * @var int
546 */
547 public $ext_CALC_PERMS;
548
549 /**
550 * Current ids page record
551 *
552 * @var array
553 */
554 protected $pageinfo;
555
556 /**
557 * Caches the available languages in a colPos
558 *
559 * @var array
560 */
561 protected $languagesInColumnCache = [];
562
563 /**
564 * Caches the amount of content elements as a matrix
565 *
566 * @var array
567 * @internal
568 */
569 protected $contentElementCache = [];
570
571 /**
572 * @var IconFactory
573 */
574 protected $iconFactory;
575
576 /**
577 * Stores whether a certain language has translations in it
578 *
579 * @var array
580 */
581 protected $languageHasTranslationsCache = [];
582
583 /**
584 * @var LocalizationController
585 */
586 protected $localizationController;
587
588 /**
589 * Override the page ids taken into account by getPageIdConstraint()
590 *
591 * @var array
592 */
593 protected $overridePageIdList = [];
594
595 /**
596 * Override/add urlparameters in listUrl() method
597 *
598 * @var string[]
599 */
600 protected $overrideUrlParameters = [];
601
602 /**
603 * Array with before/after setting for tables
604 * Structure:
605 * 'tableName' => [
606 * 'before' => ['A', ...]
607 * 'after' => []
608 * ]
609 * @var array[]
610 */
611 protected $tableDisplayOrder = [];
612
613 /**
614 * Cache the number of references to a record
615 *
616 * @var array
617 */
618 protected $referenceCount = [];
619
620 /**
621 * Construct to initialize class variables.
622 */
623 public function __construct()
624 {
625 if (isset($GLOBALS['BE_USER']->uc['titleLen']) && $GLOBALS['BE_USER']->uc['titleLen'] > 0) {
626 $this->fixedL = $GLOBALS['BE_USER']->uc['titleLen'];
627 }
628 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
629 $this->determineScriptUrl();
630 $this->localizationController = GeneralUtility::makeInstance(LocalizationController::class);
631 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
632 $pageRenderer->addInlineLanguageLabelFile('EXT:backend/Resources/Private/Language/locallang_layout.xlf');
633 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
634 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Localization');
635 }
636
637 /*****************************************
638 *
639 * Renderings
640 *
641 *****************************************/
642 /**
643 * Adds the code of a single table
644 *
645 * @param string $table Table name
646 * @param int $id Current page id
647 * @param string $fields
648 * @return string HTML for listing.
649 */
650 public function getTable($table, $id, $fields = '')
651 {
652 if (isset($this->externalTables[$table])) {
653 return $this->getExternalTables($id, $table);
654 }
655 // Branch out based on table name:
656 switch ($table) {
657 case 'pages':
658 return $this->getTable_pages($id);
659 case 'tt_content':
660 return $this->getTable_tt_content($id);
661 default:
662 return '';
663 }
664 }
665
666 /**
667 * Renders an external table from page id
668 *
669 * @param int $id Page id
670 * @param string $table Name of the table
671 * @return string HTML for the listing
672 */
673 public function getExternalTables($id, $table)
674 {
675 $this->pageinfo = BackendUtility::readPageAccess($id, '');
676 $type = $this->getPageLayoutController()->MOD_SETTINGS[$table];
677 if (!isset($type)) {
678 $type = 0;
679 }
680 // eg. "name;title;email;company,image"
681 $fList = $this->externalTables[$table][$type]['fList'];
682 // The columns are separeted by comma ','.
683 // Values separated by semicolon ';' are shown in the same column.
684 $icon = $this->externalTables[$table][$type]['icon'];
685 $addWhere = $this->externalTables[$table][$type]['addWhere'];
686 // Create listing
687 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
688 return $out;
689 }
690
691 /**
692 * Renders records from the pages table from page id
693 * (Used to get information about the page tree content by "Web>Info"!)
694 *
695 * @param int $id Page id
696 * @return string HTML for the listing
697 */
698 public function getTable_pages($id)
699 {
700 // Initializing:
701 $out = '';
702 $lang = $this->getLanguageService();
703 // Select current page:
704 if (!$id) {
705 // The root has a pseudo record in pageinfo...
706 $row = $this->getPageLayoutController()->pageinfo;
707 } else {
708 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
709 ->getQueryBuilderForTable('pages');
710 $queryBuilder->getRestrictions()
711 ->removeAll()
712 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
713 $row = $queryBuilder
714 ->select('*')
715 ->from('pages')
716 ->where(
717 $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)),
718 $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
719 )
720 ->execute()
721 ->fetch();
722 BackendUtility::workspaceOL('pages', $row);
723 }
724 // If there was found a page:
725 if (is_array($row)) {
726 // Getting select-depth:
727 $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS['pages_levels'];
728 // Overriding a few things:
729 $this->no_noWrap = 0;
730 // Items
731 $this->eCounter = $this->firstElementNumber;
732 // Creating elements:
733 list($flag, $code) = $this->fwd_rwd_nav();
734 $out .= $code;
735 $editUids = [];
736 if ($flag) {
737 // Getting children:
738 $theRows = $this->getPageRecordsRecursive($row['uid'], $depth);
739 if ($this->getBackendUser()->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
740 $editUids[] = $row['uid'];
741 }
742 $out .= $this->pages_drawItem($row, $this->fieldArray);
743 // Traverse all pages selected:
744 foreach ($theRows as $sRow) {
745 if ($this->getBackendUser()->doesUserHaveAccess($sRow, 2)) {
746 $editUids[] = $sRow['uid'];
747 }
748 $out .= $this->pages_drawItem($sRow, $this->fieldArray);
749 }
750 $this->eCounter++;
751 }
752 // Header line is drawn
753 $theData = [];
754 $editIdList = implode(',', $editUids);
755 // Traverse fields (as set above) in order to create header values:
756 foreach ($this->fieldArray as $field) {
757 if ($editIdList
758 && isset($GLOBALS['TCA']['pages']['columns'][$field])
759 && $field !== 'uid'
760 && !$this->pages_noEditColumns
761 ) {
762 $iTitle = sprintf(
763 $lang->getLL('editThisColumn'),
764 rtrim(trim($lang->sL(BackendUtility::getItemLabel('pages', $field))), ':')
765 );
766 $urlParameters = [
767 'edit' => [
768 'pages' => [
769 $editIdList => 'edit'
770 ]
771 ],
772 'columnsOnly' => $field,
773 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
774 ];
775 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
776 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
777 $eI = '<a class="btn btn-default" href="' . htmlspecialchars($url)
778 . '" title="' . htmlspecialchars($iTitle) . '">'
779 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
780 } else {
781 $eI = '';
782 }
783 switch ($field) {
784 case 'title':
785 $theData[$field] = $eI . '&nbsp;<strong>'
786 . $lang->sL($GLOBALS['TCA']['pages']['columns'][$field]['label'])
787 . '</strong>';
788 break;
789 case 'uid':
790 $theData[$field] = '';
791 break;
792 default:
793 if (strpos($field, 'table_') === 0) {
794 $f2 = substr($field, 6);
795 if ($GLOBALS['TCA'][$f2]) {
796 $theData[$field] = '&nbsp;' .
797 '<span title="' .
798 htmlspecialchars($lang->sL($GLOBALS['TCA'][$f2]['ctrl']['title'])) .
799 '">' .
800 $this->iconFactory->getIconForRecord($f2, [], Icon::SIZE_SMALL)->render() .
801 '</span>';
802 }
803 } else {
804 $theData[$field] = $eI . '&nbsp;<strong>'
805 . htmlspecialchars($lang->sL($GLOBALS['TCA']['pages']['columns'][$field]['label']))
806 . '</strong>';
807 }
808 }
809 }
810 $out = '<div class="table-fit">'
811 . '<table class="table table-striped table-hover typo3-page-pages">'
812 . '<thead>'
813 . $this->addElement(1, '', $theData)
814 . '</thead>'
815 . '<tbody>'
816 . $out
817 . '</tbody>'
818 . '</table>'
819 . '</div>';
820 }
821 return $out;
822 }
823
824 /**
825 * Renders Content Elements from the tt_content table from page id
826 *
827 * @param int $id Page id
828 * @return string HTML for the listing
829 */
830 public function getTable_tt_content($id)
831 {
832 $expressionBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
833 ->getConnectionForTable('tt_content')
834 ->getExpressionBuilder();
835 $this->pageinfo = BackendUtility::readPageAccess($this->id, '');
836 $this->initializeLanguages();
837 $this->initializeClipboard();
838 $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(BackendUtility::getRecordTitle('pages', BackendUtility::getRecordWSOL('pages', $id), true));
839 /** @var PageRenderer $pageRenderer */
840 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
841 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/DragDrop');
842 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal');
843 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/LayoutModule/Paste');
844 $pageActionsCallback = null;
845 if ($this->isPageEditable()) {
846 $languageOverlayId = 0;
847 $pageLocalizationRecord = BackendUtility::getRecordLocalization('pages', $this->id, (int)$this->tt_contentConfig['sys_language_uid']);
848 if (is_array($pageLocalizationRecord)) {
849 $pageLocalizationRecord = reset($pageLocalizationRecord);
850 }
851 if (!empty($pageLocalizationRecord['uid'])) {
852 $languageOverlayId = $pageLocalizationRecord['uid'];
853 }
854 $pageActionsCallback = 'function(PageActions) {
855 PageActions.setPageId(' . (int)$this->id . ');
856 PageActions.setLanguageOverlayId(' . $languageOverlayId . ');
857 }';
858 }
859 $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/PageActions', $pageActionsCallback);
860 // Get labels for CTypes and tt_content element fields in general:
861 $this->CType_labels = [];
862 foreach ($GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'] as $val) {
863 $this->CType_labels[$val[1]] = $this->getLanguageService()->sL($val[0]);
864 }
865
866 $this->itemLabels = [];
867 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
868 $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
869 }
870 $languageColumn = [];
871 $out = '';
872
873 // Setting language list:
874 $langList = $this->tt_contentConfig['sys_language_uid'];
875 if ($this->tt_contentConfig['languageMode']) {
876 if ($this->tt_contentConfig['languageColsPointer']) {
877 $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
878 } else {
879 $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
880 }
881 $languageColumn = [];
882 }
883 $langListArr = GeneralUtility::intExplode(',', $langList);
884 $defaultLanguageElementsByColumn = [];
885 $defLangBinding = [];
886 // For each languages... :
887 // If not languageMode, then we'll only be through this once.
888 foreach ($langListArr as $lP) {
889 $lP = (int)$lP;
890
891 if (!isset($this->contentElementCache[$lP])) {
892 $this->contentElementCache[$lP] = [];
893 }
894
895 if (count($langListArr) === 1 || $lP === 0) {
896 $showLanguage = $expressionBuilder->in('sys_language_uid', [$lP, -1]);
897 } else {
898 $showLanguage = $expressionBuilder->eq('sys_language_uid', $lP);
899 }
900 $content = [];
901 $head = [];
902
903 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
904 $columns = $backendLayout['__colPosList'];
905 // Select content records per column
906 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, $columns, $showLanguage);
907 $cList = array_keys($contentRecordsPerColumn);
908 // For each column, render the content into a variable:
909 foreach ($cList as $columnId) {
910 if (!isset($this->contentElementCache[$lP])) {
911 $this->contentElementCache[$lP] = [];
912 }
913
914 if (!$lP) {
915 $defaultLanguageElementsByColumn[$columnId] = [];
916 }
917
918 // Start wrapping div
919 $content[$columnId] .= '<div data-colpos="' . $columnId . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
920 if (empty($contentRecordsPerColumn[$columnId])) {
921 $content[$columnId] .= ' t3-page-ce-empty';
922 }
923 $content[$columnId] .= '">';
924 // Add new content at the top most position
925 $link = '';
926 if ($this->isContentEditable()
927 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
928 ) {
929 if ($this->option_newWizard) {
930 $urlParameters = [
931 'id' => $id,
932 'sys_language_uid' => $lP,
933 'colPos' => $columnId,
934 'uid_pid' => $id,
935 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
936 ];
937 $routeName = BackendUtility::getPagesTSconfig($id)['mod.']['newContentElementWizard.']['override']
938 ?? 'new_content_element_wizard';
939 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
940 $url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
941 } else {
942 $urlParameters = [
943 'edit' => [
944 'tt_content' => [
945 $id => 'new'
946 ]
947 ],
948 'defVals' => [
949 'tt_content' => [
950 'colPos' => $columnId,
951 'sys_language_uid' => $lP
952 ]
953 ],
954 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
955 ];
956 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
957 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
958 }
959 $title = htmlspecialchars($this->getLanguageService()->getLL('newContentElement'));
960 $link = '<a href="' . htmlspecialchars($url) . '" '
961 . 'title="' . $title . '"'
962 . 'data-title="' . $title . '"'
963 . 'class="btn btn-default btn-sm ' . ($this->option_newWizard ? 't3js-toggle-new-content-element-wizard' : '') . '">'
964 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render()
965 . ' '
966 . htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>';
967 }
968 if ($this->getBackendUser()->checkLanguageAccess($lP) && $columnId !== 'unused') {
969 $content[$columnId] .= '
970 <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility::getUniqueId() . '">
971 <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-page-' . $id . '-' . StringUtility::getUniqueId() . '">'
972 . $link
973 . '</div>
974 <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
975 </div>
976 ';
977 }
978 $editUidList = '';
979 if (!isset($contentRecordsPerColumn[$columnId]) || !is_array($contentRecordsPerColumn[$columnId])) {
980 $message = GeneralUtility::makeInstance(
981 FlashMessage::class,
982 $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:error.invalidBackendLayout'),
983 '',
984 FlashMessage::WARNING
985 );
986 $service = GeneralUtility::makeInstance(FlashMessageService::class);
987 $queue = $service->getMessageQueueByIdentifier();
988 $queue->addMessage($message);
989 } else {
990 $rowArr = $contentRecordsPerColumn[$columnId];
991 $this->generateTtContentDataArray($rowArr);
992
993 foreach ((array)$rowArr as $rKey => $row) {
994 $this->contentElementCache[$lP][$columnId][$row['uid']] = $row;
995 if ($this->tt_contentConfig['languageMode']) {
996 $languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
997 }
998 if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
999 $singleElementHTML = '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
1000 if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
1001 $defaultLanguageElementsByColumn[$columnId][] = ($row['_ORIG_uid'] ?? $row['uid']);
1002 }
1003 $editUidList .= $row['uid'] . ',';
1004 $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0 && $this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP);
1005 $singleElementHTML .= $this->tt_content_drawHeader(
1006 $row,
1007 $this->tt_contentConfig['showInfo'] ? 15 : 5,
1008 $disableMoveAndNewButtons,
1009 true,
1010 $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
1011 );
1012 $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>'
1013 . $this->tt_content_drawItem($row) . '</div>';
1014 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div></div>'
1015 . $this->tt_content_drawFooter($row);
1016 $isDisabled = $this->isDisabled('tt_content', $row);
1017 $statusHidden = $isDisabled ? ' t3-page-ce-hidden t3js-hidden-record' : '';
1018 $displayNone = !$this->tt_contentConfig['showHidden'] && $isDisabled ? ' style="display: none;"' : '';
1019 $highlightHeader = '';
1020 if ($this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid']) && (int)$row['l18n_parent'] === 0) {
1021 $highlightHeader = ' t3-page-ce-danger';
1022 } elseif ($columnId === 'unused') {
1023 $highlightHeader = ' t3-page-ce-warning';
1024 }
1025 $singleElementHTML = '<div class="t3-page-ce' . $highlightHeader . ' t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-'
1026 . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '"' . $displayNone . '>' . $singleElementHTML . '</div>';
1027
1028 $singleElementHTML .= '<div class="t3-page-ce" data-colpos="' . $columnId . '">';
1029 $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-page-' . $id .
1030 '-' . StringUtility::getUniqueId() . '">';
1031 // Add icon "new content element below"
1032 if (!$disableMoveAndNewButtons
1033 && $this->isContentEditable()
1034 && $this->getBackendUser()->checkLanguageAccess($lP)
1035 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
1036 && $columnId !== 'unused'
1037 ) {
1038 // New content element:
1039 if ($this->option_newWizard) {
1040 $urlParameters = [
1041 'id' => $row['pid'],
1042 'sys_language_uid' => $row['sys_language_uid'],
1043 'colPos' => $row['colPos'],
1044 'uid_pid' => -$row['uid'],
1045 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1046 ];
1047 $routeName = BackendUtility::getPagesTSconfig($row['pid'])['mod.']['newContentElementWizard.']['override']
1048 ?? 'new_content_element_wizard';
1049 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1050 $url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
1051 } else {
1052 $urlParameters = [
1053 'edit' => [
1054 'tt_content' => [
1055 -$row['uid'] => 'new'
1056 ]
1057 ],
1058 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1059 ];
1060 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1061 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1062 }
1063 $title = htmlspecialchars($this->getLanguageService()->getLL('newContentElement'));
1064 $singleElementHTML .= '<a href="' . htmlspecialchars($url) . '" '
1065 . 'title="' . $title . '"'
1066 . 'data-title="' . $title . '"'
1067 . 'class="btn btn-default btn-sm ' . ($this->option_newWizard ? 't3js-toggle-new-content-element-wizard' : '') . '">'
1068 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render()
1069 . ' '
1070 . htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>';
1071 }
1072 $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
1073 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
1074 $defLangBinding[$columnId][$lP][$row[$lP ? 'l18n_parent' : 'uid'] ?: $row['uid']] = $singleElementHTML;
1075 } else {
1076 $content[$columnId] .= $singleElementHTML;
1077 }
1078 } else {
1079 unset($rowArr[$rKey]);
1080 }
1081 }
1082 $content[$columnId] .= '</div>';
1083 $colTitle = BackendUtility::getProcessedValue('tt_content', 'colPos', $columnId);
1084 $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this);
1085 foreach ($tcaItems as $item) {
1086 if ($item[1] == $columnId) {
1087 $colTitle = $this->getLanguageService()->sL($item[0]);
1088 }
1089 }
1090 if ($columnId === 'unused') {
1091 if (empty($unusedElementsMessage)) {
1092 $unusedElementsMessage = GeneralUtility::makeInstance(
1093 FlashMessage::class,
1094 $this->getLanguageService()->getLL('staleUnusedElementsWarning'),
1095 $this->getLanguageService()->getLL('staleUnusedElementsWarningTitle'),
1096 FlashMessage::WARNING
1097 );
1098 $service = GeneralUtility::makeInstance(FlashMessageService::class);
1099 $queue = $service->getMessageQueueByIdentifier();
1100 $queue->addMessage($unusedElementsMessage);
1101 }
1102 $colTitle = $this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:colPos.I.unused');
1103 $editParam = '';
1104 } else {
1105 $editParam = $this->doEdit && !empty($rowArr)
1106 ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
1107 : '';
1108 }
1109 $head[$columnId] .= $this->tt_content_drawColHeader($colTitle, $editParam);
1110 }
1111 }
1112 // For each column, fit the rendered content into a table cell:
1113 $out = '';
1114 if ($this->tt_contentConfig['languageMode']) {
1115 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
1116 $sortedLanguageColumn = [];
1117 foreach ($cList as $columnId) {
1118 if (GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnId) || $columnId === 'unused') {
1119 $languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
1120
1121 // We sort $languageColumn again according to $cList as it may contain data already from above.
1122 $sortedLanguageColumn[$columnId] = $languageColumn[$columnId];
1123 }
1124 }
1125 if (!empty($languageColumn['unused'])) {
1126 $sortedLanguageColumn['unused'] = $languageColumn['unused'];
1127 }
1128 $languageColumn = $sortedLanguageColumn;
1129 } else {
1130 // GRID VIEW:
1131 $grid = '<div class="t3-grid-container"><table border="0" cellspacing="0" cellpadding="0" width="100%" class="t3-page-columns t3-grid-table t3js-page-columns">';
1132 // Add colgroups
1133 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
1134 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
1135 $grid .= '<colgroup>';
1136 for ($i = 0; $i < $colCount; $i++) {
1137 $grid .= '<col />';
1138 }
1139 $grid .= '</colgroup>';
1140
1141 // Check how to handle restricted columns
1142 $hideRestrictedCols = (bool)(BackendUtility::getPagesTSconfig($id)['mod.']['web_layout.']['hideRestrictedCols'] ?? false);
1143
1144 // Cycle through rows
1145 for ($row = 1; $row <= $rowCount; $row++) {
1146 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
1147 if (!isset($rowConfig)) {
1148 continue;
1149 }
1150 $grid .= '<tr>';
1151 for ($col = 1; $col <= $colCount; $col++) {
1152 $columnConfig = $rowConfig['columns.'][$col . '.'];
1153 if (!isset($columnConfig)) {
1154 continue;
1155 }
1156 // Which tt_content colPos should be displayed inside this cell
1157 $columnKey = (int)$columnConfig['colPos'];
1158 // Render the grid cell
1159 $colSpan = (int)$columnConfig['colspan'];
1160 $rowSpan = (int)$columnConfig['rowspan'];
1161 $grid .= '<td valign="top"' .
1162 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
1163 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
1164 ' data-colpos="' . (int)$columnConfig['colPos'] . '" data-language-uid="' . $lP . '" class="t3js-page-lang-column-' . $lP . ' t3js-page-column t3-grid-cell t3-page-column t3-page-column-' . $columnKey .
1165 ((!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '') ? ' t3-grid-cell-unassigned' : '') .
1166 ((isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && !$head[$columnKey]) || !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos']) ? ($hideRestrictedCols ? ' t3-grid-cell-restricted t3-grid-cell-hidden' : ' t3-grid-cell-restricted') : '') .
1167 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') .
1168 ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
1169
1170 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
1171 // If not, a new header without any buttons will be generated.
1172 if (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
1173 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
1174 ) {
1175 $grid .= $head[$columnKey] . $content[$columnKey];
1176 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
1177 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
1178 ) {
1179 if (!$hideRestrictedCols) {
1180 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'));
1181 }
1182 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
1183 && !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
1184 ) {
1185 if (!$hideRestrictedCols) {
1186 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
1187 ' (' . $this->getLanguageService()->getLL('noAccess') . ')');
1188 }
1189 } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
1190 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
1191 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')');
1192 } else {
1193 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'));
1194 }
1195
1196 $grid .= '</td>';
1197 }
1198 $grid .= '</tr>';
1199 }
1200 if (!empty($content['unused'])) {
1201 $grid .= '<tr>';
1202 // Which tt_content colPos should be displayed inside this cell
1203 $columnKey = 'unused';
1204 // Render the grid cell
1205 $colSpan = (int)$backendLayout['__config']['backend_layout.']['colCount'];
1206 $grid .= '<td valign="top"' .
1207 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
1208 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
1209 ' data-colpos="unused" data-language-uid="' . $lP . '" class="t3js-page-lang-column-' . $lP . ' t3js-page-column t3-grid-cell t3-page-column t3-page-column-' . $columnKey .
1210 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') . '">';
1211
1212 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
1213 // If not, a new header without any buttons will be generated.
1214 $grid .= $head[$columnKey] . $content[$columnKey];
1215 $grid .= '</td></tr>';
1216 }
1217 $out .= $grid . '</table></div>';
1218 }
1219 }
1220 $elFromTable = $this->clipboard->elFromTable('tt_content');
1221 if (!empty($elFromTable) && $this->isPageEditable()) {
1222 $pasteItem = substr(key($elFromTable), 11);
1223 $pasteRecord = BackendUtility::getRecord('tt_content', (int)$pasteItem);
1224 $pasteTitle = $pasteRecord['header'] ? $pasteRecord['header'] : $pasteItem;
1225 $copyMode = $this->clipboard->clipData['normal']['mode'] ? '-' . $this->clipboard->clipData['normal']['mode'] : '';
1226 $addExtOnReadyCode = '
1227 top.pasteIntoLinkTemplate = '
1228 . $this->tt_content_drawPasteIcon($pasteItem, $pasteTitle, $copyMode, 't3js-paste-into', 'pasteIntoColumn')
1229 . ';
1230 top.pasteAfterLinkTemplate = '
1231 . $this->tt_content_drawPasteIcon($pasteItem, $pasteTitle, $copyMode, 't3js-paste-after', 'pasteAfterRecord')
1232 . ';';
1233 } else {
1234 $addExtOnReadyCode = '
1235 top.pasteIntoLinkTemplate = \'\';
1236 top.pasteAfterLinkTemplate = \'\';';
1237 }
1238 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
1239 $pageRenderer->addJsInlineCode('pasteLinkTemplates', $addExtOnReadyCode);
1240 // If language mode, then make another presentation:
1241 // Notice that THIS presentation will override the value of $out!
1242 // But it needs the code above to execute since $languageColumn is filled with content we need!
1243 if ($this->tt_contentConfig['languageMode']) {
1244 // Get language selector:
1245 $languageSelector = $this->languageSelector($id);
1246 // Reset out - we will make new content here:
1247 $out = '';
1248 // Traverse languages found on the page and build up the table displaying them side by side:
1249 $cCont = [];
1250 $sCont = [];
1251 foreach ($langListArr as $lP) {
1252 $languageMode = '';
1253 $labelClass = 'info';
1254 // Header:
1255 $lP = (int)$lP;
1256 // Determine language mode
1257 if ($lP > 0 && isset($this->languageHasTranslationsCache[$lP]['mode'])) {
1258 switch ($this->languageHasTranslationsCache[$lP]['mode']) {
1259 case 'mixed':
1260 $languageMode = $this->getLanguageService()->getLL('languageModeMixed');
1261 $labelClass = 'danger';
1262 break;
1263 case 'connected':
1264 $languageMode = $this->getLanguageService()->getLL('languageModeConnected');
1265 break;
1266 case 'free':
1267 $languageMode = $this->getLanguageService()->getLL('languageModeFree');
1268 break;
1269 default:
1270 // we'll let opcode optimize this intentionally empty case
1271 }
1272 }
1273 $cCont[$lP] = '
1274 <td valign="top" class="t3-page-column t3-page-column-lang-name" data-language-uid="' . $lP . '">
1275 <h2>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</h2>
1276 ' . ($languageMode !== '' ? '<span class="label label-' . $labelClass . '">' . $languageMode . '</span>' : '') . '
1277 </td>';
1278
1279 // "View page" icon is added:
1280 $viewLink = '';
1281 if (!VersionState::cast($this->getPageLayoutController()->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
1282 $onClick = BackendUtility::viewOnClick(
1283 $this->id,
1284 '',
1285 BackendUtility::BEgetRootLine($this->id),
1286 '',
1287 '',
1288 '&L=' . $lP
1289 );
1290 $viewLink = '<a href="#" class="btn btn-default btn-sm" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">' . $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>';
1291 }
1292 // Language overlay page header:
1293 if ($lP) {
1294 $pageLocalizationRecord = BackendUtility::getRecordLocalization('pages', $id, $lP);
1295 if (is_array($pageLocalizationRecord)) {
1296 $pageLocalizationRecord = reset($pageLocalizationRecord);
1297 }
1298 BackendUtility::workspaceOL('pages', $pageLocalizationRecord);
1299 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
1300 $this->iconFactory->getIconForRecord('pages', $pageLocalizationRecord, Icon::SIZE_SMALL)->render(),
1301 'pages',
1302 $pageLocalizationRecord['uid']
1303 );
1304 $urlParameters = [
1305 'edit' => [
1306 'pages' => [
1307 $pageLocalizationRecord['uid'] => 'edit'
1308 ]
1309 ],
1310 // Disallow manual adjustment of the language field for pages
1311 'overrideVals' => [
1312 'pages' => [
1313 'sys_language_uid' => $lP
1314 ]
1315 ],
1316 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1317 ];
1318 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1319 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1320 $editLink = (
1321 $this->getBackendUser()->check('tables_modify', 'pages')
1322 ? '<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
1323 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1324 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
1325 : ''
1326 );
1327
1328 $defaultLanguageElements = [];
1329 array_walk($defaultLanguageElementsByColumn, function (array $columnContent) use (&$defaultLanguageElements) {
1330 $defaultLanguageElements = array_merge($defaultLanguageElements, $columnContent);
1331 });
1332
1333 $localizationButtons = [];
1334 $localizationButtons[] = $this->newLanguageButton(
1335 $this->getNonTranslatedTTcontentUids($defaultLanguageElements, $id, $lP),
1336 $lP
1337 );
1338
1339 $lPLabel =
1340 '<div class="btn-group">'
1341 . $viewLink
1342 . $editLink
1343 . (!empty($localizationButtons) ? implode(LF, $localizationButtons) : '')
1344 . '</div>'
1345 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageLocalizationRecord['title'], 20))
1346 ;
1347 } else {
1348 $editLink = '';
1349 $recordIcon = '';
1350 if ($this->getBackendUser()->checkLanguageAccess(0)) {
1351 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
1352 $this->iconFactory->getIconForRecord('pages', $this->pageRecord, Icon::SIZE_SMALL)->render(),
1353 'pages',
1354 $this->id
1355 );
1356 $urlParameters = [
1357 'edit' => [
1358 'pages' => [
1359 $this->id => 'edit'
1360 ]
1361 ],
1362 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1363 ];
1364 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1365 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1366 $editLink = (
1367 $this->getBackendUser()->check('tables_modify', 'pages')
1368 ? '<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
1369 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1370 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
1371 : ''
1372 );
1373 }
1374
1375 $lPLabel =
1376 '<div class="btn-group">'
1377 . $viewLink
1378 . $editLink
1379 . '</div>'
1380 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20));
1381 }
1382 $sCont[$lP] = '
1383 <td class="t3-page-column t3-page-lang-label nowrap">' . $lPLabel . '</td>';
1384 }
1385 // Add headers:
1386 $out .= '<tr>' . implode($cCont) . '</tr>';
1387 $out .= '<tr>' . implode($sCont) . '</tr>';
1388 unset($cCont, $sCont);
1389
1390 // Traverse previously built content for the columns:
1391 foreach ($languageColumn as $cKey => $cCont) {
1392 $out .= '<tr>';
1393 foreach ($cCont as $languageId => $columnContent) {
1394 $out .= '<td valign="top" data-colpos="' . $cKey . '" class="t3-grid-cell t3-page-column t3js-page-column t3js-page-lang-column t3js-page-lang-column-' . $languageId . '">' . $columnContent . '</td>';
1395 }
1396 $out .= '</tr>';
1397 if ($this->defLangBinding && !empty($defLangBinding[$cKey])) {
1398 $maxItemsCount = max(array_map('count', $defLangBinding[$cKey]));
1399 for ($i = 0; $i < $maxItemsCount; $i++) {
1400 $defUid = $defaultLanguageElementsByColumn[$cKey][$i] ?? 0;
1401 $cCont = [];
1402 foreach ($langListArr as $lP) {
1403 if ($lP > 0
1404 && is_array($defLangBinding[$cKey][$lP])
1405 && !$this->checkIfTranslationsExistInLanguage($defaultLanguageElementsByColumn[$cKey], $lP)
1406 && count($defLangBinding[$cKey][$lP]) > $i
1407 ) {
1408 $slice = array_slice($defLangBinding[$cKey][$lP], $i, 1);
1409 $element = $slice[0] ?? '';
1410 } else {
1411 $element = $defLangBinding[$cKey][$lP][$defUid] ?? '';
1412 }
1413 $cCont[] = $element;
1414 }
1415 $out .= '
1416 <tr>
1417 <td valign="top" class="t3-grid-cell">' . implode('</td>
1418 <td valign="top" class="t3-grid-cell">', $cCont) . '</td>
1419 </tr>';
1420 }
1421 }
1422 }
1423 // Finally, wrap it all in a table and add the language selector on top of it:
1424 $out = $languageSelector . '
1425 <div class="t3-grid-container">
1426 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
1427 ' . $out . '
1428 </table>
1429 </div>';
1430 }
1431
1432 return $out;
1433 }
1434
1435 /**********************************
1436 *
1437 * Generic listing of items
1438 *
1439 **********************************/
1440 /**
1441 * Creates a standard list of elements from a table.
1442 *
1443 * @param string $table Table name
1444 * @param int $id Page id.
1445 * @param string $fList Comma list of fields to display
1446 * @param bool $icon If TRUE, icon is shown
1447 * @param string $addWhere Additional WHERE-clauses.
1448 * @return string HTML table
1449 */
1450 public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = '')
1451 {
1452 // Initialize
1453 $addWhere = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
1454 $queryBuilder = $this->getQueryBuilder($table, $id, $addWhere);
1455 $this->setTotalItems($table, $id, $addWhere);
1456 $dbCount = 0;
1457 $result = false;
1458 // Make query for records if there were any records found in the count operation
1459 if ($this->totalItems) {
1460 $result = $queryBuilder->execute();
1461 // Will return FALSE, if $result is invalid
1462 $dbCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
1463 }
1464 // If records were found, render the list
1465 if (!$dbCount) {
1466 return '';
1467 }
1468 // Set fields
1469 $out = '';
1470 $this->fieldArray = GeneralUtility::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', true);
1471 $theData = [];
1472 $theData = $this->headerFields($this->fieldArray, $table, $theData);
1473 // Title row
1474 $localizedTableTitle = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
1475 $out .= '<tr><th class="col-icon"></th>'
1476 . '<th colspan="' . (count($theData) - 2) . '"><span class="c-table">'
1477 . $localizedTableTitle . '</span> (' . $dbCount . ')</td><td class="col-icon"></td>'
1478 . '</tr>';
1479 // Column's titles
1480 if ($this->doEdit) {
1481 $urlParameters = [
1482 'edit' => [
1483 $table => [
1484 $this->id => 'new'
1485 ]
1486 ],
1487 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1488 ];
1489 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1490 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1491 $title = htmlspecialchars($this->getLanguageService()->getLL('new'));
1492 $theData['__cmds__'] = '<a href="' . htmlspecialchars($url) . '" class="' . ($this->option_newWizard ? 't3js-toggle-new-content-element-wizard' : '') . '" '
1493 . 'title="' . $title . '"'
1494 . 'data-title="' . $title . '">'
1495 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</a>';
1496 }
1497 $out .= $this->addElement(1, '', $theData, ' class="c-headLine"', 15, '', 'th');
1498 // Render Items
1499 $this->eCounter = $this->firstElementNumber;
1500 while ($row = $result->fetch()) {
1501 BackendUtility::workspaceOL($table, $row);
1502 if (is_array($row)) {
1503 list($flag, $code) = $this->fwd_rwd_nav();
1504 $out .= $code;
1505 if ($flag) {
1506 $Nrow = [];
1507 // Setting icons links
1508 if ($icon) {
1509 $Nrow['__cmds__'] = $this->getIcon($table, $row);
1510 }
1511 // Get values:
1512 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
1513 // Attach edit icon
1514 if ($this->doEdit && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
1515 $urlParameters = [
1516 'edit' => [
1517 $table => [
1518 $row['uid'] => 'edit'
1519 ]
1520 ],
1521 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1522 ];
1523 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1524 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1525 $Nrow['__editIconLink__'] = '<a class="btn btn-default" href="' . htmlspecialchars($url)
1526 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1527 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
1528 } else {
1529 $Nrow['__editIconLink__'] = $this->noEditIcon();
1530 }
1531 $out .= $this->addElement(1, '', $Nrow);
1532 }
1533 $this->eCounter++;
1534 }
1535 }
1536 // Wrap it all in a table:
1537 $out = '
1538 <!--
1539 Standard list of table "' . $table . '"
1540 -->
1541 <div class="table-fit"><table class="table table-hover table-striped">
1542 ' . $out . '
1543 </table></div>';
1544 return $out;
1545 }
1546
1547 /**
1548 * Adds content to all data fields in $out array
1549 *
1550 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
1551 * Eg. "field1,field2;field3".
1552 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1553 *
1554 * @param array $fieldArr Array of fields to display
1555 * @param string $table Table name
1556 * @param array $row Record array
1557 * @param array $out Array to which the data is added
1558 * @return array $out array returned after processing.
1559 * @see makeOrdinaryList()
1560 */
1561 public function dataFields($fieldArr, $table, $row, $out = [])
1562 {
1563 // Check table validity
1564 if (!isset($GLOBALS['TCA'][$table])) {
1565 return $out;
1566 }
1567
1568 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1569 // Traverse fields
1570 foreach ($fieldArr as $fieldName) {
1571 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1572 // Each field has its own cell (if configured in TCA)
1573 // If the column is a thumbnail column:
1574 if ($fieldName == $thumbsCol) {
1575 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1576 } else {
1577 // ... otherwise just render the output:
1578 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(
1579 BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1580 250
1581 ))));
1582 }
1583 } else {
1584 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1585 // the field name with ";" and check each value there as a TCA configured field)
1586 $theFields = explode(';', $fieldName);
1587 // Traverse fields, separated by ";" (displayed in a single cell).
1588 foreach ($theFields as $fName2) {
1589 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1590 $out[$fieldName] .= '<strong>' . htmlspecialchars($this->getLanguageService()->sL(
1591 $GLOBALS['TCA'][$table]['columns'][$fName2]['label']
1592 )) . '</strong>&nbsp;&nbsp;' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
1593 BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1594 25
1595 )) . '<br />';
1596 }
1597 }
1598 }
1599 // If no value, add a nbsp.
1600 if (!$out[$fieldName]) {
1601 $out[$fieldName] = '&nbsp;';
1602 }
1603 // Wrap in dimmed-span tags if record is "disabled"
1604 if ($this->isDisabled($table, $row)) {
1605 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
1606 }
1607 }
1608 return $out;
1609 }
1610
1611 /**
1612 * Header fields made for the listing of records
1613 *
1614 * @param array $fieldArr Field names
1615 * @param string $table The table name
1616 * @param array $out Array to which the headers are added.
1617 * @return array $out returned after addition of the header fields.
1618 * @see makeOrdinaryList()
1619 */
1620 public function headerFields($fieldArr, $table, $out = [])
1621 {
1622 foreach ($fieldArr as $fieldName) {
1623 $ll = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']));
1624 $out[$fieldName] = $ll ? $ll : '&nbsp;';
1625 }
1626 return $out;
1627 }
1628
1629 /**
1630 * Gets content records per column.
1631 * This is required for correct workspace overlays.
1632 *
1633 * @param string $table UNUSED (will always be queried from tt_content)
1634 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1635 * @param array $columns colPos values to be considered to be shown
1636 * @param string $additionalWhereClause Additional where clause for database select
1637 * @return array Associative array for each column (colPos)
1638 */
1639 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '')
1640 {
1641 $contentRecordsPerColumn = array_fill_keys($columns, []);
1642 $columns = array_flip($columns);
1643 $queryBuilder = $this->getQueryBuilder(
1644 'tt_content',
1645 $id,
1646 [
1647 $additionalWhereClause
1648 ]
1649 );
1650
1651 // Traverse any selected elements and render their display code:
1652 $results = $this->getResult($queryBuilder->execute());
1653 $unused = [];
1654 $hookArray = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['record_is_used'] ?? [];
1655 foreach ($results as $record) {
1656 $used = isset($columns[$record['colPos']]);
1657 foreach ($hookArray as $_funcRef) {
1658 $_params = ['columns' => $columns, 'record' => $record, 'used' => $used];
1659 $used = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1660 }
1661 if ($used) {
1662 $columnValue = (string)$record['colPos'];
1663 $contentRecordsPerColumn[$columnValue][] = $record;
1664 } else {
1665 $unused[] = $record;
1666 }
1667 }
1668 if (!empty($unused)) {
1669 $contentRecordsPerColumn['unused'] = $unused;
1670 }
1671 return $contentRecordsPerColumn;
1672 }
1673
1674 /**********************************
1675 *
1676 * Additional functions; Pages
1677 *
1678 **********************************/
1679
1680 /**
1681 * Adds pages-rows to an array, selecting recursively in the page tree.
1682 *
1683 * @param int $pid Starting page id to select from
1684 * @param string $iconPrefix Prefix for icon code.
1685 * @param int $depth Depth (decreasing)
1686 * @param array $rows Array which will accumulate page rows
1687 * @return array $rows with added rows.
1688 */
1689 protected function getPageRecordsRecursive(int $pid, int $depth, string $iconPrefix = '', array $rows = []): array
1690 {
1691 $depth--;
1692 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
1693 $queryBuilder->getRestrictions()
1694 ->removeAll()
1695 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
1696 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
1697
1698 $queryBuilder
1699 ->select('*')
1700 ->from('pages')
1701 ->where(
1702 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)),
1703 $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
1704 $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
1705 );
1706
1707 if (!empty($GLOBALS['TCA']['pages']['ctrl']['sortby'])) {
1708 $queryBuilder->orderBy($GLOBALS['TCA']['pages']['ctrl']['sortby']);
1709 }
1710
1711 if ($depth >= 0) {
1712 $result = $queryBuilder->execute();
1713 $rowCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
1714 $count = 0;
1715 while ($row = $result->fetch()) {
1716 BackendUtility::workspaceOL('pages', $row);
1717 if (is_array($row)) {
1718 $count++;
1719 $row['treeIcons'] = $iconPrefix
1720 . '<span class="treeline-icon treeline-icon-join'
1721 . ($rowCount === $count ? 'bottom' : '')
1722 . '"></span>';
1723 $rows[] = $row;
1724 // Get the branch
1725 $spaceOutIcons = '<span class="treeline-icon treeline-icon-'
1726 . ($rowCount === $count ? 'clear' : 'line')
1727 . '"></span>';
1728 $rows = $this->getPageRecordsRecursive(
1729 $row['uid'],
1730 $row['php_tree_stop'] ? 0 : $depth,
1731 $iconPrefix . $spaceOutIcons,
1732 $rows
1733 );
1734 }
1735 }
1736 }
1737
1738 return $rows;
1739 }
1740
1741 /**
1742 * Adds a list item for the pages-rendering
1743 *
1744 * @param array $row Record array
1745 * @param array $fieldArr Field list
1746 * @return string HTML for the item
1747 */
1748 public function pages_drawItem($row, $fieldArr)
1749 {
1750 $userTsConfig = $this->getBackendUser()->getTSConfig();
1751
1752 // Initialization
1753 $theIcon = $this->getIcon('pages', $row);
1754 // Preparing and getting the data-array
1755 $theData = [];
1756 foreach ($fieldArr as $field) {
1757 switch ($field) {
1758 case 'title':
1759 $showPageId = !empty($userTsConfig['options.']['pageTree.']['showPageIdWithTitle']);
1760 $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
1761 $theData[$field] = $row['treeIcons'] . $theIcon . ($showPageId ? '[' . $row['uid'] . '] ' : '') . $pTitle;
1762 break;
1763 case 'php_tree_stop':
1764 // Intended fall through
1765 case 'TSconfig':
1766 $theData[$field] = $row[$field] ? '<strong>x</strong>' : '&nbsp;';
1767 break;
1768 case 'uid':
1769 if ($this->getBackendUser()->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
1770 $urlParameters = [
1771 'edit' => [
1772 'pages' => [
1773 $row['uid'] => 'edit'
1774 ]
1775 ],
1776 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1777 ];
1778 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1779 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1780 $onClick = BackendUtility::viewOnClick($row['uid'], '', BackendUtility::BEgetRootLine($row['uid']));
1781
1782 $eI =
1783 '<a href="#" onclick="' . htmlspecialchars($onClick) . '" class="btn btn-default" title="' .
1784 $this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' .
1785 $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() .
1786 '</a>';
1787 $eI .=
1788 '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' .
1789 htmlspecialchars($this->getLanguageService()->getLL('editThisPage')) . '">' .
1790 $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() .
1791 '</a>';
1792 } else {
1793 $eI = '';
1794 }
1795 $theData[$field] = '<div class="btn-group" role="group">' . $eI . '</div>';
1796 break;
1797 case 'shortcut':
1798 case 'shortcut_mode':
1799 if ((int)$row['doktype'] === \TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_SHORTCUT) {
1800 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1801 }
1802 break;
1803 default:
1804 if (strpos($field, 'table_') === 0) {
1805 $f2 = substr($field, 6);
1806 if ($GLOBALS['TCA'][$f2]) {
1807 $c = $this->numberOfRecords($f2, $row['uid']);
1808 $theData[$field] = ($c ? $c : '');
1809 }
1810 } else {
1811 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1812 }
1813 }
1814 }
1815 $this->addElement_tdParams['title'] = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '';
1816 return $this->addElement(1, '', $theData);
1817 }
1818
1819 /**
1820 * Returns the HTML code for rendering a field in the pages table.
1821 * The row value is processed to a human readable form and the result is parsed through htmlspecialchars().
1822 *
1823 * @param string $field The name of the field of which the value should be rendered.
1824 * @param array $row The pages table row as an associative array.
1825 * @return string The rendered table field value.
1826 */
1827 protected function getPagesTableFieldValue($field, array $row)
1828 {
1829 return htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
1830 }
1831
1832 /**********************************
1833 *
1834 * Additional functions; Content Elements
1835 *
1836 **********************************/
1837 /**
1838 * Draw header for a content element column:
1839 *
1840 * @param string $colName Column name
1841 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1842 * @return string HTML table
1843 */
1844 public function tt_content_drawColHeader($colName, $editParams = '')
1845 {
1846 $iconsArr = [];
1847 // Create command links:
1848 if ($this->tt_contentConfig['showCommands']) {
1849 // Edit whole of column:
1850 if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT) && $this->getBackendUser()->checkLanguageAccess(0)) {
1851 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1852 $link = $uriBuilder->buildUriFromRoute('record_edit') . $editParams . '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
1853 $iconsArr['edit'] = '<a href="' . htmlspecialchars($link) . '" title="'
1854 . htmlspecialchars($this->getLanguageService()->getLL('editColumn')) . '">'
1855 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1856 }
1857 }
1858 $icons = '';
1859 if (!empty($iconsArr)) {
1860 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1861 }
1862 // Create header row:
1863 $out = '<div class="t3-page-column-header">
1864 ' . $icons . '
1865 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1866 </div>';
1867 return $out;
1868 }
1869
1870 /**
1871 * Draw a paste icon either for pasting into a column or for pasting after a record
1872 *
1873 * @param int $pasteItem ID of the item in the clipboard
1874 * @param string $pasteTitle Title for the JS modal
1875 * @param string $copyMode copy or cut
1876 * @param string $cssClass CSS class to determine if pasting is done into column or after record
1877 * @param string $title title attribute of the generated link
1878 *
1879 * @return string Generated HTML code with link and icon
1880 */
1881 protected function tt_content_drawPasteIcon($pasteItem, $pasteTitle, $copyMode, $cssClass, $title)
1882 {
1883 $pasteIcon = json_encode(
1884 ' <a data-content="' . htmlspecialchars($pasteItem) . '"'
1885 . ' data-title="' . htmlspecialchars($pasteTitle) . '"'
1886 . ' data-severity="warning"'
1887 . ' class="t3js-paste t3js-paste' . htmlspecialchars($copyMode) . ' ' . htmlspecialchars($cssClass) . ' btn btn-default btn-sm"'
1888 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL($title)) . '">'
1889 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
1890 . '</a>'
1891 );
1892 return $pasteIcon;
1893 }
1894
1895 /**
1896 * Draw the footer for a single tt_content element
1897 *
1898 * @param array $row Record array
1899 * @return string HTML of the footer
1900 * @throws \UnexpectedValueException
1901 */
1902 protected function tt_content_drawFooter(array $row)
1903 {
1904 $content = '';
1905 // Get processed values:
1906 $info = [];
1907 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,space_before_class,space_after_class', $row, $info);
1908
1909 // Content element annotation
1910 if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']) && !empty($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']])) {
1911 $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
1912 }
1913
1914 // Call drawFooter hooks
1915 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'] ?? [] as $className) {
1916 $hookObject = GeneralUtility::makeInstance($className);
1917 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
1918 throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, 1404378171);
1919 }
1920 $hookObject->preProcess($this, $info, $row);
1921 }
1922
1923 // Display info from records fields:
1924 if (!empty($info)) {
1925 $content = '<div class="t3-page-ce-info">
1926 ' . implode('<br>', $info) . '
1927 </div>';
1928 }
1929 // Wrap it
1930 if (!empty($content)) {
1931 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1932 }
1933 return $content;
1934 }
1935
1936 /**
1937 * Draw the header for a single tt_content element
1938 *
1939 * @param array $row Record array
1940 * @param int $space Amount of pixel space above the header. UNUSED
1941 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1942 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1943 * @param bool $dragDropEnabled If set the move button must be hidden
1944 * @return string HTML table with the record header.
1945 */
1946 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false)
1947 {
1948 $backendUser = $this->getBackendUser();
1949 $out = '';
1950 // If show info is set...;
1951 if ($this->tt_contentConfig['showInfo'] && $backendUser->recordEditAccessInternals('tt_content', $row)) {
1952 // Render control panel for the element:
1953 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1954 // Edit content element:
1955 $urlParameters = [
1956 'edit' => [
1957 'tt_content' => [
1958 $this->tt_contentData['nextThree'][$row['uid']] => 'edit'
1959 ]
1960 ],
1961 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'],
1962 ];
1963 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1964 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters) . '#element-tt_content-' . $row['uid'];
1965
1966 $out .= '<a class="btn btn-default" href="' . htmlspecialchars($url)
1967 . '" title="' . htmlspecialchars($this->nextThree > 1
1968 ? sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree)
1969 : $this->getLanguageService()->getLL('edit'))
1970 . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
1971 // Hide element:
1972 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1973 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1974 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1975 || $backendUser->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1976 ) {
1977 if ($row[$hiddenField]) {
1978 $value = 0;
1979 $label = 'unHide';
1980 } else {
1981 $value = 1;
1982 $label = 'hide';
1983 }
1984 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
1985 . '][' . $hiddenField . ']=' . $value;
1986 $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
1987 . '#element-tt_content-' . $row['uid'] . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($label)) . '">'
1988 . $this->iconFactory->getIcon('actions-edit-' . strtolower($label), Icon::SIZE_SMALL)->render() . '</a>';
1989 }
1990 // Delete
1991 $disableDelete = (bool)\trim(
1992 $backendUser->getTSConfig()['options.']['disableDelete.']['tt_content']
1993 ?? $backendUser->getTSConfig()['options.']['disableDelete']
1994 ?? '0'
1995 );
1996 if (!$disableDelete) {
1997 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1998 $refCountMsg = BackendUtility::referenceCount(
1999 'tt_content',
2000 $row['uid'],
2001 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
2002 $this->getReferenceCount('tt_content', $row['uid'])
2003 ) . BackendUtility::translationCount(
2004 'tt_content',
2005 $row['uid'],
2006 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
2007 );
2008 $confirm = $this->getLanguageService()->getLL('deleteWarning')
2009 . $refCountMsg;
2010 $out .= '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params)) . '"'
2011 . ' data-severity="warning"'
2012 . ' data-title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf:label.confirm.delete_record.title')) . '"'
2013 . ' data-content="' . htmlspecialchars($confirm) . '" '
2014 . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')) . '"'
2015 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('deleteItem')) . '">'
2016 . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
2017 if ($out && $backendUser->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
2018 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
2019 } else {
2020 $out = '';
2021 }
2022 }
2023 if (!$disableMoveAndNewButtons) {
2024 $moveButtonContent = '';
2025 $displayMoveButtons = false;
2026 // Move element up:
2027 if ($this->tt_contentData['prev'][$row['uid']]) {
2028 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
2029 $moveButtonContent .= '<a class="btn btn-default" href="'
2030 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
2031 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
2032 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
2033 if (!$dragDropEnabled) {
2034 $displayMoveButtons = true;
2035 }
2036 } else {
2037 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
2038 }
2039 // Move element down:
2040 if ($this->tt_contentData['next'][$row['uid']]) {
2041 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
2042 $moveButtonContent .= '<a class="btn btn-default" href="'
2043 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
2044 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
2045 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
2046 if (!$dragDropEnabled) {
2047 $displayMoveButtons = true;
2048 }
2049 } else {
2050 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
2051 }
2052 if ($displayMoveButtons) {
2053 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
2054 }
2055 }
2056 }
2057 }
2058 $allowDragAndDrop = $this->isDragAndDropAllowed($row);
2059 $additionalIcons = [];
2060 $additionalIcons[] = $this->getIcon('tt_content', $row) . ' ';
2061 if ($langMode && isset($this->siteLanguages[(int)$row['sys_language_uid']])) {
2062 $additionalIcons[] = $this->renderLanguageFlag($this->siteLanguages[(int)$row['sys_language_uid']]);
2063 }
2064 // Get record locking status:
2065 if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) {
2066 $additionalIcons[] = '<a href="#" data-toggle="tooltip" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
2067 . $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
2068 }
2069 // Call stats information hook
2070 $_params = ['tt_content', $row['uid'], &$row];
2071 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ?? [] as $_funcRef) {
2072 $additionalIcons[] = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2073 }
2074
2075 // Wrap the whole header
2076 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
2077 return '<div class="t3-page-ce-header ' . ($allowDragAndDrop ? 't3-page-ce-header-draggable t3js-page-ce-draghandle' : '') . '">
2078 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
2079 <div class="t3-page-ce-header-icons-right">' . ($out ? '<div class="btn-toolbar">' . $out . '</div>' : '') . '</div>
2080 </div>
2081 <div class="t3-page-ce-body">';
2082 }
2083
2084 /**
2085 * Gets the number of records referencing the record with the UID $uid in
2086 * the table $tableName.
2087 *
2088 * @param string $tableName
2089 * @param int $uid
2090 * @return int The number of references to record $uid in table
2091 */
2092 protected function getReferenceCount(string $tableName, int $uid): int
2093 {
2094 if (!isset($this->referenceCount[$tableName][$uid])) {
2095 $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
2096 $numberOfReferences = $referenceIndex->getNumberOfReferencedRecords($tableName, $uid);
2097 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
2098 }
2099 return $this->referenceCount[$tableName][$uid];
2100 }
2101
2102 /**
2103 * Determine whether Drag & Drop should be allowed
2104 *
2105 * @param array $row
2106 * @return bool
2107 */
2108 protected function isDragAndDropAllowed(array $row)
2109 {
2110 if ((int)$row['l18n_parent'] === 0 &&
2111 (
2112 $this->getBackendUser()->isAdmin()
2113 || ((int)$row['editlock'] === 0 && (int)$this->pageinfo['editlock'] === 0)
2114 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
2115 && $this->getBackendUser()->checkAuthMode('tt_content', 'CType', $row['CType'], $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'])
2116 )
2117 ) {
2118 return true;
2119 }
2120 return false;
2121 }
2122
2123 /**
2124 * Draws the preview content for a content element
2125 *
2126 * @param array $row Content element
2127 * @return string HTML
2128 * @throws \UnexpectedValueException
2129 */
2130 public function tt_content_drawItem($row)
2131 {
2132 $out = '';
2133 $outHeader = '';
2134 // Make header:
2135
2136 if ($row['header']) {
2137 $hiddenHeaderNote = '';
2138 // If header layout is set to 'hidden', display an accordant note:
2139 if ($row['header_layout'] == 100) {
2140 $hiddenHeaderNote = ' <em>[' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.hidden')) . ']</em>';
2141 }
2142 $outHeader = $row['date']
2143 ? htmlspecialchars($this->itemLabels['date'] . ' ' . BackendUtility::date($row['date'])) . '<br />'
2144 : '';
2145 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
2146 . $hiddenHeaderNote . '</strong><br />';
2147 }
2148 // Make content:
2149 $drawItem = true;
2150 // Hook: Render an own preview of a record
2151 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'] ?? [] as $className) {
2152 $hookObject = GeneralUtility::makeInstance($className);
2153 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
2154 throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawItemHookInterface::class, 1218547409);
2155 }
2156 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
2157 }
2158
2159 // If the previous hook did not render something,
2160 // then check if a Fluid-based preview template was defined for this CType
2161 // and render it via Fluid. Possible option:
2162 // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html
2163 if ($drawItem) {
2164 $tsConfig = BackendUtility::getPagesTSconfig($row['pid'])['mod.']['web_layout.']['tt_content.']['preview.'] ?? [];
2165 $fluidTemplateFile = '';
2166
2167 if ($row['CType'] === 'list' && !empty($row['list_type'])
2168 && !empty($tsConfig['list.'][$row['list_type']])
2169 ) {
2170 $fluidTemplateFile = $tsConfig['list.'][$row['list_type']];
2171 } elseif (!empty($tsConfig[$row['CType']])) {
2172 $fluidTemplateFile = $tsConfig[$row['CType']];
2173 }
2174
2175 if ($fluidTemplateFile) {
2176 $fluidTemplateFile = GeneralUtility::getFileAbsFileName($fluidTemplateFile);
2177 if ($fluidTemplateFile) {
2178 try {
2179 $view = GeneralUtility::makeInstance(StandaloneView::class);
2180 $view->setTemplatePathAndFilename($fluidTemplateFile);
2181 $view->assignMultiple($row);
2182 if (!empty($row['pi_flexform'])) {
2183 $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
2184 $view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
2185 }
2186 $out = $view->render();
2187 $drawItem = false;
2188 } catch (\Exception $e) {
2189 $this->logger->warning(sprintf(
2190 'The backend preview for content element %d can not be rendered using the Fluid template file "%s": %s',
2191 $row['uid'],
2192 $fluidTemplateFile,
2193 $e->getMessage()
2194 ));
2195 }
2196 }
2197 }
2198 }
2199
2200 // Draw preview of the item depending on its CType (if not disabled by previous hook):
2201 if ($drawItem) {
2202 switch ($row['CType']) {
2203 case 'header':
2204 if ($row['subheader']) {
2205 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
2206 }
2207 break;
2208 case 'bullets':
2209 case 'table':
2210 if ($row['bodytext']) {
2211 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
2212 }
2213 break;
2214 case 'uploads':
2215 if ($row['media']) {
2216 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
2217 }
2218 break;
2219 case 'menu':
2220 $contentType = $this->CType_labels[$row['CType']];
2221 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
2222 // Add Menu Type
2223 $menuTypeLabel = $this->getLanguageService()->sL(
2224 BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
2225 );
2226 $menuTypeLabel = $menuTypeLabel ?: 'invalid menu type';
2227 $out .= $this->linkEditContent($menuTypeLabel, $row);
2228 if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
2229 // Show pages if menu type is not "Sitemap"
2230 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
2231 }
2232 break;
2233 case 'shortcut':
2234 if (!empty($row['records'])) {
2235 $shortcutContent = [];
2236 $recordList = explode(',', $row['records']);
2237 foreach ($recordList as $recordIdentifier) {
2238 $split = BackendUtility::splitTable_Uid($recordIdentifier);
2239 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
2240 $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
2241 if (is_array($shortcutRecord)) {
2242 $icon = $this->iconFactory->getIconForRecord($tableName, $shortcutRecord, Icon::SIZE_SMALL)->render();
2243 $icon = BackendUtility::wrapClickMenuOnIcon(
2244 $icon,
2245 $tableName,
2246 $shortcutRecord['uid']
2247 );
2248 $shortcutContent[] = $icon
2249 . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
2250 }
2251 }
2252 $out .= implode('<br />', $shortcutContent) . '<br />';
2253 }
2254 break;
2255 case 'list':
2256 $hookOut = '';
2257 $_params = ['pObj' => &$this, 'row' => $row, 'infoArr' => []];
2258 foreach (
2259 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']] ??
2260 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'] ??
2261 [] as $_funcRef
2262 ) {
2263 $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2264 }
2265 if ((string)$hookOut !== '') {
2266 $out .= $hookOut;
2267 } elseif (!empty($row['list_type'])) {
2268 $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
2269 if (!empty($label)) {
2270 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($this->getLanguageService()->sL($label)) . '</strong>', $row) . '<br />';
2271 } else {
2272 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
2273 $out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
2274 }
2275 } else {
2276 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
2277 }
2278 $out .= htmlspecialchars($this->getLanguageService()->sL(
2279 BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages'])
2280 )) . '<br />';
2281 break;
2282 default:
2283 $contentType = $this->CType_labels[$row['CType']];
2284 if (!isset($contentType)) {
2285 $contentType = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'CType', $row['CType']);
2286 }
2287
2288 if ($contentType) {
2289 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
2290 if ($row['bodytext']) {
2291 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
2292 }
2293 if ($row['image']) {
2294 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
2295 }
2296 } else {
2297 $message = sprintf(
2298 $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'),
2299 $row['CType']
2300 );
2301 $out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
2302 }
2303 }
2304 }
2305 // Wrap span-tags:
2306 $out = '
2307 <span class="exampleContent">' . $out . '</span>';
2308 // Add header:
2309 $out = $outHeader . $out;
2310 // Return values:
2311 if ($this->isDisabled('tt_content', $row)) {
2312 return '<span class="text-muted">' . $out . '</span>';
2313 }
2314 return $out;
2315 }
2316
2317 /**
2318 * Generates a list of selected pages or categories for the CType menu
2319 *
2320 * @param array $row row from pages
2321 * @return string
2322 */
2323 protected function generateListForCTypeMenu(array $row)
2324 {
2325 $table = 'pages';
2326 $field = 'pages';
2327 // get categories instead of pages
2328 if (strpos($row['menu_type'], 'categorized_') !== false) {
2329 $table = 'sys_category';
2330 $field = 'selected_categories';
2331 }
2332 if (trim($row[$field]) === '') {
2333 return '';
2334 }
2335 $content = '';
2336 $uidList = explode(',', $row[$field]);
2337 foreach ($uidList as $uid) {
2338 $uid = (int)$uid;
2339 $record = BackendUtility::getRecord($table, $uid, 'title');
2340 $content .= '<br>' . $record['title'] . ' (' . $uid . ')';
2341 }
2342 return $content;
2343 }
2344
2345 /**
2346 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
2347 * Selects across columns, but within in the same PID. Columns are expect to be the same
2348 * for translations and original but this may be a conceptual error (?)
2349 *
2350 * @param array $defaultLanguageUids Numeric array with uids of tt_content elements in the default language
2351 * @param int $id Page pid
2352 * @param int $lP Sys language UID
2353 * @return array Modified $defLanguageCount
2354 */
2355 public function getNonTranslatedTTcontentUids($defaultLanguageUids, $id, $lP)
2356 {
2357 if ($lP && !empty($defaultLanguageUids)) {
2358 // Select all translations here:
2359 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
2360 ->getQueryBuilderForTable('tt_content');
2361 $queryBuilder->getRestrictions()
2362 ->removeAll()
2363 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2364 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class, null, false));
2365 $queryBuilder
2366 ->select('*')
2367 ->from('tt_content')
2368 ->where(
2369 $queryBuilder->expr()->eq(
2370 'sys_language_uid',
2371 $queryBuilder->createNamedParameter($lP, \PDO::PARAM_INT)
2372 ),
2373 $queryBuilder->expr()->in(
2374 'l18n_parent',
2375 $queryBuilder->createNamedParameter($defaultLanguageUids, Connection::PARAM_INT_ARRAY)
2376 )
2377 );
2378
2379 $result = $queryBuilder->execute();
2380
2381 // Flip uids:
2382 $defaultLanguageUids = array_flip($defaultLanguageUids);
2383 // Traverse any selected elements and unset original UID if any:
2384 while ($row = $result->fetch()) {
2385 BackendUtility::workspaceOL('tt_content', $row);
2386 unset($defaultLanguageUids[$row['l18n_parent']]);
2387 }
2388 // Flip again:
2389 $defaultLanguageUids = array_keys($defaultLanguageUids);
2390 }
2391 return $defaultLanguageUids;
2392 }
2393
2394 /**
2395 * Creates button which is used to create copies of records..
2396 *
2397 * @param array $defaultLanguageUids Numeric array with uids of tt_content elements in the default language
2398 * @param int $lP Sys language UID
2399 * @return string "Copy languages" button, if available.
2400 */
2401 public function newLanguageButton($defaultLanguageUids, $lP)
2402 {
2403 $lP = (int)$lP;
2404 if (!$this->doEdit || !$lP) {
2405 return '';
2406 }
2407 $theNewButton = '';
2408
2409 $localizationTsConfig = BackendUtility::getPagesTSconfig($this->id)['mod.']['web_layout.']['localization.'] ?? [];
2410 $allowCopy = (bool)($localizationTsConfig['enableCopy'] ?? true);
2411 $allowTranslate = (bool)($localizationTsConfig['enableTranslate'] ?? true);
2412 if (!empty($this->languageHasTranslationsCache[$lP])) {
2413 if (isset($this->languageHasTranslationsCache[$lP]['hasStandAloneContent'])) {
2414 $allowTranslate = false;
2415 }
2416 if (isset($this->languageHasTranslationsCache[$lP]['hasTranslations'])) {
2417 $allowCopy = $allowCopy && !$this->languageHasTranslationsCache[$lP]['hasTranslations'];
2418 }
2419 }
2420
2421 if (isset($this->contentElementCache[$lP]) && is_array($this->contentElementCache[$lP])) {
2422 foreach ($this->contentElementCache[$lP] as $column => $records) {
2423 foreach ($records as $record) {
2424 $key = array_search($record['l10n_source'], $defaultLanguageUids);
2425 if ($key !== false) {
2426 unset($defaultLanguageUids[$key]);
2427 }
2428 }
2429 }
2430 }
2431
2432 if (!empty($defaultLanguageUids)) {
2433 $theNewButton =
2434 '<a'
2435 . ' href="#"'
2436 . ' class="btn btn-default btn-sm t3js-localize disabled"'
2437 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate')) . '"'
2438 . ' data-page="' . htmlspecialchars($this->getLocalizedPageTitle()) . '"'
2439 . ' data-has-elements="' . (int)!empty($this->contentElementCache[$lP]) . '"'
2440 . ' data-allow-copy="' . (int)$allowCopy . '"'
2441 . ' data-allow-translate="' . (int)$allowTranslate . '"'
2442 . ' data-table="tt_content"'
2443 . ' data-page-id="' . (int)GeneralUtility::_GP('id') . '"'
2444 . ' data-language-id="' . $lP . '"'
2445 . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '"'
2446 . '>'
2447 . $this->iconFactory->getIcon('actions-localize', Icon::SIZE_SMALL)->render()
2448 . ' ' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate'))
2449 . '</a>';
2450 }
2451
2452 return $theNewButton;
2453 }
2454
2455 /**
2456 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
2457 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
2458 *
2459 * @param string $str String to link. Must be prepared for HTML output.
2460 * @param array $row The row.
2461 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
2462 * @see getTable_tt_content()
2463 */
2464 public function linkEditContent($str, $row)
2465 {
2466 if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
2467 $urlParameters = [
2468 'edit' => [
2469 'tt_content' => [
2470 $row['uid'] => 'edit'
2471 ]
2472 ],
2473 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
2474 ];
2475 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2476 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
2477 // Return link
2478 return '<a href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $str . '</a>';
2479 }
2480 return $str;
2481 }
2482
2483 /**
2484 * Make selector box for creating new translation in a language
2485 * Displays only languages which are not yet present for the current page and
2486 * that are not disabled with page TS.
2487 *
2488 * @param int $id Page id for which to create a new translation record of pages
2489 * @return string <select> HTML element (if there were items for the box anyways...)
2490 * @see getTable_tt_content()
2491 */
2492 public function languageSelector($id)
2493 {
2494 if (!$this->getBackendUser()->check('tables_modify', 'pages')) {
2495 return '';
2496 }
2497 $id = (int)$id;
2498
2499 // First, select all languages that are available for the current user
2500 $availableTranslations = [];
2501 foreach ($this->siteLanguages as $language) {
2502 if ($language->getLanguageId() === 0) {
2503 continue;
2504 }
2505 $availableTranslations[$language->getLanguageId()] = $language->getTitle();
2506 }
2507
2508 // Then, subtract the languages which are already on the page:
2509 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
2510 $queryBuilder->getRestrictions()->removeAll()
2511 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2512 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
2513 $queryBuilder->select('uid', $GLOBALS['TCA']['pages']['ctrl']['languageField'])
2514 ->from('pages')
2515 ->where(
2516 $queryBuilder->expr()->eq(
2517 $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
2518 $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)
2519 )
2520 );
2521 $statement = $queryBuilder->execute();
2522 while ($row = $statement->fetch()) {
2523 unset($availableTranslations[(int)$row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]]);
2524 }
2525 // If any languages are left, make selector:
2526 if (!empty($availableTranslations)) {
2527 $output = '<option value="">' . htmlspecialchars($this->getLanguageService()->getLL('new_language')) . '</option>';
2528 foreach ($availableTranslations as $languageUid => $languageTitle) {
2529 // Build localize command URL to DataHandler (tce_db)
2530 // which redirects to FormEngine (record_edit)
2531 // which, when finished editing should return back to the current page (returnUrl)
2532 $parameters = [
2533 'justLocalized' => 'pages:' . $id . ':' . $languageUid,
2534 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
2535 ];
2536 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2537 $redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters);
2538 $targetUrl = BackendUtility::getLinkToDataHandlerAction(
2539 '&cmd[pages][' . $id . '][localize]=' . $languageUid,
2540 $redirectUrl
2541 );
2542
2543 $output .= '<option value="' . htmlspecialchars($targetUrl) . '">' . htmlspecialchars($languageTitle) . '</option>';
2544 }
2545
2546 return '<div class="form-inline form-inline-spaced">'
2547 . '<div class="form-group">'
2548 . '<select class="form-control input-sm" name="createNewLanguage" onchange="window.location.href=this.options[this.selectedIndex].value">'
2549 . $output
2550 . '</select></div></div>';
2551 }
2552 return '';
2553 }
2554
2555 /**
2556 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
2557 *
2558 * @param Statement $result DBAL Statement
2559 * @param string $table Table name defaulting to tt_content
2560 * @return array The selected rows returned in this array.
2561 */
2562 public function getResult(Statement $result, string $table = 'tt_content'): array
2563 {
2564 $output = [];
2565 // Traverse the result:
2566 while ($row = $result->fetch()) {
2567 BackendUtility::workspaceOL($table, $row, -99, true);
2568 if ($row) {
2569 // Add the row to the array:
2570 $output[] = $row;
2571 }
2572 }
2573 $this->generateTtContentDataArray($output);
2574 // Return selected records
2575 return $output;
2576 }
2577
2578 /********************************
2579 *
2580 * Various helper functions
2581 *
2582 ********************************/
2583
2584 /**
2585 * Initializes the clipboard for generating paste links
2586 *
2587 *
2588 * @see \TYPO3\CMS\Backend\Controller\ContextMenuController::clipboardAction()
2589 * @see \TYPO3\CMS\Filelist\Controller\FileListController::indexAction()
2590 */
2591 protected function initializeClipboard()
2592 {
2593 // Start clipboard
2594 $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
2595
2596 // Initialize - reads the clipboard content from the user session
2597 $this->clipboard->initializeClipboard();
2598
2599 // This locks the clipboard to the Normal for this request.
2600 $this->clipboard->lockToNormal();
2601
2602 // Clean up pad
2603 $this->clipboard->cleanCurrent();
2604
2605 // Save the clipboard content
2606 $this->clipboard->endClipboard();
2607 }
2608
2609 /**
2610 * Generates the data for previous and next elements which is needed for movements.
2611 *
2612 * @param array $rowArray
2613 */
2614 protected function generateTtContentDataArray(array $rowArray)
2615 {
2616 if (empty($this->tt_contentData)) {
2617 $this->tt_contentData = [
2618 'nextThree' => [],
2619 'next' => [],
2620 'prev' => [],
2621 ];
2622 }
2623 foreach ($rowArray as $key => $value) {
2624 // Create the list of the next three ids (for editing links...)
2625 for ($i = 0; $i < $this->nextThree; $i++) {
2626 if (isset($rowArray[$key - $i])
2627 && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
2628 ) {
2629 $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
2630 }
2631 }
2632
2633 // Create information for next and previous content elements
2634 if (isset($rowArray[$key - 1])) {
2635 if (isset($rowArray[$key - 2])) {
2636 $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
2637 } else {
2638 $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
2639 }
2640 $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
2641 }
2642 }
2643 }
2644
2645 /**
2646 * Counts and returns the number of records on the page with $pid
2647 *
2648 * @param string $table Table name
2649 * @param int $pid Page id
2650 * @return int Number of records.
2651 */
2652 public function numberOfRecords($table, $pid)
2653 {
2654 $count = 0;
2655 if ($GLOBALS['TCA'][$table]) {
2656 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
2657 ->getQueryBuilderForTable($table);
2658 $queryBuilder->getRestrictions()
2659 ->removeAll()
2660 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2661 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
2662 $count = (int)$queryBuilder->count('uid')
2663 ->from($table)
2664 ->where(
2665 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT))
2666 )
2667 ->execute()
2668 ->fetchColumn();
2669 }
2670
2671 return $count;
2672 }
2673
2674 /**
2675 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
2676 *
2677 * @param string $input Input string
2678 * @return string Output string
2679 */
2680 public function renderText($input)
2681 {
2682 $input = strip_tags($input);
2683 $input = GeneralUtility::fixed_lgd_cs($input, 1500);
2684 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', false));
2685 }
2686
2687 /**
2688 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
2689 *
2690 * @param string $table Table name
2691 * @param array $row Record array
2692 * @param string $enabledClickMenuItems Passthrough to wrapClickMenuOnIcon
2693 * @return string HTML for the icon
2694 */
2695 public function getIcon($table, $row, $enabledClickMenuItems = '')
2696 {
2697 // Initialization
2698 $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
2699 $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
2700 $this->counter++;
2701 // The icon with link
2702 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
2703 $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
2704 }
2705 return $icon;
2706 }
2707
2708 /**
2709 * Creates processed values for all field names in $fieldList based on values from $row array.
2710 * The result is 'returned' through $info which is passed as a reference
2711 *
2712 * @param string $table Table name
2713 * @param string $fieldList Comma separated list of fields.
2714 * @param array $row Record from which to take values for processing.
2715 * @param array $info Array to which the processed values are added.
2716 */
2717 public function getProcessedValue($table, $fieldList, array $row, array &$info)
2718 {
2719 // Splitting values from $fieldList
2720 $fieldArr = explode(',', $fieldList);
2721 // Traverse fields from $fieldList
2722 foreach ($fieldArr as $field) {
2723 if ($row[$field]) {
2724 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
2725 . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
2726 }
2727 }
2728 }
2729
2730 /**
2731 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2732 *
2733 * @param string $table Tablename of table to test
2734 * @param array $row Record row.
2735 * @return bool Returns TRUE, if disabled.
2736 */
2737 public function isDisabled($table, $row)
2738 {
2739 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2740 return $enableCols['disabled'] && $row[$enableCols['disabled']]
2741 || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2742 || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2743 }
2744
2745 /**
2746 * Returns icon for "no-edit" of a record.
2747 * Basically, the point is to signal that this record could have had an edit link if
2748 * the circumstances were right. A placeholder for the regular edit icon...
2749 *
2750 * @param string $label Label key from LOCAL_LANG
2751 * @return string IMG tag for icon.
2752 */
2753 public function noEditIcon($label = 'noEditItems')
2754 {
2755 $title = htmlspecialchars($this->getLanguageService()->getLL($label));
2756 return '<span title="' . $title . '">' . $this->iconFactory->getIcon('status-edit-read-only', Icon::SIZE_SMALL)->render() . '</span>';
2757 }
2758
2759 /*****************************************
2760 *
2761 * External renderings
2762 *
2763 *****************************************/
2764
2765 /**
2766 * Creates a menu of the tables that can be listed by this function
2767 * Only tables which has records on the page will be included.
2768 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2769 *
2770 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2771 * @return string HTML output.
2772 */
2773 public function getTableMenu($id)
2774 {
2775 // Initialize:
2776 $this->activeTables = [];
2777 $theTables = ['tt_content'];
2778 // External tables:
2779 if (is_array($this->externalTables)) {
2780 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2781 }
2782 $out = '';
2783 // Traverse tables to check:
2784 foreach ($theTables as $tName) {
2785 // Check access and whether the proper extensions are loaded:
2786 if ($this->getBackendUser()->check('tables_select', $tName)
2787 && (
2788 isset($this->externalTables[$tName])
2789 || $tName === 'fe_users' || $tName === 'tt_content'
2790 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2791 )
2792 ) {
2793 // Make query to count records from page:
2794 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
2795 ->getQueryBuilderForTable($tName);
2796 $queryBuilder->getRestrictions()
2797 ->removeAll()
2798 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2799 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
2800 $count = $queryBuilder->count('uid')
2801 ->from($tName)
2802 ->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)))
2803 ->execute()
2804 ->fetchColumn();
2805 // If records were found (or if "tt_content" is the table...):
2806 if ($count || $tName === 'tt_content') {
2807 // Add row to menu:
2808 $out .= '
2809 <td><a href="#' . $tName . '" title="' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'])) . '"></a>'
2810 . $this->iconFactory->getIconForRecord($tName, [], Icon::SIZE_SMALL)->render()
2811 . '</td>';
2812 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2813 $title = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title']))
2814 . ': ' . $count . ' ' . htmlspecialchars($this->getLanguageService()->getLL('records'));
2815 $this->activeTables[$tName] = '<span title="' . $title . '">'
2816 . $this->iconFactory->getIconForRecord($tName, [], Icon::SIZE_SMALL)->render()
2817 . '</span>'
2818 . '&nbsp;' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title']));
2819 }
2820 }
2821 }
2822 // Wrap cells in table tags:
2823 $out = '
2824 <!--
2825 Menu of tables on the page (table menu)
2826 -->
2827 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2828 <tr>' . $out . '
2829 </tr>
2830 </table>';
2831 // Return the content:
2832 return $out;
2833 }
2834
2835 /**
2836 * Create thumbnail code for record/field but not linked
2837 *
2838 * @param mixed[] $row Record array
2839 * @param string $table Table (record is from)
2840 * @param string $field Field name for which thumbnail are to be rendered.
2841 * @return string HTML for thumbnails, if any.
2842 */
2843 public function getThumbCodeUnlinked($row, $table, $field)
2844 {
2845 return BackendUtility::thumbCode($row, $table, $field, '', '', null, 0, '', '', false);
2846 }
2847
2848 /**
2849 * Checks whether translated Content Elements exist in the desired language
2850 * If so, deny creating new ones via the UI
2851 *
2852 * @param array $contentElements
2853 * @param int $language
2854 * @return bool
2855 */
2856 protected function checkIfTranslationsExistInLanguage(array $contentElements, int $language)
2857 {
2858 // If in default language, you may always create new entries
2859 // Also, you may override this strict behavior via user TS Config
2860 // If you do so, you're on your own and cannot rely on any support by the TYPO3 core
2861 // We jump out here since we don't need to do the expensive loop operations
2862 $allowInconsistentLanguageHandling = (bool)(BackendUtility::getPagesTSconfig($this->id)['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? false);
2863 if ($language === 0 || $allowInconsistentLanguageHandling) {
2864 return false;
2865 }
2866 /**
2867 * Build up caches
2868 */
2869 if (!isset($this->languageHasTranslationsCache[$language])) {
2870 foreach ($contentElements as $columns) {
2871 foreach ($columns as $contentElement) {
2872 if ((int)$contentElement['l18n_parent'] === 0) {
2873 $this->languageHasTranslationsCache[$language]['hasStandAloneContent'] = true;
2874 $this->languageHasTranslationsCache[$language]['mode'] = 'free';
2875 }
2876 if ((int)$contentElement['l18n_parent'] > 0) {
2877 $this->languageHasTranslationsCache[$language]['hasTranslations'] = true;
2878 $this->languageHasTranslationsCache[$language]['mode'] = 'connected';
2879 }
2880 }
2881 }
2882 if (!isset($this->languageHasTranslationsCache[$language])) {
2883 $this->languageHasTranslationsCache[$language]['hasTranslations'] = false;
2884 }
2885 // Check whether we have a mix of both
2886 if (isset($this->languageHasTranslationsCache[$language]['hasStandAloneContent'])
2887 && $this->languageHasTranslationsCache[$language]['hasTranslations']
2888 ) {
2889 $this->languageHasTranslationsCache[$language]['mode'] = 'mixed';
2890 $siteLanguage = $this->siteLanguages[$language];
2891 $message = GeneralUtility::makeInstance(
2892 FlashMessage::class,
2893 sprintf($this->getLanguageService()->getLL('staleTranslationWarning'), $siteLanguage->getTitle()),
2894 sprintf($this->getLanguageService()->getLL('staleTranslationWarningTitle'), $siteLanguage->getTitle()),
2895 FlashMessage::WARNING
2896 );
2897 $service = GeneralUtility::makeInstance(FlashMessageService::class);
2898 $queue = $service->getMessageQueueByIdentifier();
2899 $queue->addMessage($message);
2900 }
2901 }