[BUGFIX] PageLayoutView - Keep copy settings if disabled
[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
882 $this->itemLabels = [];
883 foreach ($GLOBALS['TCA']['tt_content']['columns'] as $name => $val) {
884 $this->itemLabels[$name] = $this->getLanguageService()->sL($val['label']);
885 }
886 $languageColumn = [];
887 $out = '';
888
889 // Setting language list:
890 $langList = $this->tt_contentConfig['sys_language_uid'];
891 if ($this->tt_contentConfig['languageMode']) {
892 if ($this->tt_contentConfig['languageColsPointer']) {
893 $langList = '0,' . $this->tt_contentConfig['languageColsPointer'];
894 } else {
895 $langList = implode(',', array_keys($this->tt_contentConfig['languageCols']));
896 }
897 $languageColumn = [];
898 }
899 $langListArr = GeneralUtility::intExplode(',', $langList);
900 $defaultLanguageElementsByColumn = [];
901 $defLangBinding = [];
902 // For each languages... :
903 // If not languageMode, then we'll only be through this once.
904 foreach ($langListArr as $lP) {
905 $lP = (int)$lP;
906
907 if (!isset($this->contentElementCache[$lP])) {
908 $this->contentElementCache[$lP] = [];
909 }
910
911 if (count($langListArr) === 1 || $lP === 0) {
912 $showLanguage = $expressionBuilder->in('sys_language_uid', [$lP, -1]);
913 } else {
914 $showLanguage = $expressionBuilder->eq('sys_language_uid', $lP);
915 }
916 $content = [];
917 $head = [];
918
919 $backendLayout = $this->getBackendLayoutView()->getSelectedBackendLayout($this->id);
920 $columns = $backendLayout['__colPosList'];
921 // Select content records per column
922 $contentRecordsPerColumn = $this->getContentRecordsPerColumn('table', $id, $columns, $showLanguage);
923 $cList = array_keys($contentRecordsPerColumn);
924 // For each column, render the content into a variable:
925 foreach ($cList as $columnId) {
926 if (!isset($this->contentElementCache[$lP])) {
927 $this->contentElementCache[$lP] = [];
928 }
929
930 if (!$lP) {
931 $defaultLanguageElementsByColumn[$columnId] = [];
932 }
933
934 // Start wrapping div
935 $content[$columnId] .= '<div data-colpos="' . $columnId . '" data-language-uid="' . $lP . '" class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-' . $lP . ' t3-page-ce-wrapper';
936 if (empty($contentRecordsPerColumn[$columnId])) {
937 $content[$columnId] .= ' t3-page-ce-empty';
938 }
939 $content[$columnId] .= '">';
940 // Add new content at the top most position
941 $link = '';
942 if ($this->isContentEditable()
943 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
944 ) {
945 if ($this->option_newWizard) {
946 $urlParameters = [
947 'id' => $id,
948 'sys_language_uid' => $lP,
949 'colPos' => $columnId,
950 'uid_pid' => $id,
951 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
952 ];
953 $routeName = BackendUtility::getPagesTSconfig($id)['mod.']['newContentElementWizard.']['override']
954 ?? 'new_content_element_wizard';
955 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
956 $url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
957 } else {
958 $urlParameters = [
959 'edit' => [
960 'tt_content' => [
961 $id => 'new'
962 ]
963 ],
964 'defVals' => [
965 'tt_content' => [
966 'colPos' => $columnId,
967 'sys_language_uid' => $lP
968 ]
969 ],
970 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
971 ];
972 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
973 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
974 }
975 $title = htmlspecialchars($this->getLanguageService()->getLL('newContentElement'));
976 $link = '<a href="#" data-url="' . htmlspecialchars($url) . '" '
977 . 'title="' . $title . '"'
978 . 'data-title="' . $title . '"'
979 . 'class="btn btn-default btn-sm t3js-toggle-new-content-element-wizard">'
980 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render()
981 . ' '
982 . htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>';
983 }
984 if ($this->getBackendUser()->checkLanguageAccess($lP) && $columnId !== 'unused') {
985 $content[$columnId] .= '
986 <div class="t3-page-ce t3js-page-ce" data-page="' . (int)$id . '" id="' . StringUtility::getUniqueId() . '">
987 <div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-' . 'page-' . $id . '-' . StringUtility::getUniqueId() . '">'
988 . $link
989 . '</div>
990 <div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
991 </div>
992 ';
993 }
994 $editUidList = '';
995 if (!isset($contentRecordsPerColumn[$columnId]) || !is_array($contentRecordsPerColumn[$columnId])) {
996 $message = GeneralUtility::makeInstance(
997 FlashMessage::class,
998 $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:error.invalidBackendLayout'),
999 '',
1000 FlashMessage::WARNING
1001 );
1002 $service = GeneralUtility::makeInstance(FlashMessageService::class);
1003 $queue = $service->getMessageQueueByIdentifier();
1004 $queue->addMessage($message);
1005 } else {
1006 $rowArr = $contentRecordsPerColumn[$columnId];
1007 $this->generateTtContentDataArray($rowArr);
1008
1009 foreach ((array)$rowArr as $rKey => $row) {
1010 $this->contentElementCache[$lP][$columnId][$row['uid']] = $row;
1011 if ($this->tt_contentConfig['languageMode']) {
1012 $languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
1013 }
1014 if (is_array($row) && !VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
1015 $singleElementHTML = '<div class="t3-page-ce-dragitem" id="' . StringUtility::getUniqueId() . '">';
1016 if (!$lP && ($this->defLangBinding || $row['sys_language_uid'] != -1)) {
1017 $defaultLanguageElementsByColumn[$columnId][] = ($row['_ORIG_uid'] ?? $row['uid']);
1018 }
1019 $editUidList .= $row['uid'] . ',';
1020 $disableMoveAndNewButtons = $this->defLangBinding && $lP > 0 && $this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP);
1021 $singleElementHTML .= $this->tt_content_drawHeader(
1022 $row,
1023 $this->tt_contentConfig['showInfo'] ? 15 : 5,
1024 $disableMoveAndNewButtons,
1025 true,
1026 $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
1027 );
1028 $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>'
1029 . $this->tt_content_drawItem($row) . '</div>';
1030 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' . $innerContent . '</div></div>'
1031 . $this->tt_content_drawFooter($row);
1032 $isDisabled = $this->isDisabled('tt_content', $row);
1033 $statusHidden = $isDisabled ? ' t3-page-ce-hidden t3js-hidden-record' : '';
1034 $displayNone = !$this->tt_contentConfig['showHidden'] && $isDisabled ? ' style="display: none;"' : '';
1035 $highlightHeader = '';
1036 if ($this->checkIfTranslationsExistInLanguage([], (int)$row['sys_language_uid']) && (int)$row['l18n_parent'] === 0) {
1037 $highlightHeader = ' t3-page-ce-danger';
1038 } elseif ($columnId === 'unused') {
1039 $highlightHeader = ' t3-page-ce-warning';
1040 }
1041 $singleElementHTML = '<div class="t3-page-ce' . $highlightHeader . ' t3js-page-ce t3js-page-ce-sortable ' . $statusHidden . '" id="element-tt_content-'
1042 . $row['uid'] . '" data-table="tt_content" data-uid="' . $row['uid'] . '"' . $displayNone . '>' . $singleElementHTML . '</div>';
1043
1044 $singleElementHTML .= '<div class="t3-page-ce" data-colpos="' . $columnId . '">';
1045 $singleElementHTML .= '<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-' . $columnId . '-' . 'page-' . $id .
1046 '-' . StringUtility::getUniqueId() . '">';
1047 // Add icon "new content element below"
1048 if (!$disableMoveAndNewButtons
1049 && $this->isContentEditable()
1050 && $this->getBackendUser()->checkLanguageAccess($lP)
1051 && (!$this->checkIfTranslationsExistInLanguage($contentRecordsPerColumn, $lP))
1052 && $columnId !== 'unused'
1053 ) {
1054 // New content element:
1055 if ($this->option_newWizard) {
1056 $urlParameters = [
1057 'id' => $row['pid'],
1058 'sys_language_uid' => $row['sys_language_uid'],
1059 'colPos' => $row['colPos'],
1060 'uid_pid' => -$row['uid'],
1061 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1062 ];
1063 $routeName = BackendUtility::getPagesTSconfig($row['pid'])['mod.']['newContentElementWizard.']['override']
1064 ?? 'new_content_element_wizard';
1065 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1066 $url = (string)$uriBuilder->buildUriFromRoute($routeName, $urlParameters);
1067 } else {
1068 $urlParameters = [
1069 'edit' => [
1070 'tt_content' => [
1071 -$row['uid'] => 'new'
1072 ]
1073 ],
1074 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1075 ];
1076 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1077 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1078 }
1079 $title = htmlspecialchars($this->getLanguageService()->getLL('newContentElement'));
1080 $singleElementHTML .= '<a href="#" data-url="' . htmlspecialchars($url) . '" '
1081 . 'title="' . $title . '"'
1082 . 'data-title="' . $title . '"'
1083 . 'class="btn btn-default btn-sm t3js-toggle-new-content-element-wizard">'
1084 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render()
1085 . ' '
1086 . htmlspecialchars($this->getLanguageService()->getLL('content')) . '</a>';
1087 }
1088 $singleElementHTML .= '</div></div><div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div></div>';
1089 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
1090 $defLangBinding[$columnId][$lP][$row[$lP ? 'l18n_parent' : 'uid'] ?: $row['uid']] = $singleElementHTML;
1091 } else {
1092 $content[$columnId] .= $singleElementHTML;
1093 }
1094 } else {
1095 unset($rowArr[$rKey]);
1096 }
1097 }
1098 $content[$columnId] .= '</div>';
1099 $colTitle = BackendUtility::getProcessedValue('tt_content', 'colPos', $columnId);
1100 $tcaItems = GeneralUtility::callUserFunction(\TYPO3\CMS\Backend\View\BackendLayoutView::class . '->getColPosListItemsParsed', $id, $this);
1101 foreach ($tcaItems as $item) {
1102 if ($item[1] == $columnId) {
1103 $colTitle = $this->getLanguageService()->sL($item[0]);
1104 }
1105 }
1106 if ($columnId === 'unused') {
1107 if (empty($unusedElementsMessage)) {
1108 $unusedElementsMessage = GeneralUtility::makeInstance(
1109 FlashMessage::class,
1110 $this->getLanguageService()->getLL('staleUnusedElementsWarning'),
1111 $this->getLanguageService()->getLL('staleUnusedElementsWarningTitle'),
1112 FlashMessage::WARNING
1113 );
1114 $service = GeneralUtility::makeInstance(FlashMessageService::class);
1115 $queue = $service->getMessageQueueByIdentifier();
1116 $queue->addMessage($unusedElementsMessage);
1117 }
1118 $colTitle = $this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:colPos.I.unused');
1119 $editParam = '';
1120 } else {
1121 $editParam = $this->doEdit && !empty($rowArr)
1122 ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
1123 : '';
1124 }
1125 $head[$columnId] .= $this->tt_content_drawColHeader($colTitle, $editParam);
1126 }
1127 }
1128 // For each column, fit the rendered content into a table cell:
1129 $out = '';
1130 if ($this->tt_contentConfig['languageMode']) {
1131 // in language mode process the content elements, but only fill $languageColumn. output will be generated later
1132 $sortedLanguageColumn = [];
1133 foreach ($cList as $columnId) {
1134 if (GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnId) || $columnId === 'unused') {
1135 $languageColumn[$columnId][$lP] = $head[$columnId] . $content[$columnId];
1136
1137 // We sort $languageColumn again according to $cList as it may contain data already from above.
1138 $sortedLanguageColumn[$columnId] = $languageColumn[$columnId];
1139 }
1140 }
1141 if (!empty($languageColumn['unused'])) {
1142 $sortedLanguageColumn['unused'] = $languageColumn['unused'];
1143 }
1144 $languageColumn = $sortedLanguageColumn;
1145 } else {
1146 // GRID VIEW:
1147 $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">';
1148 // Add colgroups
1149 $colCount = (int)$backendLayout['__config']['backend_layout.']['colCount'];
1150 $rowCount = (int)$backendLayout['__config']['backend_layout.']['rowCount'];
1151 $grid .= '<colgroup>';
1152 for ($i = 0; $i < $colCount; $i++) {
1153 $grid .= '<col />';
1154 }
1155 $grid .= '</colgroup>';
1156
1157 // Check how to handle restricted columns
1158 $hideRestrictedCols = (bool)(BackendUtility::getPagesTSconfig($id)['mod.']['web_layout.']['hideRestrictedCols'] ?? false);
1159
1160 // Cycle through rows
1161 for ($row = 1; $row <= $rowCount; $row++) {
1162 $rowConfig = $backendLayout['__config']['backend_layout.']['rows.'][$row . '.'];
1163 if (!isset($rowConfig)) {
1164 continue;
1165 }
1166 $grid .= '<tr>';
1167 for ($col = 1; $col <= $colCount; $col++) {
1168 $columnConfig = $rowConfig['columns.'][$col . '.'];
1169 if (!isset($columnConfig)) {
1170 continue;
1171 }
1172 // Which tt_content colPos should be displayed inside this cell
1173 $columnKey = (int)$columnConfig['colPos'];
1174 // Render the grid cell
1175 $colSpan = (int)$columnConfig['colspan'];
1176 $rowSpan = (int)$columnConfig['rowspan'];
1177 $grid .= '<td valign="top"' .
1178 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
1179 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
1180 ' 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 .
1181 ((!isset($columnConfig['colPos']) || $columnConfig['colPos'] === '') ? ' t3-grid-cell-unassigned' : '') .
1182 ((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') : '') .
1183 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') .
1184 ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
1185
1186 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
1187 // If not, a new header without any buttons will be generated.
1188 if (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== '' && $head[$columnKey]
1189 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
1190 ) {
1191 $grid .= $head[$columnKey] . $content[$columnKey];
1192 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
1193 && GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
1194 ) {
1195 if (!$hideRestrictedCols) {
1196 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('noAccess'));
1197 }
1198 } elseif (isset($columnConfig['colPos']) && $columnConfig['colPos'] !== ''
1199 && !GeneralUtility::inList($this->tt_contentConfig['activeCols'], $columnConfig['colPos'])
1200 ) {
1201 if (!$hideRestrictedCols) {
1202 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
1203 ' (' . $this->getLanguageService()->getLL('noAccess') . ')');
1204 }
1205 } elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
1206 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
1207 . ' (' . $this->getLanguageService()->getLL('notAssigned') . ')');
1208 } else {
1209 $grid .= $this->tt_content_drawColHeader($this->getLanguageService()->getLL('notAssigned'));
1210 }
1211
1212 $grid .= '</td>';
1213 }
1214 $grid .= '</tr>';
1215 }
1216 if (!empty($content['unused'])) {
1217 $grid .= '<tr>';
1218 // Which tt_content colPos should be displayed inside this cell
1219 $columnKey = 'unused';
1220 // Render the grid cell
1221 $colSpan = (int)$backendLayout['__config']['backend_layout.']['colCount'];
1222 $grid .= '<td valign="top"' .
1223 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
1224 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
1225 ' 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 .
1226 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') . '">';
1227
1228 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
1229 // If not, a new header without any buttons will be generated.
1230 $grid .= $head[$columnKey] . $content[$columnKey];
1231 $grid .= '</td></tr>';
1232 }
1233 $out .= $grid . '</table></div>';
1234 }
1235 }
1236 $elFromTable = $this->clipboard->elFromTable('tt_content');
1237 if (!empty($elFromTable) && $this->isPageEditable()) {
1238 $pasteItem = substr(key($elFromTable), 11);
1239 $pasteRecord = BackendUtility::getRecord('tt_content', (int)$pasteItem);
1240 $pasteTitle = $pasteRecord['header'] ? $pasteRecord['header'] : $pasteItem;
1241 $copyMode = $this->clipboard->clipData['normal']['mode'] ? '-' . $this->clipboard->clipData['normal']['mode'] : '';
1242 $addExtOnReadyCode = '
1243 top.pasteIntoLinkTemplate = '
1244 . $this->tt_content_drawPasteIcon($pasteItem, $pasteTitle, $copyMode, 't3js-paste-into', 'pasteIntoColumn')
1245 . ';
1246 top.pasteAfterLinkTemplate = '
1247 . $this->tt_content_drawPasteIcon($pasteItem, $pasteTitle, $copyMode, 't3js-paste-after', 'pasteAfterRecord')
1248 . ';';
1249 } else {
1250 $addExtOnReadyCode = '
1251 top.pasteIntoLinkTemplate = \'\';
1252 top.pasteAfterLinkTemplate = \'\';';
1253 }
1254 $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
1255 $pageRenderer->addJsInlineCode('pasteLinkTemplates', $addExtOnReadyCode);
1256 // If language mode, then make another presentation:
1257 // Notice that THIS presentation will override the value of $out!
1258 // But it needs the code above to execute since $languageColumn is filled with content we need!
1259 if ($this->tt_contentConfig['languageMode']) {
1260 // Get language selector:
1261 $languageSelector = $this->languageSelector($id);
1262 // Reset out - we will make new content here:
1263 $out = '';
1264 // Traverse languages found on the page and build up the table displaying them side by side:
1265 $cCont = [];
1266 $sCont = [];
1267 foreach ($langListArr as $lP) {
1268 $languageMode = '';
1269 $labelClass = 'info';
1270 // Header:
1271 $lP = (int)$lP;
1272 // Determine language mode
1273 if ($lP > 0 && isset($this->languageHasTranslationsCache[$lP]['mode'])) {
1274 switch ($this->languageHasTranslationsCache[$lP]['mode']) {
1275 case 'mixed':
1276 $languageMode = $this->getLanguageService()->getLL('languageModeMixed');
1277 $labelClass = 'danger';
1278 break;
1279 case 'connected':
1280 $languageMode = $this->getLanguageService()->getLL('languageModeConnected');
1281 break;
1282 case 'free':
1283 $languageMode = $this->getLanguageService()->getLL('languageModeFree');
1284 break;
1285 default:
1286 // we'll let opcode optimize this intentionally empty case
1287 }
1288 }
1289 $cCont[$lP] = '
1290 <td valign="top" class="t3-page-column t3-page-column-lang-name" data-language-uid="' . $lP . '">
1291 <h2>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</h2>
1292 ' . ($languageMode !== '' ? '<span class="label label-' . $labelClass . '">' . $languageMode . '</span>' : '') . '
1293 </td>';
1294
1295 // "View page" icon is added:
1296 $viewLink = '';
1297 if (!VersionState::cast($this->getPageLayoutController()->pageinfo['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
1298 $onClick = BackendUtility::viewOnClick(
1299 $this->id,
1300 '',
1301 BackendUtility::BEgetRootLine($this->id),
1302 '',
1303 '',
1304 '&L=' . $lP
1305 );
1306 $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>';
1307 }
1308 // Language overlay page header:
1309 if ($lP) {
1310 $pageLocalizationRecord = BackendUtility::getRecordLocalization('pages', $id, $lP);
1311 if (is_array($pageLocalizationRecord)) {
1312 $pageLocalizationRecord = reset($pageLocalizationRecord);
1313 }
1314 BackendUtility::workspaceOL('pages', $pageLocalizationRecord);
1315 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
1316 $this->iconFactory->getIconForRecord('pages', $pageLocalizationRecord, Icon::SIZE_SMALL)->render(),
1317 'pages',
1318 $pageLocalizationRecord['uid']
1319 );
1320 $urlParameters = [
1321 'edit' => [
1322 'pages' => [
1323 $pageLocalizationRecord['uid'] => 'edit'
1324 ]
1325 ],
1326 // Disallow manual adjustment of the language field for pages
1327 'overrideVals' => [
1328 'pages' => [
1329 'sys_language_uid' => $lP
1330 ]
1331 ],
1332 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1333 ];
1334 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1335 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1336 $editLink = (
1337 $this->getBackendUser()->check('tables_modify', 'pages')
1338 ? '<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
1339 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1340 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
1341 : ''
1342 );
1343
1344 $defaultLanguageElements = [];
1345 array_walk($defaultLanguageElementsByColumn, function (array $columnContent) use (&$defaultLanguageElements) {
1346 $defaultLanguageElements = array_merge($defaultLanguageElements, $columnContent);
1347 });
1348
1349 $localizationButtons = [];
1350 $localizationButtons[] = $this->newLanguageButton(
1351 $this->getNonTranslatedTTcontentUids($defaultLanguageElements, $id, $lP),
1352 $lP
1353 );
1354
1355 $lPLabel =
1356 '<div class="btn-group">'
1357 . $viewLink
1358 . $editLink
1359 . (!empty($localizationButtons) ? implode(LF, $localizationButtons) : '')
1360 . '</div>'
1361 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($pageLocalizationRecord['title'], 20))
1362 ;
1363 } else {
1364 $editLink = '';
1365 $recordIcon = '';
1366 if ($this->getBackendUser()->checkLanguageAccess(0)) {
1367 $recordIcon = BackendUtility::wrapClickMenuOnIcon(
1368 $this->iconFactory->getIconForRecord('pages', $this->pageRecord, Icon::SIZE_SMALL)->render(),
1369 'pages',
1370 $this->id
1371 );
1372 $urlParameters = [
1373 'edit' => [
1374 'pages' => [
1375 $this->id => 'edit'
1376 ]
1377 ],
1378 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1379 ];
1380 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1381 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1382 $editLink = (
1383 $this->getBackendUser()->check('tables_modify', 'pages')
1384 ? '<a href="' . htmlspecialchars($url) . '" class="btn btn-default btn-sm"'
1385 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1386 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>'
1387 : ''
1388 );
1389 }
1390
1391 $lPLabel =
1392 '<div class="btn-group">'
1393 . $viewLink
1394 . $editLink
1395 . '</div>'
1396 . ' ' . $recordIcon . ' ' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($this->pageRecord['title'], 20));
1397 }
1398 $sCont[$lP] = '
1399 <td class="t3-page-column t3-page-lang-label nowrap">' . $lPLabel . '</td>';
1400 }
1401 // Add headers:
1402 $out .= '<tr>' . implode($cCont) . '</tr>';
1403 $out .= '<tr>' . implode($sCont) . '</tr>';
1404 unset($cCont, $sCont);
1405
1406 // Traverse previously built content for the columns:
1407 foreach ($languageColumn as $cKey => $cCont) {
1408 $out .= '<tr>';
1409 foreach ($cCont as $languageId => $columnContent) {
1410 $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>';
1411 }
1412 $out .= '</tr>';
1413 if ($this->defLangBinding && !empty($defLangBinding[$cKey])) {
1414 $maxItemsCount = max(array_map('count', $defLangBinding[$cKey]));
1415 for ($i = 0; $i < $maxItemsCount; $i++) {
1416 $defUid = $defaultLanguageElementsByColumn[$cKey][$i] ?? 0;
1417 $cCont = [];
1418 foreach ($langListArr as $lP) {
1419 if ($lP > 0
1420 && is_array($defLangBinding[$cKey][$lP])
1421 && !$this->checkIfTranslationsExistInLanguage($defaultLanguageElementsByColumn[$cKey], $lP)
1422 && count($defLangBinding[$cKey][$lP]) > $i
1423 ) {
1424 $slice = array_slice($defLangBinding[$cKey][$lP], $i, 1);
1425 $element = $slice[0] ?? '';
1426 } else {
1427 $element = $defLangBinding[$cKey][$lP][$defUid] ?? '';
1428 }
1429 $cCont[] = $element;
1430 }
1431 $out .= '
1432 <tr>
1433 <td valign="top" class="t3-grid-cell">' . implode('</td>' . '
1434 <td valign="top" class="t3-grid-cell">', $cCont) . '</td>
1435 </tr>';
1436 }
1437 }
1438 }
1439 // Finally, wrap it all in a table and add the language selector on top of it:
1440 $out = $languageSelector . '
1441 <div class="t3-grid-container">
1442 <table cellpadding="0" cellspacing="0" class="t3-page-columns t3-grid-table t3js-page-columns">
1443 ' . $out . '
1444 </table>
1445 </div>';
1446 }
1447
1448 return $out;
1449 }
1450
1451 /**********************************
1452 *
1453 * Generic listing of items
1454 *
1455 **********************************/
1456 /**
1457 * Creates a standard list of elements from a table.
1458 *
1459 * @param string $table Table name
1460 * @param int $id Page id.
1461 * @param string $fList Comma list of fields to display
1462 * @param bool $icon If TRUE, icon is shown
1463 * @param string $addWhere Additional WHERE-clauses.
1464 * @return string HTML table
1465 */
1466 public function makeOrdinaryList($table, $id, $fList, $icon = false, $addWhere = '')
1467 {
1468 // Initialize
1469 $addWhere = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
1470 $queryBuilder = $this->getQueryBuilder($table, $id, $addWhere);
1471 $this->setTotalItems($table, $id, $addWhere);
1472 $dbCount = 0;
1473 $result = false;
1474 // Make query for records if there were any records found in the count operation
1475 if ($this->totalItems) {
1476 $result = $queryBuilder->execute();
1477 // Will return FALSE, if $result is invalid
1478 $dbCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
1479 }
1480 // If records were found, render the list
1481 if (!$dbCount) {
1482 return '';
1483 }
1484 // Set fields
1485 $out = '';
1486 $this->fieldArray = GeneralUtility::trimExplode(',', '__cmds__,' . $fList . ',__editIconLink__', true);
1487 $theData = [];
1488 $theData = $this->headerFields($this->fieldArray, $table, $theData);
1489 // Title row
1490 $localizedTableTitle = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
1491 $out .= '<tr><th class="col-icon"></th>'
1492 . '<th colspan="' . (count($theData) - 2) . '"><span class="c-table">'
1493 . $localizedTableTitle . '</span> (' . $dbCount . ')</td>' . '<td class="col-icon"></td>'
1494 . '</tr>';
1495 // Column's titles
1496 if ($this->doEdit) {
1497 $urlParameters = [
1498 'edit' => [
1499 $table => [
1500 $this->id => 'new'
1501 ]
1502 ],
1503 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1504 ];
1505 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1506 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1507 $title = htmlspecialchars($this->getLanguageService()->getLL('new'));
1508 $theData['__cmds__'] = '<a href="#" data-url="' . htmlspecialchars($url) . '" class="t3js-toggle-new-content-element-wizard" '
1509 . 'title="' . $title . '"'
1510 . 'data-title="' . $title . '">'
1511 . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</a>';
1512 }
1513 $out .= $this->addElement(1, '', $theData, ' class="c-headLine"', 15, '', 'th');
1514 // Render Items
1515 $this->eCounter = $this->firstElementNumber;
1516 while ($row = $result->fetch()) {
1517 BackendUtility::workspaceOL($table, $row);
1518 if (is_array($row)) {
1519 list($flag, $code) = $this->fwd_rwd_nav();
1520 $out .= $code;
1521 if ($flag) {
1522 $Nrow = [];
1523 // Setting icons links
1524 if ($icon) {
1525 $Nrow['__cmds__'] = $this->getIcon($table, $row);
1526 }
1527 // Get values:
1528 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
1529 // Attach edit icon
1530 if ($this->doEdit && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
1531 $urlParameters = [
1532 'edit' => [
1533 $table => [
1534 $row['uid'] => 'edit'
1535 ]
1536 ],
1537 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1538 ];
1539 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1540 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1541 $Nrow['__editIconLink__'] = '<a class="btn btn-default" href="' . htmlspecialchars($url)
1542 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">'
1543 . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
1544 } else {
1545 $Nrow['__editIconLink__'] = $this->noEditIcon();
1546 }
1547 $out .= $this->addElement(1, '', $Nrow);
1548 }
1549 $this->eCounter++;
1550 }
1551 }
1552 // Wrap it all in a table:
1553 $out = '
1554 <!--
1555 Standard list of table "' . $table . '"
1556 -->
1557 <div class="table-fit"><table class="table table-hover table-striped">
1558 ' . $out . '
1559 </table></div>';
1560 return $out;
1561 }
1562
1563 /**
1564 * Adds content to all data fields in $out array
1565 *
1566 * Each field name in $fieldArr has a special feature which is that the field name can be specified as more field names.
1567 * Eg. "field1,field2;field3".
1568 * Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1569 *
1570 * @param array $fieldArr Array of fields to display
1571 * @param string $table Table name
1572 * @param array $row Record array
1573 * @param array $out Array to which the data is added
1574 * @return array $out array returned after processing.
1575 * @see makeOrdinaryList()
1576 */
1577 public function dataFields($fieldArr, $table, $row, $out = [])
1578 {
1579 // Check table validity
1580 if (!isset($GLOBALS['TCA'][$table])) {
1581 return $out;
1582 }
1583
1584 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
1585 // Traverse fields
1586 foreach ($fieldArr as $fieldName) {
1587 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
1588 // Each field has its own cell (if configured in TCA)
1589 // If the column is a thumbnail column:
1590 if ($fieldName == $thumbsCol) {
1591 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
1592 } else {
1593 // ... otherwise just render the output:
1594 $out[$fieldName] = nl2br(htmlspecialchars(trim(GeneralUtility::fixed_lgd_cs(
1595 BackendUtility::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']),
1596 250
1597 ))));
1598 }
1599 } else {
1600 // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode
1601 // the field name with ";" and check each value there as a TCA configured field)
1602 $theFields = explode(';', $fieldName);
1603 // Traverse fields, separated by ";" (displayed in a single cell).
1604 foreach ($theFields as $fName2) {
1605 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
1606 $out[$fieldName] .= '<strong>' . htmlspecialchars($this->getLanguageService()->sL(
1607 $GLOBALS['TCA'][$table]['columns'][$fName2]['label']
1608 )) . '</strong>' . '&nbsp;&nbsp;' . htmlspecialchars(GeneralUtility::fixed_lgd_cs(
1609 BackendUtility::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']),
1610 25
1611 )) . '<br />';
1612 }
1613 }
1614 }
1615 // If no value, add a nbsp.
1616 if (!$out[$fieldName]) {
1617 $out[$fieldName] = '&nbsp;';
1618 }
1619 // Wrap in dimmed-span tags if record is "disabled"
1620 if ($this->isDisabled($table, $row)) {
1621 $out[$fieldName] = '<span class="text-muted">' . $out[$fieldName] . '</span>';
1622 }
1623 }
1624 return $out;
1625 }
1626
1627 /**
1628 * Header fields made for the listing of records
1629 *
1630 * @param array $fieldArr Field names
1631 * @param string $table The table name
1632 * @param array $out Array to which the headers are added.
1633 * @return array $out returned after addition of the header fields.
1634 * @see makeOrdinaryList()
1635 */
1636 public function headerFields($fieldArr, $table, $out = [])
1637 {
1638 foreach ($fieldArr as $fieldName) {
1639 $ll = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']));
1640 $out[$fieldName] = $ll ? $ll : '&nbsp;';
1641 }
1642 return $out;
1643 }
1644
1645 /**
1646 * Gets content records per column.
1647 * This is required for correct workspace overlays.
1648 *
1649 * @param string $table UNUSED (will always be queried from tt_content)
1650 * @param int $id Page Id to be used (not used at all, but part of the API, see $this->pidSelect)
1651 * @param array $columns colPos values to be considered to be shown
1652 * @param string $additionalWhereClause Additional where clause for database select
1653 * @return array Associative array for each column (colPos)
1654 */
1655 protected function getContentRecordsPerColumn($table, $id, array $columns, $additionalWhereClause = '')
1656 {
1657 $contentRecordsPerColumn = array_fill_keys($columns, []);
1658 $columns = array_flip($columns);
1659 $queryBuilder = $this->getQueryBuilder(
1660 'tt_content',
1661 $id,
1662 [
1663 $additionalWhereClause
1664 ]
1665 );
1666
1667 // Traverse any selected elements and render their display code:
1668 $results = $this->getResult($queryBuilder->execute());
1669 $unused = [];
1670 $hookArray = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['record_is_used'] ?? [];
1671 foreach ($results as $record) {
1672 $used = isset($columns[$record['colPos']]);
1673 foreach ($hookArray as $_funcRef) {
1674 $_params = ['columns' => $columns, 'record' => $record, 'used' => $used];
1675 $used = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1676 }
1677 if ($used) {
1678 $columnValue = (string)$record['colPos'];
1679 $contentRecordsPerColumn[$columnValue][] = $record;
1680 } else {
1681 $unused[] = $record;
1682 }
1683 }
1684 if (!empty($unused)) {
1685 $contentRecordsPerColumn['unused'] = $unused;
1686 }
1687 return $contentRecordsPerColumn;
1688 }
1689
1690 /**********************************
1691 *
1692 * Additional functions; Pages
1693 *
1694 **********************************/
1695
1696 /**
1697 * Adds pages-rows to an array, selecting recursively in the page tree.
1698 *
1699 * @param int $pid Starting page id to select from
1700 * @param string $iconPrefix Prefix for icon code.
1701 * @param int $depth Depth (decreasing)
1702 * @param array $rows Array which will accumulate page rows
1703 * @return array $rows with added rows.
1704 */
1705 protected function getPageRecordsRecursive(int $pid, int $depth, string $iconPrefix = '', array $rows = []): array
1706 {
1707 $depth--;
1708 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
1709 $queryBuilder->getRestrictions()
1710 ->removeAll()
1711 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
1712 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
1713
1714 $queryBuilder
1715 ->select('*')
1716 ->from('pages')
1717 ->where(
1718 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT)),
1719 $queryBuilder->expr()->eq('sys_language_uid', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)),
1720 $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW)
1721 );
1722
1723 if (!empty($GLOBALS['TCA']['pages']['ctrl']['sortby'])) {
1724 $queryBuilder->orderBy($GLOBALS['TCA']['pages']['ctrl']['sortby']);
1725 }
1726
1727 if ($depth >= 0) {
1728 $result = $queryBuilder->execute();
1729 $rowCount = $queryBuilder->count('uid')->execute()->fetchColumn(0);
1730 $count = 0;
1731 while ($row = $result->fetch()) {
1732 BackendUtility::workspaceOL('pages', $row);
1733 if (is_array($row)) {
1734 $count++;
1735 $row['treeIcons'] = $iconPrefix
1736 . '<span class="treeline-icon treeline-icon-join'
1737 . ($rowCount === $count ? 'bottom' : '')
1738 . '"></span>';
1739 $rows[] = $row;
1740 // Get the branch
1741 $spaceOutIcons = '<span class="treeline-icon treeline-icon-'
1742 . ($rowCount === $count ? 'clear' : 'line')
1743 . '"></span>';
1744 $rows = $this->getPageRecordsRecursive(
1745 $row['uid'],
1746 $row['php_tree_stop'] ? 0 : $depth,
1747 $iconPrefix . $spaceOutIcons,
1748 $rows
1749 );
1750 }
1751 }
1752 }
1753
1754 return $rows;
1755 }
1756
1757 /**
1758 * Adds a list item for the pages-rendering
1759 *
1760 * @param array $row Record array
1761 * @param array $fieldArr Field list
1762 * @return string HTML for the item
1763 */
1764 public function pages_drawItem($row, $fieldArr)
1765 {
1766 $userTsConfig = $this->getBackendUser()->getTSConfig();
1767
1768 // Initialization
1769 $theIcon = $this->getIcon('pages', $row);
1770 // Preparing and getting the data-array
1771 $theData = [];
1772 foreach ($fieldArr as $field) {
1773 switch ($field) {
1774 case 'title':
1775 $showPageId = !empty($userTsConfig['options.']['pageTree.']['showPageIdWithTitle']);
1776 $pTitle = htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field], 20));
1777 $theData[$field] = $row['treeIcons'] . $theIcon . ($showPageId ? '[' . $row['uid'] . '] ' : '') . $pTitle;
1778 break;
1779 case 'php_tree_stop':
1780 // Intended fall through
1781 case 'TSconfig':
1782 $theData[$field] = $row[$field] ? '<strong>x</strong>' : '&nbsp;';
1783 break;
1784 case 'uid':
1785 if ($this->getBackendUser()->doesUserHaveAccess($row, 2) && $row['uid'] > 0) {
1786 $urlParameters = [
1787 'edit' => [
1788 'pages' => [
1789 $row['uid'] => 'edit'
1790 ]
1791 ],
1792 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
1793 ];
1794 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1795 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
1796 $onClick = BackendUtility::viewOnClick($row['uid'], '', BackendUtility::BEgetRootLine($row['uid']));
1797
1798 $eI =
1799 '<a href="#" onclick="' . htmlspecialchars($onClick) . '" class="btn btn-default" title="' .
1800 $this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' .
1801 $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render() .
1802 '</a>';
1803 $eI .=
1804 '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' .
1805 htmlspecialchars($this->getLanguageService()->getLL('editThisPage')) . '">' .
1806 $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render() .
1807 '</a>';
1808 } else {
1809 $eI = '';
1810 }
1811 $theData[$field] = '<div class="btn-group" role="group">' . $eI . '</div>';
1812 break;
1813 case 'shortcut':
1814 case 'shortcut_mode':
1815 if ((int)$row['doktype'] === \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_SHORTCUT) {
1816 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1817 }
1818 break;
1819 default:
1820 if (strpos($field, 'table_') === 0) {
1821 $f2 = substr($field, 6);
1822 if ($GLOBALS['TCA'][$f2]) {
1823 $c = $this->numberOfRecords($f2, $row['uid']);
1824 $theData[$field] = ($c ? $c : '');
1825 }
1826 } else {
1827 $theData[$field] = $this->getPagesTableFieldValue($field, $row);
1828 }
1829 }
1830 }
1831 $this->addElement_tdParams['title'] = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '';
1832 return $this->addElement(1, '', $theData);
1833 }
1834
1835 /**
1836 * Returns the HTML code for rendering a field in the pages table.
1837 * The row value is processed to a human readable form and the result is parsed through htmlspecialchars().
1838 *
1839 * @param string $field The name of the field of which the value should be rendered.
1840 * @param array $row The pages table row as an associative array.
1841 * @return string The rendered table field value.
1842 */
1843 protected function getPagesTableFieldValue($field, array $row)
1844 {
1845 return htmlspecialchars(BackendUtility::getProcessedValue('pages', $field, $row[$field]));
1846 }
1847
1848 /**********************************
1849 *
1850 * Additional functions; Content Elements
1851 *
1852 **********************************/
1853 /**
1854 * Draw header for a content element column:
1855 *
1856 * @param string $colName Column name
1857 * @param string $editParams Edit params (Syntax: &edit[...] for FormEngine)
1858 * @return string HTML table
1859 */
1860 public function tt_content_drawColHeader($colName, $editParams = '')
1861 {
1862 $iconsArr = [];
1863 // Create command links:
1864 if ($this->tt_contentConfig['showCommands']) {
1865 // Edit whole of column:
1866 if ($editParams && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT) && $this->getBackendUser()->checkLanguageAccess(0)) {
1867 $iconsArr['edit'] = '<a href="#" onclick="'
1868 . htmlspecialchars(BackendUtility::editOnClick($editParams)) . '" title="'
1869 . htmlspecialchars($this->getLanguageService()->getLL('editColumn')) . '">'
1870 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1871 }
1872 }
1873 $icons = '';
1874 if (!empty($iconsArr)) {
1875 $icons = '<div class="t3-page-column-header-icons">' . implode('', $iconsArr) . '</div>';
1876 }
1877 // Create header row:
1878 $out = '<div class="t3-page-column-header">
1879 ' . $icons . '
1880 <div class="t3-page-column-header-label">' . htmlspecialchars($colName) . '</div>
1881 </div>';
1882 return $out;
1883 }
1884
1885 /**
1886 * Draw a paste icon either for pasting into a column or for pasting after a record
1887 *
1888 * @param int $pasteItem ID of the item in the clipboard
1889 * @param string $pasteTitle Title for the JS modal
1890 * @param string $copyMode copy or cut
1891 * @param string $cssClass CSS class to determine if pasting is done into column or after record
1892 * @param string $title title attribute of the generated link
1893 *
1894 * @return string Generated HTML code with link and icon
1895 */
1896 protected function tt_content_drawPasteIcon($pasteItem, $pasteTitle, $copyMode, $cssClass, $title)
1897 {
1898 $pasteIcon = json_encode(
1899 ' <a data-content="' . htmlspecialchars($pasteItem) . '"'
1900 . ' data-title="' . htmlspecialchars($pasteTitle) . '"'
1901 . ' data-severity="warning"'
1902 . ' class="t3js-paste t3js-paste' . htmlspecialchars($copyMode) . ' ' . htmlspecialchars($cssClass) . ' btn btn-default btn-sm"'
1903 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL($title)) . '">'
1904 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
1905 . '</a>'
1906 );
1907 return $pasteIcon;
1908 }
1909
1910 /**
1911 * Draw the footer for a single tt_content element
1912 *
1913 * @param array $row Record array
1914 * @return string HTML of the footer
1915 * @throws \UnexpectedValueException
1916 */
1917 protected function tt_content_drawFooter(array $row)
1918 {
1919 $content = '';
1920 // Get processed values:
1921 $info = [];
1922 $this->getProcessedValue('tt_content', 'starttime,endtime,fe_group,space_before_class,space_after_class', $row, $info);
1923
1924 // Content element annotation
1925 if (!empty($GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']) && !empty($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']])) {
1926 $info[] = htmlspecialchars($row[$GLOBALS['TCA']['tt_content']['ctrl']['descriptionColumn']]);
1927 }
1928
1929 // Call drawFooter hooks
1930 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawFooter'] ?? [] as $className) {
1931 $hookObject = GeneralUtility::makeInstance($className);
1932 if (!$hookObject instanceof PageLayoutViewDrawFooterHookInterface) {
1933 throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawFooterHookInterface::class, 1404378171);
1934 }
1935 $hookObject->preProcess($this, $info, $row);
1936 }
1937
1938 // Display info from records fields:
1939 if (!empty($info)) {
1940 $content = '<div class="t3-page-ce-info">
1941 ' . implode('<br>', $info) . '
1942 </div>';
1943 }
1944 // Wrap it
1945 if (!empty($content)) {
1946 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1947 }
1948 return $content;
1949 }
1950
1951 /**
1952 * Draw the header for a single tt_content element
1953 *
1954 * @param array $row Record array
1955 * @param int $space Amount of pixel space above the header. UNUSED
1956 * @param bool $disableMoveAndNewButtons If set the buttons for creating new elements and moving up and down are not shown.
1957 * @param bool $langMode If set, we are in language mode and flags will be shown for languages
1958 * @param bool $dragDropEnabled If set the move button must be hidden
1959 * @return string HTML table with the record header.
1960 */
1961 public function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = false, $langMode = false, $dragDropEnabled = false)
1962 {
1963 $backendUser = $this->getBackendUser();
1964 $out = '';
1965 // If show info is set...;
1966 if ($this->tt_contentConfig['showInfo'] && $backendUser->recordEditAccessInternals('tt_content', $row)) {
1967 // Render control panel for the element:
1968 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1969 // Edit content element:
1970 $urlParameters = [
1971 'edit' => [
1972 'tt_content' => [
1973 $this->tt_contentData['nextThree'][$row['uid']] => 'edit'
1974 ]
1975 ],
1976 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid'],
1977 ];
1978 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
1979 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters) . '#element-tt_content-' . $row['uid'];
1980
1981 $out .= '<a class="btn btn-default" href="' . htmlspecialchars($url)
1982 . '" title="' . htmlspecialchars($this->nextThree > 1
1983 ? sprintf($this->getLanguageService()->getLL('nextThree'), $this->nextThree)
1984 : $this->getLanguageService()->getLL('edit'))
1985 . '">' . $this->iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() . '</a>';
1986 // Hide element:
1987 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1988 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1989 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1990 || $backendUser->check('non_exclude_fields', 'tt_content:' . $hiddenField))
1991 ) {
1992 if ($row[$hiddenField]) {
1993 $value = 0;
1994 $label = 'unHide';
1995 } else {
1996 $value = 1;
1997 $label = 'hide';
1998 }
1999 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
2000 . '][' . $hiddenField . ']=' . $value;
2001 $out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
2002 . '#element-tt_content-' . $row['uid'] . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($label)) . '">'
2003 . $this->iconFactory->getIcon('actions-edit-' . strtolower($label), Icon::SIZE_SMALL)->render() . '</a>';
2004 }
2005 // Delete
2006 $disableDelete = (bool)\trim(
2007 $backendUser->getTSConfig()['options.']['disableDelete.']['tt_content']
2008 ?? $backendUser->getTSConfig()['options.']['disableDelete']
2009 ?? '0'
2010 );
2011 if (!$disableDelete) {
2012 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
2013 $refCountMsg = BackendUtility::referenceCount(
2014 'tt_content',
2015 $row['uid'],
2016 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
2017 $this->getReferenceCount('tt_content', $row['uid'])
2018 ) . BackendUtility::translationCount(
2019 'tt_content',
2020 $row['uid'],
2021 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
2022 );
2023 $confirm = $this->getLanguageService()->getLL('deleteWarning')
2024 . $refCountMsg;
2025 $out .= '<a class="btn btn-default t3js-modal-trigger" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params)) . '"'
2026 . ' data-severity="warning"'
2027 . ' data-title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_alt_doc.xlf:label.confirm.delete_record.title')) . '"'
2028 . ' data-content="' . htmlspecialchars($confirm) . '" '
2029 . ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')) . '"'
2030 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('deleteItem')) . '">'
2031 . $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
2032 if ($out && $backendUser->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)) {
2033 $out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
2034 } else {
2035 $out = '';
2036 }
2037 }
2038 if (!$disableMoveAndNewButtons) {
2039 $moveButtonContent = '';
2040 $displayMoveButtons = false;
2041 // Move element up:
2042 if ($this->tt_contentData['prev'][$row['uid']]) {
2043 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
2044 $moveButtonContent .= '<a class="btn btn-default" href="'
2045 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
2046 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
2047 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
2048 if (!$dragDropEnabled) {
2049 $displayMoveButtons = true;
2050 }
2051 } else {
2052 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
2053 }
2054 // Move element down:
2055 if ($this->tt_contentData['next'][$row['uid']]) {
2056 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
2057 $moveButtonContent .= '<a class="btn btn-default" href="'
2058 . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
2059 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
2060 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
2061 if (!$dragDropEnabled) {
2062 $displayMoveButtons = true;
2063 }
2064 } else {
2065 $moveButtonContent .= '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
2066 }
2067 if ($displayMoveButtons) {
2068 $out .= '<div class="btn-group btn-group-sm" role="group">' . $moveButtonContent . '</div>';
2069 }
2070 }
2071 }
2072 }
2073 $allowDragAndDrop = $this->isDragAndDropAllowed($row);
2074 $additionalIcons = [];
2075 $additionalIcons[] = $this->getIcon('tt_content', $row) . ' ';
2076 if ($langMode && isset($this->siteLanguages[(int)$row['sys_language_uid']])) {
2077 $additionalIcons[] = $this->renderLanguageFlag($this->siteLanguages[(int)$row['sys_language_uid']]);
2078 }
2079 // Get record locking status:
2080 if ($lockInfo = BackendUtility::isRecordLocked('tt_content', $row['uid'])) {
2081 $additionalIcons[] = '<a href="#" data-toggle="tooltip" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
2082 . $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</a>';
2083 }
2084 // Call stats information hook
2085 $_params = ['tt_content', $row['uid'], &$row];
2086 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ?? [] as $_funcRef) {
2087 $additionalIcons[] = GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2088 }
2089
2090 // Wrap the whole header
2091 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
2092 return '<div class="t3-page-ce-header ' . ($allowDragAndDrop ? 't3-page-ce-header-draggable t3js-page-ce-draghandle' : '') . '">
2093 <div class="t3-page-ce-header-icons-left">' . implode('', $additionalIcons) . '</div>
2094 <div class="t3-page-ce-header-icons-right">' . ($out ? '<div class="btn-toolbar">' . $out . '</div>' : '') . '</div>
2095 </div>
2096 <div class="t3-page-ce-body">';
2097 }
2098
2099 /**
2100 * Gets the number of records referencing the record with the UID $uid in
2101 * the table $tableName.
2102 *
2103 * @param string $tableName
2104 * @param int $uid
2105 * @return int The number of references to record $uid in table
2106 */
2107 protected function getReferenceCount(string $tableName, int $uid): int
2108 {
2109 if (!isset($this->referenceCount[$tableName][$uid])) {
2110 $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
2111 $numberOfReferences = $referenceIndex->getNumberOfReferencedRecords($tableName, $uid);
2112 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
2113 }
2114 return $this->referenceCount[$tableName][$uid];
2115 }
2116
2117 /**
2118 * Determine whether Drag & Drop should be allowed
2119 *
2120 * @param array $row
2121 * @return bool
2122 */
2123 protected function isDragAndDropAllowed(array $row)
2124 {
2125 if ((int)$row['l18n_parent'] === 0 &&
2126 (
2127 $this->getBackendUser()->isAdmin()
2128 || ((int)$row['editlock'] === 0 && (int)$this->pageinfo['editlock'] === 0)
2129 && $this->getBackendUser()->doesUserHaveAccess($this->pageinfo, Permission::CONTENT_EDIT)
2130 && $this->getBackendUser()->checkAuthMode('tt_content', 'CType', $row['CType'], $GLOBALS['TYPO3_CONF_VARS']['BE']['explicitADmode'])
2131 )
2132 ) {
2133 return true;
2134 }
2135 return false;
2136 }
2137
2138 /**
2139 * Draws the preview content for a content element
2140 *
2141 * @param array $row Content element
2142 * @return string HTML
2143 * @throws \UnexpectedValueException
2144 */
2145 public function tt_content_drawItem($row)
2146 {
2147 $out = '';
2148 $outHeader = '';
2149 // Make header:
2150
2151 if ($row['header']) {
2152 $infoArr = [];
2153 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
2154 $hiddenHeaderNote = '';
2155 // If header layout is set to 'hidden', display an accordant note:
2156 if ($row['header_layout'] == 100) {
2157 $hiddenHeaderNote = ' <em>[' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.hidden')) . ']</em>';
2158 }
2159 $outHeader = $row['date']
2160 ? htmlspecialchars($this->itemLabels['date'] . ' ' . BackendUtility::date($row['date'])) . '<br />'
2161 : '';
2162 $outHeader .= '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row)
2163 . $hiddenHeaderNote . '</strong><br />';
2164 }
2165 // Make content:
2166 $infoArr = [];
2167 $drawItem = true;
2168 // Hook: Render an own preview of a record
2169 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'] ?? [] as $className) {
2170 $hookObject = GeneralUtility::makeInstance($className);
2171 if (!$hookObject instanceof PageLayoutViewDrawItemHookInterface) {
2172 throw new \UnexpectedValueException($className . ' must implement interface ' . PageLayoutViewDrawItemHookInterface::class, 1218547409);
2173 }
2174 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
2175 }
2176
2177 // If the previous hook did not render something,
2178 // then check if a Fluid-based preview template was defined for this CType
2179 // and render it via Fluid. Possible option:
2180 // mod.web_layout.tt_content.preview.media = EXT:site_mysite/Resources/Private/Templates/Preview/Media.html
2181 if ($drawItem) {
2182 $tsConfig = BackendUtility::getPagesTSconfig($row['pid'])['mod.']['web_layout.']['tt_content.']['preview.'] ?? [];
2183 $fluidTemplateFile = '';
2184
2185 if ($row['CType'] === 'list' && !empty($row['list_type'])
2186 && !empty($tsConfig['list.'][$row['list_type']])
2187 ) {
2188 $fluidTemplateFile = $tsConfig['list.'][$row['list_type']];
2189 } elseif (!empty($tsConfig[$row['CType']])) {
2190 $fluidTemplateFile = $tsConfig[$row['CType']];
2191 }
2192
2193 if ($fluidTemplateFile) {
2194 $fluidTemplateFile = GeneralUtility::getFileAbsFileName($fluidTemplateFile);
2195 if ($fluidTemplateFile) {
2196 try {
2197 $view = GeneralUtility::makeInstance(StandaloneView::class);
2198 $view->setTemplatePathAndFilename($fluidTemplateFile);
2199 $view->assignMultiple($row);
2200 if (!empty($row['pi_flexform'])) {
2201 $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
2202 $view->assign('pi_flexform_transformed', $flexFormService->convertFlexFormContentToArray($row['pi_flexform']));
2203 }
2204 $out = $view->render();
2205 $drawItem = false;
2206 } catch (\Exception $e) {
2207 $this->logger->warning(sprintf(
2208 'The backend preview for content element %d can not be rendered using the Fluid template file "%s": %s',
2209 $row['uid'],
2210 $fluidTemplateFile,
2211 $e->getMessage()
2212 ));
2213 }
2214 }
2215 }
2216 }
2217
2218 // Draw preview of the item depending on its CType (if not disabled by previous hook):
2219 if ($drawItem) {
2220 switch ($row['CType']) {
2221 case 'header':
2222 if ($row['subheader']) {
2223 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
2224 }
2225 break;
2226 case 'bullets':
2227 case 'table':
2228 if ($row['bodytext']) {
2229 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
2230 }
2231 break;
2232 case 'uploads':
2233 if ($row['media']) {
2234 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'media'), $row) . '<br />';
2235 }
2236 break;
2237 case 'menu':
2238 $contentType = $this->CType_labels[$row['CType']];
2239 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
2240 // Add Menu Type
2241 $menuTypeLabel = $this->getLanguageService()->sL(
2242 BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'menu_type', $row['menu_type'])
2243 );
2244 $menuTypeLabel = $menuTypeLabel ?: 'invalid menu type';
2245 $out .= $this->linkEditContent($menuTypeLabel, $row);
2246 if ($row['menu_type'] !== '2' && ($row['pages'] || $row['selected_categories'])) {
2247 // Show pages if menu type is not "Sitemap"
2248 $out .= ':' . $this->linkEditContent($this->generateListForCTypeMenu($row), $row) . '<br />';
2249 }
2250 break;
2251 case 'shortcut':
2252 if (!empty($row['records'])) {
2253 $shortcutContent = [];
2254 $recordList = explode(',', $row['records']);
2255 foreach ($recordList as $recordIdentifier) {
2256 $split = BackendUtility::splitTable_Uid($recordIdentifier);
2257 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
2258 $shortcutRecord = BackendUtility::getRecord($tableName, $split[1]);
2259 if (is_array($shortcutRecord)) {
2260 $icon = $this->iconFactory->getIconForRecord($tableName, $shortcutRecord, Icon::SIZE_SMALL)->render();
2261 $icon = BackendUtility::wrapClickMenuOnIcon(
2262 $icon,
2263 $tableName,
2264 $shortcutRecord['uid']
2265 );
2266 $shortcutContent[] = $icon
2267 . htmlspecialchars(BackendUtility::getRecordTitle($tableName, $shortcutRecord));
2268 }
2269 }
2270 $out .= implode('<br />', $shortcutContent) . '<br />';
2271 }
2272 break;
2273 case 'list':
2274 $hookOut = '';
2275 $_params = ['pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr];
2276 foreach (
2277 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']] ??
2278 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'] ??
2279 [] as $_funcRef
2280 ) {
2281 $hookOut .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2282 }
2283 if ((string)$hookOut !== '') {
2284 $out .= $hookOut;
2285 } elseif (!empty($row['list_type'])) {
2286 $label = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'list_type', $row['list_type']);
2287 if (!empty($label)) {
2288 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($this->getLanguageService()->sL($label)) . '</strong>', $row) . '<br />';
2289 } else {
2290 $message = sprintf($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'), $row['list_type']);
2291 $out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
2292 }
2293 } else {
2294 $out .= '<strong>' . $this->getLanguageService()->getLL('noPluginSelected') . '</strong>';
2295 }
2296 $out .= htmlspecialchars($this->getLanguageService()->sL(
2297 BackendUtility::getLabelFromItemlist('tt_content', 'pages', $row['pages'])
2298 )) . '<br />';
2299 break;
2300 default:
2301 $contentType = $this->CType_labels[$row['CType']];
2302 if (!isset($contentType)) {
2303 $contentType = BackendUtility::getLabelFromItemListMerged($row['pid'], 'tt_content', 'CType', $row['CType']);
2304 }
2305
2306 if ($contentType) {
2307 $out .= $this->linkEditContent('<strong>' . htmlspecialchars($contentType) . '</strong>', $row) . '<br />';
2308 if ($row['bodytext']) {
2309 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
2310 }
2311 if ($row['image']) {
2312 $out .= $this->linkEditContent($this->getThumbCodeUnlinked($row, 'tt_content', 'image'), $row) . '<br />';
2313 }
2314 } else {
2315 $message = sprintf(
2316 $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'),
2317 $row['CType']
2318 );
2319 $out .= '<span class="label label-warning">' . htmlspecialchars($message) . '</span>';
2320 }
2321 }
2322 }
2323 // Wrap span-tags:
2324 $out = '
2325 <span class="exampleContent">' . $out . '</span>';
2326 // Add header:
2327 $out = $outHeader . $out;
2328 // Return values:
2329 if ($this->isDisabled('tt_content', $row)) {
2330 return '<span class="text-muted">' . $out . '</span>';
2331 }
2332 return $out;
2333 }
2334
2335 /**
2336 * Generates a list of selected pages or categories for the CType menu
2337 *
2338 * @param array $row row from pages
2339 * @return string
2340 */
2341 protected function generateListForCTypeMenu(array $row)
2342 {
2343 $table = 'pages';
2344 $field = 'pages';
2345 // get categories instead of pages
2346 if (strpos($row['menu_type'], 'categorized_') !== false) {
2347 $table = 'sys_category';
2348 $field = 'selected_categories';
2349 }
2350 if (trim($row[$field]) === '') {
2351 return '';
2352 }
2353 $content = '';
2354 $uidList = explode(',', $row[$field]);
2355 foreach ($uidList as $uid) {
2356 $uid = (int)$uid;
2357 $record = BackendUtility::getRecord($table, $uid, 'title');
2358 $content .= '<br>' . $record['title'] . ' (' . $uid . ')';
2359 }
2360 return $content;
2361 }
2362
2363 /**
2364 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
2365 * Selects across columns, but within in the same PID. Columns are expect to be the same
2366 * for translations and original but this may be a conceptual error (?)
2367 *
2368 * @param array $defaultLanguageUids Numeric array with uids of tt_content elements in the default language
2369 * @param int $id Page pid
2370 * @param int $lP Sys language UID
2371 * @return array Modified $defLanguageCount
2372 */
2373 public function getNonTranslatedTTcontentUids($defaultLanguageUids, $id, $lP)
2374 {
2375 if ($lP && !empty($defaultLanguageUids)) {
2376 // Select all translations here:
2377 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
2378 ->getQueryBuilderForTable('tt_content');
2379 $queryBuilder->getRestrictions()
2380 ->removeAll()
2381 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2382 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class, null, false));
2383 $queryBuilder
2384 ->select('*')
2385 ->from('tt_content')
2386 ->where(
2387 $queryBuilder->expr()->eq(
2388 'sys_language_uid',
2389 $queryBuilder->createNamedParameter($lP, \PDO::PARAM_INT)
2390 ),
2391 $queryBuilder->expr()->in(
2392 'l18n_parent',
2393 $queryBuilder->createNamedParameter($defaultLanguageUids, Connection::PARAM_INT_ARRAY)
2394 )
2395 );
2396
2397 $result = $queryBuilder->execute();
2398
2399 // Flip uids:
2400 $defaultLanguageUids = array_flip($defaultLanguageUids);
2401 // Traverse any selected elements and unset original UID if any:
2402 while ($row = $result->fetch()) {
2403 BackendUtility::workspaceOL('tt_content', $row);
2404 unset($defaultLanguageUids[$row['l18n_parent']]);
2405 }
2406 // Flip again:
2407 $defaultLanguageUids = array_keys($defaultLanguageUids);
2408 }
2409 return $defaultLanguageUids;
2410 }
2411
2412 /**
2413 * Creates button which is used to create copies of records..
2414 *
2415 * @param array $defaultLanguageUids Numeric array with uids of tt_content elements in the default language
2416 * @param int $lP Sys language UID
2417 * @return string "Copy languages" button, if available.
2418 */
2419 public function newLanguageButton($defaultLanguageUids, $lP)
2420 {
2421 $lP = (int)$lP;
2422 if (!$this->doEdit || !$lP) {
2423 return '';
2424 }
2425 $theNewButton = '';
2426
2427 $localizationTsConfig = BackendUtility::getPagesTSconfig($this->id)['mod.']['web_layout.']['localization.'] ?? [];
2428 $allowCopy = (bool)($localizationTsConfig['enableCopy'] ?? true);
2429 $allowTranslate = (bool)($localizationTsConfig['enableTranslate'] ?? true);
2430 if (!empty($this->languageHasTranslationsCache[$lP])) {
2431 if (isset($this->languageHasTranslationsCache[$lP]['hasStandAloneContent'])) {
2432 $allowTranslate = false;
2433 }
2434 if (isset($this->languageHasTranslationsCache[$lP]['hasTranslations'])) {
2435 $allowCopy = $allowCopy && !$this->languageHasTranslationsCache[$lP]['hasTranslations'];
2436 }
2437 }
2438
2439 if (isset($this->contentElementCache[$lP]) && is_array($this->contentElementCache[$lP])) {
2440 foreach ($this->contentElementCache[$lP] as $column => $records) {
2441 foreach ($records as $record) {
2442 $key = array_search($record['l10n_source'], $defaultLanguageUids);
2443 if ($key !== false) {
2444 unset($defaultLanguageUids[$key]);
2445 }
2446 }
2447 }
2448 }
2449
2450 if (!empty($defaultLanguageUids)) {
2451 $theNewButton =
2452 '<a'
2453 . ' href="#"'
2454 . ' class="btn btn-default btn-sm t3js-localize disabled"'
2455 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate')) . '"'
2456 . ' data-page="' . htmlspecialchars($this->getLocalizedPageTitle()) . '"'
2457 . ' data-has-elements="' . (int)!empty($this->contentElementCache[$lP]) . '"'
2458 . ' data-allow-copy="' . (int)$allowCopy . '"'
2459 . ' data-allow-translate="' . (int)$allowTranslate . '"'
2460 . ' data-table="tt_content"'
2461 . ' data-page-id="' . (int)GeneralUtility::_GP('id') . '"'
2462 . ' data-language-id="' . $lP . '"'
2463 . ' data-language-name="' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '"'
2464 . '>'
2465 . $this->iconFactory->getIcon('actions-localize', Icon::SIZE_SMALL)->render()
2466 . ' ' . htmlspecialchars($this->getLanguageService()->getLL('newPageContent_translate'))
2467 . '</a>';
2468 }
2469
2470 return $theNewButton;
2471 }
2472
2473 /**
2474 * Creates onclick-attribute content for a new content element
2475 *
2476 * @param int $id Page id where to create the element.
2477 * @param int $colPos Preset: Column position value
2478 * @param int $sys_language Preset: Sys language value
2479 * @return string String for onclick attribute.
2480 * @see getTable_tt_content()
2481 */
2482 public function newContentElementOnClick($id, $colPos, $sys_language)
2483 {
2484 if ($this->option_newWizard) {
2485 $routeName = BackendUtility::getPagesTSconfig($id)['mod.']['newContentElementWizard.']['override']
2486 ?? 'new_content_element_wizard';
2487 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2488 $url = $uriBuilder->buildUriFromRoute($routeName, [
2489 'id' => $id,
2490 'colPos' => $colPos,
2491 'sys_language_uid' => $sys_language,
2492 'uid_pid' => $id,
2493 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
2494 ]);
2495 $onClick = 'window.location.href=' . GeneralUtility::quoteJSvalue((string)$url) . ';';
2496 } else {
2497 $onClick = BackendUtility::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]='
2498 . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language);
2499 }
2500 return $onClick;
2501 }
2502
2503 /**
2504 * Will create a link on the input string and possibly a big button after the string which links to editing in the RTE.
2505 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
2506 *
2507 * @param string $str String to link. Must be prepared for HTML output.
2508 * @param array $row The row.
2509 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
2510 * @see getTable_tt_content()
2511 */
2512 public function linkEditContent($str, $row)
2513 {
2514 if ($this->doEdit && $this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) {
2515 $urlParameters = [
2516 'edit' => [
2517 'tt_content' => [
2518 $row['uid'] => 'edit'
2519 ]
2520 ],
2521 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $row['uid']
2522 ];
2523 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2524 $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
2525 // Return link
2526 return '<a href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $str . '</a>';
2527 }
2528 return $str;
2529 }
2530
2531 /**
2532 * Make selector box for creating new translation in a language
2533 * Displays only languages which are not yet present for the current page and
2534 * that are not disabled with page TS.
2535 *
2536 * @param int $id Page id for which to create a new translation record of pages
2537 * @return string <select> HTML element (if there were items for the box anyways...)
2538 * @see getTable_tt_content()
2539 */
2540 public function languageSelector($id)
2541 {
2542 if (!$this->getBackendUser()->check('tables_modify', 'pages')) {
2543 return '';
2544 }
2545 $id = (int)$id;
2546
2547 // First, select all languages that are available for the current user
2548 $availableTranslations = [];
2549 foreach ($this->siteLanguages as $language) {
2550 if ($language->getLanguageId() === 0) {
2551 continue;
2552 }
2553 $availableTranslations[$language->getLanguageId()] = $language->getTitle();
2554 }
2555
2556 // Then, subtract the languages which are already on the page:
2557 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
2558 $queryBuilder->getRestrictions()->removeAll()
2559 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2560 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
2561 $queryBuilder->select('uid', $GLOBALS['TCA']['pages']['ctrl']['languageField'])
2562 ->from('pages')
2563 ->where(
2564 $queryBuilder->expr()->eq(
2565 $GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField'],
2566 $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)
2567 )
2568 );
2569 $statement = $queryBuilder->execute();
2570 while ($row = $statement->fetch()) {
2571 unset($availableTranslations[(int)$row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]]);
2572 }
2573 // If any languages are left, make selector:
2574 if (!empty($availableTranslations)) {
2575 $output = '<option value="">' . htmlspecialchars($this->getLanguageService()->getLL('new_language')) . '</option>';
2576 foreach ($availableTranslations as $languageUid => $languageTitle) {
2577 // Build localize command URL to DataHandler (tce_db)
2578 // which redirects to FormEngine (record_edit)
2579 // which, when finished editing should return back to the current page (returnUrl)
2580 $parameters = [
2581 'justLocalized' => 'pages:' . $id . ':' . $languageUid,
2582 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
2583 ];
2584 $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
2585 $redirectUrl = (string)$uriBuilder->buildUriFromRoute('record_edit', $parameters);
2586 $targetUrl = BackendUtility::getLinkToDataHandlerAction(
2587 '&cmd[pages][' . $id . '][localize]=' . $languageUid,
2588 $redirectUrl
2589 );
2590
2591 $output .= '<option value="' . htmlspecialchars($targetUrl) . '">' . htmlspecialchars($languageTitle) . '</option>';
2592 }
2593
2594 return '<div class="form-inline form-inline-spaced">'
2595 . '<div class="form-group">'
2596 . '<select class="form-control input-sm" name="createNewLanguage" onchange="window.location.href=this.options[this.selectedIndex].value">'
2597 . $output
2598 . '</select></div></div>';
2599 }
2600 return '';
2601 }
2602
2603 /**
2604 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
2605 *
2606 * @param Statement $result DBAL Statement
2607 * @param string $table Table name defaulting to tt_content
2608 * @return array The selected rows returned in this array.
2609 */
2610 public function getResult(Statement $result, string $table = 'tt_content'): array
2611 {
2612 $output = [];
2613 // Traverse the result:
2614 while ($row = $result->fetch()) {
2615 BackendUtility::workspaceOL($table, $row, -99, true);
2616 if ($row) {
2617 // Add the row to the array:
2618 $output[] = $row;
2619 }
2620 }
2621 $this->generateTtContentDataArray($output);
2622 // Return selected records
2623 return $output;
2624 }
2625
2626 /********************************
2627 *
2628 * Various helper functions
2629 *
2630 ********************************/
2631
2632 /**
2633 * Initializes the clipboard for generating paste links
2634 *
2635 *
2636 * @see \TYPO3\CMS\Backend\Controller\ContextMenuController::clipboardAction()
2637 * @see \TYPO3\CMS\Filelist\Controller\FileListController::indexAction()
2638 */
2639 protected function initializeClipboard()
2640 {
2641 // Start clipboard
2642 $this->clipboard = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Clipboard\Clipboard::class);
2643
2644 // Initialize - reads the clipboard content from the user session
2645 $this->clipboard->initializeClipboard();
2646
2647 // This locks the clipboard to the Normal for this request.
2648 $this->clipboard->lockToNormal();
2649
2650 // Clean up pad
2651 $this->clipboard->cleanCurrent();
2652
2653 // Save the clipboard content
2654 $this->clipboard->endClipboard();
2655 }
2656
2657 /**
2658 * Generates the data for previous and next elements which is needed for movements.
2659 *
2660 * @param array $rowArray
2661 */
2662 protected function generateTtContentDataArray(array $rowArray)
2663 {
2664 if (empty($this->tt_contentData)) {
2665 $this->tt_contentData = [
2666 'nextThree' => [],
2667 'next' => [],
2668 'prev' => [],
2669 ];
2670 }
2671 foreach ($rowArray as $key => $value) {
2672 // Create the list of the next three ids (for editing links...)
2673 for ($i = 0; $i < $this->nextThree; $i++) {
2674 if (isset($rowArray[$key - $i])
2675 && !GeneralUtility::inList($this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']], $value['uid'])
2676 ) {
2677 $this->tt_contentData['nextThree'][$rowArray[$key - $i]['uid']] .= $value['uid'] . ',';
2678 }
2679 }
2680
2681 // Create information for next and previous content elements
2682 if (isset($rowArray[$key - 1])) {
2683 if (isset($rowArray[$key - 2])) {
2684 $this->tt_contentData['prev'][$value['uid']] = -$rowArray[$key - 2]['uid'];
2685 } else {
2686 $this->tt_contentData['prev'][$value['uid']] = $value['pid'];
2687 }
2688 $this->tt_contentData['next'][$rowArray[$key - 1]['uid']] = -$value['uid'];
2689 }
2690 }
2691 }
2692
2693 /**
2694 * Counts and returns the number of records on the page with $pid
2695 *
2696 * @param string $table Table name
2697 * @param int $pid Page id
2698 * @return int Number of records.
2699 */
2700 public function numberOfRecords($table, $pid)
2701 {
2702 $count = 0;
2703 if ($GLOBALS['TCA'][$table]) {
2704 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
2705 ->getQueryBuilderForTable($table);
2706 $queryBuilder->getRestrictions()
2707 ->removeAll()
2708 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2709 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
2710 $count = (int)$queryBuilder->count('uid')
2711 ->from($table)
2712 ->where(
2713 $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT))
2714 )
2715 ->execute()
2716 ->fetchColumn();
2717 }
2718
2719 return $count;
2720 }
2721
2722 /**
2723 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
2724 *
2725 * @param string $input Input string
2726 * @return string Output string
2727 */
2728 public function renderText($input)
2729 {
2730 $input = strip_tags($input);
2731 $input = GeneralUtility::fixed_lgd_cs($input, 1500);
2732 return nl2br(htmlspecialchars(trim($input), ENT_QUOTES, 'UTF-8', false));
2733 }
2734
2735 /**
2736 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
2737 *
2738 * @param string $table Table name
2739 * @param array $row Record array
2740 * @param string $enabledClickMenuItems Passthrough to wrapClickMenuOnIcon
2741 * @return string HTML for the icon
2742 */
2743 public function getIcon($table, $row, $enabledClickMenuItems = '')
2744 {
2745 // Initialization
2746 $toolTip = BackendUtility::getRecordToolTip($row, 'tt_content');
2747 $icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render() . '</span>';
2748 $this->counter++;
2749 // The icon with link
2750 if ($this->getBackendUser()->recordEditAccessInternals($table, $row)) {
2751 $icon = BackendUtility::wrapClickMenuOnIcon($icon, $table, $row['uid']);
2752 }
2753 return $icon;
2754 }
2755
2756 /**
2757 * Creates processed values for all field names in $fieldList based on values from $row array.
2758 * The result is 'returned' through $info which is passed as a reference
2759 *
2760 * @param string $table Table name
2761 * @param string $fieldList Comma separated list of fields.
2762 * @param array $row Record from which to take values for processing.
2763 * @param array $info Array to which the processed values are added.
2764 */
2765 public function getProcessedValue($table, $fieldList, array $row, array &$info)
2766 {
2767 // Splitting values from $fieldList
2768 $fieldArr = explode(',', $fieldList);
2769 // Traverse fields from $fieldList
2770 foreach ($fieldArr as $field) {
2771 if ($row[$field]) {
2772 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> '
2773 . htmlspecialchars(BackendUtility::getProcessedValue($table, $field, $row[$field]));
2774 }
2775 }
2776 }
2777
2778 /**
2779 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2780 *
2781 * @param string $table Tablename of table to test
2782 * @param array $row Record row.
2783 * @return bool Returns TRUE, if disabled.
2784 */
2785 public function isDisabled($table, $row)
2786 {
2787 $enableCols = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns'];
2788 return $enableCols['disabled'] && $row[$enableCols['disabled']]
2789 || $enableCols['starttime'] && $row[$enableCols['starttime']] > $GLOBALS['EXEC_TIME']
2790 || $enableCols['endtime'] && $row[$enableCols['endtime']] && $row[$enableCols['endtime']] < $GLOBALS['EXEC_TIME'];
2791 }
2792
2793 /**
2794 * Returns icon for "no-edit" of a record.
2795 * Basically, the point is to signal that this record could have had an edit link if
2796 * the circumstances were right. A placeholder for the regular edit icon...
2797 *
2798 * @param string $label Label key from LOCAL_LANG
2799 * @return string IMG tag for icon.
2800 */
2801 public function noEditIcon($label = 'noEditItems')
2802 {
2803 $title = htmlspecialchars($this->getLanguageService()->getLL($label));
2804 return '<span title="' . $title . '">' . $this->iconFactory->getIcon('status-edit-read-only', Icon::SIZE_SMALL)->render() . '</span>';
2805 }
2806
2807 /*****************************************
2808 *
2809 * External renderings
2810 *
2811 *****************************************/
2812
2813 /**
2814 * Creates a menu of the tables that can be listed by this function
2815 * Only tables which has records on the page will be included.
2816 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2817 *
2818 * @param int $id Page id from which we are listing records (the function will look up if there are records on the page)
2819 * @return string HTML output.
2820 */
2821 public function getTableMenu($id)
2822 {
2823 // Initialize:
2824 $this->activeTables = [];
2825 $theTables = ['tt_content'];
2826 // External tables:
2827 if (is_array($this->externalTables)) {
2828 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2829 }
2830 $out = '';
2831 // Traverse tables to check:
2832 foreach ($theTables as $tName) {
2833 // Check access and whether the proper extensions are loaded:
2834 if ($this->getBackendUser()->check('tables_select', $tName)
2835 && (
2836 isset($this->externalTables[$tName])
2837 || $tName === 'fe_users' || $tName === 'tt_content'
2838 || \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($tName)
2839 )
2840 ) {
2841 // Make query to count records from page:
2842 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
2843 ->getQueryBuilderForTable($tName);
2844 $queryBuilder->getRestrictions()
2845 ->removeAll()
2846 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
2847 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
2848 $count = $queryBuilder->count('uid')
2849 ->from($tName)
2850 ->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)))
2851 ->execute()
2852 ->fetchColumn();
2853 // If records were found (or if "tt_content" is the table...):
2854 if ($count || $tName === 'tt_content') {
2855 // Add row to menu:
2856 $out .= '
2857 <td><a href="#' . $tName . '" title="' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title'])) . '"></a>'
2858 . $this->iconFactory->getIconForRecord($tName, [], Icon::SIZE_SMALL)->render()
2859 . '</td>';
2860 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2861 $title = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title']))
2862 . ': ' . $count . ' ' . htmlspecialchars($this->getLanguageService()->getLL('records'));
2863 $this->activeTables[$tName] = '<span title="' . $title . '">'
2864 . $this->iconFactory->getIconForRecord($tName, [], Icon::SIZE_SMALL)->render()
2865 . '</span>'
2866 . '&nbsp;' . htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$tName]['ctrl']['title']));
2867 }
2868 }
2869 }
2870 // Wrap cells in table tags:
2871 $out = '
2872 <!--
2873 Menu of tables on the page (table menu)
2874 -->
2875 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2876 <tr>' . $out . '
2877 </tr>
2878 </table>';
2879 // Return the content:
2880 return $out;
2881 }
2882
2883 /**
2884 * Create thumbnail code for record/field but not linked
2885 *
2886 * @param mixed[] $row Record array
2887 * @param string $table Table (record is from)
2888 * @param string $field Field name for which thumbnail are to be rendered.
2889 * @return string HTML for thumbnails, if any.
2890 */
2891 public function getThumbCodeUnlinked($row, $table, $field)
2892 {
2893 return BackendUtility::thumbCode($row, $table, $field, '', '', null, 0, '', '', false);
2894 }
2895
2896 /**
2897 * Checks whether translated Content Elements exist in the desired language
2898 * If so, deny creating new ones via the UI
2899 *
2900 * @param array $contentElements
2901 * @param int $language
2902 * @return bool
2903 */
2904 protected function checkIfTranslationsExistInLanguage(array $contentElements, int $language)
2905 {
2906 // If in default language, you may always create new entries
2907 // Also, you may override this strict behavior via user TS Config
2908 // If you do so, you're on your own and cannot rely on any support by the TYPO3 core
2909 // We jump out here since we don't need to do the expensive loop operations
2910 $allowInconsistentLanguageHandling = (bool)(BackendUtility::getPagesTSconfig($this->id)['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? false);
2911 if ($language === 0 || $allowInconsistentLanguageHandling) {
2912 return false;
2913 }
2914 /**
2915 * Build up caches
2916 */
2917 if (!isset($this->languageHasTranslationsCache[$language])) {
2918