2 namespace TYPO3\CMS\Recordlist\RecordList
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider
;
18 use TYPO3\CMS\Backend\Module\BaseScriptClass
;
19 use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface
;
20 use TYPO3\CMS\Backend\Routing\UriBuilder
;
21 use TYPO3\CMS\Backend\Template\Components\ButtonBar
;
22 use TYPO3\CMS\Backend\Template\DocumentTemplate
;
23 use TYPO3\CMS\Backend\Template\ModuleTemplate
;
24 use TYPO3\CMS\Backend\Tree\View\PageTreeView
;
25 use TYPO3\CMS\Backend\Utility\BackendUtility
;
26 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
27 use TYPO3\CMS\Core\Database\Connection
;
28 use TYPO3\CMS\Core\Database\ConnectionPool
;
29 use TYPO3\CMS\Core\Database\Query\QueryBuilder
;
30 use TYPO3\CMS\Core\Database\Query\QueryHelper
;
31 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction
;
32 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction
;
33 use TYPO3\CMS\Core\Imaging\Icon
;
34 use TYPO3\CMS\Core\Imaging\IconFactory
;
35 use TYPO3\CMS\Core\Localization\LanguageService
;
36 use TYPO3\CMS\Core\Log\LogManager
;
37 use TYPO3\CMS\Core\Messaging\FlashMessage
;
38 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
39 use TYPO3\CMS\Core\Service\DependencyOrderingService
;
40 use TYPO3\CMS\Core\Type\Bitmask\Permission
;
41 use TYPO3\CMS\Core\Utility\CsvUtility
;
42 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
43 use TYPO3\CMS\Core\Utility\GeneralUtility
;
44 use TYPO3\CMS\Core\Utility\HttpUtility
;
45 use TYPO3\CMS\Core\Utility\MathUtility
;
46 use TYPO3\CMS\Frontend\Page\PageRepository
;
49 * Class for rendering of Web>List module
51 class DatabaseRecordList
58 * Used to indicate which tables (values in the array) that can have a
59 * create-new-record link. If the array is empty, all tables are allowed.
63 public $allowedNewTables = [];
66 * Used to indicate which tables (values in the array) that cannot have a
67 * create-new-record link. If the array is empty, all tables are allowed.
71 public $deniedNewTables = [];
74 * If TRUE, the control panel will contain links to the create-new wizards for
75 * pages and tt_content elements (normally, the link goes to just creatinga new
76 * element without the wizards!).
80 public $newWizards = false;
83 * If TRUE, will disable the rendering of clipboard + control panels.
87 public $dontShowClipControlPanels = false;
90 * If TRUE, will show the clipboard in the field list.
94 public $showClipboard = false;
97 * If TRUE, will DISABLE all control panels in lists. (Takes precedence)
101 public $noControlPanels = false;
104 * If TRUE, clickmenus will be rendered
108 public $clickMenuEnabled = true;
111 * Count of record rows in view
115 public $totalRowCount;
118 * Space icon used for alignment
125 * Disable single table view
129 public $disableSingleTableView = false;
136 * Set to the page record (see writeTop())
140 public $pageRow = [];
143 * Shared module configuration, used by localization features
147 public $modSharedTSconfig = [];
150 * Contains page translation languages
154 public $pageOverlays = [];
157 * Contains sys language icons and titles
161 public $languageIconTitles = [];
164 * Tables which should not list their translations
168 public $hideTranslations = '';
171 * If set, the listing is returned as CSV instead.
175 public $csvOutput = false;
178 * Cache for record path
182 public $recPath_cache = [];
185 * Field, to sort list by
192 * default Max items shown per table in "multi-table mode", may be overridden by tables.php
196 public $itemsLimitPerTable = 20;
199 * Keys are fieldnames and values are td-parameters to add in addElement(), please use $addElement_tdCSSClass for CSS-classes;
203 public $addElement_tdParams = [];
215 public $no_noWrap = 0;
218 * Set to zero, if you don't want a left-margin with addElement function
222 public $setLMargin = 1;
225 * Used for tracking duplicate values of fields
229 public $duplicateStack = [];
232 * Current script name
236 public $script = 'index.php';
239 * If TRUE, records are listed only if a specific table is selected.
243 public $listOnlyInSingleTableMode = false;
250 public $thisScript = '';
253 * JavaScript code accumulation
260 * @var TranslationConfigurationProvider
262 public $translateTools;
265 * default Max items shown per table in "single-table mode", may be overridden by tables.php
269 public $itemsLimitSingleTable = 100;
272 * Array of collapsed / uncollapsed tables in multi table view
276 public $tablesCollapsed = [];
279 * @var array[] Module configuration
284 * String with accumulated HTML content
288 public $HTMLcode = '';
291 * Keys are fieldnames and values are td-css-classes to add in addElement();
295 public $addElement_tdCssClass = [];
298 * Thumbnails on records containing files (pictures)
305 * Used for tracking next/prev uids
309 public $currentTable = [];
312 * Indicates if all available fields for a user should be selected or not.
316 public $allFields = 0;
319 * Number of records to show
323 public $showLimit = 0;
326 * Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column.
330 public $fieldArray = [];
333 * Tables which should not get listed
337 public $hideTables = '';
340 * Containing which fields to display in extended mode
344 public $displayFields;
347 * If set this is <td> CSS-classname for odd columns in addElement. Used with db_layout / pages section
351 public $oddColumnsCssClass = '';
354 * Not used in this class - but maybe extension classes...
355 * Max length of strings
362 * Page select permissions
366 public $perms_clause = '';
373 public $returnUrl = '';
376 * Tablename if single-table mode
383 * Some permissions...
387 public $calcPerms = 0;
390 * Mode for what happens when a user clicks the title of a record.
394 public $clickTitleMode = '';
399 public $showIcon = 1;
402 * Levels to search down.
406 public $searchLevels = '';
416 * Set to the total number of items for a table when selecting.
420 public $totalItems = '';
423 * OBSOLETE - NOT USED ANYMORE. leftMargin
427 public $leftMargin = 0;
430 * TSconfig which overwrites TCA-Settings
434 public $tableTSconfigOverTCA = [];
437 * Loaded with page record with version overlay if any.
441 public $pageRecord = [];
444 * Fields to display for the current table
448 public $setFields = [];
451 * Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard
458 * Pointer for browsing list
462 public $firstElementNumber = 0;
465 * Counting the elements no matter what...
469 public $eCounter = 0;
476 public $searchString = '';
479 * Field, indicating to sort in reverse order.
486 * String, can contain the field name from a table which must have duplicate values marked.
490 public $duplicateField;
493 * Specify a list of tables which are the only ones allowed to be displayed.
497 public $tableList = '';
500 * Used to accumulate CSV lines for CSV export.
504 protected $csvLines = [];
509 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
514 * Tracking names of elements (for clipboard use)
518 public $CBnames = [];
521 * [$tablename][$uid] = number of references to this record
525 protected $referenceCount = [];
528 * Translations of the current record
532 public $translations;
535 * select fields for the query which fetches the translations of the current
540 public $selFieldList;
548 * Injected by RecordList
555 * If defined the records are editable
559 protected $editable = true;
564 protected $iconFactory;
567 * Array with before/after setting for tables
570 * 'before' => ['A', ...]
576 protected $tableDisplayOrder = [];
579 * Override the page ids taken into account by getPageIdConstraint()
583 protected $overridePageIdList = [];
586 * Override/add urlparameters in listUrl() method
589 protected $overrideUrlParameters = [];
592 * Only used to render translated records, used in list module to show page translations
596 protected $showOnlyTranslatedRecords = false;
601 public function __construct()
603 if (isset($GLOBALS['BE_USER']->uc
['titleLen']) && $GLOBALS['BE_USER']->uc
['titleLen'] > 0) {
604 $this->fixedL
= $GLOBALS['BE_USER']->uc
['titleLen'];
606 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
607 $this->getTranslateTools();
608 $this->determineScriptUrl();
610 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
614 * Create the panel of buttons for submitting the form or otherwise perform
617 * @return string[] All available buttons as an assoc. array
619 public function getButtons()
621 $module = $this->getModule();
622 $backendUser = $this->getBackendUserAuthentication();
623 $lang = $this->getLanguageService();
640 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
641 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
642 // Get users permissions for this page record:
643 $localCalcPerms = $backendUser->calcPerms($this->pageRow
);
645 if ((string)$this->id
=== '') {
646 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module_noId');
647 } elseif (!$this->id
) {
648 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module_root');
650 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module');
652 if (isset($this->id
)) {
653 // View Exclude doktypes 254,255 Configuration:
654 // mod.web_list.noViewWithDokTypes = 254,255
655 if (isset($module->modTSconfig
['properties']['noViewWithDokTypes'])) {
656 $noViewDokTypes = GeneralUtility
::trimExplode(',', $module->modTSconfig
['properties']['noViewWithDokTypes'], true);
658 //default exclusion: doktype 254 (folder), 255 (recycler)
660 PageRepository
::DOKTYPE_SYSFOLDER
,
661 PageRepository
::DOKTYPE_RECYCLER
664 if (!in_array($this->pageRow
['doktype'], $noViewDokTypes)) {
665 $onClick = htmlspecialchars(BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
)));
666 $buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
667 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'
668 . $this->iconFactory
->getIcon('actions-document-view', Icon
::SIZE_SMALL
)->render() . '</a>';
670 // New record on pages that are not locked by editlock
671 if (!$module->modTSconfig
['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
672 $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('db_new', ['id' => $this->id
])) . ');');
673 $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
674 . htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
675 . $this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
)->render() . '</a>';
677 // If edit permissions are set, see
678 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
679 if ($localCalcPerms & Permission
::PAGE_EDIT
&& !empty($this->id
) && $this->editLockPermissions() && $this->getBackendUserAuthentication()->checkLanguageAccess(0)) {
681 $params = '&edit[pages][' . $this->pageRow
['uid'] . ']=edit';
682 $onClick = htmlspecialchars(BackendUtility
::editOnClick($params, '', -1));
683 $buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('editPage')) . '">'
684 . $this->iconFactory
->getIcon('actions-page-open', Icon
::SIZE_SMALL
)->render()
688 if (($localCalcPerms & Permission
::PAGE_NEW ||
$localCalcPerms & Permission
::CONTENT_EDIT
) && $this->editLockPermissions()) {
689 $elFromTable = $this->clipObj
->elFromTable('');
690 if (!empty($elFromTable)) {
691 $confirmText = $this->clipObj
->confirmMsgText('pages', $this->pageRow
, 'into', $elFromTable);
692 $buttons['paste'] = '<a'
693 . ' href="' . htmlspecialchars($this->clipObj
->pasteUrl('', $this->id
)) . '"'
694 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
695 . ' class="t3js-modal-trigger"'
696 . ' data-severity="warning"'
697 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
698 . ' data-content="' . htmlspecialchars($confirmText) . '"'
700 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render()
705 $buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
706 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache')) . '">'
707 . $this->iconFactory
->getIcon('actions-system-cache-clear', Icon
::SIZE_SMALL
)->render() . '</a>';
708 if ($this->table
&& (!isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
709 ||
(isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
710 && !$module->modTSconfig
['properties']['noExportRecordsLinks']))
713 $buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
714 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.csv')) . '">'
715 . $this->iconFactory
->getIcon('actions-document-export-csv', Icon
::SIZE_SMALL
)->render() . '</a>';
717 if (ExtensionManagementUtility
::isLoaded('impexp')) {
718 $url = (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
719 $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
720 . rawurlencode($this->table
. ':' . $this->id
)) . '" title="'
721 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export')) . '">'
722 . $this->iconFactory
->getIcon('actions-document-export-t3d', Icon
::SIZE_SMALL
)->render() . '</a>';
726 $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
727 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload')) . '">'
728 . $this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
)->render() . '</a>';
730 if ($backendUser->mayMakeShortcut()) {
731 $buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
732 'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
733 implode(',', array_keys($this->MOD_MENU
)),
738 if ($this->returnUrl
) {
739 $href = htmlspecialchars(GeneralUtility
::linkThisUrl($this->returnUrl
, ['id' => $this->id
]));
740 $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
741 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack')) . '">'
742 . $this->iconFactory
->getIcon('actions-view-go-back', Icon
::SIZE_SMALL
)->render() . '</a>';
749 * Create the panel of buttons for submitting the form or otherwise perform
752 * @param ModuleTemplate $moduleTemplate
754 public function getDocHeaderButtons(ModuleTemplate
$moduleTemplate)
756 $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
757 $module = $this->getModule();
758 $backendUser = $this->getBackendUserAuthentication();
759 $lang = $this->getLanguageService();
760 // Get users permissions for this page record:
761 $localCalcPerms = $backendUser->calcPerms($this->pageRow
);
762 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
763 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
765 if ((string)$this->id
=== '') {
766 $fieldName = 'list_module_noId';
767 } elseif (!$this->id
) {
768 $fieldName = 'list_module_root';
770 $fieldName = 'list_module';
772 $cshButton = $buttonBar->makeHelpButton()
773 ->setModuleName('xMOD_csh_corebe')
774 ->setFieldName($fieldName);
775 $buttonBar->addButton($cshButton);
776 if (isset($this->id
)) {
777 // View Exclude doktypes 254,255 Configuration:
778 // mod.web_list.noViewWithDokTypes = 254,255
779 if (isset($module->modTSconfig
['properties']['noViewWithDokTypes'])) {
780 $noViewDokTypes = GeneralUtility
::trimExplode(',', $module->modTSconfig
['properties']['noViewWithDokTypes'], true);
782 //default exclusion: doktype 254 (folder), 255 (recycler)
784 PageRepository
::DOKTYPE_SYSFOLDER
,
785 PageRepository
::DOKTYPE_RECYCLER
788 // New record on pages that are not locked by editlock
789 if (!$module->modTSconfig
['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
790 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('db_new', ['id' => $this->id
])) . ');';
791 $newRecordButton = $buttonBar->makeLinkButton()
793 ->setOnClick($onClick)
794 ->setTitle($lang->getLL('newRecordGeneral'))
795 ->setIcon($this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
));
796 $buttonBar->addButton($newRecordButton, ButtonBar
::BUTTON_POSITION_LEFT
, 10);
798 if (!in_array($this->pageRow
['doktype'], $noViewDokTypes)) {
799 $onClick = BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
));
800 $viewButton = $buttonBar->makeLinkButton()
802 ->setOnClick($onClick)
803 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
804 ->setIcon($this->iconFactory
->getIcon('actions-view-page', Icon
::SIZE_SMALL
));
805 $buttonBar->addButton($viewButton, ButtonBar
::BUTTON_POSITION_LEFT
, 20);
807 // If edit permissions are set, see
808 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
809 if ($localCalcPerms & Permission
::PAGE_EDIT
&& !empty($this->id
) && $this->editLockPermissions()) {
811 $params = '&edit[pages][' . $this->pageRow
['uid'] . ']=edit';
812 $onClick = BackendUtility
::editOnClick($params, '', -1);
813 $editButton = $buttonBar->makeLinkButton()
815 ->setOnClick($onClick)
816 ->setTitle($lang->getLL('editPage'))
817 ->setIcon($this->iconFactory
->getIcon('actions-page-open', Icon
::SIZE_SMALL
));
818 $buttonBar->addButton($editButton, ButtonBar
::BUTTON_POSITION_LEFT
, 20);
821 if ($this->showClipboard
&& ($localCalcPerms & Permission
::PAGE_NEW ||
$localCalcPerms & Permission
::CONTENT_EDIT
) && $this->editLockPermissions()) {
822 $elFromTable = $this->clipObj
->elFromTable('');
823 if (!empty($elFromTable)) {
824 $confirmMessage = $this->clipObj
->confirmMsgText('pages', $this->pageRow
, 'into', $elFromTable);
825 $pasteButton = $buttonBar->makeLinkButton()
826 ->setHref($this->clipObj
->pasteUrl('', $this->id
))
827 ->setTitle($lang->getLL('clip_paste'))
828 ->setClasses('t3js-modal-trigger')
829 ->setDataAttributes([
830 'severity' => 'warning',
831 'content' => $confirmMessage,
832 'title' => $lang->getLL('clip_paste')
834 ->setIcon($this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
));
835 $buttonBar->addButton($pasteButton, ButtonBar
::BUTTON_POSITION_LEFT
, 40);
839 $clearCacheButton = $buttonBar->makeLinkButton()
840 ->setHref($this->listURL() . '&clear_cache=1')
841 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
842 ->setIcon($this->iconFactory
->getIcon('actions-system-cache-clear', Icon
::SIZE_SMALL
));
843 $buttonBar->addButton($clearCacheButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
844 if ($this->table
&& (!isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
845 ||
(isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
846 && !$module->modTSconfig
['properties']['noExportRecordsLinks']))
849 $csvButton = $buttonBar->makeLinkButton()
850 ->setHref($this->listURL() . '&csv=1')
851 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.csv'))
852 ->setIcon($this->iconFactory
->getIcon('actions-document-export-csv', Icon
::SIZE_SMALL
));
853 $buttonBar->addButton($csvButton, ButtonBar
::BUTTON_POSITION_LEFT
, 40);
855 if (ExtensionManagementUtility
::isLoaded('impexp')) {
856 $url = (string)$uriBuilder->buildUriFromRoute('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
857 $exportButton = $buttonBar->makeLinkButton()
858 ->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table
. ':' . $this->id
))
859 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export'))
860 ->setIcon($this->iconFactory
->getIcon('actions-document-export-t3d', Icon
::SIZE_SMALL
));
861 $buttonBar->addButton($exportButton, ButtonBar
::BUTTON_POSITION_LEFT
, 40);
865 $reloadButton = $buttonBar->makeLinkButton()
866 ->setHref($this->listURL())
867 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload'))
868 ->setIcon($this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
));
869 $buttonBar->addButton($reloadButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
871 if ($backendUser->mayMakeShortcut()) {
872 $shortCutButton = $buttonBar->makeShortcutButton()
873 ->setModuleName('web_list')
886 ->setSetVariables(array_keys($this->MOD_MENU
));
887 $buttonBar->addButton($shortCutButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
890 if ($this->returnUrl
) {
891 $backButton = $buttonBar->makeLinkButton()
892 ->setHref($this->returnUrl
)
893 ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
894 ->setIcon($this->iconFactory
->getIcon('actions-view-go-back', Icon
::SIZE_SMALL
));
895 $buttonBar->addButton($backButton, ButtonBar
::BUTTON_POSITION_LEFT
);
901 * Creates the listing of records from a single table
903 * @param string $table Table name
904 * @param int $id Page id
905 * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
906 * @throws \UnexpectedValueException
907 * @return string HTML table with the listing for the record.
909 public function getTable($table, $id, $rowList = '')
911 $rowListArray = GeneralUtility
::trimExplode(',', $rowList, true);
912 // if no columns have been specified, show description (if configured)
913 if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
914 $rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
916 $backendUser = $this->getBackendUserAuthentication();
917 $lang = $this->getLanguageService();
920 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)->getQueryBuilderForTable($table);
921 $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
922 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
923 $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
924 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
925 $tableCollapsed = (bool)$this->tablesCollapsed
[$table];
926 // prepare space icon
927 $this->spaceIcon
= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
928 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
929 $this->fieldArray
= [];
932 $this->fieldArray
[] = $titleCol;
934 if (!GeneralUtility
::inList($rowList, '_CONTROL_')) {
935 $this->fieldArray
[] = '_CONTROL_';
938 if ($this->showClipboard
) {
939 $this->fieldArray
[] = '_CLIPBOARD_';
942 if (!$this->dontShowClipControlPanels
) {
943 $this->fieldArray
[] = '_REF_';
946 if ($this->searchLevels
) {
947 $this->fieldArray
[] = '_PATH_';
951 $this->fieldArray
[] = '_LOCALIZATION_';
952 // Do not show the "Localize to:" field when only translated records should be shown
953 if (!$this->showOnlyTranslatedRecords
) {
954 $this->fieldArray
[] = '_LOCALIZATION_b';
956 // Only restrict to the default language if no search request is in place
957 // And if only translations should be shown
958 if ($this->searchString
=== '' && !$this->showOnlyTranslatedRecords
) {
959 $addWhere = (string)$queryBuilder->expr()->orX(
960 $queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
961 $queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
966 $this->fieldArray
= array_unique(array_merge($this->fieldArray
, $rowListArray));
967 if ($this->noControlPanels
) {
968 $tempArray = array_flip($this->fieldArray
);
969 unset($tempArray['_CONTROL_']);
970 unset($tempArray['_CLIPBOARD_']);
971 $this->fieldArray
= array_keys($tempArray);
973 // Creating the list of fields to include in the SQL query:
974 $selectFields = $this->fieldArray
;
975 $selectFields[] = 'uid';
976 $selectFields[] = 'pid';
977 // adding column for thumbnails
979 $selectFields[] = $thumbsCol;
981 if ($table === 'pages') {
982 $selectFields[] = 'module';
983 $selectFields[] = 'extendToSubpages';
984 $selectFields[] = 'nav_hide';
985 $selectFields[] = 'doktype';
986 $selectFields[] = 'shortcut';
987 $selectFields[] = 'shortcut_mode';
988 $selectFields[] = 'mount_pid';
990 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
991 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
993 foreach (['type', 'typeicon_column', 'editlock'] as $field) {
994 if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
995 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
998 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
999 $selectFields[] = 't3ver_id';
1000 $selectFields[] = 't3ver_state';
1001 $selectFields[] = 't3ver_wsid';
1004 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
1005 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
1007 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
1008 $selectFields = array_merge(
1010 GeneralUtility
::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
1014 $selectFields = array_unique($selectFields);
1015 $fieldListFields = $this->makeFieldList($table, 1);
1016 if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
1017 $message = sprintf($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'), $table, $table);
1018 $messageTitle = $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle');
1019 /** @var FlashMessage $flashMessage */
1020 $flashMessage = GeneralUtility
::makeInstance(
1021 FlashMessage
::class,
1024 FlashMessage
::WARNING
,
1027 /** @var $flashMessageService FlashMessageService */
1028 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
1029 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
1030 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
1031 $defaultFlashMessageQueue->enqueue($flashMessage);
1033 // Making sure that the fields in the field-list ARE in the field-list from TCA!
1034 $selectFields = array_intersect($selectFields, $fieldListFields);
1035 // Implode it into a list of fields for the SQL-statement.
1036 $selFieldList = implode(',', $selectFields);
1037 $this->selFieldList
= $selFieldList;
1038 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] ??
[] as $className) {
1039 $hookObject = GeneralUtility
::makeInstance($className);
1040 if (!$hookObject instanceof RecordListGetTableHookInterface
) {
1041 throw new \
UnexpectedValueException($className . ' must implement interface ' . RecordListGetTableHookInterface
::class, 1195114460);
1043 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
1045 $additionalConstraints = empty($addWhere) ?
[] : [QueryHelper
::stripLogicalOperatorPrefix($addWhere)];
1046 $selFieldList = GeneralUtility
::trimExplode(',', $selFieldList, true);
1048 // Create the SQL query for selecting the elements in the listing:
1049 // do not do paging when outputting as CSV
1050 if ($this->csvOutput
) {
1053 if ($this->firstElementNumber
> 2 && $this->iLimit
> 0) {
1054 // Get the two previous rows for sorting if displaying page > 1
1055 $this->firstElementNumber
-= 2;
1057 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1058 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
1059 $this->firstElementNumber +
= 2;
1062 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1063 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
1066 // Finding the total amount of records on the page
1067 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
1068 $this->setTotalItems($table, $id, $additionalConstraints);
1071 $queryResult = $queryBuilder->execute();
1075 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode
&& !$this->table
;
1076 // If the count query returned any number of records, we perform the real query,
1077 // selecting records.
1078 if ($this->totalItems
) {
1079 // Fetch records only if not in single table mode
1080 if ($listOnlyInSingleTableMode) {
1081 $dbCount = $this->totalItems
;
1083 // Set the showLimit to the number of records when outputting as CSV
1084 if ($this->csvOutput
) {
1085 $this->showLimit
= $this->totalItems
;
1086 $this->iLimit
= $this->totalItems
;
1088 $dbCount = $queryResult->rowCount();
1091 // If any records was selected, render the list:
1093 // Use a custom table title for translated pages
1094 if ($table == 'pages' && $this->showOnlyTranslatedRecords
) {
1095 $tableTitle = htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:pageTranslation'));
1097 $tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
1098 if ($tableTitle === '') {
1099 $tableTitle = $table;
1102 // Header line is drawn
1104 if ($this->disableSingleTableView
) {
1105 $theData[$titleCol] = '<span class="c-table">' . BackendUtility
::wrapInHelp($table, '', $tableTitle)
1106 . '</span> (<span class="t3js-table-total-items">' . $this->totalItems
. '</span>)';
1108 $icon = $this->table
1109 ?
'<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory
->getIcon('actions-view-table-collapse', Icon
::SIZE_SMALL
)->render() . '</span>'
1110 : '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory
->getIcon('actions-view-table-expand', Icon
::SIZE_SMALL
)->render() . '</span>';
1111 $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems
. '</span>) ' . $icon);
1113 if ($listOnlyInSingleTableMode) {
1114 $tableHeader .= BackendUtility
::wrapInHelp($table, '', $theData[$titleCol]);
1116 // Render collapse button if in multi table mode
1118 if (!$this->table
) {
1119 $href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ?
'0' : '1')));
1120 $title = $tableCollapsed
1121 ?
htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
1122 : htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
1123 $icon = '<span class="collapseIcon">' . $this->iconFactory
->getIcon(($tableCollapsed ?
'actions-view-list-expand' : 'actions-view-list-collapse'), Icon
::SIZE_SMALL
)->render() . '</span>';
1124 $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>';
1126 $tableHeader .= $theData[$titleCol] . $collapseIcon;
1128 // Render table rows only if in multi table view or if in single table view
1130 if (!$listOnlyInSingleTableMode ||
$this->table
) {
1131 // Fixing an order table for sortby tables
1132 $this->currentTable
= [];
1133 $currentIdList = [];
1134 $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField
;
1137 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
1138 if ($this->firstElementNumber
> 2 && $this->iLimit
> 0) {
1139 $row = $queryResult->fetch();
1140 $prevPrevUid = -((int)$row['uid']);
1141 $row = $queryResult->fetch();
1142 $prevUid = $row['uid'];
1145 // Accumulate rows here
1146 while ($row = $queryResult->fetch()) {
1147 if (!$this->isRowListingConditionFulfilled($table, $row)) {
1150 // In offline workspace, look for alternative record:
1151 BackendUtility
::workspaceOL($table, $row, $backendUser->workspace
, true);
1152 if (is_array($row)) {
1154 $currentIdList[] = $row['uid'];
1157 $this->currentTable
['prev'][$row['uid']] = $prevPrevUid;
1158 $this->currentTable
['next'][$prevUid] = '-' . $row['uid'];
1159 $this->currentTable
['prevUid'][$row['uid']] = $prevUid;
1161 $prevPrevUid = isset($this->currentTable
['prev'][$row['uid']]) ?
-$prevUid : $row['pid'];
1162 $prevUid = $row['uid'];
1166 $this->totalRowCount
= count($accRows);
1168 if ($this->csvOutput
) {
1172 $this->CBnames
= [];
1173 $this->duplicateStack
= [];
1174 $this->eCounter
= $this->firstElementNumber
;
1176 foreach ($accRows as $row) {
1177 // Render item row if counter < limit
1178 if ($cc < $this->iLimit
) {
1180 $this->translations
= false;
1181 $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
1182 // If no search happened it means that the selected
1183 // records are either default or All language and here we will not select translations
1184 // which point to the main record:
1185 if ($l10nEnabled && $this->searchString
=== '') {
1186 // For each available translation, render the record:
1187 if (is_array($this->translations
)) {
1188 foreach ($this->translations
as $lRow) {
1189 // $lRow isn't always what we want - if record was moved we've to work with the
1190 // placeholder records otherwise the list is messed up a bit
1191 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
1192 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)
1193 ->getQueryBuilderForTable($table);
1194 $queryBuilder->getRestrictions()
1196 ->add(GeneralUtility
::makeInstance(DeletedRestriction
::class));
1198 $queryBuilder->expr()->eq(
1200 $queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO
::PARAM_INT
)
1202 $queryBuilder->expr()->eq(
1204 $queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO
::PARAM_INT
)
1206 $queryBuilder->expr()->eq(
1208 $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO
::PARAM_INT
)
1212 $tmpRow = $queryBuilder
1213 ->select(...$selFieldList)
1215 ->andWhere(...$predicates)
1219 $lRow = is_array($tmpRow) ?
$tmpRow : $lRow;
1221 // In offline workspace, look for alternative record:
1222 BackendUtility
::workspaceOL($table, $lRow, $backendUser->workspace
, true);
1223 if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
1224 $currentIdList[] = $lRow['uid'];
1225 $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
1231 // Counter of total rows incremented:
1234 // Record navigation is added to the beginning and end of the table if in single
1237 $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
1239 // Show that there are more records than shown
1240 if ($this->totalItems
> $this->itemsLimitPerTable
) {
1241 $countOnFirstPage = $this->totalItems
> $this->itemsLimitSingleTable ?
$this->itemsLimitSingleTable
: $this->totalItems
;
1242 $hasMore = $this->totalItems
> $this->itemsLimitSingleTable
;
1243 $colspan = $this->showIcon ?
count($this->fieldArray
) +
1 : count($this->fieldArray
);
1244 $rowOutput .= '<tr><td colspan="' . $colspan . '">
1245 <a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '" class="btn btn-default">'
1246 . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ?
'+' : '') . ']</i></a>
1250 // The header row for the table is now created:
1251 $out .= $this->renderListHeader($table, $currentIdList);
1254 $collapseClass = $tableCollapsed && !$this->table ?
'collapse' : 'collapse in';
1255 $dataState = $tableCollapsed && !$this->table ?
'collapsed' : 'expanded';
1257 // The list of records is added after the header:
1259 // ... and it is all wrapped in a table:
1265 DB listing of elements: "' . htmlspecialchars($table) . '"
1267 <div class="panel panel-space panel-default recordlist">
1268 <div class="panel-heading">
1269 ' . $tableHeader . '
1271 <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
1272 <div class="table-fit">
1273 <table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ?
' typo3-dblist-overview' : '') . '">
1281 // This ends the page with exit.
1282 if ($this->csvOutput
) {
1283 $this->outputCSV($table);
1291 * Get viewOnClick link for pages or tt_content records
1293 * @param string $table
1298 protected function getOnClickForRow(string $table, array $row): string
1300 if ($table === 'tt_content') {
1301 // Link to a content element
1302 $onClick = BackendUtility
::viewOnClick($this->id
, '', null, '#' . $row['uid']);
1303 } elseif ($table === 'pages' && $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']] > 0) {
1304 // Link to a page translation
1305 $onClick = BackendUtility
::viewOnClick(
1306 $row[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']],
1311 '&L=' . $row[$GLOBALS['TCA']['pages']['ctrl']['languageField']]
1314 // Link to a page in the default language
1315 $onClick = BackendUtility
::viewOnClick($row['uid']);
1321 * Check if all row listing conditions are fulfilled.
1323 * This function serves as a dummy method to be overridden in extending classes.
1325 * @param string $table Table name
1326 * @param string[] $row Record
1327 * @return bool True, if all conditions are fulfilled.
1329 protected function isRowListingConditionFulfilled($table, $row)
1335 * Rendering a single row for the list
1337 * @param string $table Table name
1338 * @param mixed[] $row Current record
1339 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
1340 * @param string $titleCol Table field (column) where header value is found
1341 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
1342 * @param int $indent Indent from left.
1343 * @return string Table row for the element
1347 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
1349 if (!is_array($row)) {
1354 // If in search mode, make sure the preview will show the correct page
1355 if ((string)$this->searchString
!== '') {
1356 $id_orig = $this->id
;
1357 $this->id
= $row['pid'];
1361 'class' => ['t3js-entity'],
1362 'data-table' => $table,
1363 'title' => 'id=' . $row['uid'],
1366 // Add special classes for first and last row
1367 if ($cc == 1 && $indent == 0) {
1368 $tagAttributes['class'][] = 'firstcol';
1370 if ($cc == $this->totalRowCount ||
$cc == $this->iLimit
) {
1371 $tagAttributes['class'][] = 'lastcol';
1373 // Overriding with versions background color if any:
1374 if (!empty($row['_CSSCLASS'])) {
1375 $tagAttributes['class'] = [$row['_CSSCLASS']];
1379 // The icon with link
1380 $toolTip = BackendUtility
::getRecordToolTip($row, $table);
1381 $additionalStyle = $indent ?
' style="margin-left: ' . $indent . 'px;"' : '';
1382 $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
1383 . $this->iconFactory
->getIconForRecord($table, $row, Icon
::SIZE_SMALL
)->render()
1385 $theIcon = $this->clickMenuEnabled ? BackendUtility
::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
1386 // Preparing and getting the data-array
1388 $localizationMarkerClass = '';
1389 foreach ($this->fieldArray
as $fCol) {
1390 if ($fCol == $titleCol) {
1391 $recTitle = BackendUtility
::getRecordTitle($table, $row, false, true);
1393 // If the record is edit-locked by another user, we will show a little warning sign:
1394 $lockInfo = BackendUtility
::isRecordLocked($table, $row['uid']);
1396 $warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
1397 . $this->iconFactory
->getIcon('warning-in-use', Icon
::SIZE_SMALL
)->render() . '</span>';
1399 $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
1400 // Render thumbnails, if:
1401 // - a thumbnail column exists
1402 // - there is content in it
1403 // - the thumbnail column is visible for the current type
1405 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
1406 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
1407 $type = $row[$typeColumn];
1409 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
1410 // if 0 doesn't exist)
1411 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
1412 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ?
0 : 1;
1414 $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
1416 if ($this->thumbs
&&
1417 trim($row[$thumbsCol]) &&
1418 preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
1420 $thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
1421 $theData[$fCol] .= $thumbCode;
1422 $theData['__label'] .= $thumbCode;
1424 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1425 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
1426 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
1428 // It's a translated record with a language parent
1429 $localizationMarkerClass = ' localization';
1431 } elseif ($fCol === 'pid') {
1432 $theData[$fCol] = $row[$fCol];
1433 } elseif ($fCol === '_PATH_') {
1434 $theData[$fCol] = $this->recPath($row['pid']);
1435 } elseif ($fCol === '_REF_') {
1436 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
1437 } elseif ($fCol === '_CONTROL_') {
1438 $theData[$fCol] = $this->makeControl($table, $row);
1439 } elseif ($fCol === '_CLIPBOARD_') {
1440 $theData[$fCol] = $this->makeClip($table, $row);
1441 } elseif ($fCol === '_LOCALIZATION_') {
1442 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
1443 $theData[$fCol] = $lC1;
1444 $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
1445 } elseif ($fCol === '_LOCALIZATION_b') {
1446 // deliberately empty
1448 $pageId = $table === 'pages' ?
$row['uid'] : $row['pid'];
1449 $tmpProc = BackendUtility
::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
1450 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
1451 if ($this->csvOutput
) {
1452 $row[$fCol] = BackendUtility
::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
1456 // Reset the ID if it was overwritten
1457 if ((string)$this->searchString
!== '') {
1458 $this->id
= $id_orig;
1460 // Add row to CSV list:
1461 if ($this->csvOutput
) {
1462 $this->addToCSV($row);
1464 // Add classes to table cells
1465 $this->addElement_tdCssClass
[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
1466 $this->addElement_tdCssClass
['__label'] = $this->addElement_tdCssClass
[$titleCol];
1467 $this->addElement_tdCssClass
['_CONTROL_'] = 'col-control';
1468 if ($this->getModule()->MOD_SETTINGS
['clipBoard']) {
1469 $this->addElement_tdCssClass
['_CLIPBOARD_'] = 'col-clipboard';
1471 $this->addElement_tdCssClass
['_PATH_'] = 'col-path';
1472 $this->addElement_tdCssClass
['_LOCALIZATION_'] = 'col-localizationa';
1473 $this->addElement_tdCssClass
['_LOCALIZATION_b'] = 'col-localizationb';
1474 // Create element in table cells:
1475 $theData['uid'] = $row['uid'];
1476 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1477 && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
1479 $theData['_l10nparent_'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
1482 $tagAttributes = array_map(
1483 function ($attributeValue) {
1484 if (is_array($attributeValue)) {
1485 return implode(' ', $attributeValue);
1487 return $attributeValue;
1492 $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility
::implodeAttributes($tagAttributes, true));
1493 // Finally, return table row element:
1498 * Gets the number of records referencing the record with the UID $uid in
1499 * the table $tableName.
1501 * @param string $tableName
1503 * @return int The number of references to record $uid in table
1505 protected function getReferenceCount($tableName, $uid)
1507 if (!isset($this->referenceCount
[$tableName][$uid])) {
1508 $numberOfReferences = GeneralUtility
::makeInstance(ConnectionPool
::class)
1509 ->getConnectionForTable('sys_refindex')
1514 'ref_table' => $tableName,
1515 'ref_uid' => (int)$uid,
1519 $this->referenceCount
[$tableName][$uid] = $numberOfReferences;
1521 return $this->referenceCount
[$tableName][$uid];
1525 * Rendering the header row for a table
1527 * @param string $table Table name
1528 * @param int[] $currentIdList Array of the currently displayed uids of the table
1529 * @throws \UnexpectedValueException
1530 * @return string Header table row
1534 public function renderListHeader($table, $currentIdList)
1536 $lang = $this->getLanguageService();
1540 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1541 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
1542 // Traverse the fields:
1543 foreach ($this->fieldArray
as $fCol) {
1544 // Calculate users permissions to edit records in the table:
1545 $permsEdit = $this->calcPerms
& ($table === 'pages' ?
2 : 16) && $this->overlayEditLockPermissions($table);
1546 switch ((string)$fCol) {
1549 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>';
1553 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:filelist/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_')) . ']</i>';
1555 case '_LOCALIZATION_':
1557 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>';
1559 case '_LOCALIZATION_b':
1561 $theData[$fCol] = htmlspecialchars($lang->getLL('Localize'));
1564 if (!$this->getModule()->MOD_SETTINGS
['clipBoard']) {
1569 // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
1570 // then display the "paste into" icon:
1571 $elFromTable = $this->clipObj
->elFromTable($table);
1572 if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
1573 $href = htmlspecialchars($this->clipObj
->pasteUrl($table, $this->id
));
1574 $confirmMessage = $this->clipObj
->confirmMsgText('pages', $this->pageRow
, 'into', $elFromTable);
1575 $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"'
1576 . ' href="' . $href . '"'
1577 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1578 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1579 . ' data-content="' . htmlspecialchars($confirmMessage) . '"'
1580 . ' data-severity="warning">'
1581 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render()
1584 // If the numeric clipboard pads are enabled, display the control icons for that:
1585 if ($this->clipObj
->current
!== 'normal') {
1586 // The "select" link:
1587 $spriteIcon = $this->iconFactory
->getIcon('actions-edit-copy', Icon
::SIZE_SMALL
)->render();
1588 $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked'));
1589 // The "edit marked" link:
1590 $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit')
1591 . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit'
1592 . '&returnUrl={T3_THIS_LOCATION}';
1593 $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1594 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1595 . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
1596 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1597 // The "Delete marked" link:
1598 $cells['delete'] = $this->linkClipboardHeaderIcon(
1599 $this->iconFactory
->getIcon('actions-edit-delete', Icon
::SIZE_SMALL
)->render(),
1602 sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
1603 $lang->getLL('clip_deleteMarked')
1605 // The "Select all" link:
1606 $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility
::quoteJSvalue(implode(',', $this->CBnames
)) . ', this); return false;'));
1607 $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
1608 . htmlspecialchars($lang->getLL('clip_markRecords')) . '">'
1609 . $this->iconFactory
->getIcon('actions-document-select', Icon
::SIZE_SMALL
)->render() . '</a>';
1611 $cells['empty'] = '';
1614 * hook: renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
1615 * usage: Above each listed table in Web>List a header row is shown.
1616 * This hook allows to modify the icons responsible for the clipboard functions
1617 * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
1618 * or other "Action" functions which perform operations on the listed records.
1620 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ??
[] as $className) {
1621 $hookObject = GeneralUtility
::makeInstance($className);
1622 if (!$hookObject instanceof RecordListHookInterface
) {
1623 throw new \
UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface
::class, 1195567850);
1625 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
1627 $theData[$fCol] = '';
1628 if (isset($cells['edit']) && isset($cells['delete'])) {
1629 $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>';
1630 unset($cells['edit'], $cells['delete']);
1632 $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1636 if ($this->isEditable($table)) {
1637 // If new records can be created on this page, add links:
1638 $permsAdditional = ($table === 'pages' ?
8 : 16);
1639 if ($this->calcPerms
& $permsAdditional && $this->showNewRecLink($table)) {
1640 $spriteIcon = $table === 'pages'
1641 ?
$this->iconFactory
->getIcon('actions-page-new', Icon
::SIZE_SMALL
)
1642 : $this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
);
1643 if ($table === 'tt_content' && $this->newWizards
) {
1644 // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
1645 $tmpTSc = BackendUtility
::getModTSconfig($this->pageinfo
['uid'], 'mod');
1646 $newContentElementWizard = isset($tmpTSc['properties']['newContentElementWizard.']['override'])
1647 ?
$tmpTSc['properties']['newContentElementWizard.']['override']
1648 : 'new_content_element';
1649 $newContentWizScriptPath = (string)$uriBuilder->buildUriFromRoute($newContentElementWizard, ['id' => $this->id
]);
1651 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue($newContentWizScriptPath) . ');';
1652 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1653 . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1654 } elseif ($table === 'pages' && $this->newWizards
) {
1655 $parameters = ['id' => $this->id
, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')];
1656 $href = (string)$uriBuilder->buildUriFromRoute('db_new', $parameters);
1657 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
1658 . $spriteIcon->render() . '</a>';
1660 $params = '&edit[' . $table . '][' . $this->id
. ']=new';
1661 if ($table === 'pages') {
1662 $params .= '&overrideVals[pages][doktype]=' . (int)$this->pageRow
['doktype'];
1664 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1665 . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1668 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1669 if ($permsEdit && $this->table
&& is_array($currentIdList)) {
1670 $entityIdentifiers = 'entityIdentifiers';
1671 if ($this->clipNumPane()) {
1672 $entityIdentifiers .= ':editList';
1674 $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit')
1675 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1676 . '&columnsOnly=' . implode(',', $this->fieldArray
)
1677 . '&returnUrl={T3_THIS_LOCATION}';
1678 $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1679 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1680 . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
1681 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1682 $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1684 // Add an empty entry, so column count fits again after moving this into $icon
1685 $theData[$fCol] = ' ';
1689 // Regular fields header:
1690 $theData[$fCol] = '';
1692 // Check if $fCol is really a field and get the label and remove the colons
1694 $sortLabel = BackendUtility
::getItemLabel($table, $fCol);
1695 if ($sortLabel !== null) {
1696 $sortLabel = htmlspecialchars($lang->sL($sortLabel));
1697 $sortLabel = rtrim(trim($sortLabel), ':');
1699 // No TCA field, only output the $fCol variable with square brackets []
1700 $sortLabel = htmlspecialchars($fCol);
1701 $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1704 if ($this->table
&& is_array($currentIdList)) {
1705 // If the numeric clipboard pads are selected, show duplicate sorting link:
1706 if ($this->clipNumPane()) {
1707 $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', '-1') . '&duplicateField=' . $fCol)
1708 . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">'
1709 . $this->iconFactory
->getIcon('actions-document-duplicates-select', Icon
::SIZE_SMALL
)->render() . '</a>';
1711 // If the table can be edited, add link for editing THIS field for all
1713 if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1714 $entityIdentifiers = 'entityIdentifiers';
1715 if ($this->clipNumPane()) {
1716 $entityIdentifiers .= ':editList';
1718 $editUri = (string)$uriBuilder->buildUriFromRoute('record_edit')
1719 . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1720 . '&columnsOnly=' . $fCol
1721 . '&returnUrl={T3_THIS_LOCATION}';
1722 $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1723 $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1724 . ' data-uri="' . htmlspecialchars($editUri) . '"'
1725 . ' title="' . htmlspecialchars($iTitle) . '">'
1726 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1728 if (strlen($theData[$fCol]) > 0) {
1729 $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1732 $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1736 * hook: renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
1737 * usage: Above each listed table in Web>List a header row is shown.
1738 * Containing the labels of all shown fields and additional icons to create new records for this
1739 * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
1741 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ??
[] as $className) {
1742 $hookObject = GeneralUtility
::makeInstance($className);
1743 if (!$hookObject instanceof RecordListHookInterface
) {
1744 throw new \
UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface
::class, 1195567855);
1746 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1749 // Create and return header table row:
1750 return '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1754 * Get pointer for first element on the page
1756 * @param int $page Page number starting with 1
1757 * @return int Pointer to first element on the page (starting with 0)
1759 protected function getPointerForPage($page)
1761 return ($page - 1) * $this->iLimit
;
1765 * Creates a page browser for tables with many records
1767 * @param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1768 * @return string Navigation HTML
1770 protected function renderListNavigation($renderPart = 'top')
1772 $totalPages = ceil($this->totalItems
/ $this->iLimit
);
1773 // Show page selector if not all records fit into one page
1774 if ($totalPages <= 1) {
1778 $listURL = $this->listURL('', $this->table
);
1780 // 0 = first element
1781 $currentPage = floor($this->firstElementNumber
/ $this->iLimit
) +
1;
1782 // Compile first, previous, next, last and refresh buttons
1783 if ($currentPage > 1) {
1784 $labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:first'));
1785 $labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:previous'));
1786 $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1787 . $this->iconFactory
->getIcon('actions-view-paging-first', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1788 $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1789 . $this->iconFactory
->getIcon('actions-view-paging-previous', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1791 $first = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-first', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1792 $previous = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-previous', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1794 if ($currentPage < $totalPages) {
1795 $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:next'));
1796 $labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:last'));
1797 $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage +
1) . '" title="' . $labelNext . '">'
1798 . $this->iconFactory
->getIcon('actions-view-paging-next', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1799 $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1800 . $this->iconFactory
->getIcon('actions-view-paging-last', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1802 $next = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-next', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1803 $last = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-last', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1805 $reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility
::quoteJSvalue($listURL
1806 . '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility
::quoteJSvalue('jumpPage-' . $renderPart)
1807 . ').value); document.dblistForm.submit(); return true;" title="'
1808 . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
1809 . $this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1810 if ($renderPart === 'top') {
1811 // Add js to traverse a page select input to a pointer value
1813 <script type="text/javascript">
1815 function calculatePointer(page) {
1816 if (page > ' . $totalPages . ') {
1817 page = ' . $totalPages . ';
1822 return (page - 1) * ' . $this->iLimit
. ';
1828 $pageNumberInput = '
1829 <input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1830 . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . GeneralUtility
::quoteJSvalue($listURL
1831 . '&pointer=') . '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1833 $pageIndicatorText = sprintf(
1834 $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
1838 $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1839 if ($this->totalItems
> $this->firstElementNumber +
$this->iLimit
) {
1840 $lastElementNumber = $this->firstElementNumber +
$this->iLimit
;
1842 $lastElementNumber = $this->totalItems
;
1844 $rangeIndicator = '<li><span>' . sprintf($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber +
1), $lastElementNumber) . '</span></li>';
1846 $titleColumn = $this->fieldArray
[0];
1848 $titleColumn => $content . '
1849 <nav class="pagination-wrap">
1850 <ul class="pagination pagination-block">
1853 ' . $rangeIndicator . '
1854 ' . $pageIndicator . '
1862 return $this->addElement(1, '', $data);
1865 /*********************************
1867 * Rendering of various elements
1869 *********************************/
1872 * Creates the control panel for a single record in the listing.
1874 * @param string $table The table
1875 * @param mixed[] $row The record for which to make the control panel.
1876 * @throws \UnexpectedValueException
1877 * @return string HTML table with the control panel (unless disabled)
1879 public function makeControl($table, $row)
1881 $module = $this->getModule();
1882 $rowUid = $row['uid'];
1883 if (ExtensionManagementUtility
::isLoaded('workspaces') && isset($row['_ORIG_uid'])) {
1884 $rowUid = $row['_ORIG_uid'];
1890 // Enables to hide the move elements for localized records - doesn't make much sense to perform these options for them
1891 // For page translations these icons should never be shown
1892 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1893 // If the listed table is 'pages' we have to request the permission settings for each page:
1894 $localCalcPerms = 0;
1895 if ($table === 'pages') {
1896 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $row['uid']));
1898 $permsEdit = $table === 'pages'
1899 && $this->getBackendUserAuthentication()->checkLanguageAccess(0)
1900 && $localCalcPerms & Permission
::PAGE_EDIT
1901 ||
$table !== 'pages'
1902 && $this->calcPerms
& Permission
::CONTENT_EDIT
1903 && $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row);
1904 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1905 // "Show" link (only pages and tt_content elements)
1906 /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
1907 $uriBuilder = GeneralUtility
::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder
::class);
1909 if ($table === 'pages' ||
$table === 'tt_content') {
1910 $onClick = $this->getOnClickForRow($table, $row);
1911 $viewAction = '<a class="btn btn-default" href="#" onclick="'
1914 ) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">';
1915 if ($table === 'pages') {
1916 $viewAction .= $this->iconFactory
->getIcon('actions-view-page', Icon
::SIZE_SMALL
)->render();
1918 $viewAction .= $this->iconFactory
->getIcon('actions-view', Icon
::SIZE_SMALL
)->render();
1920 $viewAction .= '</a>';
1921 $this->addActionToCellGroup($cells, $viewAction, 'view');
1923 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1925 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1926 $iconIdentifier = 'actions-open';
1927 if ($table === 'pages') {
1928 $iconIdentifier = 'actions-page-open';
1930 $overlayIdentifier = !$this->isEditable($table) ?
'overlay-readonly' : null;
1931 $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1932 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory
->getIcon($iconIdentifier, Icon
::SIZE_SMALL
, $overlayIdentifier)->render() . '</a>';
1934 $editAction = $this->spaceIcon
;
1936 $this->addActionToCellGroup($cells, $editAction, 'edit');
1937 // "Info": (All records)
1938 $onClick = 'top.launchView(' . GeneralUtility
::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
1939 $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
1940 . $this->iconFactory
->getIcon('actions-document-info', Icon
::SIZE_SMALL
)->render() . '</a>';
1941 $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1942 // "Move" wizard link for pages/tt_content elements:
1943 if ($permsEdit && ($table === 'tt_content' ||
$table === 'pages')) {
1944 if ($isL10nOverlay) {
1945 $moveAction = $this->spaceIcon
;
1947 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue((string)$uriBuilder->buildUriFromRoute('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
1948 $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ?
'record' : 'page')));
1949 $icon = ($table === 'pages' ?
$this->iconFactory
->getIcon('actions-page-move', Icon
::SIZE_SMALL
) : $this->iconFactory
->getIcon('actions-document-move', Icon
::SIZE_SMALL
));
1950 $moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
1952 $this->addActionToCellGroup($cells, $moveAction, 'move');
1954 // If the table is NOT a read-only table, then show these links:
1955 if ($this->isEditable($table)) {
1956 // "Revert" link (history/undo)
1957 $moduleUrl = (string)$uriBuilder->buildUriFromRoute('record_history', ['element' => $table . ':' . $row['uid']]);
1958 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue($moduleUrl) . ',\'#latest\');';
1959 $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1960 . htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
1961 . $this->iconFactory
->getIcon('actions-document-history-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1962 $this->addActionToCellGroup($cells, $historyAction, 'history');
1963 // "Edit Perms" link:
1964 if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility
::isLoaded('beuser')) {
1965 if ($isL10nOverlay) {
1966 $permsAction = $this->spaceIcon
;
1968 $href = (string)$uriBuilder->buildUriFromRoute('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
1969 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1970 . htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
1971 . $this->iconFactory
->getIcon('actions-lock', Icon
::SIZE_SMALL
)->render() . '</a>';
1973 $this->addActionToCellGroup($cells, $permsAction, 'perms');
1975 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
1976 // or if default values can depend on previous record):
1977 if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] ||
$GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
1978 if ($table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT ||
$table === 'pages' && $this->calcPerms
& Permission
::PAGE_NEW
) {
1979 if ($table === 'pages' && $isL10nOverlay) {
1980 $this->addActionToCellGroup($cells, $this->spaceIcon
, 'new');
1981 } elseif ($this->showNewRecLink($table)) {
1982 $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ?
$row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
1983 $icon = ($table === 'pages' ?
$this->iconFactory
->getIcon('actions-page-new', Icon
::SIZE_SMALL
) : $this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
));
1984 $titleLabel = 'new';
1985 if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1986 $titleLabel .= ($table === 'pages' ?
'Page' : 'Record');
1988 $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1989 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
1990 . $icon->render() . '</a>';
1991 $this->addActionToCellGroup($cells, $newAction, 'new');
1996 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField
&& !$this->searchLevels
) {
1997 if (!$isL10nOverlay && isset($this->currentTable
['prev'][$row['uid']])) {
1999 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['prev'][$row['uid']];
2000 $moveUpAction = '<a class="btn btn-default" href="#" onclick="'
2001 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
2002 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
2003 . $this->iconFactory
->getIcon('actions-move-up', Icon
::SIZE_SMALL
)->render() . '</a>';
2005 $moveUpAction = $this->spaceIcon
;
2007 $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
2009 if (!$isL10nOverlay && $this->currentTable
['next'][$row['uid']]) {
2011 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['next'][$row['uid']];
2012 $moveDownAction = '<a class="btn btn-default" href="#" onclick="'
2013 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
2014 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
2015 . $this->iconFactory
->getIcon('actions-move-down', Icon
::SIZE_SMALL
)->render() . '</a>';
2017 $moveDownAction = $this->spaceIcon
;
2019 $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
2021 // "Hide/Unhide" links:
2022 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
2025 !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
2026 && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
2027 ||
$this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
2029 if (!$permsEdit ||
$this->isRecordCurrentBackendUser($table, $row)) {
2030 $hideAction = $this->spaceIcon
;
2032 $hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ?
'Page' : '')));
2033 $unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ?
'Page' : '')));
2034 if ($row[$hiddenField]) {
2035 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
2036 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
2037 . ' data-params="' . htmlspecialchars($params) . '"'
2038 . ' title="' . $unhideTitle . '"'
2039 . ' data-toggle-title="' . $hideTitle . '">'
2040 . $this->iconFactory
->getIcon('actions-edit-unhide', Icon
::SIZE_SMALL
)->render() . '</a>';
2042 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
2043 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
2044 . ' data-params="' . htmlspecialchars($params) . '"'
2045 . ' title="' . $hideTitle . '"'
2046 . ' data-toggle-title="' . $unhideTitle . '">'
2047 . $this->iconFactory
->getIcon('actions-edit-hide', Icon
::SIZE_SMALL
)->render() . '</a>';
2050 $this->addActionToCellGroup($cells, $hideAction, 'hide');
2053 $disableDeleteTS = $this->getBackendUserAuthentication()->getTSConfig('options.disableDelete');
2054 $disableDelete = (bool) trim(isset($disableDeleteTS['properties'][$table]) ?
$disableDeleteTS['properties'][$table] : $disableDeleteTS['value']);
2055 if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission
::PAGE_DELETE ||
$table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT
)) {
2056 // Check if the record version is in "deleted" state, because that will switch the action to "restore"
2057 if ($this->getBackendUserAuthentication()->workspace
> 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
2058 $actionName = 'restore';
2061 $actionName = 'delete';
2062 $refCountMsg = BackendUtility
::referenceCount(
2065 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
2066 $this->getReferenceCount($table, $row['uid'])
2067 ) . BackendUtility
::translationCount(
2070 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
2074 if ($this->isRecordCurrentBackendUser($table, $row)) {
2075 $deleteAction = $this->spaceIcon
;
2077 $title = BackendUtility
::getRecordTitle($table, $row);
2078 $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
2080 $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
2081 $icon = $this->iconFactory
->getIcon('actions-edit-' . $actionName, Icon
::SIZE_SMALL
)->render();
2082 $linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
2083 $l10nParentField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] ??
'';
2084 $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
2085 . ' data-l10parent="' . ($l10nParentField ?
htmlspecialchars($row[$l10nParentField]) : '') . '"'
2086 . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
2087 . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
2088 . '>' . $icon . '</a>';
2091 $deleteAction = $this->spaceIcon
;
2093 $this->addActionToCellGroup($cells, $deleteAction, 'delete');
2094 // "Levels" links: Moving pages into new levels...
2095 if ($permsEdit && $table === 'pages' && !$this->searchLevels
) {
2096 // Up (Paste as the page right after the current parent page)
2097 if ($this->calcPerms
& Permission
::PAGE_NEW
) {
2098 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id
;
2099 $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
2100 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
2101 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
2102 . $this->iconFactory
->getIcon('actions-move-left', Icon
::SIZE_SMALL
)->render() . '</a>';
2103 $this->addActionToCellGroup($cells, $isL10nOverlay ?
$this->spaceIcon
: $moveLeftAction, 'moveLeft');
2105 // Down (Paste as subpage to the page right above)
2106 if (!$isL10nOverlay && $this->currentTable
['prevUid'][$row['uid']]) {
2107 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $this->currentTable
['prevUid'][$row['uid']]));
2108 if ($localCalcPerms & Permission
::PAGE_NEW
) {
2109 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['prevUid'][$row['uid']];
2110 $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
2111 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
2112 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
2113 . $this->iconFactory
->getIcon('actions-move-right', Icon
::SIZE_SMALL
)->render() . '</a>';
2115 $moveRightAction = $this->spaceIcon
;
2118 $moveRightAction = $this->spaceIcon
;
2120 $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
2124 * hook: recStatInfoHooks: Allows to insert HTML before record icons on various places
2126 $hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] ??
[];
2127 if (!empty($hooks)) {
2129 $_params = [$table, $row['uid']];
2130 foreach ($hooks as $_funcRef) {
2131 $stat .= GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
2133 $this->addActionToCellGroup($cells, $stat, 'stat');
2136 * hook: makeControl: Allows to change control icons of records in list-module
2137 * usage: This hook method gets passed the current $cells array as third parameter.
2138 * This array contains values for the icons/actions generated for each record in Web>List.
2139 * Each array entry is accessible by an index-key.
2140 * The order of the icons is depending on the order of those array entries.
2142 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ??
false)) {
2143 // for compatibility reason, we move all icons to the rootlevel
2144 // before calling the hooks
2145 foreach ($cells as $section => $actions) {
2146 foreach ($actions as $actionKey => $action) {
2147 $cells[$actionKey] = $action;
2150 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $className) {
2151 $hookObject = GeneralUtility
::makeInstance($className);
2152 if (!$hookObject instanceof RecordListHookInterface
) {
2153 throw new \
UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface
::class, 1195567840);
2155 $cells = $hookObject->makeControl($table, $row, $cells, $this);
2157 // now sort icons again into primary and secondary sections
2158 // after all hooks are processed
2159 $hookCells = $cells;
2160 foreach ($hookCells as $key => $value) {
2161 if ($key === 'primary' ||
$key === 'secondary') {
2164 $this->addActionToCellGroup($cells, $value, $key);
2167 $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
2168 foreach ($cells as $classification => $actions) {
2169 $visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS
['bigControlPanel'] ?
'collapsed' : 'expanded');
2170 if ($visibilityClass === 'collapsed') {
2172 foreach ($actions as $action) {
2173 $cellOutput .= $action;
2175 $output .= ' <div class="btn-group">' .
2176 '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
2177 '<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>' .
2180 $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
2187 * Creates the clipboard panel for a single record in the listing.
2189 * @param string $table The table
2190 * @param mixed[] $row The record for which to make the clipboard panel.
2191 * @throws \UnexpectedValueException
2192 * @return string HTML table with the clipboard panel (unless disabled)
2194 public function makeClip($table, $row)
2196 // Return blank, if disabled:
2197 if (!$this->getModule()->MOD_SETTINGS
['clipBoard']) {
2201 $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon
);
2202 // Enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
2203 // For page translations these icons should never be shown
2204 $isL10nOverlay = $table === 'pages' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
2205 // Return blank, if disabled:
2206 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
2207 // For the "Normal" pad:
2208 if ($this->clipObj
->current
=== 'normal') {
2209 // Show copy/cut icons:
2210 $isSel = (string)$this->clipObj
->isSelected($table, $row['uid']);
2211 if ($isL10nOverlay ||
!$this->overlayEditLockPermissions($table, $row)) {
2212 $cells['copy'] = $this->spaceIcon
;
2213 $cells['cut'] = $this->spaceIcon
;
2215 $copyIcon = $this->iconFactory
->getIcon('actions-edit-copy', Icon
::SIZE_SMALL
);
2216 $cutIcon = $this->iconFactory
->getIcon('actions-edit-cut', Icon
::SIZE_SMALL
);
2218 if ($isSel === 'copy') {
2219 $copyIcon = $this->iconFactory
->getIcon('actions-edit-copy-release', Icon
::SIZE_SMALL
);
2220 } elseif ($isSel === 'cut') {
2221 $cutIcon = $this->iconFactory
->getIcon('actions-edit-cut-release', Icon
::SIZE_SMALL
);
2224 $cells['copy'] = '<a class="btn btn-default" href="#" onclick="'
2225 . htmlspecialchars('return jumpSelf(' . GeneralUtility
::quoteJSvalue($this->clipObj
->selUrlDB($table, $row['uid'], 1, ($isSel === 'copy'), ['returnUrl' => ''])) . ');')
2226 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">'
2227 . $copyIcon->render() . '</a>';
2229 // Check permission to cut page or content
2230 if ($table === 'pages') {
2231 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $row['uid']));
2232 $permsEdit = $localCalcPerms & Permission
::PAGE_EDIT
;
2234 $permsEdit = $this->calcPerms
& Permission
::CONTENT_EDIT
;
2236 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
2238 // If the listed table is 'pages' we have to request the permission settings for each page:
2239 if ($table === 'pages') {
2241 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
2242 . htmlspecialchars('return jumpSelf(' . GeneralUtility
::quoteJSvalue($this->clipObj
->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
2243 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2244 . $cutIcon->render() . '</a>';
2246 $cells['cut'] = $this->spaceIcon
;
2249 if ($this->calcPerms
& Permission
::CONTENT_EDIT
) {
2250 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
2251 . htmlspecialchars('return jumpSelf(' . GeneralUtility
::quoteJSvalue($this->clipObj
->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
2252 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
2253 . $cutIcon->render() . '</a>';
2255 $cells['cut'] = $this->spaceIcon
;
2260 // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
2261 // Setting name of the element in ->CBnames array:
2262 $n = $table . '|' . $row['uid'];
2263 $this->CBnames
[] = $n;
2264 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
2265 $checked = $this->clipObj
->isSelected($table, $row['uid']) ?
'checked="checked" ' : '';
2266 // If the "duplicateField" value is set then select all elements which are duplicates...
2267 if ($this->duplicateField
&& isset($row[$this->duplicateField
])) {
2269 if (in_array($row[$this->duplicateField
], $this->duplicateStack
)) {
2270 $checked = 'checked="checked" ';
2272 $this->duplicateStack
[] = $row[$this->duplicateField
];
2274 // Adding the checkbox to the panel:
2275 $cells['select'] = $isL10nOverlay
2277 : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
2278 . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
2280 // Now, looking for selected elements from the current table:
2281 $elFromTable = $this->clipObj
->elFromTable($table);
2282 if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
2283 // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
2284 $cells['pasteAfter'] = $isL10nOverlay ||
!$this->overlayEditLockPermissions($table, $row)
2286 : '<a class="btn btn-default t3js-modal-trigger"'
2287 . ' href="' . htmlspecialchars($this->clipObj
->pasteUrl($table, -$row['uid'])) . '"'
2288 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2289 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
2290 . ' data-content="' . htmlspecialchars($this->clipObj
->confirmMsgText($table, $row, 'after', $elFromTable)) . '"'
2291 . ' data-severity="warning">'
2292 . $this->iconFactory
->getIcon('actions-document-paste-after', Icon
::SIZE_SMALL
)->render() . '</a>';
2294 // Now, looking for elements in general:
2295 $elFromTable = $this->clipObj
->elFromTable('');
2296 if ($table === 'pages' && !$isL10nOverlay && !empty($elFromTable)) {
2297 $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"'
2298 . ' href="' . htmlspecialchars($this->clipObj
->pasteUrl('', $row['uid'])) . '"'
2299 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2300 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
2301 . ' data-content="' . htmlspecialchars($this->clipObj
->confirmMsgText($table, $row, 'into', $elFromTable)) . '"'
2302 . ' data-severity="warning">'
2303 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render() . '</a>';
2306 * hook: makeClip: Allows to change clip-icons of records in list-module
2307 * usage: This hook method gets passed the current $cells array as third parameter.
2308 * This array contains values for the clipboard icons generated for each record in Web>List.
2309 * Each array entry is accessible by an index-key.
2310 * The order of the icons is depending on the order of those array entries.
2312 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] ??
[] as $className) {
2313 $hookObject = GeneralUtility
::makeInstance($className);
2314 if (!$hookObject instanceof RecordListHookInterface
) {
2315 throw new \
UnexpectedValueException($className . ' must implement interface ' . RecordListHookInterface
::class, 1195567845);
2317 $cells = $hookObject->makeClip($table, $row, $cells, $this);
2319 return '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
2323 * Creates the HTML for a reference count for the record with the UID $uid
2324 * in the table $tableName.
2326 * @param string $tableName
2328 * @return string HTML of reference a link, will be empty if there are no
2330 protected function createReferenceHtml($tableName, $uid)
2332 $referenceCount = GeneralUtility
::makeInstance(ConnectionPool
::class)
2333 ->getConnectionForTable('sys_refindex')
2338 'ref_table' => $tableName,
2339 'ref_uid' => (int)$uid,
2344 return $this->generateReferenceToolTip(
2346 GeneralUtility
::quoteJSvalue($tableName) . ', ' . GeneralUtility
::quoteJSvalue($uid)
2351 * Creates the localization panel
2353 * @param string $table The table
2354 * @param mixed[] $row The record for which to make the localization panel.
2355 * @return string[] Array with key 0/1 with content for column 1 and 2
2357 public function makeLocalizationPanel($table, $row)
2363 // Reset translations
2364 $this->translations
= [];
2366 // Language title and icon:
2367 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
2368 // Guard clause so we can quickly return if a record is localized to "all languages"
2369 // It should only be possible to localize a record off default (uid 0)
2370 // Reasoning: The Parent is for ALL languages... why overlay with a localization?
2371 if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) {
2375 $translations = $this->translateTools
->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList
);
2376 if (is_array($translations)) {
2377 $this->translations
= $translations['translations'];
2378 // Traverse page translations and add icon for each language that does NOT yet exist:
2380 foreach ($this->pageOverlays
as $lUid_OnPage => $lsysRec) {
2381 if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
2382 $url = $this->listURL();
2383 $href = BackendUtility
::getLinkToDataHandlerAction(
2384 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
2385 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
2387 $language = BackendUtility
::getRecord('sys_language', $lUid_OnPage, 'title');
2388 if ($this->languageIconTitles
[$lUid_OnPage]['flagIcon']) {
2389 $lC = $this->iconFactory
->getIcon($this->languageIconTitles
[$lUid_OnPage]['flagIcon'], Icon
::SIZE_SMALL
)->render();
2391 $lC = $this->languageIconTitles
[$lUid_OnPage]['title'];
2393 $lC = '<a href="' . htmlspecialchars($href) . '" title="'
2394 . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> ';
2401 } elseif ($row['l18n_parent']) {
2402 $out[0] = ' ' . $out[0];
2408 * Creates a checkbox list for selecting fields to display from a table:
2410 * @param string $table Table name
2411 * @param bool $formFields If TRUE, form-fields will be wrapped around the table.
2412 * @return string HTML table with the selector check box (name: displayFields['.$table.'][])
2414 public function fieldSelectBox($table, $formFields = true)
2416 $lang = $this->getLanguageService();
2418 $formElements = ['', ''];
2420 $formElements = ['<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>'];
2422 // Load already selected fields, if any:
2423 $setFields = is_array($this->setFields
[$table]) ?
$this->setFields
[$table] : [];
2424 // Request fields from table:
2425 $fields = $this->makeFieldList($table, false, true);
2426 // Add pseudo "control" fields
2427 $fields[] = '_PATH_';
2428 $fields[] = '_REF_';
2429 $fields[] = '_LOCALIZATION_';
2430 $fields[] = '_CONTROL_';
2431 $fields[] = '_CLIPBOARD_';
2432 // Create a checkbox for each field:
2434 $checkAllChecked = true;
2435 $tsConfig = BackendUtility
::getPagesTSconfig($this->id
);
2436 $tsConfigOfTable = is_array($tsConfig['TCEFORM.'][$table . '.']) ?
$tsConfig['TCEFORM.'][$table . '.'] : null;
2437 foreach ($fields as $fieldName) {
2438 // Hide field if hidden
2439 if ($tsConfigOfTable && is_array($tsConfigOfTable[$fieldName . '.']) && isset($tsConfigOfTable[$fieldName . '.']['disabled']) && (int)$tsConfigOfTable[$fieldName . '.']['disabled'] === 1) {
2442 // Determine, if checkbox should be checked
2443 if (in_array($fieldName, $setFields, true) ||
$fieldName === $this->fieldArray
[0]) {
2444 $checked = ' checked="checked"';
2446 $checkAllChecked = false;
2450 $fieldLabel = is_array($GLOBALS['TCA'][$table]['columns'][$fieldName])
2451 ?
rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']), ':')
2453 $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
2454 . $table . '][]" value="' . $fieldName . '" ' . $checked
2455 . ($fieldName === $this->fieldArray
[0] ?
' disabled="disabled"' : '') . '></td><td class="col-title">'
2456 . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($fieldLabel) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
2458 // Table with the field selector::
2459 $content = $formElements[0] . '
2460 <input type="hidden" name="displayFields[' . $table . '][]" value="">
2461 <div class="table-fit table-scrollable">
2462 <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
2465 <th class="col-checkbox checkbox" colspan="2">
2466 <label><input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ?
' checked="checked"' : '') . '>
2467 ' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.toggleall')) . '</label>
2472 ' . implode('', $checkboxes) . '
2476 <input type="submit" name="search" class="btn btn-default" value="'
2477 . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.setFields')) . '"/>
2478 ' . $formElements[1];
2479 return '<div class="fieldSelectBox">' . $content . '</div>';
2482 /*********************************
2486 *********************************/
2488 * Creates a link around $string. The link contains an onclick action
2489 * which submits the script with some clipboard action.
2490 * Currently, this is used for setting elements / delete elements.
2492 * @param string $string The HTML content to link (image/text)
2493 * @param string $table Table name
2494 * @param string $cmd Clipboard command (eg. "setCB" or "delete")
2495 * @param string $warning Warning text, if any ("delete" uses this for confirmation
2496 * @param string $title title attribute for the anchor
2497 * @return string <a> tag wrapped link.
2499 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '', $title = '')
2501 $jsCode = 'document.dblistForm.cmd.value=' . GeneralUtility
::quoteJSvalue($cmd)
2502 . ';document.dblistForm.cmd_table.value='
2503 . GeneralUtility
::quoteJSvalue($table)
2504 . ';document.dblistForm.submit();';
2507 if ($title !== '') {
2508 $attributes['title'] = $title;
2511 $attributes['class'] = 'btn btn-default t3js-modal-trigger';
2512 $attributes['data-href'] = 'javascript:' . $jsCode;
2513 $attributes['data-severity'] = 'warning';
2514 $attributes['data-title'] = $title;
2515 $attributes['data-content'] = $warning;
2517 $attributes['class'] = 'btn btn-default';
2518 $attributes['onclick'] = $jsCode . 'return false;';
2521 $attributesString = '';
2522 foreach ($attributes as $key => $value) {
2523 $attributesString .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
2525 return '<a href="#" ' . $attributesString . '>' . $string . '</a>';
2529 * Returns TRUE if a numeric clipboard pad is selected/active
2533 public function clipNumPane()
2535 return in_array('_CLIPBOARD_', $this->fieldArray
) && $this->clipObj
->current
!== 'normal';
2539 * Creates a sort-by link on the input string ($code).
2540 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
2541 * Also some fields will not be possible to sort (including if single-table-view is disabled).
2543 * @param string $code The string to link (text)
2544 * @param string $field The fieldname represented by the title ($code)
2545 * @param string $table Table name
2546 * @return string Linked $code variable
2548 public function addSortLink($code, $field, $table)
2550 // Certain circumstances just return string right away (no links):
2551 if ($field === '_CONTROL_' ||
$field === '_LOCALIZATION_' ||
$field === '_CLIPBOARD_' ||
$field === '_REF_' ||
$this->disableSingleTableView
) {
2554 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
2555 if ($field === '_PATH_') {
2558 // Create the sort link:
2559 $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
2560 . '&sortField=' . $field . '&sortRev=' . ($this->sortRev ||
$this->sortField
!= $field ?
0 : 1);
2561 $sortArrow = $this->sortField
=== $field
2562 ?
$this->iconFactory
->getIcon('status-status-sorting-' . ($this->sortRev ?
'desc' : 'asc'), Icon
::SIZE_SMALL
)->render()
2564 // Return linked field:
2565 return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
2569 * Returns the path for a certain pid
2570 * The result is cached internally for the session, thus you can call
2571 * this function as much as you like without performance problems.
2573 * @param int $pid The page id for which to get the path
2574 * @return mixed[] The path.
2576 public function recPath($pid)
2578 if (!isset($this->recPath_cache
[$pid])) {
2579 $this->recPath_cache
[$pid] = BackendUtility
::getRecordPath($pid, $this->perms_clause
, 20);
2581 return $this->recPath_cache
[$pid];
2585 * Returns TRUE if a link for creating new records should be displayed for $table
2587 * @param string $table Table name
2588 * @return bool Returns TRUE if a link for creating new records should be displayed for $table
2589 * @see \TYPO3\CMS\Backend\Controller\NewRecordController::showNewRecLink
2591 public function showNewRecLink($table)
2593 // No deny/allow tables are set:
2594 if (empty($this->allowedNewTables
) && empty($this->deniedNewTables
)) {
2597 return !in_array($table, $this->deniedNewTables
)
2598 && (empty($this->allowedNewTables
) ||
in_array($table, $this->allowedNewTables
));
2602 * Creates the "&returnUrl" parameter for links - this is used when the script links
2603 * to other scripts and passes its own URL with the link so other scripts can return to the listing again.
2604 * Uses REQUEST_URI as value.
2608 public function makeReturnUrl()
2610 return '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI'));
2613 /************************************