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