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