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