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