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