Revert "[TASK] Avoid slow array functions in loops"
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / RecordList / DatabaseRecordList.php
1 <?php
2 namespace TYPO3\CMS\Recordlist\RecordList;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
18 use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface;
19 use TYPO3\CMS\Backend\Routing\UriBuilder;
20 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
21 use TYPO3\CMS\Backend\Template\ModuleTemplate;
22 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
23 use TYPO3\CMS\Backend\Utility\BackendUtility;
24 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
25 use TYPO3\CMS\Core\Cache\CacheManager;
26 use TYPO3\CMS\Core\Database\Connection;
27 use TYPO3\CMS\Core\Database\ConnectionPool;
28 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
29 use TYPO3\CMS\Core\Database\Query\QueryHelper;
30 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
31 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
32 use TYPO3\CMS\Core\Database\ReferenceIndex;
33 use TYPO3\CMS\Core\Domain\Repository\PageRepository;
34 use TYPO3\CMS\Core\Imaging\Icon;
35 use TYPO3\CMS\Core\Imaging\IconFactory;
36 use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
37 use TYPO3\CMS\Core\LinkHandling\LinkService;
38 use TYPO3\CMS\Core\Localization\LanguageService;
39 use TYPO3\CMS\Core\Log\LogManager;
40 use TYPO3\CMS\Core\Messaging\FlashMessage;
41 use TYPO3\CMS\Core\Messaging\FlashMessageService;
42 use TYPO3\CMS\Core\Service\DependencyOrderingService;
43 use TYPO3\CMS\Core\Type\Bitmask\Permission;
44 use TYPO3\CMS\Core\Utility\CsvUtility;
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\Versioning\VersionState;
50
51 /**
52 * Class for rendering of Web>List module
53 * @internal This class is a specific TYPO3 Backend implementation and is not part of the TYPO3's Core API.
54 */
55 class DatabaseRecordList
56 {
57 // *********
58 // External:
59 // *********
60
61 /**
62 * Used to indicate which tables (values in the array) that can have a
63 * create-new-record link. If the array is empty, all tables are allowed.
64 *
65 * @var string[]
66 */
67 public $allowedNewTables = [];
68
69 /**
70 * Used to indicate which tables (values in the array) that cannot have a
71 * create-new-record link. If the array is empty, all tables are allowed.
72 *
73 * @var string[]
74 */
75 public $deniedNewTables = [];
76
77 /**
78 * If TRUE, will disable the rendering of clipboard + control panels.
79 *
80 * @var bool
81 */
82 public $dontShowClipControlPanels = false;
83
84 /**
85 * If TRUE, will show the clipboard in the field list.
86 *
87 * @var bool
88 */
89 public $showClipboard = false;
90
91 /**
92 * If TRUE, will DISABLE all control panels in lists. (Takes precedence)
93 *
94 * @var bool
95 */
96 public $noControlPanels = false;
97
98 /**
99 * If TRUE, clickmenus will be rendered
100 *
101 * @var bool
102 */
103 public $clickMenuEnabled = true;
104
105 /**
106 * Count of record rows in view
107 *
108 * @var int
109 */
110 public $totalRowCount;
111
112 /**
113 * Space icon used for alignment
114 *
115 * @var string
116 */
117 public $spaceIcon;
118
119 /**
120 * Disable single table view
121 *
122 * @var bool
123 */
124 public $disableSingleTableView = false;
125
126 // *********
127 // Internal:
128 // *********
129
130 /**
131 * Set to the page record (see writeTop())
132 *
133 * @var string[]
134 */
135 public $pageRow = [];
136
137 /**
138 * Contains page translation languages
139 *
140 * @var array
141 */
142 public $pageOverlays = [];
143
144 /**
145 * Contains sys language icons and titles
146 *
147 * @var array
148 */
149 public $languageIconTitles = [];
150
151 /**
152 * Tables which should not list their translations
153 *
154 * @var string
155 */
156 public $hideTranslations = '';
157
158 /**
159 * If set, the listing is returned as CSV instead.
160 *
161 * @var bool
162 */
163 public $csvOutput = false;
164
165 /**
166 * Cache for record path
167 *
168 * @var mixed[]
169 */
170 public $recPath_cache = [];
171
172 /**
173 * Field, to sort list by
174 *
175 * @var string
176 */
177 public $sortField;
178
179 /**
180 * default Max items shown per table in "multi-table mode", may be overridden by tables.php
181 *
182 * @var int
183 */
184 public $itemsLimitPerTable = 20;
185
186 /**
187 * Module data
188 *
189 * @internal
190 * @var array
191 */
192 protected $moduleData = [];
193
194 /**
195 * Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
196 *
197 * @var array
198 */
199 public $addElement_tdParams = [];
200
201 /**
202 * Page id
203 *
204 * @var int
205 */
206 public $id;
207
208 /**
209 * Used for tracking duplicate values of fields
210 *
211 * @var string[]
212 */
213 public $duplicateStack = [];
214
215 /**
216 * Current script name
217 *
218 * @var string
219 */
220 public $script = 'index.php';
221
222 /**
223 * If TRUE, records are listed only if a specific table is selected.
224 *
225 * @var bool
226 */
227 public $listOnlyInSingleTableMode = false;
228
229 /**
230 * Script URL
231 *
232 * @var string
233 */
234 public $thisScript = '';
235
236 /**
237 * @var TranslationConfigurationProvider
238 */
239 public $translateTools;
240
241 /**
242 * default Max items shown per table in "single-table mode", may be overridden by tables.php
243 *
244 * @var int
245 */
246 public $itemsLimitSingleTable = 100;
247
248 /**
249 * Array of collapsed / uncollapsed tables in multi table view
250 *
251 * @var int[][]
252 */
253 public $tablesCollapsed = [];
254
255 /**
256 * @var array[] Module configuration
257 */
258 public $modTSconfig;
259
260 /**
261 * String with accumulated HTML content
262 *
263 * @var string
264 */
265 public $HTMLcode = '';
266
267 /**
268 * Keys are fieldnames and values are td-css-classes to add in addElement();
269 *
270 * @var array
271 */
272 public $addElement_tdCssClass = [];
273
274 /**
275 * Thumbnails on records containing files (pictures)
276 *
277 * @var bool
278 */
279 public $thumbs = false;
280
281 /**
282 * Used for tracking next/prev uids
283 *
284 * @var int[][]
285 */
286 public $currentTable = [];
287
288 /**
289 * Indicates if all available fields for a user should be selected or not.
290 *
291 * @var int
292 */
293 public $allFields = 0;
294
295 /**
296 * Number of records to show
297 *
298 * @var int
299 */
300 public $showLimit = 0;
301
302 /**
303 * Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
304 *
305 * @var array
306 */
307 public $fieldArray = [];
308
309 /**
310 * Tables which should not get listed
311 *
312 * @var string
313 */
314 public $hideTables = '';
315
316 /**
317 * Containing which fields to display in extended mode
318 *
319 * @var string[]
320 */
321 public $displayFields;
322
323 /**
324 * If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
325 *
326 * @var string
327 */
328 public $oddColumnsCssClass = '';
329
330 /**
331 * Not used in this class - but maybe extension classes...
332 * Max length of strings
333 *
334 * @var int
335 */
336 public $fixedL = 30;
337
338 /**
339 * Page select permissions
340 *
341 * @var string
342 */
343 public $perms_clause = '';
344
345 /**
346 * Return URL
347 *
348 * @var string
349 */
350 public $returnUrl = '';
351
352 /**
353 * Tablename if single-table mode
354 *
355 * @var string
356 */
357 public $table = '';
358
359 /**
360 * Some permissions...
361 *
362 * @var int
363 */
364 public $calcPerms = 0;
365
366 /**
367 * Mode for what happens when a user clicks the title of a record.
368 *
369 * @var string
370 */
371 public $clickTitleMode = '';
372
373 /**
374 * @var int
375 */
376 public $showIcon = 1;
377
378 /**
379 * Levels to search down.
380 *
381 * @var int
382 */
383 public $searchLevels = 0;
384
385 /**
386 * "LIMIT " in SQL...
387 *
388 * @var int
389 */
390 public $iLimit = 0;
391
392 /**
393 * Set to the total number of items for a table when selecting.
394 *
395 * @var string
396 */
397 public $totalItems = '';
398
399 /**
400 * TSconfig which overwrites TCA-Settings
401 *
402 * @var mixed[][]
403 */
404 public $tableTSconfigOverTCA = [];
405
406 /**
407 * Loaded with page record with version overlay if any.
408 *
409 * @var string[]
410 */
411 public $pageRecord = [];
412
413 /**
414 * Fields to display for the current table
415 *
416 * @var string[]
417 */
418 public $setFields = [];
419
420 /**
421 * Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
422 *
423 * @var int
424 */
425 public $counter = 0;
426
427 /**
428 * Pointer for browsing list
429 *
430 * @var int
431 */
432 public $firstElementNumber = 0;
433
434 /**
435 * Counting the elements no matter what...
436 *
437 * @var int
438 */
439 public $eCounter = 0;
440
441 /**
442 * Search string
443 *
444 * @var string
445 */
446 public $searchString = '';
447
448 /**
449 * Field, indicating to sort in reverse order.
450 *
451 * @var bool
452 */
453 public $sortRev;
454
455 /**
456 * String, can contain the field name from a table which must have duplicate values marked.
457 *
458 * @var string
459 */
460 public $duplicateField;
461
462 /**
463 * Specify a list of tables which are the only ones allowed to be displayed.
464 *
465 * @var string
466 */
467 public $tableList = '';
468
469 /**
470 * Used to accumulate CSV lines for CSV export.
471 *
472 * @var string[]
473 */
474 protected $csvLines = [];
475
476 /**
477 * Clipboard object
478 *
479 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
480 */
481 public $clipObj;
482
483 /**
484 * Tracking names of elements (for clipboard use)
485 *
486 * @var string[]
487 */
488 public $CBnames = [];
489
490 /**
491 * [$tablename][$uid] = number of references to this record
492 *
493 * @var int[][]
494 */
495 protected $referenceCount = [];
496
497 /**
498 * Translations of the current record
499 *
500 * @var string[]
501 */
502 public $translations;
503
504 /**
505 * select fields for the query which fetches the translations of the current
506 * record
507 *
508 * @var string
509 */
510 public $selFieldList;
511
512 /**
513 * @var mixed[]
514 */
515 public $pageinfo;
516
517 /**
518 * Injected by RecordList
519 *
520 * @var string[]
521 */
522 public $MOD_MENU;
523
524 /**
525 * If defined the records are editable
526 *
527 * @var bool
528 */
529 protected $editable = true;
530
531 /**
532 * @var IconFactory
533 */
534 protected $iconFactory;
535
536 /**
537 * @var UriBuilder
538 */
539 protected $uriBuilder;
540
541 /**
542 * Array with before/after setting for tables
543 * Structure:
544 * 'tableName' => [
545 * 'before' => ['A', ...]
546 * 'after' => []
547 * ]
548 *
549 * @var array[]
550 */
551 protected $tableDisplayOrder = [];
552
553 /**
554 * Override the page ids taken into account by getPageIdConstraint()
555 *
556 * @var array
557 */
558 protected $overridePageIdList = [];
559
560 /**
561 * Override/add urlparameters in listUrl() method
562 * @var mixed[]
563 */
564 protected $overrideUrlParameters = [];
565
566 /**
567 * Current link: array with table names and uid
568 *
569 * @var array
570 */
571 protected $currentLink = [];
572
573 /**
574 * Only used to render translated records, used in list module to show page translations
575 *
576 * @var bool
577 */
578 protected $showOnlyTranslatedRecords = false;
579
580 /**
581 * Constructor
582 */
583 public function __construct()
584 {
585 if (isset($GLOBALS['BE_USER']->uc['titleLen']) && $GLOBALS['BE_USER']->uc['titleLen'] > 0) {
586 $this->fixedL = $GLOBALS['BE_USER']->uc['titleLen'];
587 }
588 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
589 $this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
590
591 $this->getTranslateTools();
592 $this->determineScriptUrl();
593
594 $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
595 }
596
597 /**
598 * Create the panel of buttons for submitting the form or otherwise perform
599 * operations.
600 *
601 * @param ModuleTemplate $moduleTemplate
602 */
603 public function getDocHeaderButtons(ModuleTemplate $moduleTemplate)
604 {
605 $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
606 $modulePageTsConfig = BackendUtility::getPagesTSconfig($this->id)['mod.']['web_list.'] ?? [];
607 $backendUser = $this->getBackendUserAuthentication();
608 $lang = $this->getLanguageService();
609 // Get users permissions for this page record:
610 $localCalcPerms = $backendUser->calcPerms($this->pageRow);
611 // CSH
612 if ((string)$this->id === '') {
613 $fieldName = 'list_module_noId';
614 } elseif (!$this->id) {
615 $fieldName = 'list_module_root';
616 } else {
617 $fieldName = 'list_module';
618 }
619 $cshButton = $buttonBar->makeHelpButton()
620 ->setModuleName('xMOD_csh_corebe')
621 ->setFieldName($fieldName);
622 $buttonBar->addButton($cshButton);
623 if (isset($this->id)) {
624 // View Exclude doktypes 254,255 Configuration:
625 // mod.web_list.noViewWithDokTypes = 254,255
626 if (isset($modulePageTsConfig['noViewWithDokTypes'])) {
627 $noViewDokTypes = GeneralUtility::trimExplode(',', $modulePageTsConfig['noViewWithDokTypes'], true);
628 } else {
629 //default exclusion: doktype 254 (folder), 255 (recycler)
630 $noViewDokTypes = [
631 PageRepository::DOKTYPE_SYSFOLDER,
632 PageRepository::DOKTYPE_RECYCLER
633 ];
634 }
635 // New record on pages that are not locked by editlock
636 if (!$modulePageTsConfig['noCreateRecordsLink'] && $this->editLockPermissions()) {
637 $newRecordButton = $buttonBar->makeLinkButton()
638 ->setHref((string)$this->uriBuilder->buildUriFromRoute('db_new', ['id' => $this->id, 'returnUrl' => $this->listURL()]))
639 ->setTitle($lang->getLL('newRecordGeneral'))
640 ->setIcon($this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
641 $buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
642 }
643 if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
644 $onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id));
645 $viewButton = $buttonBar->makeLinkButton()
646 ->setHref('#')
647 ->setOnClick($onClick)
648 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
649 ->setIcon($this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL));
650 $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
651 }
652 // If edit permissions are set, see
653 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
654 if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
655 // Edit
656 $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
657 $editLink = $this->uriBuilder->buildUriFromRoute('record_edit') . $params . $this->makeReturnUrl();
658 $editButton = $buttonBar->makeLinkButton()
659 ->setHref($editLink)
660 ->setTitle($lang->getLL('editPage'))
661 ->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
662 $buttonBar->addButton($editButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
663 }
664 // Paste
665 if ($this->showClipboard && ($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
666 $elFromTable = $this->clipObj->elFromTable('');
667 if (!empty($elFromTable)) {
668 $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
669 $pasteButton = $buttonBar->makeLinkButton()
670 ->setHref($this->clipObj->pasteUrl('', $this->id))
671 ->setTitle($lang->getLL('clip_paste'))
672 ->setClasses('t3js-modal-trigger')
673 ->setDataAttributes([
674 'severity' => 'warning',
675 'content' => $confirmMessage,
676 'title' => $lang->getLL('clip_paste')
677 ])
678 ->setIcon($this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL));
679 $buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
680 }
681 }
682 // Cache
683 if ($this->id !== 0) {
684 $clearCacheButton = $buttonBar->makeLinkButton()
685 ->setHref('#')
686 ->setDataAttributes(['id' => $this->id])
687 ->setClasses('t3js-clear-page-cache')
688 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
689 ->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
690 $buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
691 }
692 if ($this->table && (!isset($modulePageTsConfig['noExportRecordsLinks'])
693 || (isset($modulePageTsConfig['noExportRecordsLinks'])
694 && !$modulePageTsConfig['noExportRecordsLinks']))
695 ) {
696 // CSV
697 $csvButton = $buttonBar->makeLinkButton()
698 ->setHref($this->listURL() . '&csv=1')
699 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.csv'))
700 ->setIcon($this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL))
701 ->setShowLabelText(true);
702 $buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
703 // Export
704 if (ExtensionManagementUtility::isLoaded('impexp')) {
705 $url = (string)$this->uriBuilder->buildUriFromRoute('tx_impexp_export');
706 $exportButton = $buttonBar->makeLinkButton()
707 ->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id))
708 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.export'))
709 ->setIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL))
710 ->setShowLabelText(true);
711 $buttonBar->addButton($exportButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
712 }
713 }
714 // Reload
715 $reloadButton = $buttonBar->makeLinkButton()
716 ->setHref($this->listURL())
717 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.reload'))
718 ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
719 $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
720 // Shortcut
721 if ($backendUser->mayMakeShortcut()) {
722 $shortCutButton = $buttonBar->makeShortcutButton()
723 ->setModuleName('web_list')
724 ->setGetVariables([
725 'id',
726 'route',
727 'imagemode',
728 'pointer',
729 'table',
730 'search_field',
731 'search_levels',
732 'showLimit',
733 'sortField',
734 'sortRev'
735 ])
736 ->setSetVariables(array_keys($this->MOD_MENU));
737 $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
738 }
739 // Back
740 if ($this->returnUrl) {
741 $backButton = $buttonBar->makeLinkButton()
742 ->setHref($this->returnUrl)
743 ->setTitle($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
744 ->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
745 $buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT);
746 }
747 }
748 }
749
750 /**
751 * Creates the listing of records from a single table
752 *
753 * @param string $table Table name
754 * @param int $id Page id
755 * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
756 * @throws \UnexpectedValueException
757 * @return string HTML table with the listing for the record.
758 */
759 public function getTable($table, $id, $rowList = '')
760 {
761 $rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
762 // if no columns have been specified, show description (if configured)
763 if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
764 $rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
765 }
766 $backendUser = $this->getBackendUserAuthentication();
767 $lang = $this->getLanguageService();
768 // Init
769 $addWhere = '';
770 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
771 $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
772 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
773 $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
774 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
775 $tableCollapsed = (bool)$this->tablesCollapsed[$table];
776 // prepare space icon
777 $this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
778 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
779 $this->fieldArray = [];
780 // title Column
781 // Add title column
782 $this->fieldArray[] = $titleCol;
783 // Control-Panel
784 if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
785 $this->fieldArray[] = '_CONTROL_';
786 }
787 // Clipboard
788 if ($this->showClipboard) {
789 $this->fieldArray[] = '_CLIPBOARD_';
790 }
791 // Ref
792 if (!$this->dontShowClipControlPanels) {
793 $this->fieldArray[] = '_REF_';
794 }
795 // Path
796 if ($this->searchLevels) {
797 $this->fieldArray[] = '_PATH_';
798 }
799 // Localization
800 if ($l10nEnabled) {
801 $this->fieldArray[] = '_LOCALIZATION_';
802 // Do not show the "Localize to:" field when only translated records should be shown
803 if (!$this->showOnlyTranslatedRecords) {
804 $this->fieldArray[] = '_LOCALIZATION_b';
805 }
806 // Only restrict to the default language if no search request is in place
807 // And if only translations should be shown
808 if ($this->searchString === '' && !$this->showOnlyTranslatedRecords) {
809 $addWhere = (string)$queryBuilder->expr()->orX(
810 $queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
811 $queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
812 );
813 }
814 }
815 // Cleaning up:
816 $this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
817 if ($this->noControlPanels) {
818 $tempArray = array_flip($this->fieldArray);
819 unset($tempArray['_CONTROL_']);
820 unset($tempArray['_CLIPBOARD_']);
821 $this->fieldArray = array_keys($tempArray);
822 }
823 // Creating the list of fields to include in the SQL query:
824 $selectFields = $this->fieldArray;
825 $selectFields[] = 'uid';
826 $selectFields[] = 'pid';
827 // adding column for thumbnails
828 if ($thumbsCol) {
829 $selectFields[] = $thumbsCol;
830 }
831 if ($table === 'pages') {
832 $selectFields[] = 'module';
833 $selectFields[] = 'extendToSubpages';
834 $selectFields[] = 'nav_hide';
835 $selectFields[] = 'doktype';
836 $selectFields[] = 'shortcut';
837 $selectFields[] = 'shortcut_mode';
838 $selectFields[] = 'mount_pid';
839 }
840 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
841 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
842 }
843 foreach (['type', 'typeicon_column', 'editlock'] as $field) {
844 if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
845 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
846 }
847 }
848 if (BackendUtility::isTableWorkspaceEnabled($table)) {
849 $selectFields[] = 't3ver_state';
850 $selectFields[] = 't3ver_wsid';
851 $selectFields[] = 't3ver_oid';
852 }
853 if ($l10nEnabled) {
854 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
855 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
856 }
857 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
858 $selectFields = array_merge(
859 $selectFields,
860 GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
861 );
862 }
863 // Unique list!
864 $selectFields = array_unique($selectFields);
865 $fieldListFields = $this->makeFieldList($table, 1);
866 if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
867 $message = sprintf($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'), $table, $table);
868 $messageTitle = $lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle');
869 /** @var FlashMessage $flashMessage */
870 $flashMessage = GeneralUtility::makeInstance(
871 FlashMessage::class,
872 $message,
873 $messageTitle,
874 FlashMessage::WARNING,
875 true
876 );
877 /** @var FlashMessageService $flashMessageService */
878 $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
879 /** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue $defaultFlashMessageQueue */
880 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
881 $defaultFlashMessageQueue->enqueue($flashMessage);
882 }
883 // Making sure that the fields in the field-list ARE in the field-list from TCA!
884 $selectFields = array_intersect($selectFields, $fieldListFields);
885 // Implode it into a list of fields for the SQL-statement.
886 $selFieldList = implode(',', $selectFields);
887 $this->selFieldList = $selFieldList;
888 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] ?? [] as $className) {
889 $hookObject = GeneralUtility::makeInstance($className);
890 if (!$hookObject instanceof RecordListGetTableHookInterface) {
891 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListGetTableHookInterface::class, 1195114460);
892 }
893 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
894 }
895 $additionalConstraints = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
896 $selFieldList = GeneralUtility::trimExplode(',', $selFieldList, true);
897
898 // Create the SQL query for selecting the elements in the listing:
899 // do not do paging when outputting as CSV
900 if ($this->csvOutput) {
901 $this->iLimit = 0;
902 }
903 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
904 // Get the two previous rows for sorting if displaying page > 1
905 $this->firstElementNumber -= 2;
906 $this->iLimit += 2;
907 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
908 $this->firstElementNumber += 2;
909 $this->iLimit -= 2;
910 } else {
911 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
912 }
913
914 // Finding the total amount of records on the page
915 $this->setTotalItems($table, $id, $additionalConstraints);
916
917 // Init:
918 $queryResult = $queryBuilder->execute();
919 $dbCount = 0;
920 $out = '';
921 $tableHeader = '';
922 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
923 // If the count query returned any number of records, we perform the real query,
924 // selecting records.
925 if ($this->totalItems) {
926 // Fetch records only if not in single table mode
927 if ($listOnlyInSingleTableMode) {
928 $dbCount = $this->totalItems;
929 } else {
930 // Set the showLimit to the number of records when outputting as CSV
931 if ($this->csvOutput) {
932 $this->showLimit = $this->totalItems;
933 $this->iLimit = $this->totalItems;
934 $dbCount = $this->totalItems;
935 } else {
936 if ($this->firstElementNumber + $this->showLimit <= $this->totalItems) {
937 $dbCount = $this->showLimit + 2;
938 } else {
939 $dbCount = $this->totalItems - $this->firstElementNumber + 2;
940 }
941 }
942 }
943 }
944 // If any records was selected, render the list:
945 if ($dbCount) {
946 $tableIdentifier = $table;
947 // Use a custom table title for translated pages
948 if ($table == 'pages' && $this->showOnlyTranslatedRecords) {
949 // pages records in list module are split into two own sections, one for pages with
950 // sys_language_uid = 0 "Page" and an own section for sys_language_uid > 0 "Page Translation".
951 // This if sets the different title for the page translation case and a unique table identifier
952 // which is used in DOM as id.
953 $tableTitle = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:pageTranslation'));
954 $tableIdentifier = 'pages_translated';
955 } else {
956 $tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
957 if ($tableTitle === '') {
958 $tableTitle = $table;
959 }
960 }
961 // Header line is drawn
962 $theData = [];
963 if ($this->disableSingleTableView) {
964 $theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
965 . '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
966 } else {
967 $icon = $this->table
968 ? '<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory->getIcon('actions-view-table-collapse', Icon::SIZE_SMALL)->render() . '</span>'
969 : '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory->getIcon('actions-view-table-expand', Icon::SIZE_SMALL)->render() . '</span>';
970 $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
971 }
972 if ($listOnlyInSingleTableMode) {
973 $tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
974 } else {
975 // Render collapse button if in multi table mode
976 $collapseIcon = '';
977 if (!$this->table) {
978 $title = $tableCollapsed
979 ? htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
980 : htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
981 $icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon(($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'), Icon::SIZE_SMALL)->render() . '</span>';
982 $collapseIcon = '<a href="#" title="' . $title . '" class="pull-right t3js-toggle-recordlist" data-table="' . htmlspecialchars($tableIdentifier) . '" data-toggle="collapse" data-target="#recordlist-' . htmlspecialchars($tableIdentifier) . '">' . $icon . '</a>';
983 }
984 $tableHeader .= $theData[$titleCol] . $collapseIcon;
985 }
986 // Render table rows only if in multi table view or if in single table view
987 $rowOutput = '';
988 if (!$listOnlyInSingleTableMode || $this->table) {
989 // Fixing an order table for sortby tables
990 $this->currentTable = [];
991 $currentIdList = [];
992 $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
993 $prevUid = 0;
994 $prevPrevUid = 0;
995 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
996 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
997 $row = $queryResult->fetch();
998 $prevPrevUid = -((int)$row['uid']);
999 $row = $queryResult->fetch();
1000 $prevUid = $row['uid'];
1001 }
1002 $accRows = [];
1003 // Accumulate rows here
1004 while ($row = $queryResult->fetch()) {
1005 if (!$this->isRowListingConditionFulfilled($table, $row)) {
1006 continue;
1007 }
1008 // In offline workspace, look for alternative record:
1009 BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
1010 if (is_array($row)) {
1011 $accRows[] = $row;
1012 $currentIdList[] = $row['uid'];
1013 if ($doSort) {
1014 if ($prevUid) {
1015 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
1016 $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
1017 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
1018 }
1019 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
1020 $prevUid = $row['uid'];
1021 }
1022 }
1023 }
1024 $this->totalRowCount = count($accRows);
1025 // CSV initiated
1026 if ($this->csvOutput) {
1027 $this->initCSV();
1028 }
1029 // Render items:
1030 $this->CBnames = [];
1031 $this->duplicateStack = [];
1032 $this->eCounter = $this->firstElementNumber;
1033 $cc = 0;
1034 foreach ($accRows as $row) {
1035 // Render item row if counter < limit
1036 if ($cc < $this->iLimit) {
1037 $cc++;
1038 $this->translations = false;
1039 $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
1040 // If no search happened it means that the selected
1041 // records are either default or All language and here we will not select translations
1042 // which point to the main record:
1043 if ($l10nEnabled && $this->searchString === '' && !($this->hideTranslations === '*' || GeneralUtility::inList($this->hideTranslations, $table))) {
1044 // For each available translation, render the record:
1045 if (is_array($this->translations)) {
1046 foreach ($this->translations as $lRow) {
1047 // $lRow isn't always what we want - if record was moved we've to work with the
1048 // placeholder records otherwise the list is messed up a bit
1049 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
1050 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
1051 ->getQueryBuilderForTable($table);
1052 $queryBuilder->getRestrictions()
1053 ->removeAll()
1054 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
1055 $predicates = [
1056 $queryBuilder->expr()->eq(
1057 't3ver_move_id',
1058 $queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
1059 ),
1060 $queryBuilder->expr()->eq(
1061 'pid',
1062 $queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO::PARAM_INT)
1063 ),
1064 $queryBuilder->expr()->eq(
1065 't3ver_wsid',
1066 $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
1067 ),
1068 ];
1069
1070 $tmpRow = $queryBuilder
1071 ->select(...$selFieldList)
1072 ->from($table)
1073 ->andWhere(...$predicates)
1074 ->execute()
1075 ->fetch();
1076
1077 $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
1078 }
1079 if (!$this->isRowListingConditionFulfilled($table, $lRow)) {
1080 continue;
1081 }
1082 // In offline workspace, look for alternative record:
1083 BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
1084 if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
1085 $currentIdList[] = $lRow['uid'];
1086 $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
1087 }
1088 }
1089 }
1090 }
1091 }
1092 // Counter of total rows incremented:
1093 $this->eCounter++;
1094 }
1095 // Record navigation is added to the beginning and end of the table if in single
1096 // table mode
1097 if ($this->table) {
1098 $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
1099 } else {
1100 // Show that there are more records than shown
1101 if ($this->totalItems > $this->itemsLimitPerTable) {
1102 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
1103 $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
1104 $colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
1105 $rowOutput .= '<tr><td colspan="' . $colspan . '">
1106 <a href="' . htmlspecialchars($this->listURL() . '&table=' . rawurlencode($tableIdentifier)) . '" class="btn btn-default">'
1107 . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
1108 </td></tr>';
1109 }
1110 }
1111 // The header row for the table is now created:
1112 $out .= $this->renderListHeader($table, $currentIdList);
1113 }
1114
1115 $collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
1116 $dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
1117
1118 // The list of records is added after the header:
1119 $out .= $rowOutput;
1120 // ... and it is all wrapped in a table:
1121 $out = '
1122
1123
1124
1125 <!--
1126 DB listing of elements: "' . htmlspecialchars($tableIdentifier) . '"
1127 -->
1128 <div class="panel panel-space panel-default recordlist">
1129 <div class="panel-heading">
1130 ' . $tableHeader . '
1131 </div>
1132 <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($tableIdentifier) . '">
1133 <div class="table-fit">
1134 <table data-table="' . htmlspecialchars($tableIdentifier) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
1135 ' . $out . '
1136 </table>
1137 </div>
1138 </div>
1139 </div>
1140 ';
1141 // Output csv if...
1142 // This ends the page with exit.
1143 if ($this->csvOutput) {
1144 $this->outputCSV($table);
1145 }
1146 }
1147 // Return content:
1148 return $out;
1149 }
1150
1151 /**
1152 * Get viewOnClick link for pages or tt_content records
1153 *
1154 * @param string $table
1155 * @param array $row
1156 *
1157 * @return string
1158 */
1159 protected function getOnClickForRow(string $table, array $row): string
1160 {
1161 if ($table === 'tt_content') {
1162 // Link to a content element, possibly translated and with anchor
1163 $additionalParams = '';
1164 $language = (int)$row[$GLOBALS['TCA']['tt_content']['ctrl']['languageField']];
1165 if ($language > 0) {
1166 $additionalParams = '&L=' . $language;
1167 }
1168 $onClick = BackendUtility::viewOnClick(
1169 $this->id,
1170 '',
1171 null,
1172 '#c' . $row['uid'],
1173 '',
1174 $additionalParams
1175 );
1176 } elseif ($table === 'pages' && $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] > 0) {
1177 // Link to a page translation needs uid of default language page as id
1178 $onClick = BackendUtility::viewOnClick(
1179 $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']],
1180 '',
1181 null,
1182 '',
1183 '',
1184 '&L=' . (int)$row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]
1185 );
1186 } else {
1187 // Link to a page in the default language
1188 $onClick = BackendUtility::viewOnClick($row['uid']);
1189 }
1190 return $onClick;
1191 }
1192
1193 /**
1194 * Check if all row listing conditions are fulfilled.
1195 *
1196 * This function serves as a dummy method to be overridden in extending classes.
1197 *
1198 * @param string $table Table name
1199 * @param string[] $row Record
1200 * @return bool True, if all conditions are fulfilled.
1201 */
1202 protected function isRowListingConditionFulfilled($table, $row)
1203 {
1204 return true;
1205 }
1206
1207 /**
1208 * Rendering a single row for the list
1209 *
1210 * @param string $table Table name
1211 * @param mixed[] $row Current record
1212 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
1213 * @param string $titleCol Table field (column) where header value is found
1214 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
1215 * @param int $indent Indent from left.
1216 * @return string Table row for the element
1217 * @internal
1218 * @see getTable()
1219 */
1220 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
1221 {
1222 if (!is_array($row)) {
1223 return '';
1224 }
1225 $rowOutput = '';
1226 $id_orig = null;
1227 // If in search mode, make sure the preview will show the correct page
1228 if ((string)$this->searchString !== '') {
1229 $id_orig = $this->id;
1230 $this->id = $row['pid'];
1231 }
1232
1233 $tagAttributes = [
1234 'class' => ['t3js-entity'],
1235 'data-table' => $table,
1236 'title' => 'id=' . $row['uid'],
1237 ];
1238
1239 // Add active class to record of current link
1240 if (
1241 isset($this->currentLink['tableNames'])
1242 && (int)$this->currentLink['uid'] === (int)$row['uid']
1243 && GeneralUtility::inList($this->currentLink['tableNames'], $table)
1244 ) {
1245 $tagAttributes['class'][] = 'active';
1246 }
1247 // Add special classes for first and last row
1248 if ($cc == 1 && $indent == 0) {
1249 $tagAttributes['class'][] = 'firstcol';
1250 }
1251 if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
1252 $tagAttributes['class'][] = 'lastcol';
1253 }
1254 // Overriding with versions background color if any:
1255 if (!empty($row['_CSSCLASS'])) {
1256 $tagAttributes['class'] = [$row['_CSSCLASS']];
1257 }
1258 // Incr. counter.
1259 $this->counter++;
1260 // The icon with link
1261 $toolTip = BackendUtility::getRecordToolTip($row, $table);
1262 $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
1263 $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
1264 . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
1265 . '</span>';
1266 $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
1267 // Preparing and getting the data-array
1268 $theData = [];
1269 $localizationMarkerClass = '';
1270 foreach ($this->fieldArray as $fCol) {
1271 if ($fCol == $titleCol) {
1272 $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
1273 $warning = '';
1274 // If the record is edit-locked by another user, we will show a little warning sign:
1275 $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
1276 if ($lockInfo) {
1277 $warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
1278 . $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</span>';
1279 }
1280 $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
1281 // Render thumbnails, if:
1282 // - a thumbnail column exists
1283 // - there is content in it
1284 // - the thumbnail column is visible for the current type
1285 $type = 0;
1286 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
1287 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
1288 $type = $row[$typeColumn];
1289 }
1290 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
1291 // if 0 doesn't exist)
1292 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
1293 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
1294 }
1295
1296 $visibleColumns = $this->getVisibleColumns($GLOBALS['TCA'][$table], $type);
1297
1298 if ($this->thumbs &&
1299 trim($row[$thumbsCol]) &&
1300 preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
1301 ) {
1302 $thumbCode = '<br />' . BackendUtility::thumbCode($row, $table, $thumbsCol);
1303 $theData[$fCol] .= $thumbCode;
1304 $theData['__label'] .= $thumbCode;
1305 }
1306 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1307 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
1308 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
1309 ) {
1310 // It's a translated record with a language parent
1311 $localizationMarkerClass = ' localization';
1312 }
1313 } elseif ($fCol === 'pid') {
1314 $theData[$fCol] = $row[$fCol];
1315 } elseif ($fCol === '_PATH_') {
1316 $theData[$fCol] = $this->recPath($row['pid']);
1317 } elseif ($fCol === '_REF_') {
1318 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
1319 } elseif ($fCol === '_CONTROL_') {
1320 $theData[$fCol] = $this->makeControl($table, $row);
1321 } elseif ($fCol === '_CLIPBOARD_') {
1322 $theData[$fCol] = $this->makeClip($table, $row);
1323 } elseif ($fCol === '_LOCALIZATION_') {
1324 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
1325 $theData[$fCol] = $lC1;
1326 $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
1327 } elseif ($fCol === '_LOCALIZATION_b') {
1328 // deliberately empty
1329 } else {
1330 $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
1331 $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
1332 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
1333 if ($this->csvOutput) {
1334 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
1335 }
1336 }
1337 }
1338 // Reset the ID if it was overwritten
1339 if ((string)$this->searchString !== '') {
1340 $this->id = $id_orig;
1341 }
1342 // Add row to CSV list:
1343 if ($this->csvOutput) {
1344 $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvRow'] ?? [];
1345 if (!empty($hooks)) {
1346 $hookParameters = [
1347 'databaseRow' => &$row,
1348 'tableName' => $table,
1349 'pageId' => $this->id
1350 ];
1351 foreach ($hooks as $hookFunction) {
1352 GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
1353 }
1354 }
1355 $this->addToCSV($row);
1356 }
1357 // Add classes to table cells
1358 $this->addElement_tdCssClass[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
1359 $this->addElement_tdCssClass['__label'] = $this->addElement_tdCssClass[$titleCol];
1360 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
1361 if ($this->moduleData['clipBoard']) {
1362 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
1363 }
1364 $this->addElement_tdCssClass['_PATH_'] = 'col-path';
1365 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
1366 $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
1367 // Create element in table cells:
1368 $theData['uid'] = $row['uid'];
1369 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1370 && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
1371 ) {
1372 $theData['_l10nparent_'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
1373 }
1374
1375 $tagAttributes = array_map(
1376 function ($attributeValue) {
1377 if (is_array($attributeValue)) {
1378 return implode(' ', $attributeValue);
1379 }
1380 return $attributeValue;
1381 },
1382 $tagAttributes
1383 );
1384
1385 $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
1386 // Finally, return table row element:
1387 return $rowOutput;
1388 }
1389
1390 /**
1391 * Gets the number of records referencing the record with the UID $uid in
1392 * the table $tableName.
1393 *
1394 * @param string $tableName
1395 * @param int $uid
1396 * @return int The number of references to record $uid in table
1397 */
1398 protected function getReferenceCount($tableName, $uid)
1399 {
1400 if (!isset($this->referenceCount[$tableName][$uid])) {
1401 $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
1402 $numberOfReferences = $referenceIndex->getNumberOfReferencedRecords($tableName, $uid);
1403 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
1404 }
1405 return $this->referenceCount[$tableName][$uid];
1406 }
1407
1408 /**
1409 * Rendering the header row for a table
1410 *
1411 * @param string $table Table name
1412 * @param int[] $currentIdList Array of the currently displayed uids of the table
1413 * @throws \UnexpectedValueException
1414 * @return string Header table row
1415 * @internal
1416 * @see getTable()
1417 */
1418 public function renderListHeader($table, $currentIdList)
1419 {
1420 $tsConfig = BackendUtility::getPagesTSconfig($this->id);
1421 $tsConfigOfTable = is_array($tsConfig['TCEFORM.'][$table . '.']) ? $tsConfig['TCEFORM.'][$table . '.'] : null;
1422
1423 $lang = $this->getLanguageService();
1424 // Init:
1425 $theData = [];
1426 $icon = '';
1427 // Traverse the fields:
1428 foreach ($this->fieldArray as $fCol) {
1429 // Calculate users permissions to edit records in the table:
1430 $permsEdit = $this->calcPerms & ($table === 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table);
1431 switch ((string)$fCol) {
1432 case '_PATH_':
1433 // Path
1434 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>';
1435 break;
1436 case '_REF_':
1437 // References
1438 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._REF_')) . ']</i>';
1439 break;
1440 case '_LOCALIZATION_':
1441 // Path
1442 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>';
1443 break;
1444 case '_LOCALIZATION_b':
1445 // Path
1446 $theData[$fCol] = htmlspecialchars($lang->getLL('Localize'));
1447 break;
1448 case '_CLIPBOARD_':
1449 if (!$this->moduleData['clipBoard']) {
1450 break;
1451 }
1452 // Clipboard:
1453 $cells = [];
1454 // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
1455 // then display the "paste into" icon:
1456 $elFromTable = $this->clipObj->elFromTable($table);
1457 if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
1458 $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id));
1459 $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
1460 $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"'
1461 . ' href="' . $href . '"'
1462 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1463 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1464 . ' data-content="' . htmlspecialchars($confirmMessage) . '"'
1465 . ' data-severity="warning">'
1466 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
1467 . '</a>';
1468 }
1469 // If the numeric clipboard pads are enabled, display the control icons for that:
1470 if ($this->clipObj->current !== 'normal') {
1471 // The "select" link:
1472 $spriteIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render();
1473 $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked'));
1474 // The "edit marked" link:
1475 $editUri = (string)$this->uriBuilder->buildUriFromRoute('record_edit')
1476 . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit'
1477 . '&returnUrl=' . rawurlencode($this->listURL());
1478 $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1479 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1480 . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
1481 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1482 // The "Delete marked" link:
1483 $cells['delete'] = $this->linkClipboardHeaderIcon(
1484 $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(),
1485 $table,
1486 'delete',
1487 sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
1488 $lang->getLL('clip_deleteMarked')
1489 );
1490 // The "Select all" link:
1491 $onClick = htmlspecialchars('checkOffCB(' . GeneralUtility::quoteJSvalue(implode(',', $this->CBnames)) . ', this); return false;');
1492 $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
1493 . htmlspecialchars($lang->getLL('clip_markRecords')) . '">'
1494 . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL)->render() . '</a>';
1495 } else {
1496 $cells['empty'] = '';
1497 }
1498 /*
1499 * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
1500 * usage: Above each listed table in Web>List a header row is shown.
1501 * This hook allows to modify the icons responsible for the clipboard functions
1502 * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
1503 * or other "Action" functions which perform operations on the listed records.
1504 */
1505 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
1506 $hookObject = GeneralUtility::makeInstance($className);
1507 if (!$hookObject instanceof RecordListHookInterface) {
1508 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567850);
1509 }
1510 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
1511 }
1512 $theData[$fCol] = '';
1513 if (isset($cells['edit']) && isset($cells['delete'])) {
1514 $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>';
1515 unset($cells['edit'], $cells['delete']);
1516 }
1517 $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1518 break;
1519 case '_CONTROL_':
1520 // Control panel:
1521 if ($this->isEditable($table)) {
1522 // If new records can be created on this page, add links:
1523 $permsAdditional = ($table === 'pages' ? 8 : 16);
1524 if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) {
1525 $spriteIcon = $table === 'pages'
1526 ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)
1527 : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL);
1528 if ($table === 'tt_content') {
1529 // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
1530 $newContentElementWizard = BackendUtility::getPagesTSconfig($this->pageinfo['uid'])['mod.']['newContentElementWizard.']['override']
1531 ?? 'new_content_element_wizard';
1532 $url = (string)$this->uriBuilder->buildUriFromRoute(
1533 $newContentElementWizard,
1534 [
1535 'id' => $this->id,
1536 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
1537 ]
1538 );
1539 $icon = '<a href="' . htmlspecialchars($url) . '" '
1540 . 'data-title="' . htmlspecialchars($lang->getLL('new')) . '"'
1541 . 'class="btn btn-default t3js-toggle-new-content-element-wizard">'
1542 . $spriteIcon->render()
1543 . '</a>';
1544 } elseif ($table === 'pages') {
1545 $parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
1546 $href = (string)$this->uriBuilder->buildUriFromRoute('db_new', $parameters);
1547 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
1548 . $spriteIcon->render() . '</a>';
1549 } else {
1550 $params = '&edit[' . $table . '][' . $this->id . ']=new';
1551 if ($table === 'pages') {
1552 $params .= '&overrideVals[pages][doktype]=' . (int)$this->pageRow['doktype'];
1553 }
1554 $newLink = $this->uriBuilder->buildUriFromRoute('record_edit') . $params . $this->makeReturnUrl();
1555 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($newLink) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1556 }
1557 }
1558 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1559 if ($permsEdit && $this->table && is_array($currentIdList)) {
1560 $entityIdentifiers = 'entityIdentifiers';
1561 if ($this->clipNumPane()) {
1562 $entityIdentifiers .= ':editList';
1563 }
1564 $editUri = (string)$this->uriBuilder->buildUriFromRoute('record_edit')
1565 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1566 . '&columnsOnly=' . implode(',', $this->fieldArray)
1567 . '&returnUrl=' . rawurlencode($this->listURL());
1568 $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1569 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1570 . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
1571 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1572 $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1573 }
1574 // Add an empty entry, so column count fits again after moving this into $icon
1575 $theData[$fCol] = '&nbsp;';
1576 }
1577 break;
1578 default:
1579 // Regular fields header:
1580 $theData[$fCol] = '';
1581
1582 // Check if $fCol is really a field and get the label and remove the colons
1583 // at the end
1584 $sortLabel = BackendUtility::getItemLabel($table, $fCol);
1585 if ($sortLabel !== null) {
1586 $sortLabel = rtrim(trim($lang->sL($sortLabel)), ':');
1587
1588 // Field label
1589 $fieldTSConfig = [];
1590 if (isset($tsConfigOfTable[$fCol . '.'])
1591 && is_array($tsConfigOfTable[$fCol . '.'])
1592 ) {
1593 $fieldTSConfig = $tsConfigOfTable[$fCol . '.'];
1594 }
1595 if (!empty($fieldTSConfig['label'])) {
1596 $sortLabel = $lang->sL($fieldTSConfig['label']);
1597 }
1598 if (!empty($fieldTSConfig['label.'][$lang->lang])) {
1599 $sortLabel = $lang->sL($fieldTSConfig['label.'][$lang->lang]);
1600 }
1601 $sortLabel = htmlspecialchars($sortLabel);
1602 } else {
1603 // No TCA field, only output the $fCol variable with square brackets []
1604 $sortLabel = htmlspecialchars($fCol);
1605 $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1606 }
1607
1608 if ($this->table && is_array($currentIdList)) {
1609 // If the numeric clipboard pads are selected, show duplicate sorting link:
1610 if ($this->clipNumPane()) {
1611 $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', '-1') . '&duplicateField=' . $fCol)
1612 . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">'
1613 . $this->iconFactory->getIcon('actions-document-duplicates-select', Icon::SIZE_SMALL)->render() . '</a>';
1614 }
1615 // If the table can be edited, add link for editing THIS field for all
1616 // listed records:
1617 if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1618 $entityIdentifiers = 'entityIdentifiers';
1619 if ($this->clipNumPane()) {
1620 $entityIdentifiers .= ':editList';
1621 }
1622 $editUri = (string)$this->uriBuilder->buildUriFromRoute('record_edit')
1623 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1624 . '&columnsOnly=' . $fCol
1625 . '&returnUrl=' . rawurlencode($this->listURL());
1626 $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1627 $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1628 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1629 . ' title="' . htmlspecialchars($iTitle) . '">'
1630 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1631 }
1632 if (strlen($theData[$fCol]) > 0) {
1633 $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1634 }
1635 }
1636 $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1637 }
1638 }
1639 /*
1640 * hook: renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
1641 * usage: Above each listed table in Web>List a header row is shown.
1642 * Containing the labels of all shown fields and additional icons to create new records for this
1643 * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
1644 */
1645 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
1646 $hookObject = GeneralUtility::makeInstance($className);
1647 if (!$hookObject instanceof RecordListHookInterface) {
1648 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567855);
1649 }
1650 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1651 }
1652
1653 // Create and return header table row:
1654 return '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1655 }
1656
1657 /**
1658 * Get pointer for first element on the page
1659 *
1660 * @param int $page Page number starting with 1
1661 * @return int Pointer to first element on the page (starting with 0)
1662 */
1663 protected function getPointerForPage($page)
1664 {
1665 return ($page - 1) * $this->iLimit;
1666 }
1667
1668 /**
1669 * Creates a page browser for tables with many records
1670 *
1671 * @param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1672 * @return string Navigation HTML
1673 */
1674 protected function renderListNavigation($renderPart = 'top')
1675 {
1676 $totalPages = ceil($this->totalItems / $this->iLimit);
1677 // Show page selector if not all records fit into one page
1678 if ($totalPages <= 1) {
1679 return '';
1680 }
1681 $content = '';
1682 $listURL = $this->listURL('', $this->table, 'firstElementNumber');
1683 // 1 = first page
1684 // 0 = first element
1685 $currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
1686 // Compile first, previous, next, last and refresh buttons
1687 if ($currentPage > 1) {
1688 $labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:first'));
1689 $labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:previous'));
1690 $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1691 . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</a></li>';
1692 $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1693 . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</a></li>';
1694 } else {
1695 $first = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</span></li>';
1696 $previous = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</span></li>';
1697 }
1698 if ($currentPage < $totalPages) {
1699 $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:next'));
1700 $labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:last'));
1701 $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '" title="' . $labelNext . '">'
1702 . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</a></li>';
1703 $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1704 . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</a></li>';
1705 } else {
1706 $next = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</span></li>';
1707 $last = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</span></li>';
1708 }
1709 $reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
1710 . '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility::quoteJSvalue('jumpPage-' . $renderPart)
1711 . ').value); document.dblistForm.submit(); return true;" title="'
1712 . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
1713 . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a></li>';
1714 if ($renderPart === 'top') {
1715 // Add js to traverse a page select input to a pointer value
1716 $content = '
1717 <script>
1718 /*<![CDATA[*/
1719 function calculatePointer(page) {
1720 if (page > ' . $totalPages . ') {
1721 page = ' . $totalPages . ';
1722 }
1723 if (page < 1) {
1724 page = 1;
1725 }
1726 return (page - 1) * ' . $this->iLimit . ';
1727 }
1728 /*]]>*/
1729 </script>
1730 ';
1731 }
1732 $pageNumberInput = '
1733 <input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1734 . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . htmlspecialchars(GeneralUtility::quoteJSvalue($listURL . '&pointer='))
1735 . '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1736 ';
1737 $pageIndicatorText = sprintf(
1738 $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
1739 $pageNumberInput,
1740 $totalPages
1741 );
1742 $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1743 if ($this->totalItems > $this->firstElementNumber + $this->iLimit) {
1744 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1745 } else {
1746 $lastElementNumber = $this->totalItems;
1747 }
1748 $rangeIndicator = '<li><span>' . sprintf(
1749 $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'),
1750 $this->firstElementNumber + 1,
1751 $lastElementNumber
1752 ) . '</span></li>';
1753
1754 $titleColumn = $this->fieldArray[0];
1755 $data = [
1756 $titleColumn => $content . '
1757 <nav class="pagination-wrap">
1758 <ul class="pagination pagination-block">
1759 ' . $first . '
1760 ' . $previous . '
1761 ' . $rangeIndicator . '
1762 ' . $pageIndicator . '
1763 ' . $next . '
1764 ' . $last . '
1765 ' . $reload . '
1766 </ul>
1767 </nav>
1768 '
1769 ];
1770 return $this->addElement(1, '', $data);
1771 }
1772
1773 /*********************************
1774 *
1775 * Rendering of various elements
1776 *
1777 *********************************/
1778
1779 /**
1780 * Creates the control panel for a single record in the listing.
1781 *
1782 * @param string $table The table
1783 * @param mixed[] $row The record for which to make the control panel.
1784 * @throws \UnexpectedValueException
1785 * @return string HTML table with the control panel (unless disabled)
1786 */
1787 public function makeControl($table, $row)
1788 {
1789 $backendUser = $this->getBackendUserAuthentication();
1790 $userTsConfig = $backendUser->getTSConfig();
1791 $rowUid = $row['uid'];
1792 if (ExtensionManagementUtility::isLoaded('workspaces') && isset($row['_ORIG_uid'])) {
1793 $rowUid = $row['_ORIG_uid'];
1794 }
1795 $cells = [
1796 'primary' => [],
1797 'secondary' => []
1798 ];
1799 // Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them
1800 // For page translations these icons should never be shown
1801 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1802 if ($table === 'pages') {
1803 // If the listed table is 'pages' we have to request the permission settings for each page.
1804 $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
1805 } else {
1806 // If the listed table is not 'pages' we have to request the permission settings from the parent page
1807 $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $row['pid']));
1808 }
1809 $permsEdit = $table === 'pages'
1810 && $backendUser->checkLanguageAccess(0)
1811 && $localCalcPerms & Permission::PAGE_EDIT
1812 || $table !== 'pages'
1813 && $localCalcPerms & Permission::CONTENT_EDIT
1814 && $backendUser->recordEditAccessInternals($table, $row);
1815 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1816 // "Show" link (only pages and tt_content elements)
1817
1818 if ($table === 'pages' || $table === 'tt_content') {
1819 $onClick = $this->getOnClickForRow($table, $row);
1820 $viewAction = '<a class="btn btn-default" href="#" onclick="'
1821 . htmlspecialchars(
1822 $onClick
1823 ) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">';
1824 if ($table === 'pages') {
1825 $viewAction .= $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render();
1826 } else {
1827 $viewAction .= $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render();
1828 }
1829 $viewAction .= '</a>';
1830 $this->addActionToCellGroup($cells, $viewAction, 'view');
1831 }
1832 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1833 if ($permsEdit) {
1834 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1835 $iconIdentifier = 'actions-open';
1836 if ($table === 'pages') {
1837 // Disallow manual adjustment of the language field for pages
1838 $params .= '&overrideVals[pages][sys_language_uid]=' . (int)$row[$GLOBALS['TCA']['pages']['ctrl']['languageField']];
1839 $iconIdentifier = 'actions-page-open';
1840 }
1841 $overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null;
1842 $editLink = $this->uriBuilder->buildUriFromRoute('record_edit') . $params . $this->makeReturnUrl();
1843 $editAction = '<a class="btn btn-default" href="' . htmlspecialchars($editLink) . '"'
1844 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL, $overlayIdentifier)->render() . '</a>';
1845 } else {
1846 $editAction = $this->spaceIcon;
1847 }
1848 $this->addActionToCellGroup($cells, $editAction, 'edit');
1849 // "Info": (All records)
1850 $onClick = 'top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
1851 $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
1852 . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
1853 $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1854 // "Move" wizard link for pages/tt_content elements:
1855 if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) {
1856 if ($isL10nOverlay) {
1857 $moveAction = $this->spaceIcon;
1858 } else {
1859 $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page')));
1860 $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-move', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL));
1861 $url = (string)$this->uriBuilder->buildUriFromRoute('move_element', [
1862 'table' => $table,
1863 'uid' => $row['uid'],
1864 'returnUrl' => $this->listURL(),
1865 ]);
1866 $moveAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
1867 }
1868 $this->addActionToCellGroup($cells, $moveAction, 'move');
1869 }
1870 // If the table is NOT a read-only table, then show these links:
1871 if ($this->isEditable($table)) {
1872 // "Revert" link (history/undo)
1873 if ((bool)\trim($userTsConfig['options.']['showHistory.'][$table] ?? $userTsConfig['options.']['showHistory'] ?? '1')) {
1874 $moduleUrl = $this->uriBuilder->buildUriFromRoute('record_history', [
1875 'element' => $table . ':' . $row['uid'],
1876 'returnUrl' => $this->listURL(),
1877 ]) . '#latest';
1878 $historyAction = '<a class="btn btn-default" href="' . htmlspecialchars($moduleUrl) . '" title="'
1879 . htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
1880 . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '</a>';
1881 $this->addActionToCellGroup($cells, $historyAction, 'history');
1882 }
1883 // "Edit Perms" link:
1884 if ($table === 'pages' && $backendUser->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
1885 if ($isL10nOverlay) {
1886 $permsAction = $this->spaceIcon;
1887 } else {
1888 $href = (string)$this->uriBuilder->buildUriFromRoute('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
1889 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1890 . htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
1891 . $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
1892 }
1893 $this->addActionToCellGroup($cells, $permsAction, 'perms');
1894 }
1895 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
1896 // or if default values can depend on previous record):
1897 if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
1898 if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
1899 if ($table === 'pages' && $isL10nOverlay) {
1900 $this->addActionToCellGroup($cells, $this->spaceIcon, 'new');
1901 } elseif ($this->showNewRecLink($table)) {
1902 $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
1903 $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
1904 $titleLabel = 'new';
1905 if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1906 $titleLabel .= ($table === 'pages' ? 'Page' : 'Record');
1907 }
1908 $newLink = $this->uriBuilder->buildUriFromRoute('record_edit') . $params . $this->makeReturnUrl();
1909 $newAction = '<a class="btn btn-default" href="' . htmlspecialchars($newLink) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
1910 . $icon->render() . '</a>';
1911 $this->addActionToCellGroup($cells, $newAction, 'new');
1912 }
1913 }
1914 }
1915 // "Up/Down" links
1916 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
1917 if (!$isL10nOverlay && isset($this->currentTable['prev'][$row['uid']])) {
1918 // Up
1919 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
1920 $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
1921 $moveUpAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
1922 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
1923 } else {
1924 $moveUpAction = $this->spaceIcon;
1925 }
1926 $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
1927
1928 if (!$isL10nOverlay && $this->currentTable['next'][$row['uid']]) {
1929 // Down
1930 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
1931 $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
1932 $moveDownAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
1933 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
1934 } else {
1935 $moveDownAction = $this->spaceIcon;
1936 }
1937 $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
1938 }
1939 // "Hide/Unhide" links:
1940 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1941
1942 if (
1943 !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
1944 && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
1945 || $backendUser->check('non_exclude_fields', $table . ':' . $hiddenField))
1946 ) {
1947 if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) {
1948 $hideAction = $this->spaceIcon;
1949 } else {
1950 $hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ? 'Page' : '')));
1951 $unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ? 'Page' : '')));
1952 if ($row[$hiddenField]) {
1953 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
1954 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
1955 . ' data-params="' . htmlspecialchars($params) . '"'
1956 . ' title="' . $unhideTitle . '"'
1957 . ' data-toggle-title="' . $hideTitle . '">'
1958 . $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '</a>';
1959 } else {
1960 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
1961 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
1962 . ' data-params="' . htmlspecialchars($params) . '"'
1963 . ' title="' . $hideTitle . '"'
1964 . ' data-toggle-title="' . $unhideTitle . '">'
1965 . $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '</a>';
1966 }
1967 }
1968 $this->addActionToCellGroup($cells, $hideAction, 'hide');
1969 }
1970 // "Delete" link:
1971 $disableDelete = (bool)\trim($userTsConfig['options.']['disableDelete.'][$table] ?? $userTsConfig['options.']['disableDelete'] ?? '0');
1972 if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) {
1973 // Check if the record version is in "deleted" state, because that will switch the action to "restore"
1974 if ($backendUser->workspace > 0 && isset($row['t3ver_state']) && VersionState::cast($row['t3ver_state'])->equals(VersionState::DELETE_PLACEHOLDER)) {
1975 $actionName = 'restore';
1976 $refCountMsg = '';
1977 } else {
1978 $actionName = 'delete';
1979 $refCountMsg = BackendUtility::referenceCount(
1980 $table,
1981 $row['uid'],
1982 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
1983 $this->getReferenceCount($table, $row['uid'])
1984 ) . BackendUtility::translationCount(
1985 $table,
1986 $row['uid'],
1987 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
1988 );
1989 }
1990
1991 if ($this->isRecordCurrentBackendUser($table, $row)) {
1992 $deleteAction = $this->spaceIcon;
1993 } else {
1994 $title = BackendUtility::getRecordTitle($table, $row);
1995 $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" [' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
1996
1997 $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
1998 $icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
1999 $linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
2000 $l10nParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '';
2001 $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
2002 . ' data-l10parent="' . ($l10nParentField ? htmlspecialchars($row[$l10nParentField]) : '') . '"'
2003 . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
2004 . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
2005 . '>' . $icon . '</a>';
2006 }
2007 } else {
2008 $deleteAction = $this->spaceIcon;
2009 }
2010 $this->addActionToCellGroup($cells, $deleteAction, 'delete');
2011 // "Levels" links: Moving pages into new levels...
2012 if ($permsEdit && $table === 'pages' && !$this->searchLevels) {
2013 // Up (Paste as the page right after the current parent page)
2014 if ($this->calcPerms & Permission::PAGE_NEW) {
2015 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
2016 $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
2017 $moveLeftAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
2018 . $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
2019 $this->addActionToCellGroup($cells, $isL10nOverlay ? $this->spaceIcon : $moveLeftAction, 'moveLeft');
2020 }
2021 // Down (Paste as subpage to the page right above)
2022 if (!$isL10nOverlay && $this->currentTable['prevUid'][$row['uid']]) {
2023 $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
2024 if ($localCalcPerms & Permission::PAGE_NEW) {
2025 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
2026 $url = BackendUtility::getLinkToDataHandlerAction($params, $this->listURL());
2027 $moveRightAction = '<a class="btn btn-default" href="' . htmlspecialchars($url) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
2028 . $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
2029 } else {
2030 $moveRightAction = $this->spaceIcon;
2031 }
2032 } else {
2033 $moveRightAction = $this->spaceIcon;
2034 }
2035 $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
2036 }
2037 }
2038 /*
2039 * hook: recStatInfoHooks: Allows to insert HTML before record icons on various places
2040 */
2041 $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ?? [];
2042 if (!empty($hooks)) {
2043 $stat = '';
2044 $_params = [$table, $row['uid']];
2045 foreach ($hooks as $_funcRef) {
2046 $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2047 }
2048 $this->addActionToCellGroup($cells, $stat, 'stat');
2049 }
2050 /*
2051 * hook: makeControl: Allows to change control icons of records in list-module
2052 * usage: This hook method gets passed the current $cells array as third parameter.
2053 * This array contains values for the icons/actions generated for each record in Web>List.
2054 * Each array entry is accessible by an index-key.
2055 * The order of the icons is depending on the order of those array entries.
2056 */
2057 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? false)) {
2058 // for compatibility reason, we move all icons to the rootlevel
2059 // before calling the hooks
2060 foreach ($cells as $section => $actions) {
2061 foreach ($actions as $actionKey => $action) {
2062 $cells[$actionKey] = $action;
2063 }
2064 }
2065 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
2066 $hookObject = GeneralUtility::makeInstance($className);
2067 if (!$hookObject instanceof RecordListHookInterface) {
2068 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567840);
2069 }
2070 $cells = $hookObject->makeControl($table, $row, $cells, $this);
2071 }
2072 // now sort icons again into primary and secondary sections
2073 // after all hooks are processed
2074 $hookCells = $cells;
2075 foreach ($hookCells as $key => $value) {
2076 if ($key === 'primary' || $key === 'secondary') {
2077 continue;
2078 }
2079 $this->addActionToCellGroup($cells, $value, $key);
2080 }
2081 }
2082 $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
2083 foreach ($cells as $classification => $actions) {
2084 $visibilityClass = ($classification !== 'primary' && !$this->moduleData['bigControlPanel'] ? 'collapsed' : 'expanded');
2085 if ($visibilityClass === 'collapsed') {
2086 $cellOutput = '';
2087 foreach ($actions as $action) {
2088 $cellOutput .= $action;
2089 }
2090 $output .= ' <div class="btn-group">' .
2091 '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
2092 '<a href="#actions_' . $table . '_' . $row['uid'] . '" class="btn btn-default collapsed" data-toggle="collapse" aria-expanded="false"><span class="t3-icon fa fa-ellipsis-h"></span></a>' .
2093 '</div>';
2094 } else {
2095 $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
2096 }
2097 }
2098 return $output;
2099 }
2100
2101 /**
2102 * Creates the clipboard panel for a single record in the listing.
2103 *
2104 * @param string $table The table
2105 * @param mixed[] $row The record for which to make the clipboard panel.
2106 * @throws \UnexpectedValueException
2107 * @return string HTML table with the clipboard panel (unless disabled)
2108 */
2109 public function makeClip($table, $row)
2110 {
2111 // Return blank, if disabled:
2112 if (!$this->moduleData['clipBoard']) {
2113 return '';
2114 }
2115 if (!$this->isEditable($table)) {
2116 return '';
2117 }
2118 $cells = [];
2119 $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon);
2120 // Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
2121 // For page translations these icons should never be shown
2122 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
2123 // Return blank, if disabled:
2124 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
2125 // For the "Normal" pad:
2126 if ($this->clipObj->current === 'normal') {
2127 // Show copy/cut icons:
2128 $isSel = (string)$this->clipObj->isSelected($table, $row['uid']);
2129 if ($isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)) {
2130 $cells['copy'] = $this->spaceIcon;
2131 $cells['cut'] = $this->spaceIcon;
2132 } else {
2133 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL);
2134 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL);
2135
2136 if ($isSel === 'copy') {
2137 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL);
2138 } elseif ($isSel === 'cut') {
2139 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL);
2140 }
2141
2142 $cells['copy'] = '<a class="btn btn-default" href="'
2143 . htmlspecialchars($this->clipObj->selUrlDB(
2144 $table,
2145 $row['uid'],
2146 1,
2147 $isSel === 'copy',
2148 ['returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]
2149 ))
2150 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">'
2151 . $copyIcon->render() . '</a>';
2152
2153 // Check permission to cut page or content
2154 if ($table === 'pages') {
2155 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
2156 $permsEdit = $localCalcPerms & Permission::PAGE_EDIT;
2157 } else {
2158 $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT;
2159 }
2160 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
2161
2162 // If the listed table is 'pages' we have to request the permission settings for each page:
2163 if ($table === 'pages') {
2164 if ($permsEdit) {
2165 $cells['cut'] = '<a class="btn btn-default" href="'
2166 . htmlspecialchars($this->clipObj->selUrlDB(
2167 $table,
2168 $row['uid'],
2169 0,
2170 $isSel === 'cut',
2171 ['returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]
2172 ))
2173 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2174 . $cutIcon->render() . '</a>';
2175 } else {
2176 $cells['cut'] = $this->spaceIcon;
2177 }
2178 } elseif ($this->calcPerms & Permission::CONTENT_EDIT) {
2179 $cells['cut'] = '<a class="btn btn-default" href="'
2180 . htmlspecialchars($this->clipObj->selUrlDB(
2181 $table,
2182 $row['uid'],
2183 0,
2184 $isSel === 'cut',
2185 ['returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]
2186 ))
2187 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2188 . $cutIcon->render() . '</a>';
2189 } else {
2190 $cells['cut'] = $this->spaceIcon;
2191 }
2192 }
2193 } else {
2194 // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
2195 // Setting name of the element in ->CBnames array:
2196 $n = $table . '|' . $row['uid'];
2197 $this->CBnames[] = $n;
2198 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
2199 $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : '';
2200 // If the "duplicateField" value is set then select all elements which are duplicates...
2201 if ($this->duplicateField && isset($row[$this->duplicateField])) {
2202 $checked = '';
2203 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
2204 $checked = 'checked="checked" ';
2205 }
2206 $this->duplicateStack[] = $row[$this->duplicateField];
2207 }
2208 // Adding the checkbox to the panel:
2209 $cells['select'] = $isL10nOverlay
2210 ? $this->spaceIcon
2211 : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
2212 . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
2213 }
2214 // Now, looking for selected elements from the current table:
2215 $elFromTable = $this->clipObj->elFromTable($table);
2216 if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
2217 // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
2218 $cells['pasteAfter'] = $isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)
2219 ? $this->spaceIcon
2220 : '<a class="btn btn-default t3js-modal-trigger"'
2221 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"'
2222 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2223 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2224 . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'after', $elFromTable)) . '"'
2225 . ' data-severity="warning">'
2226 . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . '</a>';
2227 }
2228 // Now, looking for elements in general:
2229 $elFromTable = $this->clipObj->elFromTable('');
2230 if ($table === 'pages' && !$isL10nOverlay && !empty($elFromTable)) {
2231 $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"'
2232 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"'
2233 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2234 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2235 . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'into', $elFromTable)) . '"'
2236 . ' data-severity="warning">'
2237 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
2238 }
2239 /*
2240 * hook: makeClip: Allows to change clip-icons of records in list-module
2241 * usage: This hook method gets passed the current $cells array as third parameter.
2242 * This array contains values for the clipboard icons generated for each record in Web>List.
2243 * Each array entry is accessible by an index-key.
2244 * The order of the icons is depending on the order of those array entries.
2245 */
2246 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
2247 $hookObject = GeneralUtility::makeInstance($className);
2248 if (!$hookObject instanceof RecordListHookInterface) {
2249 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567845);
2250 }
2251 $cells = $hookObject->makeClip($table, $row, $cells, $this);
2252 }
2253 return '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
2254 }
2255
2256 /**
2257 * Creates the HTML for a reference count for the record with the UID $uid
2258 * in the table $tableName.
2259 *
2260 * @param string $tableName
2261 * @param int $uid
2262 * @return string HTML of reference a link, will be empty if there are no
2263 */
2264 protected function createReferenceHtml($tableName, $uid)
2265 {
2266 $referenceCount = GeneralUtility::makeInstance(ConnectionPool::class)
2267 ->getConnectionForTable('sys_refindex')
2268 ->count(
2269 '*',
2270 'sys_refindex',
2271 [
2272 'ref_table' => $tableName,
2273 'ref_uid' => (int)$uid,
2274 'deleted' => 0,
2275 ]
2276 );
2277
2278 return $this->generateReferenceToolTip(
2279 $referenceCount,
2280 GeneralUtility::quoteJSvalue($tableName) . ', ' . GeneralUtility::quoteJSvalue($uid)
2281 );
2282 }
2283
2284 /**
2285 * Creates the localization panel
2286 *
2287 * @param string $table The table
2288 * @param mixed[] $row The record for which to make the localization panel.
2289 * @return string[] Array with key 0/1 with content for column 1 and 2
2290 */
2291 public function makeLocalizationPanel($table, $row)
2292 {
2293 $out = [
2294 0 => '',
2295 1 => ''
2296 ];
2297 // Reset translations
2298 $this->translations = [];
2299
2300 // Language title and icon:
2301 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
2302 // Guard clause so we can quickly return if a record is localized to "all languages"
2303 // It should only be possible to localize a record off default (uid 0)
2304 // Reasoning: The Parent is for ALL languages... why overlay with a localization?
2305 if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) {
2306 return $out;
2307 }
2308 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
2309 if (is_array($translations)) {
2310 $this->translations = $translations['translations'];
2311 // Traverse page translations and add icon for each language that does NOT yet exist:
2312 $lNew = '';
2313 foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
2314 if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
2315 $redirectUrl = (string)$this->uriBuilder->buildUriFromRoute(
2316 'record_edit',
2317 [
2318 'justLocalized' => $table . ':' . $row['uid'] . ':' . $lUid_OnPage,
2319 'returnUrl' => $this->listURL()
2320 ]
2321 );
2322 $href = BackendUtility::getLinkToDataHandlerAction(
2323 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
2324 $redirectUrl
2325 );
2326 $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title');
2327 if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
2328 $lC = $this->iconFactory->getIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL)->render();
2329 } else {
2330 $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
2331 }
2332 $lC = '<a href="' . htmlspecialchars($href) . '" title="'
2333 . htmlspecialchars($language['title']) . '" class="btn btn-default t3js-action-localize">'
2334 . $lC . '</a> ';
2335 $lNew .= $lC;
2336 }
2337 }
2338 if ($lNew) {
2339 $out[1] .= $lNew;
2340 }
2341 } elseif ($row['l18n_parent']) {
2342 $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;' . $out[0];
2343 }
2344 return $out;
2345 }
2346
2347 /**
2348 * Creates a checkbox list for selecting fields to display from a table:
2349 *
2350 * @param string $table Table name
2351 * @param bool $formFields If TRUE, form-fields will be wrapped around the table.
2352 * @return string HTML table with the selector check box (name: displayFields['.$table.'][])
2353 */
2354 public function fieldSelectBox($table, $formFields = true)
2355 {
2356 $lang = $this->getLanguageService();
2357 // Init:
2358 $formElements = ['', ''];
2359 if ($formFields) {
2360 $formElements = ['<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>'];
2361 }
2362 // Load already selected fields, if any:
2363 $setFields = is_array($this->setFields[$table]) ? $this->setFields[$table] : [];
2364 // Request fields from table:
2365 $fields = $this->makeFieldList($table, false, true);
2366 // Add pseudo "control" fields
2367 $fields[] = '_PATH_';
2368 $fields[] = '_REF_';
2369 $fields[] = '_LOCALIZATION_';
2370 $fields[] = '_CONTROL_';
2371 $fields[] = '_CLIPBOARD_';
2372 // Create a checkbox for each field:
2373 $checkboxes = [];
2374 $checkAllChecked = true;
2375 $tsConfig = BackendUtility::getPagesTSconfig($this->id);
2376 $tsConfigOfTable = is_array($tsConfig['TCEFORM.'][$table . '.']) ? $tsConfig['TCEFORM.'][$table . '.'] : null;
2377 foreach ($fields as $fieldName) {
2378 // Hide field if hidden
2379 if ($tsConfigOfTable && is_array($tsConfigOfTable[$fieldName . '.']) && isset($tsConfigOfTable[$fieldName . '.']['disabled']) && (int)$tsConfigOfTable[$fieldName . '.']['disabled'] === 1) {
2380 continue;
2381 }
2382 // Determine, if checkbox should be checked
2383 if (in_array($fieldName, $setFields, true) || $fieldName === $this->fieldArray[0]) {
2384 $checked = ' checked="checked"';
2385 } else {
2386 $checkAllChecked = false;
2387 $checked = '';
2388 }
2389
2390 // Field label
2391 $fieldTSConfig = [];
2392 $fieldLabel = '';
2393 if (isset($tsConfigOfTable[$fieldName . '.'])
2394 && is_array($tsConfigOfTable[$fieldName . '.'])
2395 ) {
2396 $fieldTSConfig = $tsConfigOfTable[$fieldName . '.'];
2397 }
2398 if (!empty($fieldTSConfig['label'])) {
2399 $fieldLabel = $fieldTSConfig['label'];
2400 }
2401 if (!empty($fieldTSConfig['label.'][$lang->lang])) {
2402 $fieldLabel = $fieldTSConfig['label.'][$lang->lang];
2403 }
2404
2405 $fieldLabel = $fieldLabel ?: BackendUtility::getItemLabel($table, $fieldName);
2406
2407 $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
2408 . $table . '][]" value="' . $fieldName . '" ' . $checked
2409 . ($fieldName === $this->fieldArray[0] ? ' disabled="disabled"' : '') . '></td><td class="col-title">'
2410 . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($lang->sL($fieldLabel)) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
2411 }
2412 // Table with the field selector::
2413 $content = $formElements[0] . '
2414 <input type="hidden" name="displayFields[' . $table . '][]" value="">
2415 <div class="table-fit table-scrollable">
2416 <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
2417 <thead>
2418 <tr>
2419 <th class="col-checkbox checkbox" colspan="2">
2420 <label><input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ? ' checked="checked"' : '') . '>
2421 ' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall')) . '</label>
2422 </th>
2423 </tr>
2424 </thead>
2425 <tbody>
2426 ' . implode('', $checkboxes) . '
2427 </tbody>
2428 </table>
2429 </div>
2430 <input type="submit" name="search" class="btn btn-default" value="'
2431 . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.setFields')) . '"/>
2432 ' . $formElements[1];
2433 return '<div class="fieldSelectBox">' . $content . '</div>';
2434 }
2435
2436 /*********************************
2437 *
2438 * Helper functions
2439 *
2440 *********************************/
2441 /**
2442 * Creates a link around $string. The link contains an onclick action
2443 * which submits the script with some clipboard action.
2444 * Currently, this is used for setting elements / delete elements.
2445 *
2446 * @param string $string The HTML content to link (image/text)
2447 * @param string $table Table name
2448 * @param string $cmd Clipboard command (eg. "setCB" or "delete")
2449 * @param string $warning Warning text, if any ("delete" uses this for confirmation
2450 * @param string $title title attribute for the anchor
2451 * @return string <a> tag wrapped link.
2452 */
2453 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '', $title = '')
2454 {
2455 $jsCode = 'document.dblistForm.cmd.value=' . GeneralUtility::quoteJSvalue($cmd)
2456 . ';document.dblistForm.cmd_table.value='
2457 . GeneralUtility::quoteJSvalue($table)
2458 . ';document.dblistForm.submit();';
2459
2460 $attributes = [];
2461 if ($title !== '') {
2462 $attributes['title'] = $title;
2463 }
2464 if ($warning) {
2465 $attributes['class'] = 'btn btn-default t3js-modal-trigger';
2466 $attributes['data-href'] = 'javascript:' . $jsCode;
2467 $attributes['data-severity'] = 'warning';
2468 $attributes['data-title'] = $title;
2469 $attributes['data-content'] = $warning;
2470 } else {
2471 $attributes['class'] = 'btn btn-default';
2472 $attributes['onclick'] = $jsCode . 'return false;';
2473 }
2474
2475 $attributesString = '';
2476 foreach ($attributes as $key => $value) {
2477 $attributesString .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
2478 }
2479 return '<a href="#" ' . $attributesString . '>' . $string . '</a>';
2480 }
2481
2482 /**
2483 * Returns TRUE if a numeric clipboard pad is selected/active
2484 *
2485 * @return bool
2486 */
2487 public function clipNumPane()
2488 {
2489 return in_array('_CLIPBOARD_', $this->fieldArray) && $this->clipObj->current !== 'normal';
2490 }
2491
2492 /**
2493 * Creates a sort-by link on the input string ($code).
2494 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
2495 * Also some fields will not be possible to sort (including if single-table-view is disabled).
2496 *
2497 * @param string $code The string to link (text)
2498 * @param string $field The fieldname represented by the title ($code)
2499 * @param string $table Table name
2500 * @return string Linked $code variable
2501 */
2502 public function addSortLink($code, $field, $table)
2503 {
2504 // Certain circumstances just return string right away (no links):
2505 if ($field === '_CONTROL_' || $field === '_LOCALIZATION_' || $field === '_CLIPBOARD_' || $field === '_REF_' || $this->disableSingleTableView) {
2506 return $code;
2507 }
2508 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
2509 if ($field === '_PATH_') {
2510 $field = 'pid';
2511 }
2512 // Create the sort link:
2513 $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
2514 . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || $this->sortField != $field ? 0 : 1);
2515 $sortArrow = $this->sortField === $field
2516 ? $this->iconFactory->getIcon('status-status-sorting-' . ($this->sortRev ? 'desc' : 'asc'), Icon::SIZE_SMALL)->render()
2517 : '';
2518 // Return linked field:
2519 return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
2520 }
2521
2522 /**
2523 * Returns the path for a certain pid
2524 * The result is cached internally for the session, thus you can call
2525 * this function as much as you like without performance problems.
2526 *
2527 * @param int $pid The page id for which to get the path
2528 * @return mixed[] The path.
2529 */
2530 public function recPath($pid)
2531 {
2532 if (!isset($this->recPath_cache[$pid])) {
2533 $this->recPath_cache[$pid] = BackendUtility::getRecordPath($pid, $this->perms_clause, 20);
2534 }
2535 return $this->recPath_cache[$pid];
2536 }
2537
2538 /**
2539 * Returns TRUE if a link for creating new records should be displayed for $table
2540 *
2541 * @param string $table Table name
2542 * @return bool Returns TRUE if a link for creating new records should be displayed for $table
2543 */
2544 public function showNewRecLink($table)
2545 {
2546 // No deny/allow tables are set:
2547 if (empty($this->allowedNewTables) && empty($this->deniedNewTables)) {
2548 return true;
2549 }
2550 return !in_array($table, $this->deniedNewTables)
2551 && (empty($this->allowedNewTables) || in_array($table, $this->allowedNewTables));
2552 }
2553
2554 /**
2555 * Creates the "&returnUrl" parameter for links - this is used when the script links
2556 * to other scripts and passes its own URL with the link so other scripts can return to the listing again.
2557 * Uses REQUEST_URI as value.
2558 *
2559 * @return string
2560 */
2561 public function makeReturnUrl()
2562 {
2563 return '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
2564 }
2565
2566 /************************************
2567 *
2568 * CSV related functions
2569 *
2570 ************************************/
2571 /**
2572 * Initializes internal csvLines array with the header of field names
2573 */
2574 protected function initCSV()
2575 {
2576 $this->addHeaderRowToCSV();
2577 }
2578
2579 /**
2580 * Add header line with field names as CSV line
2581 */
2582 protected function addHeaderRowToCSV()
2583 {
2584 $fieldArray = array_combine($this->fieldArray, $this->fieldArray);
2585 $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvHeader'] ?? [];
2586 if (!empty($hooks)) {
2587 $hookParameters = [
2588 'fields' => &$fieldArray
2589 ];
2590 foreach ($hooks as $hookFunction) {
2591 GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
2592 }
2593 }
2594 // Add header row, control fields will be reduced inside addToCSV()
2595 $this->addToCSV($fieldArray);
2596 }
2597
2598 /**
2599 * Adds selected columns of one table row as CSV line.
2600 *
2601 * @param mixed[] $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
2602 */
2603 protected function addToCSV(array $row = [])
2604 {
2605 $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
2606 // Get an field array without control fields but in the expected order
2607 $fieldArray = array_intersect_key(array_flip($this->fieldArray), $rowReducedByControlFields);
2608 // Overwrite fieldArray to keep the order with an array of needed fields
2609 $rowReducedToSelectedColumns = array_replace($fieldArray, array_intersect_key($rowReducedByControlFields, $fieldArray));
2610 $this->setCsvRow($rowReducedToSelectedColumns);
2611 }
2612
2613 /**
2614 * Remove control fields from row for CSV export
2615 *
2616 * @param mixed[] $row fieldNames => fieldValues
2617 * @return mixed[] Input array reduces by control fields
2618 */
2619 protected static function removeControlFieldsFromFieldRow(array $row = [])
2620 {
2621 // Possible control fields in a list row
2622 $controlFields = [
2623 '_PATH_',
2624 '_REF_',
2625 '_CONTROL_',
2626 '_CLIPBOARD_',
2627 '_LOCALIZATION_',
2628 '_LOCALIZATION_b'
2629 ];
2630 return array_diff_key($row, array_flip($controlFields));
2631 }
2632
2633 /**
2634 * Adds input row of values to the internal csvLines array as a CSV formatted line
2635 *
2636 * @param mixed[] $csvRow Array with values to be listed.
2637 */
2638 public function setCsvRow($csvRow)
2639 {
2640 $csvDelimiter = $this->modTSconfig['properties']['csvDelimiter'] ?? ',';
2641 $csvQuote = $this->modTSconfig['properties']['csvQuote'] ?? '"';
2642
2643 $this->csvLines[] = CsvUtility::csvValues($csvRow, $csvDelimiter, $csvQuote);
2644 }
2645
2646 /**
2647 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
2648 * This function exits!
2649 *
2650 * @param string $prefix Filename prefix:
2651 */
2652 public function outputCSV($prefix)
2653 {
2654 // Setting filename:
2655 $filename = $prefix . '_' . date('dmy-Hi') . '.csv';
2656 // Creating output header:
2657 header('Content-Type: application/octet-stream');
2658 header('Content-Disposition: attachment; filename=' . $filename);
2659 // Cache-Control header is needed here to solve an issue with browser IE and
2660 // versions lower than 9. See for more information: http://support.microsoft.com/kb/323308
2661 header("Cache-Control: ''");
2662 // Printing the content of the CSV lines:
2663 echo implode(CRLF, $this->csvLines);
2664 // Exits:
2665 die;
2666 }
2667
2668 /**
2669 * add action into correct section
2670 *
2671 * @param array $cells
2672 * @param string $action
2673 * @param string $actionKey
2674 */
2675 public function addActionToCellGroup(&$cells, $action, $actionKey)
2676 {
2677 $cellsMap = [
2678 'primary' => [
2679 'view', 'edit', 'hide', 'delete', 'stat'
2680 ],
2681 'secondary' => [
2682 'viewBig', 'history', 'perms', 'new', 'move', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'version'
2683 ]
2684 ];
2685 $classification = in_array($actionKey, $cellsMap['primary']) ? 'primary' : 'secondary';
2686 $cells[$classification][$actionKey] = $action;
2687 unset($cells[$actionKey]);
2688 }
2689
2690 /**
2691 * Check if the record represents the current backend user
2692 *
2693 * @param string $table
2694 * @param array $row
2695 * @return bool
2696 */
2697 protected function isRecordCurrentBackendUser($table, $row)
2698 {
2699 return $table === 'be_users' && (int)$row['uid'] === $this->getBackendUserAuthentication()->user['uid'];
2700 }
2701
2702 /**
2703 * @param bool $isEditable
2704 */
2705 public function setIsEditable(bool $isEditable): void
2706 {
2707 $this->editable = $isEditable;
2708 }
2709
2710 /**
2711 * Check if the table is readonly or editable
2712 * @param string $