[BUGFIX] Calculate count of records instead of using a query
[Packages/TYPO3.CMS.git] / typo3 / sysext / recordlist / Classes / RecordList / DatabaseRecordList.php
1 <?php
2 namespace TYPO3\CMS\Recordlist\RecordList;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
18 use TYPO3\CMS\Backend\Module\BaseScriptClass;
19 use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface;
20 use TYPO3\CMS\Backend\Routing\UriBuilder;
21 use TYPO3\CMS\Backend\Template\Components\ButtonBar;
22 use TYPO3\CMS\Backend\Template\DocumentTemplate;
23 use TYPO3\CMS\Backend\Template\ModuleTemplate;
24 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
25 use TYPO3\CMS\Backend\Utility\BackendUtility;
26 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
27 use TYPO3\CMS\Core\Cache\CacheManager;
28 use TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait;
29 use TYPO3\CMS\Core\Database\Connection;
30 use TYPO3\CMS\Core\Database\ConnectionPool;
31 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
32 use TYPO3\CMS\Core\Database\Query\QueryHelper;
33 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
34 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
35 use TYPO3\CMS\Core\Database\ReferenceIndex;
36 use TYPO3\CMS\Core\Imaging\Icon;
37 use TYPO3\CMS\Core\Imaging\IconFactory;
38 use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
39 use TYPO3\CMS\Core\LinkHandling\LinkService;
40 use TYPO3\CMS\Core\Localization\LanguageService;
41 use TYPO3\CMS\Core\Log\LogManager;
42 use TYPO3\CMS\Core\Messaging\FlashMessage;
43 use TYPO3\CMS\Core\Messaging\FlashMessageService;
44 use TYPO3\CMS\Core\Service\DependencyOrderingService;
45 use TYPO3\CMS\Core\Type\Bitmask\Permission;
46 use TYPO3\CMS\Core\Utility\CsvUtility;
47 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
48 use TYPO3\CMS\Core\Utility\GeneralUtility;
49 use TYPO3\CMS\Core\Utility\HttpUtility;
50 use TYPO3\CMS\Core\Utility\MathUtility;
51 use TYPO3\CMS\Frontend\Page\PageRepository;
52
53 /**
54 * Class for rendering of Web>List module
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 v10.',
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 v9, will be removed in v10
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 $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
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 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1080 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
1081 $this->firstElementNumber += 2;
1082 $this->iLimit -= 2;
1083 } else {
1084 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1085 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
1086 }
1087
1088 // Finding the total amount of records on the page
1089 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1090 $this->setTotalItems($table, $id, $additionalConstraints);
1091
1092 // Init:
1093 $queryResult = $queryBuilder->execute();
1094 $dbCount = 0;
1095 $out = '';
1096 $tableHeader = '';
1097 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
1098 // If the count query returned any number of records, we perform the real query,
1099 // selecting records.
1100 if ($this->totalItems) {
1101 // Fetch records only if not in single table mode
1102 if ($listOnlyInSingleTableMode) {
1103 $dbCount = $this->totalItems;
1104 } else {
1105 // Set the showLimit to the number of records when outputting as CSV
1106 if ($this->csvOutput) {
1107 $this->showLimit = $this->totalItems;
1108 $this->iLimit = $this->totalItems;
1109 $dbCount = $this->totalItems;
1110 } else {
1111 if ($this->firstElementNumber + $this->showLimit <= $this->totalItems) {
1112 $dbCount = $this->showLimit + 2;
1113 } else {
1114 $dbCount = $this->totalItems - $this->firstElementNumber + 2;
1115 }
1116 }
1117 }
1118 }
1119 // If any records was selected, render the list:
1120 if ($dbCount) {
1121 // Use a custom table title for translated pages
1122 if ($table == 'pages' && $this->showOnlyTranslatedRecords) {
1123 $tableTitle = htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:pageTranslation'));
1124 } else {
1125 $tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
1126 if ($tableTitle === '') {
1127 $tableTitle = $table;
1128 }
1129 }
1130 // Header line is drawn
1131 $theData = [];
1132 if ($this->disableSingleTableView) {
1133 $theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
1134 . '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
1135 } else {
1136 $icon = $this->table
1137 ? '<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory->getIcon('actions-view-table-collapse', Icon::SIZE_SMALL)->render() . '</span>'
1138 : '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory->getIcon('actions-view-table-expand', Icon::SIZE_SMALL)->render() . '</span>';
1139 $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
1140 }
1141 if ($listOnlyInSingleTableMode) {
1142 $tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
1143 } else {
1144 // Render collapse button if in multi table mode
1145 $collapseIcon = '';
1146 if (!$this->table) {
1147 $href = htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1'));
1148 $title = $tableCollapsed
1149 ? htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
1150 : htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
1151 $icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon(($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'), Icon::SIZE_SMALL)->render() . '</span>';
1152 $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>';
1153 }
1154 $tableHeader .= $theData[$titleCol] . $collapseIcon;
1155 }
1156 // Render table rows only if in multi table view or if in single table view
1157 $rowOutput = '';
1158 if (!$listOnlyInSingleTableMode || $this->table) {
1159 // Fixing an order table for sortby tables
1160 $this->currentTable = [];
1161 $currentIdList = [];
1162 $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
1163 $prevUid = 0;
1164 $prevPrevUid = 0;
1165 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
1166 if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
1167 $row = $queryResult->fetch();
1168 $prevPrevUid = -((int)$row['uid']);
1169 $row = $queryResult->fetch();
1170 $prevUid = $row['uid'];
1171 }
1172 $accRows = [];
1173 // Accumulate rows here
1174 while ($row = $queryResult->fetch()) {
1175 if (!$this->isRowListingConditionFulfilled($table, $row)) {
1176 continue;
1177 }
1178 // In offline workspace, look for alternative record:
1179 BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
1180 if (is_array($row)) {
1181 $accRows[] = $row;
1182 $currentIdList[] = $row['uid'];
1183 if ($doSort) {
1184 if ($prevUid) {
1185 $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
1186 $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
1187 $this->currentTable['prevUid'][$row['uid']] = $prevUid;
1188 }
1189 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
1190 $prevUid = $row['uid'];
1191 }
1192 }
1193 }
1194 $this->totalRowCount = count($accRows);
1195 // CSV initiated
1196 if ($this->csvOutput) {
1197 $this->initCSV();
1198 }
1199 // Render items:
1200 $this->CBnames = [];
1201 $this->duplicateStack = [];
1202 $this->eCounter = $this->firstElementNumber;
1203 $cc = 0;
1204 foreach ($accRows as $row) {
1205 // Render item row if counter < limit
1206 if ($cc < $this->iLimit) {
1207 $cc++;
1208 $this->translations = false;
1209 $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
1210 // If no search happened it means that the selected
1211 // records are either default or All language and here we will not select translations
1212 // which point to the main record:
1213 if ($l10nEnabled && $this->searchString === '') {
1214 // For each available translation, render the record:
1215 if (is_array($this->translations)) {
1216 foreach ($this->translations as $lRow) {
1217 // $lRow isn't always what we want - if record was moved we've to work with the
1218 // placeholder records otherwise the list is messed up a bit
1219 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
1220 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
1221 ->getQueryBuilderForTable($table);
1222 $queryBuilder->getRestrictions()
1223 ->removeAll()
1224 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
1225 $predicates = [
1226 $queryBuilder->expr()->eq(
1227 't3ver_move_id',
1228 $queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
1229 ),
1230 $queryBuilder->expr()->eq(
1231 'pid',
1232 $queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO::PARAM_INT)
1233 ),
1234 $queryBuilder->expr()->eq(
1235 't3ver_wsid',
1236 $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
1237 ),
1238 ];
1239
1240 $tmpRow = $queryBuilder
1241 ->select(...$selFieldList)
1242 ->from($table)
1243 ->andWhere(...$predicates)
1244 ->execute()
1245 ->fetch();
1246
1247 $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
1248 }
1249 // In offline workspace, look for alternative record:
1250 BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
1251 if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
1252 $currentIdList[] = $lRow['uid'];
1253 $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
1254 }
1255 }
1256 }
1257 }
1258 }
1259 // Counter of total rows incremented:
1260 $this->eCounter++;
1261 }
1262 // Record navigation is added to the beginning and end of the table if in single
1263 // table mode
1264 if ($this->table) {
1265 $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
1266 } else {
1267 // Show that there are more records than shown
1268 if ($this->totalItems > $this->itemsLimitPerTable) {
1269 $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
1270 $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
1271 $colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
1272 $rowOutput .= '<tr><td colspan="' . $colspan . '">
1273 <a href="' . htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '" class="btn btn-default">'
1274 . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
1275 </td></tr>';
1276 }
1277 }
1278 // The header row for the table is now created:
1279 $out .= $this->renderListHeader($table, $currentIdList);
1280 }
1281
1282 $collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
1283 $dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
1284
1285 // The list of records is added after the header:
1286 $out .= $rowOutput;
1287 // ... and it is all wrapped in a table:
1288 $out = '
1289
1290
1291
1292 <!--
1293 DB listing of elements: "' . htmlspecialchars($table) . '"
1294 -->
1295 <div class="panel panel-space panel-default recordlist">
1296 <div class="panel-heading">
1297 ' . $tableHeader . '
1298 </div>
1299 <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
1300 <div class="table-fit">
1301 <table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
1302 ' . $out . '
1303 </table>
1304 </div>
1305 </div>
1306 </div>
1307 ';
1308 // Output csv if...
1309 // This ends the page with exit.
1310 if ($this->csvOutput) {
1311 $this->outputCSV($table);
1312 }
1313 }
1314 // Return content:
1315 return $out;
1316 }
1317
1318 /**
1319 * Get viewOnClick link for pages or tt_content records
1320 *
1321 * @param string $table
1322 * @param array $row
1323 *
1324 * @return string
1325 */
1326 protected function getOnClickForRow(string $table, array $row): string
1327 {
1328 if ($table === 'tt_content') {
1329 // Link to a content element, possibly translated and with anchor
1330 $additionalParams = '';
1331 $language = (int)$row[$GLOBALS['TCA']['tt_content']['ctrl']['languageField']];
1332 if ($language > 0) {
1333 $additionalParams = '&L=' . $language;
1334 }
1335 $onClick = BackendUtility::viewOnClick(
1336 $this->id,
1337 '',
1338 null,
1339 '#c' . $row['uid'],
1340 '',
1341 $additionalParams
1342 );
1343 } elseif ($table === 'pages' && $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] > 0) {
1344 // Link to a page translation needs uid of default language page as id
1345 $onClick = BackendUtility::viewOnClick(
1346 $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']],
1347 '',
1348 null,
1349 '',
1350 '',
1351 '&L=' . (int)$row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]
1352 );
1353 } else {
1354 // Link to a page in the default language
1355 $onClick = BackendUtility::viewOnClick($row['uid']);
1356 }
1357 return $onClick;
1358 }
1359
1360 /**
1361 * Check if all row listing conditions are fulfilled.
1362 *
1363 * This function serves as a dummy method to be overridden in extending classes.
1364 *
1365 * @param string $table Table name
1366 * @param string[] $row Record
1367 * @return bool True, if all conditions are fulfilled.
1368 */
1369 protected function isRowListingConditionFulfilled($table, $row)
1370 {
1371 return true;
1372 }
1373
1374 /**
1375 * Rendering a single row for the list
1376 *
1377 * @param string $table Table name
1378 * @param mixed[] $row Current record
1379 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
1380 * @param string $titleCol Table field (column) where header value is found
1381 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
1382 * @param int $indent Indent from left.
1383 * @return string Table row for the element
1384 * @access private
1385 * @see getTable()
1386 */
1387 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
1388 {
1389 if (!is_array($row)) {
1390 return '';
1391 }
1392 $rowOutput = '';
1393 $id_orig = null;
1394 // If in search mode, make sure the preview will show the correct page
1395 if ((string)$this->searchString !== '') {
1396 $id_orig = $this->id;
1397 $this->id = $row['pid'];
1398 }
1399
1400 $tagAttributes = [
1401 'class' => ['t3js-entity'],
1402 'data-table' => $table,
1403 'title' => 'id=' . $row['uid'],
1404 ];
1405
1406 // Add active class to record of current link
1407 if (
1408 isset($this->currentLink['tableNames'])
1409 && (int)$this->currentLink['uid'] === (int)$row['uid']
1410 && GeneralUtility::inList($this->currentLink['tableNames'], $table)
1411 ) {
1412 $tagAttributes['class'][] = 'active';
1413 }
1414 // Add special classes for first and last row
1415 if ($cc == 1 && $indent == 0) {
1416 $tagAttributes['class'][] = 'firstcol';
1417 }
1418 if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
1419 $tagAttributes['class'][] = 'lastcol';
1420 }
1421 // Overriding with versions background color if any:
1422 if (!empty($row['_CSSCLASS'])) {
1423 $tagAttributes['class'] = [$row['_CSSCLASS']];
1424 }
1425 // Incr. counter.
1426 $this->counter++;
1427 // The icon with link
1428 $toolTip = BackendUtility::getRecordToolTip($row, $table);
1429 $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
1430 $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
1431 . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
1432 . '</span>';
1433 $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
1434 // Preparing and getting the data-array
1435 $theData = [];
1436 $localizationMarkerClass = '';
1437 foreach ($this->fieldArray as $fCol) {
1438 if ($fCol == $titleCol) {
1439 $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
1440 $warning = '';
1441 // If the record is edit-locked by another user, we will show a little warning sign:
1442 $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
1443 if ($lockInfo) {
1444 $warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
1445 . $this->iconFactory->getIcon('warning-in-use', Icon::SIZE_SMALL)->render() . '</span>';
1446 }
1447 $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
1448 // Render thumbnails, if:
1449 // - a thumbnail column exists
1450 // - there is content in it
1451 // - the thumbnail column is visible for the current type
1452 $type = 0;
1453 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
1454 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
1455 $type = $row[$typeColumn];
1456 }
1457 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
1458 // if 0 doesn't exist)
1459 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
1460 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
1461 }
1462 $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
1463
1464 if ($this->thumbs &&
1465 trim($row[$thumbsCol]) &&
1466 preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
1467 ) {
1468 $thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
1469 $theData[$fCol] .= $thumbCode;
1470 $theData['__label'] .= $thumbCode;
1471 }
1472 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1473 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
1474 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
1475 ) {
1476 // It's a translated record with a language parent
1477 $localizationMarkerClass = ' localization';
1478 }
1479 } elseif ($fCol === 'pid') {
1480 $theData[$fCol] = $row[$fCol];
1481 } elseif ($fCol === '_PATH_') {
1482 $theData[$fCol] = $this->recPath($row['pid']);
1483 } elseif ($fCol === '_REF_') {
1484 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
1485 } elseif ($fCol === '_CONTROL_') {
1486 $theData[$fCol] = $this->makeControl($table, $row);
1487 } elseif ($fCol === '_CLIPBOARD_') {
1488 $theData[$fCol] = $this->makeClip($table, $row);
1489 } elseif ($fCol === '_LOCALIZATION_') {
1490 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
1491 $theData[$fCol] = $lC1;
1492 $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
1493 } elseif ($fCol === '_LOCALIZATION_b') {
1494 // deliberately empty
1495 } else {
1496 $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
1497 $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
1498 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
1499 if ($this->csvOutput) {
1500 $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
1501 }
1502 }
1503 }
1504 // Reset the ID if it was overwritten
1505 if ((string)$this->searchString !== '') {
1506 $this->id = $id_orig;
1507 }
1508 // Add row to CSV list:
1509 if ($this->csvOutput) {
1510 $this->addToCSV($row);
1511 }
1512 // Add classes to table cells
1513 $this->addElement_tdCssClass[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
1514 $this->addElement_tdCssClass['__label'] = $this->addElement_tdCssClass[$titleCol];
1515 $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
1516 if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
1517 $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
1518 }
1519 $this->addElement_tdCssClass['_PATH_'] = 'col-path';
1520 $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
1521 $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
1522 // Create element in table cells:
1523 $theData['uid'] = $row['uid'];
1524 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1525 && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
1526 ) {
1527 $theData['_l10nparent_'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
1528 }
1529
1530 $tagAttributes = array_map(
1531 function ($attributeValue) {
1532 if (is_array($attributeValue)) {
1533 return implode(' ', $attributeValue);
1534 }
1535 return $attributeValue;
1536 },
1537 $tagAttributes
1538 );
1539
1540 $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
1541 // Finally, return table row element:
1542 return $rowOutput;
1543 }
1544
1545 /**
1546 * Gets the number of records referencing the record with the UID $uid in
1547 * the table $tableName.
1548 *
1549 * @param string $tableName
1550 * @param int $uid
1551 * @return int The number of references to record $uid in table
1552 */
1553 protected function getReferenceCount($tableName, $uid)
1554 {
1555 if (!isset($this->referenceCount[$tableName][$uid])) {
1556 $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
1557 $numberOfReferences = $referenceIndex->getNumberOfReferencedRecords($tableName, $uid);
1558 $this->referenceCount[$tableName][$uid] = $numberOfReferences;
1559 }
1560 return $this->referenceCount[$tableName][$uid];
1561 }
1562
1563 /**
1564 * Rendering the header row for a table
1565 *
1566 * @param string $table Table name
1567 * @param int[] $currentIdList Array of the currently displayed uids of the table
1568 * @throws \UnexpectedValueException
1569 * @return string Header table row
1570 * @access private
1571 * @see getTable()
1572 */
1573 public function renderListHeader($table, $currentIdList)
1574 {
1575 $lang = $this->getLanguageService();
1576 // Init:
1577 $theData = [];
1578 $icon = '';
1579 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1580 $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
1581 // Traverse the fields:
1582 foreach ($this->fieldArray as $fCol) {
1583 // Calculate users permissions to edit records in the table:
1584 $permsEdit = $this->calcPerms & ($table === 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table);
1585 switch ((string)$fCol) {
1586 case '_PATH_':
1587 // Path
1588 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>';
1589 break;
1590 case '_REF_':
1591 // References
1592 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_')) . ']</i>';
1593 break;
1594 case '_LOCALIZATION_':
1595 // Path
1596 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>';
1597 break;
1598 case '_LOCALIZATION_b':
1599 // Path
1600 $theData[$fCol] = htmlspecialchars($lang->getLL('Localize'));
1601 break;
1602 case '_CLIPBOARD_':
1603 if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
1604 break;
1605 }
1606 // Clipboard:
1607 $cells = [];
1608 // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
1609 // then display the "paste into" icon:
1610 $elFromTable = $this->clipObj->elFromTable($table);
1611 if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
1612 $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id));
1613 $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
1614 $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"'
1615 . ' href="' . $href . '"'
1616 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1617 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1618 . ' data-content="' . htmlspecialchars($confirmMessage) . '"'
1619 . ' data-severity="warning">'
1620 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
1621 . '</a>';
1622 }
1623 // If the numeric clipboard pads are enabled, display the control icons for that:
1624 if ($this->clipObj->current !== 'normal') {
1625 // The "select" link:
1626 $spriteIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render();
1627 $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked'));
1628 // The "edit marked" link:
1629 $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit')
1630 . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit'
1631 . '&returnUrl={T3_THIS_LOCATION}';
1632 $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1633 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1634 . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
1635 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1636 // The "Delete marked" link:
1637 $cells['delete'] = $this->linkClipboardHeaderIcon(
1638 $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(),
1639 $table,
1640 'delete',
1641 sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
1642 $lang->getLL('clip_deleteMarked')
1643 );
1644 // The "Select all" link:
1645 $onClick = htmlspecialchars('checkOffCB(' . GeneralUtility::quoteJSvalue(implode(',', $this->CBnames)) . ', this); return false;');
1646 $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
1647 . htmlspecialchars($lang->getLL('clip_markRecords')) . '">'
1648 . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL)->render() . '</a>';
1649 } else {
1650 $cells['empty'] = '';
1651 }
1652 /*
1653 * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
1654 * usage: Above each listed table in Web>List a header row is shown.
1655 * This hook allows to modify the icons responsible for the clipboard functions
1656 * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
1657 * or other "Action" functions which perform operations on the listed records.
1658 */
1659 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
1660 $hookObject = GeneralUtility::makeInstance($className);
1661 if (!$hookObject instanceof RecordListHookInterface) {
1662 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567850);
1663 }
1664 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
1665 }
1666 $theData[$fCol] = '';
1667 if (isset($cells['edit']) && isset($cells['delete'])) {
1668 $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>';
1669 unset($cells['edit'], $cells['delete']);
1670 }
1671 $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1672 break;
1673 case '_CONTROL_':
1674 // Control panel:
1675 if ($this->isEditable($table)) {
1676 // If new records can be created on this page, add links:
1677 $permsAdditional = ($table === 'pages' ? 8 : 16);
1678 if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) {
1679 $spriteIcon = $table === 'pages'
1680 ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)
1681 : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL);
1682 if ($table === 'tt_content') {
1683 // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
1684 $newContentElementWizard = BackendUtility::getPagesTSconfig($this->pageinfo['uid'])['mod.']['newContentElementWizard.']['override']
1685 ?? 'new_content_element_wizard';
1686 $url = (string)$uriBuilder->buildUriFromRoute(
1687 $newContentElementWizard,
1688 [
1689 'id' => $this->id,
1690 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
1691 ]
1692 );
1693 $icon = '<a href="#" data-url="' . htmlspecialchars($url) . '" '
1694 . 'data-title="' . htmlspecialchars($lang->getLL('new')) . '"'
1695 . 'class="btn btn-default t3js-toggle-new-content-element-wizard">'
1696 . $spriteIcon->render()
1697 . '</a>';
1698 } elseif ($table === 'pages') {
1699 $parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
1700 $href = (string)$uriBuilder->buildUriFromRoute('db_new', $parameters);
1701 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
1702 . $spriteIcon->render() . '</a>';
1703 } else {
1704 $params = '&edit[' . $table . '][' . $this->id . ']=new';
1705 if ($table === 'pages') {
1706 $params .= '&overrideVals[pages][doktype]=' . (int)$this->pageRow['doktype'];
1707 }
1708 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1709 . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1710 }
1711 }
1712 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1713 if ($permsEdit && $this->table && is_array($currentIdList)) {
1714 $entityIdentifiers = 'entityIdentifiers';
1715 if ($this->clipNumPane()) {
1716 $entityIdentifiers .= ':editList';
1717 }
1718 $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit')
1719 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1720 . '&columnsOnly=' . implode(',', $this->fieldArray)
1721 . '&returnUrl={T3_THIS_LOCATION}';
1722 $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1723 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1724 . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
1725 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1726 $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1727 }
1728 // Add an empty entry, so column count fits again after moving this into $icon
1729 $theData[$fCol] = '&nbsp;';
1730 }
1731 break;
1732 default:
1733 // Regular fields header:
1734 $theData[$fCol] = '';
1735
1736 // Check if $fCol is really a field and get the label and remove the colons
1737 // at the end
1738 $sortLabel = BackendUtility::getItemLabel($table, $fCol);
1739 if ($sortLabel !== null) {
1740 $sortLabel = htmlspecialchars($lang->sL($sortLabel));
1741 $sortLabel = rtrim(trim($sortLabel), ':');
1742 } else {
1743 // No TCA field, only output the $fCol variable with square brackets []
1744 $sortLabel = htmlspecialchars($fCol);
1745 $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1746 }
1747
1748 if ($this->table && is_array($currentIdList)) {
1749 // If the numeric clipboard pads are selected, show duplicate sorting link:
1750 if ($this->clipNumPane()) {
1751 $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', '-1') . '&duplicateField=' . $fCol)
1752 . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">'
1753 . $this->iconFactory->getIcon('actions-document-duplicates-select', Icon::SIZE_SMALL)->render() . '</a>';
1754 }
1755 // If the table can be edited, add link for editing THIS field for all
1756 // listed records:
1757 if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1758 $entityIdentifiers = 'entityIdentifiers';
1759 if ($this->clipNumPane()) {
1760 $entityIdentifiers .= ':editList';
1761 }
1762 $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit')
1763 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1764 . '&columnsOnly=' . $fCol
1765 . '&returnUrl={T3_THIS_LOCATION}';
1766 $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1767 $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1768 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1769 . ' title="' . htmlspecialchars($iTitle) . '">'
1770 . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1771 }
1772 if (strlen($theData[$fCol]) > 0) {
1773 $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1774 }
1775 }
1776 $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1777 }
1778 }
1779 /*
1780 * hook: renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
1781 * usage: Above each listed table in Web>List a header row is shown.
1782 * Containing the labels of all shown fields and additional icons to create new records for this
1783 * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
1784 */
1785 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
1786 $hookObject = GeneralUtility::makeInstance($className);
1787 if (!$hookObject instanceof RecordListHookInterface) {
1788 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567855);
1789 }
1790 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1791 }
1792
1793 // Create and return header table row:
1794 return '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1795 }
1796
1797 /**
1798 * Get pointer for first element on the page
1799 *
1800 * @param int $page Page number starting with 1
1801 * @return int Pointer to first element on the page (starting with 0)
1802 */
1803 protected function getPointerForPage($page)
1804 {
1805 return ($page - 1) * $this->iLimit;
1806 }
1807
1808 /**
1809 * Creates a page browser for tables with many records
1810 *
1811 * @param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1812 * @return string Navigation HTML
1813 */
1814 protected function renderListNavigation($renderPart = 'top')
1815 {
1816 $totalPages = ceil($this->totalItems / $this->iLimit);
1817 // Show page selector if not all records fit into one page
1818 if ($totalPages <= 1) {
1819 return '';
1820 }
1821 $content = '';
1822 $listURL = $this->listURL('', $this->table);
1823 // 1 = first page
1824 // 0 = first element
1825 $currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
1826 // Compile first, previous, next, last and refresh buttons
1827 if ($currentPage > 1) {
1828 $labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:first'));
1829 $labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:previous'));
1830 $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1831 . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</a></li>';
1832 $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1833 . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</a></li>';
1834 } else {
1835 $first = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</span></li>';
1836 $previous = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</span></li>';
1837 }
1838 if ($currentPage < $totalPages) {
1839 $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:next'));
1840 $labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:last'));
1841 $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '" title="' . $labelNext . '">'
1842 . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</a></li>';
1843 $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1844 . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</a></li>';
1845 } else {
1846 $next = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</span></li>';
1847 $last = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</span></li>';
1848 }
1849 $reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
1850 . '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility::quoteJSvalue('jumpPage-' . $renderPart)
1851 . ').value); document.dblistForm.submit(); return true;" title="'
1852 . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
1853 . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a></li>';
1854 if ($renderPart === 'top') {
1855 // Add js to traverse a page select input to a pointer value
1856 $content = '
1857 <script type="text/javascript">
1858 /*<![CDATA[*/
1859 function calculatePointer(page) {
1860 if (page > ' . $totalPages . ') {
1861 page = ' . $totalPages . ';
1862 }
1863 if (page < 1) {
1864 page = 1;
1865 }
1866 return (page - 1) * ' . $this->iLimit . ';
1867 }
1868 /*]]>*/
1869 </script>
1870 ';
1871 }
1872 $pageNumberInput = '
1873 <input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1874 . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . htmlspecialchars(GeneralUtility::quoteJSvalue($listURL . '&pointer='))
1875 . '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1876 ';
1877 $pageIndicatorText = sprintf(
1878 $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
1879 $pageNumberInput,
1880 $totalPages
1881 );
1882 $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1883 if ($this->totalItems > $this->firstElementNumber + $this->iLimit) {
1884 $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1885 } else {
1886 $lastElementNumber = $this->totalItems;
1887 }
1888 $rangeIndicator = '<li><span>' . sprintf(
1889 $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'),
1890 $this->firstElementNumber + 1,
1891 $lastElementNumber
1892 ) . '</span></li>';
1893
1894 $titleColumn = $this->fieldArray[0];
1895 $data = [
1896 $titleColumn => $content . '
1897 <nav class="pagination-wrap">
1898 <ul class="pagination pagination-block">
1899 ' . $first . '
1900 ' . $previous . '
1901 ' . $rangeIndicator . '
1902 ' . $pageIndicator . '
1903 ' . $next . '
1904 ' . $last . '
1905 ' . $reload . '
1906 </ul>
1907 </nav>
1908 '
1909 ];
1910 return $this->addElement(1, '', $data);
1911 }
1912
1913 /*********************************
1914 *
1915 * Rendering of various elements
1916 *
1917 *********************************/
1918
1919 /**
1920 * Creates the control panel for a single record in the listing.
1921 *
1922 * @param string $table The table
1923 * @param mixed[] $row The record for which to make the control panel.
1924 * @throws \UnexpectedValueException
1925 * @return string HTML table with the control panel (unless disabled)
1926 */
1927 public function makeControl($table, $row)
1928 {
1929 $backendUser = $this->getBackendUserAuthentication();
1930 $userTsConfig = $backendUser->getTSConfig();
1931 $module = $this->getModule();
1932 $rowUid = $row['uid'];
1933 if (ExtensionManagementUtility::isLoaded('workspaces') && isset($row['_ORIG_uid'])) {
1934 $rowUid = $row['_ORIG_uid'];
1935 }
1936 $cells = [
1937 'primary' => [],
1938 'secondary' => []
1939 ];
1940 // Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them
1941 // For page translations these icons should never be shown
1942 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1943 // If the listed table is 'pages' we have to request the permission settings for each page:
1944 $localCalcPerms = 0;
1945 if ($table === 'pages') {
1946 $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
1947 }
1948 $permsEdit = $table === 'pages'
1949 && $backendUser->checkLanguageAccess(0)
1950 && $localCalcPerms & Permission::PAGE_EDIT
1951 || $table !== 'pages'
1952 && $this->calcPerms & Permission::CONTENT_EDIT
1953 && $backendUser->recordEditAccessInternals($table, $row);
1954 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1955 // "Show" link (only pages and tt_content elements)
1956 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1957 $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
1958
1959 if ($table === 'pages' || $table === 'tt_content') {
1960 $onClick = $this->getOnClickForRow($table, $row);
1961 $viewAction = '<a class="btn btn-default" href="#" onclick="'
1962 . htmlspecialchars(
1963 $onClick
1964 ) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">';
1965 if ($table === 'pages') {
1966 $viewAction .= $this->iconFactory->getIcon('actions-view-page', Icon::SIZE_SMALL)->render();
1967 } else {
1968 $viewAction .= $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render();
1969 }
1970 $viewAction .= '</a>';
1971 $this->addActionToCellGroup($cells, $viewAction, 'view');
1972 }
1973 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1974 if ($permsEdit) {
1975 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1976 $iconIdentifier = 'actions-open';
1977 if ($table === 'pages') {
1978 $iconIdentifier = 'actions-page-open';
1979 }
1980 $overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null;
1981 $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1982 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL, $overlayIdentifier)->render() . '</a>';
1983 } else {
1984 $editAction = $this->spaceIcon;
1985 }
1986 $this->addActionToCellGroup($cells, $editAction, 'edit');
1987 // "Info": (All records)
1988 $onClick = 'top.TYPO3.InfoWindow.showItem(' . GeneralUtility::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
1989 $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
1990 . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
1991 $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1992 // "Move" wizard link for pages/tt_content elements:
1993 if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) {
1994 if ($isL10nOverlay) {
1995 $moveAction = $this->spaceIcon;
1996 } else {
1997 $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
1998 $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page')));
1999 $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-move', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL));
2000 $moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
2001 }
2002 $this->addActionToCellGroup($cells, $moveAction, 'move');
2003 }
2004 // If the table is NOT a read-only table, then show these links:
2005 if ($this->isEditable($table)) {
2006 // "Revert" link (history/undo)
2007 if ((bool)\trim($userTsConfig['options.']['showHistory.'][$table] ?? $userTsConfig['options.']['showHistory'] ?? '1')) {
2008 $moduleUrl = (string)$uriBuilder->buildUriFromRoute('record_history', ['element' => $table . ':' . $row['uid']]);
2009 $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');';
2010 $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
2011 . htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
2012 . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '</a>';
2013 $this->addActionToCellGroup($cells, $historyAction, 'history');
2014 }
2015 // "Edit Perms" link:
2016 if ($table === 'pages' && $backendUser->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
2017 if ($isL10nOverlay) {
2018 $permsAction = $this->spaceIcon;
2019 } else {
2020 $href = (string)$uriBuilder->buildUriFromRoute('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
2021 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
2022 . htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
2023 . $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
2024 }
2025 $this->addActionToCellGroup($cells, $permsAction, 'perms');
2026 }
2027 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
2028 // or if default values can depend on previous record):
2029 if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
2030 if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
2031 if ($table === 'pages' && $isL10nOverlay) {
2032 $this->addActionToCellGroup($cells, $this->spaceIcon, 'new');
2033 } elseif ($this->showNewRecLink($table)) {
2034 $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
2035 $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
2036 $titleLabel = 'new';
2037 if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
2038 $titleLabel .= ($table === 'pages' ? 'Page' : 'Record');
2039 }
2040 $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
2041 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
2042 . $icon->render() . '</a>';
2043 $this->addActionToCellGroup($cells, $newAction, 'new');
2044 }
2045 }
2046 }
2047 // "Up/Down" links
2048 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
2049 if (!$isL10nOverlay && isset($this->currentTable['prev'][$row['uid']])) {
2050 // Up
2051 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
2052 $moveUpAction = '<a class="btn btn-default" href="#" onclick="'
2053 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2054 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
2055 . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
2056 } else {
2057 $moveUpAction = $this->spaceIcon;
2058 }
2059 $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
2060
2061 if (!$isL10nOverlay && $this->currentTable['next'][$row['uid']]) {
2062 // Down
2063 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
2064 $moveDownAction = '<a class="btn btn-default" href="#" onclick="'
2065 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2066 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
2067 . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
2068 } else {
2069 $moveDownAction = $this->spaceIcon;
2070 }
2071 $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
2072 }
2073 // "Hide/Unhide" links:
2074 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
2075
2076 if (
2077 !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
2078 && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
2079 || $backendUser->check('non_exclude_fields', $table . ':' . $hiddenField))
2080 ) {
2081 if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) {
2082 $hideAction = $this->spaceIcon;
2083 } else {
2084 $hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ? 'Page' : '')));
2085 $unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ? 'Page' : '')));
2086 if ($row[$hiddenField]) {
2087 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
2088 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
2089 . ' data-params="' . htmlspecialchars($params) . '"'
2090 . ' title="' . $unhideTitle . '"'
2091 . ' data-toggle-title="' . $hideTitle . '">'
2092 . $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '</a>';
2093 } else {
2094 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
2095 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
2096 . ' data-params="' . htmlspecialchars($params) . '"'
2097 . ' title="' . $hideTitle . '"'
2098 . ' data-toggle-title="' . $unhideTitle . '">'
2099 . $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '</a>';
2100 }
2101 }
2102 $this->addActionToCellGroup($cells, $hideAction, 'hide');
2103 }
2104 // "Delete" link:
2105 $disableDelete = (bool)\trim($userTsConfig['options.']['disableDelete.'][$table] ?? $userTsConfig['options.']['disableDelete'] ?? '0');
2106 if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) {
2107 // Check if the record version is in "deleted" state, because that will switch the action to "restore"
2108 if ($backendUser->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
2109 $actionName = 'restore';
2110 $refCountMsg = '';
2111 } else {
2112 $actionName = 'delete';
2113 $refCountMsg = BackendUtility::referenceCount(
2114 $table,
2115 $row['uid'],
2116 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
2117 $this->getReferenceCount($table, $row['uid'])
2118 ) . BackendUtility::translationCount(
2119 $table,
2120 $row['uid'],
2121 ' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
2122 );
2123 }
2124
2125 if ($this->isRecordCurrentBackendUser($table, $row)) {
2126 $deleteAction = $this->spaceIcon;
2127 } else {
2128 $title = BackendUtility::getRecordTitle($table, $row);
2129 $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
2130
2131 $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
2132 $icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
2133 $linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
2134 $l10nParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ?? '';
2135 $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
2136 . ' data-l10parent="' . ($l10nParentField ? htmlspecialchars($row[$l10nParentField]) : '') . '"'
2137 . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
2138 . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
2139 . '>' . $icon . '</a>';
2140 }
2141 } else {
2142 $deleteAction = $this->spaceIcon;
2143 }
2144 $this->addActionToCellGroup($cells, $deleteAction, 'delete');
2145 // "Levels" links: Moving pages into new levels...
2146 if ($permsEdit && $table === 'pages' && !$this->searchLevels) {
2147 // Up (Paste as the page right after the current parent page)
2148 if ($this->calcPerms & Permission::PAGE_NEW) {
2149 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
2150 $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
2151 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2152 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
2153 . $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
2154 $this->addActionToCellGroup($cells, $isL10nOverlay ? $this->spaceIcon : $moveLeftAction, 'moveLeft');
2155 }
2156 // Down (Paste as subpage to the page right above)
2157 if (!$isL10nOverlay && $this->currentTable['prevUid'][$row['uid']]) {
2158 $localCalcPerms = $backendUser->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
2159 if ($localCalcPerms & Permission::PAGE_NEW) {
2160 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
2161 $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
2162 . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
2163 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
2164 . $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
2165 } else {
2166 $moveRightAction = $this->spaceIcon;
2167 }
2168 } else {
2169 $moveRightAction = $this->spaceIcon;
2170 }
2171 $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
2172 }
2173 }
2174 /*
2175 * hook: recStatInfoHooks: Allows to insert HTML before record icons on various places
2176 */
2177 $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ?? [];
2178 if (!empty($hooks)) {
2179 $stat = '';
2180 $_params = [$table, $row['uid']];
2181 foreach ($hooks as $_funcRef) {
2182 $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
2183 }
2184 $this->addActionToCellGroup($cells, $stat, 'stat');
2185 }
2186 /*
2187 * hook: makeControl: Allows to change control icons of records in list-module
2188 * usage: This hook method gets passed the current $cells array as third parameter.
2189 * This array contains values for the icons/actions generated for each record in Web>List.
2190 * Each array entry is accessible by an index-key.
2191 * The order of the icons is depending on the order of those array entries.
2192 */
2193 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? false)) {
2194 // for compatibility reason, we move all icons to the rootlevel
2195 // before calling the hooks
2196 foreach ($cells as $section => $actions) {
2197 foreach ($actions as $actionKey => $action) {
2198 $cells[$actionKey] = $action;
2199 }
2200 }
2201 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
2202 $hookObject = GeneralUtility::makeInstance($className);
2203 if (!$hookObject instanceof RecordListHookInterface) {
2204 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567840);
2205 }
2206 $cells = $hookObject->makeControl($table, $row, $cells, $this);
2207 }
2208 // now sort icons again into primary and secondary sections
2209 // after all hooks are processed
2210 $hookCells = $cells;
2211 foreach ($hookCells as $key => $value) {
2212 if ($key === 'primary' || $key === 'secondary') {
2213 continue;
2214 }
2215 $this->addActionToCellGroup($cells, $value, $key);
2216 }
2217 }
2218 $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
2219 foreach ($cells as $classification => $actions) {
2220 $visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS['bigControlPanel'] ? 'collapsed' : 'expanded');
2221 if ($visibilityClass === 'collapsed') {
2222 $cellOutput = '';
2223 foreach ($actions as $action) {
2224 $cellOutput .= $action;
2225 }
2226 $output .= ' <div class="btn-group">' .
2227 '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
2228 '<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>' .
2229 '</div>';
2230 } else {
2231 $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
2232 }
2233 }
2234 return $output;
2235 }
2236
2237 /**
2238 * Creates the clipboard panel for a single record in the listing.
2239 *
2240 * @param string $table The table
2241 * @param mixed[] $row The record for which to make the clipboard panel.
2242 * @throws \UnexpectedValueException
2243 * @return string HTML table with the clipboard panel (unless disabled)
2244 */
2245 public function makeClip($table, $row)
2246 {
2247 // Return blank, if disabled:
2248 if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
2249 return '';
2250 }
2251 $cells = [];
2252 $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon);
2253 // Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
2254 // For page translations these icons should never be shown
2255 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
2256 // Return blank, if disabled:
2257 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
2258 // For the "Normal" pad:
2259 if ($this->clipObj->current === 'normal') {
2260 // Show copy/cut icons:
2261 $isSel = (string)$this->clipObj->isSelected($table, $row['uid']);
2262 if ($isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)) {
2263 $cells['copy'] = $this->spaceIcon;
2264 $cells['cut'] = $this->spaceIcon;
2265 } else {
2266 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL);
2267 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL);
2268
2269 if ($isSel === 'copy') {
2270 $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL);
2271 } elseif ($isSel === 'cut') {
2272 $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL);
2273 }
2274
2275 $cells['copy'] = '<a class="btn btn-default" href="#" onclick="'
2276 . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB(
2277 $table,
2278 $row['uid'],
2279 1,
2280 $isSel === 'copy',
2281 ['returnUrl' => '']
2282 )) . ');')
2283 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">'
2284 . $copyIcon->render() . '</a>';
2285
2286 // Check permission to cut page or content
2287 if ($table === 'pages') {
2288 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
2289 $permsEdit = $localCalcPerms & Permission::PAGE_EDIT;
2290 } else {
2291 $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT;
2292 }
2293 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
2294
2295 // If the listed table is 'pages' we have to request the permission settings for each page:
2296 if ($table === 'pages') {
2297 if ($permsEdit) {
2298 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
2299 . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB(
2300 $table,
2301 $row['uid'],
2302 0,
2303 $isSel === 'cut',
2304 ['returnUrl' => '']
2305 )) . ');')
2306 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2307 . $cutIcon->render() . '</a>';
2308 } else {
2309 $cells['cut'] = $this->spaceIcon;
2310 }
2311 } else {
2312 if ($this->calcPerms & Permission::CONTENT_EDIT) {
2313 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
2314 . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB(
2315 $table,
2316 $row['uid'],
2317 0,
2318 $isSel === 'cut',
2319 ['returnUrl' => '']
2320 )) . ');')
2321 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2322 . $cutIcon->render() . '</a>';
2323 } else {
2324 $cells['cut'] = $this->spaceIcon;
2325 }
2326 }
2327 }
2328 } else {
2329 // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
2330 // Setting name of the element in ->CBnames array:
2331 $n = $table . '|' . $row['uid'];
2332 $this->CBnames[] = $n;
2333 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
2334 $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : '';
2335 // If the "duplicateField" value is set then select all elements which are duplicates...
2336 if ($this->duplicateField && isset($row[$this->duplicateField])) {
2337 $checked = '';
2338 if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
2339 $checked = 'checked="checked" ';
2340 }
2341 $this->duplicateStack[] = $row[$this->duplicateField];
2342 }
2343 // Adding the checkbox to the panel:
2344 $cells['select'] = $isL10nOverlay
2345 ? $this->spaceIcon
2346 : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
2347 . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
2348 }
2349 // Now, looking for selected elements from the current table:
2350 $elFromTable = $this->clipObj->elFromTable($table);
2351 if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
2352 // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
2353 $cells['pasteAfter'] = $isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)
2354 ? $this->spaceIcon
2355 : '<a class="btn btn-default t3js-modal-trigger"'
2356 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"'
2357 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2358 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2359 . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'after', $elFromTable)) . '"'
2360 . ' data-severity="warning">'
2361 . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . '</a>';
2362 }
2363 // Now, looking for elements in general:
2364 $elFromTable = $this->clipObj->elFromTable('');
2365 if ($table === 'pages' && !$isL10nOverlay && !empty($elFromTable)) {
2366 $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"'
2367 . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"'
2368 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2369 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2370 . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'into', $elFromTable)) . '"'
2371 . ' data-severity="warning">'
2372 . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
2373 }
2374 /*
2375 * hook: makeClip: Allows to change clip-icons of records in list-module
2376 * usage: This hook method gets passed the current $cells array as third parameter.
2377 * This array contains values for the clipboard icons generated for each record in Web>List.
2378 * Each array entry is accessible by an index-key.
2379 * The order of the icons is depending on the order of those array entries.
2380 */
2381 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ?? [] as $className) {
2382 $hookObject = GeneralUtility::makeInstance($className);
2383 if (!$hookObject instanceof RecordListHookInterface) {
2384 throw new \UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface::class, 1195567845);
2385 }
2386 $cells = $hookObject->makeClip($table, $row, $cells, $this);
2387 }
2388 return '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
2389 }
2390
2391 /**
2392 * Creates the HTML for a reference count for the record with the UID $uid
2393 * in the table $tableName.
2394 *
2395 * @param string $tableName
2396 * @param int $uid
2397 * @return string HTML of reference a link, will be empty if there are no
2398 */
2399 protected function createReferenceHtml($tableName, $uid)
2400 {
2401 $referenceCount = GeneralUtility::makeInstance(ConnectionPool::class)
2402 ->getConnectionForTable('sys_refindex')
2403 ->count(
2404 '*',
2405 'sys_refindex',
2406 [
2407 'ref_table' => $tableName,
2408 'ref_uid' => (int)$uid,
2409 'deleted' => 0,
2410 ]
2411 );
2412
2413 return $this->generateReferenceToolTip(
2414 $referenceCount,
2415 GeneralUtility::quoteJSvalue($tableName) . ', ' . GeneralUtility::quoteJSvalue($uid)
2416 );
2417 }
2418
2419 /**
2420 * Creates the localization panel
2421 *
2422 * @param string $table The table
2423 * @param mixed[] $row The record for which to make the localization panel.
2424 * @return string[] Array with key 0/1 with content for column 1 and 2
2425 */
2426 public function makeLocalizationPanel($table, $row)
2427 {
2428 $out = [
2429 0 => '',
2430 1 => ''
2431 ];
2432 // Reset translations
2433 $this->translations = [];
2434
2435 // Language title and icon:
2436 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
2437 // Guard clause so we can quickly return if a record is localized to "all languages"
2438 // It should only be possible to localize a record off default (uid 0)
2439 // Reasoning: The Parent is for ALL languages... why overlay with a localization?
2440 if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) {
2441 return $out;
2442 }
2443
2444 $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
2445 if (is_array($translations)) {
2446 $this->translations = $translations['translations'];
2447 // Traverse page translations and add icon for each language that does NOT yet exist:
2448 $lNew = '';
2449 foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
2450 if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
2451 $url = $this->listURL();
2452 $href = BackendUtility::getLinkToDataHandlerAction(
2453 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
2454 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
2455 );
2456 $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title');
2457 if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
2458 $lC = $this->iconFactory->getIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL)->render();
2459 } else {
2460 $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
2461 }
2462 $lC = '<a href="' . htmlspecialchars($href) . '" title="'
2463 . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> ';
2464 $lNew .= $lC;
2465 }
2466 }
2467 if ($lNew) {
2468 $out[1] .= $lNew;
2469 }
2470 } elseif ($row['l18n_parent']) {
2471 $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;' . $out[0];
2472 }
2473 return $out;
2474 }
2475
2476 /**
2477 * Creates a checkbox list for selecting fields to display from a table:
2478 *
2479 * @param string $table Table name
2480 * @param bool $formFields If TRUE, form-fields will be wrapped around the table.
2481 * @return string HTML table with the selector check box (name: displayFields['.$table.'][])
2482 */
2483 public function fieldSelectBox($table, $formFields = true)
2484 {
2485 $lang = $this->getLanguageService();
2486 // Init:
2487 $formElements = ['', ''];
2488 if ($formFields) {
2489 $formElements = ['<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>'];
2490 }
2491 // Load already selected fields, if any:
2492 $setFields = is_array($this->setFields[$table]) ? $this->setFields[$table] : [];
2493 // Request fields from table:
2494 $fields = $this->makeFieldList($table, false, true);
2495 // Add pseudo "control" fields
2496 $fields[] = '_PATH_';
2497 $fields[] = '_REF_';
2498 $fields[] = '_LOCALIZATION_';
2499 $fields[] = '_CONTROL_';
2500 $fields[] = '_CLIPBOARD_';
2501 // Create a checkbox for each field:
2502 $checkboxes = [];
2503 $checkAllChecked = true;
2504 $tsConfig = BackendUtility::getPagesTSconfig($this->id);
2505 $tsConfigOfTable = is_array($tsConfig['TCEFORM.'][$table . '.']) ? $tsConfig['TCEFORM.'][$table . '.'] : null;
2506 foreach ($fields as $fieldName) {
2507 // Hide field if hidden
2508 if ($tsConfigOfTable && is_array($tsConfigOfTable[$fieldName . '.']) && isset($tsConfigOfTable[$fieldName . '.']['disabled']) && (int)$tsConfigOfTable[$fieldName . '.']['disabled'] === 1) {
2509 continue;
2510 }
2511 // Determine, if checkbox should be checked
2512 if (in_array($fieldName, $setFields, true) || $fieldName === $this->fieldArray[0]) {
2513 $checked = ' checked="checked"';
2514 } else {
2515 $checkAllChecked = false;
2516 $checked = '';
2517 }
2518 // Field label
2519 $fieldLabel = is_array($GLOBALS['TCA'][$table]['columns'][$fieldName])
2520 ? rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']), ':')
2521 : '';
2522 $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
2523 . $table . '][]" value="' . $fieldName . '" ' . $checked
2524 . ($fieldName === $this->fieldArray[0] ? ' disabled="disabled"' : '') . '></td><td class="col-title">'
2525 . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($fieldLabel) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
2526 }
2527 // Table with the field selector::
2528 $content = $formElements[0] . '
2529 <input type="hidden" name="displayFields[' . $table . '][]" value="">
2530 <div class="table-fit table-scrollable">
2531 <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
2532 <thead>
2533 <tr>
2534 <th class="col-checkbox checkbox" colspan="2">
2535 <label><input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ? ' checked="checked"' : '') . '>
2536 ' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.toggleall')) . '</label>
2537 </th>
2538 </tr>
2539 </thead>
2540 <tbody>
2541 ' . implode('', $checkboxes) . '
2542 </tbody>
2543 </table>
2544 </div>
2545 <input type="submit" name="search" class="btn btn-default" value="'
2546 . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.setFields')) . '"/>
2547 ' . $formElements[1];
2548 return '<div class="fieldSelectBox">' . $content . '</div>';
2549 }
2550
2551 /*********************************
2552 *
2553 * Helper functions
2554 *
2555 *********************************/
2556 /**
2557 * Creates a link around $string. The link contains an onclick action
2558 * which submits the script with some clipboard action.
2559 * Currently, this is used for setting elements / delete elements.
2560 *
2561 * @param string $string The HTML content to link (image/text)
2562 * @param string $table Table name
2563 * @param string $cmd Clipboard command (eg. "setCB" or "delete")
2564 * @param string $warning Warning text, if any ("delete" uses this for confirmation
2565 * @param string $title title attribute for the anchor
2566 * @return string <a> tag wrapped link.
2567 */
2568 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '', $title = '')
2569 {
2570 $jsCode = 'document.dblistForm.cmd.value=' . GeneralUtility::quoteJSvalue($cmd)
2571 . ';document.dblistForm.cmd_table.value='
2572 . GeneralUtility::quoteJSvalue($table)
2573 . ';document.dblistForm.submit();';
2574
2575 $attributes = [];
2576 if ($title !== '') {
2577 $attributes['title'] = $title;
2578 }
2579 if ($warning) {
2580 $attributes['class'] = 'btn btn-default t3js-modal-trigger';
2581 $attributes['data-href'] = 'javascript:' . $jsCode;
2582 $attributes['data-severity'] = 'warning';
2583 $attributes['data-title'] = $title;
2584 $attributes['data-content'] = $warning;
2585 } else {
2586 $attributes['class'] = 'btn btn-default';
2587 $attributes['onclick'] = $jsCode . 'return false;';
2588 }
2589
2590 $attributesString = '';
2591 foreach ($attributes as $key => $value) {
2592 $attributesString .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
2593 }
2594 return '<a href="#" ' . $attributesString . '>' . $string . '</a>';
2595 }
2596
2597 /**
2598 * Returns TRUE if a numeric clipboard pad is selected/active
2599 *
2600 * @return bool
2601 */
2602 public function clipNumPane()
2603 {
2604 return in_array('_CLIPBOARD_', $this->fieldArray) && $this->clipObj->current !== 'normal';
2605 }
2606
2607 /**
2608 * Creates a sort-by link on the input string ($code).
2609 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
2610 * Also some fields will not be possible to sort (including if single-table-view is disabled).
2611 *
2612 * @param string $code The string to link (text)
2613 * @param string $field The fieldname represented by the title ($code)
2614 * @param string $table Table name
2615 * @return string Linked $code variable
2616 */
2617 public function addSortLink($code, $field, $table)
2618 {
2619 // Certain circumstances just return string right away (no links):
2620 if ($field === '_CONTROL_' || $field === '_LOCALIZATION_' || $field === '_CLIPBOARD_' || $field === '_REF_' || $this->disableSingleTableView) {
2621 return $code;
2622 }
2623 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
2624 if ($field === '_PATH_') {
2625 $field = 'pid';
2626 }
2627 // Create the sort link:
2628 $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
2629 . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || $this->sortField != $field ? 0 : 1);
2630 $sortArrow = $this->sortField === $field
2631 ? $this->iconFactory->getIcon('status-status-sorting-' . ($this->sortRev ? 'desc' : 'asc'), Icon::SIZE_SMALL)->render()
2632 : '';
2633 // Return linked field:
2634 return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
2635 }
2636
2637 /**
2638 * Returns the path for a certain pid
2639 * The result is cached internally for the session, thus you can call
2640 * this function as much as you like without performance problems.
2641 *
2642 * @param int $pid The page id for which to get the path
2643 * @return mixed[] The path.
2644 */
2645 public function recPath($pid)
2646 {
2647 if (!isset($this->recPath_cache[$pid])) {
2648 $this->recPath_cache[$pid] = BackendUtility::getRecordPath($pid, $this->perms_clause, 20);
2649 }
2650 return $this->recPath_cache[$pid];
2651 }
2652
2653 /**
2654 * Returns TRUE if a link for creating new records should be displayed for $table
2655 *
2656 * @param string $table Table name
2657 * @return bool Returns TRUE if a link for creating new records should be displayed for $table
2658 * @see \TYPO3\CMS\Backend\Controller\NewRecordController::showNewRecLink
2659 */
2660 public function showNewRecLink($table)
2661 {
2662 // No deny/allow tables are set:
2663 if (empty($this->allowedNewTables) && empty($this->deniedNewTables)) {
2664 return true;
2665 }
2666 return !in_array($table, $this->deniedNewTables)
2667 && (empty($this->allowedNewTables) || in_array($table, $this->allowedNewTables));
2668 }
2669
2670 /**
2671 * Creates the "&returnUrl" parameter for links - this is used when the script links
2672 * to other scripts and passes its