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\Module\BaseScriptClass
;
18 use TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface
;
19 use TYPO3\CMS\Backend\Template\Components\ButtonBar
;
20 use TYPO3\CMS\Backend\Template\DocumentTemplate
;
21 use TYPO3\CMS\Backend\Template\ModuleTemplate
;
22 use TYPO3\CMS\Backend\Utility\BackendUtility
;
23 use TYPO3\CMS\Core\Database\ConnectionPool
;
24 use TYPO3\CMS\Core\Database\Query\QueryHelper
;
25 use TYPO3\CMS\Core\Imaging\Icon
;
26 use TYPO3\CMS\Core\Imaging\IconFactory
;
27 use TYPO3\CMS\Core\Messaging\FlashMessage
;
28 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
29 use TYPO3\CMS\Core\Type\Bitmask\Permission
;
30 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
31 use TYPO3\CMS\Core\Utility\GeneralUtility
;
32 use TYPO3\CMS\Frontend\Page\PageRepository
;
35 * Class for rendering of Web>List module
37 class DatabaseRecordList
extends AbstractDatabaseRecordList
44 * Used to indicate which tables (values in the array) that can have a
45 * create-new-record link. If the array is empty, all tables are allowed.
49 public $allowedNewTables = [];
52 * Used to indicate which tables (values in the array) that cannot have a
53 * create-new-record link. If the array is empty, all tables are allowed.
57 public $deniedNewTables = [];
60 * If TRUE, the control panel will contain links to the create-new wizards for
61 * pages and tt_content elements (normally, the link goes to just creatinga new
62 * element without the wizards!).
66 public $newWizards = false;
69 * If TRUE, will disable the rendering of clipboard + control panels.
73 public $dontShowClipControlPanels = false;
76 * If TRUE, will show the clipboard in the field list.
80 public $showClipboard = false;
83 * If TRUE, will DISABLE all control panels in lists. (Takes precedence)
87 public $noControlPanels = false;
90 * If TRUE, clickmenus will be rendered
94 public $clickMenuEnabled = true;
97 * Count of record rows in view
101 public $totalRowCount;
104 * Space icon used for alignment
111 * Disable single table view
115 public $disableSingleTableView = false;
122 * Set to the page record (see writeTop())
126 public $pageRow = [];
129 * Used to accumulate CSV lines for CSV export.
133 protected $csvLines = [];
136 * If set, the listing is returned as CSV instead.
140 public $csvOutput = false;
145 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
150 * Tracking names of elements (for clipboard use)
154 public $CBnames = [];
157 * [$tablename][$uid] = number of references to this record
161 protected $referenceCount = [];
164 * Translations of the current record
168 public $translations;
171 * select fields for the query which fetches the translations of the current
176 public $selFieldList;
184 * Injected by RecordList
191 * If defined the records are editable
195 protected $editable = true;
200 protected $iconFactory;
205 public function __construct()
207 parent
::__construct();
208 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
212 * Create the panel of buttons for submitting the form or otherwise perform
215 * @return string[] All available buttons as an assoc. array
217 public function getButtons()
219 $module = $this->getModule();
220 $backendUser = $this->getBackendUserAuthentication();
221 $lang = $this->getLanguageService();
238 // Get users permissions for this page record:
239 $localCalcPerms = $backendUser->calcPerms($this->pageRow
);
241 if ((string)$this->id
=== '') {
242 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module_noId');
243 } elseif (!$this->id
) {
244 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module_root');
246 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module');
248 if (isset($this->id
)) {
249 // View Exclude doktypes 254,255 Configuration:
250 // mod.web_list.noViewWithDokTypes = 254,255
251 if (isset($module->modTSconfig
['properties']['noViewWithDokTypes'])) {
252 $noViewDokTypes = GeneralUtility
::trimExplode(',', $module->modTSconfig
['properties']['noViewWithDokTypes'], true);
254 //default exclusion: doktype 254 (folder), 255 (recycler)
256 PageRepository
::DOKTYPE_SYSFOLDER
,
257 PageRepository
::DOKTYPE_RECYCLER
260 if (!in_array($this->pageRow
['doktype'], $noViewDokTypes)) {
261 $onClick = htmlspecialchars(BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
)));
262 $buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
263 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage')) . '">'
264 . $this->iconFactory
->getIcon('actions-document-view', Icon
::SIZE_SMALL
)->render() . '</a>';
266 // New record on pages that are not locked by editlock
267 if (!$module->modTSconfig
['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
268 $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('db_new', ['id' => $this->id
])) . ');');
269 $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
270 . htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
271 . $this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
)->render() . '</a>';
273 // If edit permissions are set, see
274 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
275 if ($localCalcPerms & Permission
::PAGE_EDIT
&& !empty($this->id
) && $this->editLockPermissions() && $this->getBackendUserAuthentication()->checkLanguageAccess(0)) {
277 $params = '&edit[pages][' . $this->pageRow
['uid'] . ']=edit';
278 $onClick = htmlspecialchars(BackendUtility
::editOnClick($params, '', -1));
279 $buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('editPage')) . '">'
280 . $this->iconFactory
->getIcon('actions-page-open', Icon
::SIZE_SMALL
)->render()
284 if (($localCalcPerms & Permission
::PAGE_NEW ||
$localCalcPerms & Permission
::CONTENT_EDIT
) && $this->editLockPermissions()) {
285 $elFromTable = $this->clipObj
->elFromTable('');
286 if (!empty($elFromTable)) {
287 $confirmText = $this->clipObj
->confirmMsgText('pages', $this->pageRow
, 'into', $elFromTable);
288 $buttons['paste'] = '<a'
289 . ' href="' . htmlspecialchars($this->clipObj
->pasteUrl('', $this->id
)) . '"'
290 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
291 . ' class="t3js-modal-trigger"'
292 . ' data-severity="warning"'
293 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
294 . ' data-content="' . htmlspecialchars($confirmText) . '"'
296 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render()
301 $buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
302 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache')) . '">'
303 . $this->iconFactory
->getIcon('actions-system-cache-clear', Icon
::SIZE_SMALL
)->render() . '</a>';
304 if ($this->table
&& (!isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
305 ||
(isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
306 && !$module->modTSconfig
['properties']['noExportRecordsLinks']))
309 $buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
310 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv')) . '">'
311 . $this->iconFactory
->getIcon('actions-document-export-csv', Icon
::SIZE_SMALL
)->render() . '</a>';
313 if (ExtensionManagementUtility
::isLoaded('impexp')) {
314 $url = BackendUtility
::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
315 $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
316 . rawurlencode($this->table
. ':' . $this->id
)) . '" title="'
317 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.export')) . '">'
318 . $this->iconFactory
->getIcon('actions-document-export-t3d', Icon
::SIZE_SMALL
)->render() . '</a>';
322 $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
323 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload')) . '">'
324 . $this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
)->render() . '</a>';
326 if ($backendUser->mayMakeShortcut()) {
327 $buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
328 'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
329 implode(',', array_keys($this->MOD_MENU
)),
334 if ($this->returnUrl
) {
335 $href = htmlspecialchars(GeneralUtility
::linkThisUrl($this->returnUrl
, ['id' => $this->id
]));
336 $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
337 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack')) . '">'
338 . $this->iconFactory
->getIcon('actions-view-go-back', Icon
::SIZE_SMALL
)->render() . '</a>';
345 * Create the panel of buttons for submitting the form or otherwise perform
348 * @param ModuleTemplate $moduleTemplate
350 public function getDocHeaderButtons(ModuleTemplate
$moduleTemplate)
352 $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
353 $module = $this->getModule();
354 $backendUser = $this->getBackendUserAuthentication();
355 $lang = $this->getLanguageService();
356 // Get users permissions for this page record:
357 $localCalcPerms = $backendUser->calcPerms($this->pageRow
);
359 if ((string)$this->id
=== '') {
360 $fieldName = 'list_module_noId';
361 } elseif (!$this->id
) {
362 $fieldName = 'list_module_root';
364 $fieldName = 'list_module';
366 $cshButton = $buttonBar->makeHelpButton()
367 ->setModuleName('xMOD_csh_corebe')
368 ->setFieldName($fieldName);
369 $buttonBar->addButton($cshButton);
370 if (isset($this->id
)) {
371 // View Exclude doktypes 254,255 Configuration:
372 // mod.web_list.noViewWithDokTypes = 254,255
373 if (isset($module->modTSconfig
['properties']['noViewWithDokTypes'])) {
374 $noViewDokTypes = GeneralUtility
::trimExplode(',', $module->modTSconfig
['properties']['noViewWithDokTypes'], true);
376 //default exclusion: doktype 254 (folder), 255 (recycler)
378 PageRepository
::DOKTYPE_SYSFOLDER
,
379 PageRepository
::DOKTYPE_RECYCLER
382 // New record on pages that are not locked by editlock
383 if (!$module->modTSconfig
['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
384 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('db_new', ['id' => $this->id
])) . ');';
385 $newRecordButton = $buttonBar->makeLinkButton()
387 ->setOnClick($onClick)
388 ->setTitle($lang->getLL('newRecordGeneral'))
389 ->setIcon($this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
));
390 $buttonBar->addButton($newRecordButton, ButtonBar
::BUTTON_POSITION_LEFT
, 10);
392 if (!in_array($this->pageRow
['doktype'], $noViewDokTypes)) {
393 $onClick = BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
));
394 $viewButton = $buttonBar->makeLinkButton()
396 ->setOnClick($onClick)
397 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage'))
398 ->setIcon($this->iconFactory
->getIcon('actions-document-view', Icon
::SIZE_SMALL
));
399 $buttonBar->addButton($viewButton, ButtonBar
::BUTTON_POSITION_LEFT
, 20);
401 // If edit permissions are set, see
402 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
403 if ($localCalcPerms & Permission
::PAGE_EDIT
&& !empty($this->id
) && $this->editLockPermissions()) {
405 $params = '&edit[pages][' . $this->pageRow
['uid'] . ']=edit';
406 $onClick = BackendUtility
::editOnClick($params, '', -1);
407 $editButton = $buttonBar->makeLinkButton()
409 ->setOnClick($onClick)
410 ->setTitle($lang->getLL('editPage'))
411 ->setIcon($this->iconFactory
->getIcon('actions-page-open', Icon
::SIZE_SMALL
));
412 $buttonBar->addButton($editButton, ButtonBar
::BUTTON_POSITION_LEFT
, 20);
415 if ($this->showClipboard
&& ($localCalcPerms & Permission
::PAGE_NEW ||
$localCalcPerms & Permission
::CONTENT_EDIT
) && $this->editLockPermissions()) {
416 $elFromTable = $this->clipObj
->elFromTable('');
417 if (!empty($elFromTable)) {
418 $confirmMessage = $this->clipObj
->confirmMsgText('pages', $this->pageRow
, 'into', $elFromTable);
419 $pasteButton = $buttonBar->makeLinkButton()
420 ->setHref($this->clipObj
->pasteUrl('', $this->id
))
421 ->setTitle($lang->getLL('clip_paste'))
422 ->setClasses('t3js-modal-trigger')
423 ->setDataAttributes([
424 'severity' => 'warning',
425 'content' => $confirmMessage,
426 'title' => $lang->getLL('clip_paste')
428 ->setIcon($this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
));
429 $buttonBar->addButton($pasteButton, ButtonBar
::BUTTON_POSITION_LEFT
, 40);
433 $clearCacheButton = $buttonBar->makeLinkButton()
434 ->setHref($this->listURL() . '&clear_cache=1')
435 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache'))
436 ->setIcon($this->iconFactory
->getIcon('actions-system-cache-clear', Icon
::SIZE_SMALL
));
437 $buttonBar->addButton($clearCacheButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
438 if ($this->table
&& (!isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
439 ||
(isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
440 && !$module->modTSconfig
['properties']['noExportRecordsLinks']))
443 $csvButton = $buttonBar->makeLinkButton()
444 ->setHref($this->listURL() . '&csv=1')
445 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv'))
446 ->setIcon($this->iconFactory
->getIcon('actions-document-export-csv', Icon
::SIZE_SMALL
));
447 $buttonBar->addButton($csvButton, ButtonBar
::BUTTON_POSITION_LEFT
, 40);
449 if (ExtensionManagementUtility
::isLoaded('impexp')) {
450 $url = BackendUtility
::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
451 $exportButton = $buttonBar->makeLinkButton()
452 ->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table
. ':' . $this->id
))
453 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.export'))
454 ->setIcon($this->iconFactory
->getIcon('actions-document-export-t3d', Icon
::SIZE_SMALL
));
455 $buttonBar->addButton($exportButton, ButtonBar
::BUTTON_POSITION_LEFT
, 40);
459 $reloadButton = $buttonBar->makeLinkButton()
460 ->setHref($this->listURL())
461 ->setTitle($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload'))
462 ->setIcon($this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
));
463 $buttonBar->addButton($reloadButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
465 if ($backendUser->mayMakeShortcut()) {
466 $shortCutButton = $buttonBar->makeShortcutButton()
467 ->setModuleName('web_list')
480 ->setSetVariables(array_keys($this->MOD_MENU
));
481 $buttonBar->addButton($shortCutButton, ButtonBar
::BUTTON_POSITION_RIGHT
);
484 if ($this->returnUrl
) {
485 $href = htmlspecialchars(GeneralUtility
::linkThisUrl($this->returnUrl
, ['id' => $this->id
]));
486 $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
487 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack')) . '">'
488 . $this->iconFactory
->getIcon('actions-view-go-back', Icon
::SIZE_SMALL
) . '</a>';
494 * Creates the listing of records from a single table
496 * @param string $table Table name
497 * @param int $id Page id
498 * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
499 * @throws \UnexpectedValueException
500 * @return string HTML table with the listing for the record.
502 public function getTable($table, $id, $rowList = '')
504 $rowListArray = GeneralUtility
::trimExplode(',', $rowList, true);
505 // if no columns have been specified, show description (if configured)
506 if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
507 array_push($rowListArray, $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']);
509 $backendUser = $this->getBackendUserAuthentication();
510 $lang = $this->getLanguageService();
513 $queryBuilder = GeneralUtility
::makeInstance(ConnectionPool
::class)->getQueryBuilderForTable($table);
514 $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
515 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
516 $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
517 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
518 && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
519 $tableCollapsed = (bool)$this->tablesCollapsed
[$table];
520 // prepare space icon
521 $this->spaceIcon
= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
522 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
523 $this->fieldArray
= [];
526 $this->fieldArray
[] = $titleCol;
528 if (!GeneralUtility
::inList($rowList, '_CONTROL_')) {
529 $this->fieldArray
[] = '_CONTROL_';
532 if ($this->showClipboard
) {
533 $this->fieldArray
[] = '_CLIPBOARD_';
536 if (!$this->dontShowClipControlPanels
) {
537 $this->fieldArray
[] = '_REF_';
540 if ($this->searchLevels
) {
541 $this->fieldArray
[] = '_PATH_';
544 if ($this->localizationView
&& $l10nEnabled) {
545 $this->fieldArray
[] = '_LOCALIZATION_';
546 $this->fieldArray
[] = '_LOCALIZATION_b';
547 // Only restrict to the default language if no search request is in place
548 if ($this->searchString
=== '') {
549 $addWhere = (string)$queryBuilder->expr()->orX(
550 $queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
551 $queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
556 $this->fieldArray
= array_unique(array_merge($this->fieldArray
, $rowListArray));
557 if ($this->noControlPanels
) {
558 $tempArray = array_flip($this->fieldArray
);
559 unset($tempArray['_CONTROL_']);
560 unset($tempArray['_CLIPBOARD_']);
561 $this->fieldArray
= array_keys($tempArray);
563 // Creating the list of fields to include in the SQL query:
564 $selectFields = $this->fieldArray
;
565 $selectFields[] = 'uid';
566 $selectFields[] = 'pid';
567 // adding column for thumbnails
569 $selectFields[] = $thumbsCol;
571 if ($table == 'pages') {
572 $selectFields[] = 'module';
573 $selectFields[] = 'extendToSubpages';
574 $selectFields[] = 'nav_hide';
575 $selectFields[] = 'doktype';
576 $selectFields[] = 'shortcut';
577 $selectFields[] = 'shortcut_mode';
578 $selectFields[] = 'mount_pid';
580 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
581 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
583 foreach (['type', 'typeicon_column', 'editlock'] as $field) {
584 if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
585 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
588 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
589 $selectFields[] = 't3ver_id';
590 $selectFields[] = 't3ver_state';
591 $selectFields[] = 't3ver_wsid';
594 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
595 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
597 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
598 $selectFields = array_merge(
600 GeneralUtility
::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
604 $selectFields = array_unique($selectFields);
605 $fieldListFields = $this->makeFieldList($table, 1);
606 if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
607 $message = sprintf(htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessage')), $table, $table);
608 $messageTitle = htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle'));
609 /** @var FlashMessage $flashMessage */
610 $flashMessage = GeneralUtility
::makeInstance(
614 FlashMessage
::WARNING
,
617 /** @var $flashMessageService FlashMessageService */
618 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
619 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
620 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
621 $defaultFlashMessageQueue->enqueue($flashMessage);
623 // Making sure that the fields in the field-list ARE in the field-list from TCA!
624 $selectFields = array_intersect($selectFields, $fieldListFields);
625 // Implode it into a list of fields for the SQL-statement.
626 $selFieldList = implode(',', $selectFields);
627 $this->selFieldList
= $selFieldList;
628 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
629 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
630 $hookObject = GeneralUtility
::getUserObj($classData);
631 if (!$hookObject instanceof RecordListGetTableHookInterface
) {
632 throw new \
UnexpectedValueException($classData . ' must implement interface ' . RecordListGetTableHookInterface
::class, 1195114460);
634 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
637 $additionalConstraints = empty($addWhere) ?
[] : [QueryHelper
::stripLogicalOperatorPrefix($addWhere)];
638 $selFieldList = GeneralUtility
::trimExplode(',', $selFieldList, true);
640 // Create the SQL query for selecting the elements in the listing:
641 // do not do paging when outputting as CSV
642 if ($this->csvOutput
) {
645 if ($this->firstElementNumber
> 2 && $this->iLimit
> 0) {
646 // Get the two previous rows for sorting if displaying page > 1
647 $this->firstElementNumber
= $this->firstElementNumber
- 2;
648 $this->iLimit
= $this->iLimit +
2;
649 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
650 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
651 $this->firstElementNumber
= $this->firstElementNumber +
2;
652 $this->iLimit
= $this->iLimit
- 2;
654 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
655 $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
658 // Finding the total amount of records on the page
659 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
660 $this->setTotalItems($table, $id, $additionalConstraints);
663 $queryResult = $queryBuilder->execute();
667 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode
&& !$this->table
;
668 // If the count query returned any number of records, we perform the real query,
669 // selecting records.
670 if ($this->totalItems
) {
671 // Fetch records only if not in single table mode
672 if ($listOnlyInSingleTableMode) {
673 $dbCount = $this->totalItems
;
675 // Set the showLimit to the number of records when outputting as CSV
676 if ($this->csvOutput
) {
677 $this->showLimit
= $this->totalItems
;
678 $this->iLimit
= $this->totalItems
;
680 $dbCount = $queryResult->rowCount();
683 // If any records was selected, render the list:
685 $tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
686 if ($tableTitle === '') {
687 $tableTitle = $table;
689 // Header line is drawn
691 if ($this->disableSingleTableView
) {
692 $theData[$titleCol] = '<span class="c-table">' . BackendUtility
::wrapInHelp($table, '', $tableTitle)
693 . '</span> (<span class="t3js-table-total-items">' . $this->totalItems
. '</span>)';
696 ?
'<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory
->getIcon('actions-view-table-collapse', Icon
::SIZE_SMALL
)->render() . '</span>'
697 : '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory
->getIcon('actions-view-table-expand', Icon
::SIZE_SMALL
)->render() . '</span>';
698 $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems
. '</span>) ' . $icon);
700 if ($listOnlyInSingleTableMode) {
701 $tableHeader .= BackendUtility
::wrapInHelp($table, '', $theData[$titleCol]);
703 // Render collapse button if in multi table mode
706 $href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ?
'0' : '1')));
707 $title = $tableCollapsed
708 ?
htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.expandTable'))
709 : htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.collapseTable'));
710 $icon = '<span class="collapseIcon">' . $this->iconFactory
->getIcon(($tableCollapsed ?
'actions-view-list-expand' : 'actions-view-list-collapse'), Icon
::SIZE_SMALL
)->render() . '</span>';
711 $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>';
713 $tableHeader .= $theData[$titleCol] . $collapseIcon;
715 // Render table rows only if in multi table view or if in single table view
717 if (!$listOnlyInSingleTableMode ||
$this->table
) {
718 // Fixing an order table for sortby tables
719 $this->currentTable
= [];
721 $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField
;
724 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
725 if ($this->firstElementNumber
> 2 && $this->iLimit
> 0) {
726 $row = $queryResult->fetch();
727 $prevPrevUid = -((int)$row['uid']);
728 $row = $queryResult->fetch();
729 $prevUid = $row['uid'];
732 // Accumulate rows here
733 while ($row = $queryResult->fetch()) {
734 if (!$this->isRowListingConditionFulfilled($table, $row)) {
737 // In offline workspace, look for alternative record:
738 BackendUtility
::workspaceOL($table, $row, $backendUser->workspace
, true);
739 if (is_array($row)) {
741 $currentIdList[] = $row['uid'];
744 $this->currentTable
['prev'][$row['uid']] = $prevPrevUid;
745 $this->currentTable
['next'][$prevUid] = '-' . $row['uid'];
746 $this->currentTable
['prevUid'][$row['uid']] = $prevUid;
748 $prevPrevUid = isset($this->currentTable
['prev'][$row['uid']]) ?
-$prevUid : $row['pid'];
749 $prevUid = $row['uid'];
753 $this->totalRowCount
= count($accRows);
755 if ($this->csvOutput
) {
760 $this->duplicateStack
= [];
761 $this->eCounter
= $this->firstElementNumber
;
763 foreach ($accRows as $row) {
764 // Render item row if counter < limit
765 if ($cc < $this->iLimit
) {
767 $this->translations
= false;
768 $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
769 // If localization view is enabled and no search happened it means that the selected
770 // records are either default or All language and here we will not select translations
771 // which point to the main record:
772 if ($this->localizationView
&& $l10nEnabled && $this->searchString
=== '') {
773 // For each available translation, render the record:
774 if (is_array($this->translations
)) {
775 foreach ($this->translations
as $lRow) {
776 // $lRow isn't always what we want - if record was moved we've to work with the
777 // placeholder records otherwise the list is messed up a bit
778 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
779 $where = 't3ver_move_id="' . (int)$lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid']
780 . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility
::deleteClause($table);
781 $tmpRow = BackendUtility
::getRecordRaw($table, $where, $selFieldList);
782 $lRow = is_array($tmpRow) ?
$tmpRow : $lRow;
784 // In offline workspace, look for alternative record:
785 BackendUtility
::workspaceOL($table, $lRow, $backendUser->workspace
, true);
786 if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
787 $currentIdList[] = $lRow['uid'];
788 $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
794 // Counter of total rows incremented:
797 // Record navigation is added to the beginning and end of the table if in single
800 $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
802 // Show that there are more records than shown
803 if ($this->totalItems
> $this->itemsLimitPerTable
) {
804 $countOnFirstPage = $this->totalItems
> $this->itemsLimitSingleTable ?
$this->itemsLimitSingleTable
: $this->totalItems
;
805 $hasMore = $this->totalItems
> $this->itemsLimitSingleTable
;
806 $colspan = $this->showIcon ?
count($this->fieldArray
) +
1 : count($this->fieldArray
);
807 $rowOutput .= '<tr><td colspan="' . $colspan . '">
808 <a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '" class="btn btn-default">'
809 . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ?
'+' : '') . ']</i></a>
813 // The header row for the table is now created:
814 $out .= $this->renderListHeader($table, $currentIdList);
817 $collapseClass = $tableCollapsed && !$this->table ?
'collapse' : 'collapse in';
818 $dataState = $tableCollapsed && !$this->table ?
'collapsed' : 'expanded';
820 // The list of records is added after the header:
822 // ... and it is all wrapped in a table:
828 DB listing of elements: "' . htmlspecialchars($table) . '"
830 <div class="panel panel-space panel-default recordlist">
831 <div class="panel-heading">
834 <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
835 <div class="table-fit">
836 <table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ?
' typo3-dblist-overview' : '') . '">
844 // This ends the page with exit.
845 if ($this->csvOutput
) {
846 $this->outputCSV($table);
854 * Check if all row listing conditions are fulfilled.
856 * This function serves as a dummy method to be overriden in extending classes.
858 * @param string $table Table name
859 * @param string[] $row Record
860 * @return bool True, if all conditions are fulfilled.
862 protected function isRowListingConditionFulfilled($table, $row)
868 * Rendering a single row for the list
870 * @param string $table Table name
871 * @param mixed[] $row Current record
872 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
873 * @param string $titleCol Table field (column) where header value is found
874 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
875 * @param int $indent Indent from left.
876 * @return string Table row for the element
880 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
882 if (!is_array($row)) {
887 // If in search mode, make sure the preview will show the correct page
888 if ((string)$this->searchString
!== '') {
889 $id_orig = $this->id
;
890 $this->id
= $row['pid'];
892 // Add special classes for first and last row
894 if ($cc == 1 && $indent == 0) {
895 $rowSpecial .= ' firstcol';
897 if ($cc == $this->totalRowCount ||
$cc == $this->iLimit
) {
898 $rowSpecial .= ' lastcol';
901 $row_bgColor = ' class="' . $rowSpecial . '"';
903 // Overriding with versions background color if any:
904 $row_bgColor = $row['_CSSCLASS'] ?
' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
907 // The icon with link
908 $toolTip = BackendUtility
::getRecordToolTip($row, $table);
909 $additionalStyle = $indent ?
' style="margin-left: ' . $indent . 'px;"' : '';
910 $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
911 . $this->iconFactory
->getIconForRecord($table, $row, Icon
::SIZE_SMALL
)->render()
913 $theIcon = $this->clickMenuEnabled ? BackendUtility
::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
914 // Preparing and getting the data-array
916 $localizationMarkerClass = '';
917 foreach ($this->fieldArray
as $fCol) {
918 if ($fCol == $titleCol) {
919 $recTitle = BackendUtility
::getRecordTitle($table, $row, false, true);
921 // If the record is edit-locked by another user, we will show a little warning sign:
922 $lockInfo = BackendUtility
::isRecordLocked($table, $row['uid']);
924 $warning = '<a href="#" onclick="alert('
925 . GeneralUtility
::quoteJSvalue($lockInfo['msg']) . '); return false;" title="'
926 . htmlspecialchars($lockInfo['msg']) . '">'
927 . $this->iconFactory
->getIcon('status-warning-in-use', Icon
::SIZE_SMALL
)->render() . '</a>';
929 $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
930 // Render thumbnails, if:
931 // - a thumbnail column exists
932 // - there is content in it
933 // - the thumbnail column is visible for the current type
935 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
936 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
937 $type = $row[$typeColumn];
939 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
940 // if 0 doesn't exist)
941 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
942 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ?
0 : 1;
944 $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
947 trim($row[$thumbsCol]) &&
948 preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
950 $thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
951 $theData[$fCol] .= $thumbCode;
952 $theData['__label'] .= $thumbCode;
954 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
955 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
956 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
958 // It's a translated record with a language parent
959 $localizationMarkerClass = ' localization';
961 } elseif ($fCol == 'pid') {
962 $theData[$fCol] = $row[$fCol];
963 } elseif ($fCol == '_PATH_') {
964 $theData[$fCol] = $this->recPath($row['pid']);
965 } elseif ($fCol == '_REF_') {
966 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
967 } elseif ($fCol == '_CONTROL_') {
968 $theData[$fCol] = $this->makeControl($table, $row);
969 } elseif ($fCol == '_CLIPBOARD_') {
970 $theData[$fCol] = $this->makeClip($table, $row);
971 } elseif ($fCol == '_LOCALIZATION_') {
972 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
973 $theData[$fCol] = $lC1;
974 $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
975 } elseif ($fCol == '_LOCALIZATION_b') {
976 // deliberately empty
978 $pageId = $table === 'pages' ?
$row['uid'] : $row['pid'];
979 $tmpProc = BackendUtility
::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
980 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
981 if ($this->csvOutput
) {
982 $row[$fCol] = BackendUtility
::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
986 // Reset the ID if it was overwritten
987 if ((string)$this->searchString
!== '') {
988 $this->id
= $id_orig;
990 // Add row to CSV list:
991 if ($this->csvOutput
) {
992 $this->addToCSV($row);
994 // Add classes to table cells
995 $this->addElement_tdCssClass
[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
996 $this->addElement_tdCssClass
['__label'] = $this->addElement_tdCssClass
[$titleCol];
997 $this->addElement_tdCssClass
['_CONTROL_'] = 'col-control';
998 if ($this->getModule()->MOD_SETTINGS
['clipBoard']) {
999 $this->addElement_tdCssClass
['_CLIPBOARD_'] = 'col-clipboard';
1001 $this->addElement_tdCssClass
['_PATH_'] = 'col-path';
1002 $this->addElement_tdCssClass
['_LOCALIZATION_'] = 'col-localizationa';
1003 $this->addElement_tdCssClass
['_LOCALIZATION_b'] = 'col-localizationb';
1004 // Create element in table cells:
1005 $theData['uid'] = $row['uid'];
1006 if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1007 && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
1008 && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])
1010 $theData['_l10nparent_'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
1012 $rowOutput .= $this->addElement(1, $theIcon, $theData, $row_bgColor);
1013 // Finally, return table row element:
1018 * Gets the number of records referencing the record with the UID $uid in
1019 * the table $tableName.
1021 * @param string $tableName
1023 * @return int The number of references to record $uid in table
1025 protected function getReferenceCount($tableName, $uid)
1027 if (!isset($this->referenceCount
[$tableName][$uid])) {
1028 $numberOfReferences = GeneralUtility
::makeInstance(ConnectionPool
::class)
1029 ->getConnectionForTable('sys_refindex')
1034 'ref_table' => $tableName,
1035 'ref_uid' => (int)$uid,
1039 $this->referenceCount
[$tableName][$uid] = $numberOfReferences;
1041 return $this->referenceCount
[$tableName][$uid];
1045 * Rendering the header row for a table
1047 * @param string $table Table name
1048 * @param int[] $currentIdList Array of the currently displayed uids of the table
1049 * @throws \UnexpectedValueException
1050 * @return string Header table row
1054 public function renderListHeader($table, $currentIdList)
1056 $lang = $this->getLanguageService();
1060 // Traverse the fields:
1061 foreach ($this->fieldArray
as $fCol) {
1062 // Calculate users permissions to edit records in the table:
1063 $permsEdit = $this->calcPerms
& ($table == 'pages' ?
2 : 16) && $this->overlayEditLockPermissions($table);
1064 switch ((string)$fCol) {
1067 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._PATH_')) . ']</i>';
1071 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:c__REF_')) . ']</i>';
1073 case '_LOCALIZATION_':
1075 $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>';
1077 case '_LOCALIZATION_b':
1079 $theData[$fCol] = htmlspecialchars($lang->getLL('Localize'));
1082 if (!$this->getModule()->MOD_SETTINGS
['clipBoard']) {
1087 // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
1088 // then display the "paste into" icon:
1089 $elFromTable = $this->clipObj
->elFromTable($table);
1090 if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
1091 $href = htmlspecialchars($this->clipObj
->pasteUrl($table, $this->id
));
1092 $confirmMessage = $this->clipObj
->confirmMsgText('pages', $this->pageRow
, 'into', $elFromTable);
1093 $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"'
1094 . ' href="' . $href . '"'
1095 . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1096 . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1097 . ' data-content="' . htmlspecialchars($confirmMessage) . '"'
1098 . ' data-severity="warning">'
1099 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render()
1102 // If the numeric clipboard pads are enabled, display the control icons for that:
1103 if ($this->clipObj
->current
!= 'normal') {
1104 // The "select" link:
1105 $spriteIcon = $this->iconFactory
->getIcon('actions-edit-copy', Icon
::SIZE_SMALL
)->render();
1106 $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked'));
1107 // The "edit marked" link:
1108 $editIdList = implode(',', $currentIdList);
1109 $editIdList = '\'+editList(' . GeneralUtility
::quoteJSvalue($table) . ',' . GeneralUtility
::quoteJSvalue($editIdList) . ')+\'';
1110 $params = 'edit[' . $table . '][' . $editIdList . ']=edit';
1111 $onClick = BackendUtility
::editOnClick('', '', -1);
1112 $onClickArray = explode('?', $onClick, 2);
1113 $lastElement = array_pop($onClickArray);
1114 array_push($onClickArray, $params . '&' . $lastElement);
1115 $onClick = implode('?', $onClickArray);
1116 $cells['edit'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1117 . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
1118 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1119 // The "Delete marked" link:
1120 $cells['delete'] = $this->linkClipboardHeaderIcon(
1121 $this->iconFactory
->getIcon('actions-edit-delete', Icon
::SIZE_SMALL
)->render(),
1124 sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
1125 $lang->getLL('clip_deleteMarked')
1127 // The "Select all" link:
1128 $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility
::quoteJSvalue(implode(',', $this->CBnames
)) . ', this); return false;'));
1129 $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
1130 . htmlspecialchars($lang->getLL('clip_markRecords')) . '">'
1131 . $this->iconFactory
->getIcon('actions-document-select', Icon
::SIZE_SMALL
)->render() . '</a>';
1133 $cells['empty'] = '';
1136 * @hook renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
1137 * @usage Above each listed table in Web>List a header row is shown.
1138 * This hook allows to modify the icons responsible for the clipboard functions
1139 * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
1140 * or other "Action" functions which perform operations on the listed records.
1142 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1143 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1144 $hookObject = GeneralUtility
::getUserObj($classData);
1145 if (!$hookObject instanceof RecordListHookInterface
) {
1146 throw new \
UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface
::class, 1195567850);
1148 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
1151 $theData[$fCol] = '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1155 if ($this->isEditable($table)) {
1156 // If new records can be created on this page, add links:
1157 $permsAdditional = ($table === 'pages' ?
8 : 16);
1158 if ($this->calcPerms
& $permsAdditional && $this->showNewRecLink($table)) {
1159 $spriteIcon = $table === 'pages'
1160 ?
$this->iconFactory
->getIcon('actions-page-new', Icon
::SIZE_SMALL
)
1161 : $this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
);
1162 if ($table === 'tt_content' && $this->newWizards
) {
1163 // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
1164 $tmpTSc = BackendUtility
::getModTSconfig($this->pageinfo
['uid'], 'mod');
1165 $newContentElementWizard = isset($tmpTSc['properties']['newContentElementWizard.']['override'])
1166 ?
$tmpTSc['properties']['newContentElementWizard.']['override']
1167 : 'new_content_element';
1168 $newContentWizScriptPath = BackendUtility
::getModuleUrl($newContentElementWizard, ['id' => $this->id
]);
1170 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue($newContentWizScriptPath) . ');';
1171 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1172 . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1173 } elseif ($table == 'pages' && $this->newWizards
) {
1174 $parameters = ['id' => $this->id
, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')];
1175 $href = BackendUtility
::getModuleUrl('db_new', $parameters);
1176 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
1177 . $spriteIcon->render() . '</a>';
1179 $params = '&edit[' . $table . '][' . $this->id
. ']=new';
1180 if ($table == 'pages_language_overlay') {
1181 $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRow
['doktype'];
1183 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1184 . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1187 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1188 if ($permsEdit && $this->table
&& is_array($currentIdList)) {
1189 $editIdList = implode(',', $currentIdList);
1190 if ($this->clipNumPane()) {
1191 $editIdList = '\'+editList(' . GeneralUtility
::quoteJSvalue($table) . ',' . GeneralUtility
::quoteJSvalue($editIdList) . ')+\'';
1193 $params = 'edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode(',', $this->fieldArray
);
1194 // we need to build this uri differently, otherwise GeneralUtility::quoteJSvalue messes up the edit list function
1195 $onClick = BackendUtility
::editOnClick('', '', -1);
1196 $onClickArray = explode('?', $onClick, 2);
1197 $lastElement = array_pop($onClickArray);
1198 array_push($onClickArray, $params . '&' . $lastElement);
1199 $onClick = implode('?', $onClickArray);
1200 $icon .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick)
1201 . '" title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
1202 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1203 $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1205 // Add an empty entry, so column count fits again after moving this into $icon
1206 $theData[$fCol] = ' ';
1210 // Regular fields header:
1211 $theData[$fCol] = '';
1213 // Check if $fCol is really a field and get the label and remove the colons
1215 $sortLabel = BackendUtility
::getItemLabel($table, $fCol);
1216 if ($sortLabel !== null) {
1217 $sortLabel = htmlspecialchars($lang->sL($sortLabel));
1218 $sortLabel = rtrim(trim($sortLabel), ':');
1220 // No TCA field, only output the $fCol variable with square brackets []
1221 $sortLabel = htmlspecialchars($fCol);
1222 $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1225 if ($this->table
&& is_array($currentIdList)) {
1226 // If the numeric clipboard pads are selected, show duplicate sorting link:
1227 if ($this->clipNumPane()) {
1228 $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', '-1') . '&duplicateField=' . $fCol)
1229 . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">'
1230 . $this->iconFactory
->getIcon('actions-document-duplicates-select', Icon
::SIZE_SMALL
)->render() . '</a>';
1232 // If the table can be edited, add link for editing THIS field for all
1234 if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1235 $editIdList = implode(',', $currentIdList);
1236 if ($this->clipNumPane()) {
1237 $editIdList = '\'+editList(' . GeneralUtility
::quoteJSvalue($table) . ',' . GeneralUtility
::quoteJSvalue($editIdList) . ')+\'';
1239 $params = 'edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . $fCol;
1240 // we need to build this uri differently, otherwise GeneralUtility::quoteJSvalue messes up the edit list function
1241 $onClick = BackendUtility
::editOnClick('', '', -1);
1242 $onClickArray = explode('?', $onClick, 2);
1243 $lastElement = array_pop($onClickArray);
1244 array_push($onClickArray, $params . '&' . $lastElement);
1245 $onClick = implode('?', $onClickArray);
1246 $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1247 $theData[$fCol] .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick)
1248 . '" title="' . htmlspecialchars($iTitle) . '">'
1249 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1251 if (strlen($theData[$fCol]) > 0) {
1252 $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1255 $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1259 * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
1260 * @usage Above each listed table in Web>List a header row is shown.
1261 * Containing the labels of all shown fields and additional icons to create new records for this
1262 * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
1264 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1265 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1266 $hookObject = GeneralUtility
::getUserObj($classData);
1267 if (!$hookObject instanceof RecordListHookInterface
) {
1268 throw new \
UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface
::class, 1195567855);
1270 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1274 // Create and return header table row:
1275 return '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1279 * Get pointer for first element on the page
1281 * @param int $page Page number starting with 1
1282 * @return int Pointer to first element on the page (starting with 0)
1284 protected function getPointerForPage($page)
1286 return ($page - 1) * $this->iLimit
;
1290 * Creates a page browser for tables with many records
1292 * @param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1293 * @return string Navigation HTML
1295 protected function renderListNavigation($renderPart = 'top')
1297 $totalPages = ceil($this->totalItems
/ $this->iLimit
);
1298 // Show page selector if not all records fit into one page
1299 if ($totalPages <= 1) {
1303 $listURL = $this->listURL('', $this->table
);
1305 // 0 = first element
1306 $currentPage = floor($this->firstElementNumber
/ $this->iLimit
) +
1;
1307 // Compile first, previous, next, last and refresh buttons
1308 if ($currentPage > 1) {
1309 $labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:first'));
1310 $labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:previous'));
1311 $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1312 . $this->iconFactory
->getIcon('actions-view-paging-first', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1313 $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1314 . $this->iconFactory
->getIcon('actions-view-paging-previous', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1316 $first = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-first', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1317 $previous = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-previous', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1319 if ($currentPage < $totalPages) {
1320 $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:next'));
1321 $labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:last'));
1322 $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage +
1) . '" title="' . $labelNext . '">'
1323 . $this->iconFactory
->getIcon('actions-view-paging-next', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1324 $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1325 . $this->iconFactory
->getIcon('actions-view-paging-last', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1327 $next = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-next', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1328 $last = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-last', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1330 $reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility
::quoteJSvalue($listURL
1331 . '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility
::quoteJSvalue('jumpPage-' . $renderPart)
1332 . ').value); document.dblistForm.submit(); return true;" title="'
1333 . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:reload')) . '">'
1334 . $this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1335 if ($renderPart === 'top') {
1336 // Add js to traverse a page select input to a pointer value
1338 <script type="text/javascript">
1340 function calculatePointer(page) {
1341 if (page > ' . $totalPages . ') {
1342 page = ' . $totalPages . ';
1347 return (page - 1) * ' . $this->iLimit
. ';
1353 $pageNumberInput = '
1354 <input type="text" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1355 . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . GeneralUtility
::quoteJSvalue($listURL
1356 . '&pointer=') . '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1358 $pageIndicatorText = sprintf(
1359 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:pageIndicator'),
1363 $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1364 if ($this->totalItems
> $this->firstElementNumber +
$this->iLimit
) {
1365 $lastElementNumber = $this->firstElementNumber +
$this->iLimit
;
1367 $lastElementNumber = $this->totalItems
;
1369 $rangeIndicator = '<li><span>' . sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber +
1), $lastElementNumber) . '</span></li>';
1371 $titleColumn = $this->fieldArray
[0];
1373 $titleColumn => $content . '
1374 <nav class="pagination-wrap">
1375 <ul class="pagination pagination-block">
1378 ' . $rangeIndicator . '
1379 ' . $pageIndicator . '
1387 return $this->addElement(1, '', $data);
1390 /*********************************
1392 * Rendering of various elements
1394 *********************************/
1397 * Creates the control panel for a single record in the listing.
1399 * @param string $table The table
1400 * @param mixed[] $row The record for which to make the control panel.
1401 * @throws \UnexpectedValueException
1402 * @return string HTML table with the control panel (unless disabled)
1404 public function makeControl($table, $row)
1406 $module = $this->getModule();
1407 $rowUid = $row['uid'];
1408 if (ExtensionManagementUtility
::isLoaded('version') && isset($row['_ORIG_uid'])) {
1409 $rowUid = $row['_ORIG_uid'];
1415 // If the listed table is 'pages' we have to request the permission settings for each page:
1416 $localCalcPerms = 0;
1417 if ($table == 'pages') {
1418 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $row['uid']));
1420 $permsEdit = $table === 'pages'
1421 && $this->getBackendUserAuthentication()->checkLanguageAccess(0)
1422 && $localCalcPerms & Permission
::PAGE_EDIT
1423 ||
$table !== 'pages'
1424 && $this->calcPerms
& Permission
::CONTENT_EDIT
1425 && $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row);
1426 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1427 // "Show" link (only pages and tt_content elements)
1428 if ($table == 'pages' ||
$table == 'tt_content') {
1429 $viewAction = '<a class="btn btn-default" href="#" onclick="'
1431 BackendUtility
::viewOnClick(
1432 ($table === 'tt_content' ?
$this->id
: $row['uid']),
1435 ($table === 'tt_content' ?
'#' . $row['uid'] : '')
1437 ) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage')) . '">'
1438 . $this->iconFactory
->getIcon('actions-view', Icon
::SIZE_SMALL
)->render() . '</a>';
1439 $this->addActionToCellGroup($cells, $viewAction, 'view');
1441 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1443 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1444 $iconIdentifier = 'actions-open';
1445 if ($table === 'pages') {
1446 $iconIdentifier = 'actions-page-open';
1448 $overlayIdentifier = !$this->isEditable($table) ?
'overlay-readonly' : null;
1449 $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1450 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory
->getIcon($iconIdentifier, Icon
::SIZE_SMALL
, $overlayIdentifier)->render() . '</a>';
1452 $editAction = $this->spaceIcon
;
1454 $this->addActionToCellGroup($cells, $editAction, 'edit');
1455 // "Info": (All records)
1456 $onClick = 'top.launchView(' . GeneralUtility
::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
1457 $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
1458 . $this->iconFactory
->getIcon('actions-document-info', Icon
::SIZE_SMALL
)->render() . '</a>';
1459 $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1460 // "Move" wizard link for pages/tt_content elements:
1461 if ($permsEdit && ($table === 'tt_content' ||
$table === 'pages')) {
1462 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
1463 $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ?
'record' : 'page')));
1464 $icon = ($table == 'pages' ?
$this->iconFactory
->getIcon('actions-page-move', Icon
::SIZE_SMALL
) : $this->iconFactory
->getIcon('actions-document-move', Icon
::SIZE_SMALL
));
1465 $moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
1466 $this->addActionToCellGroup($cells, $moveAction, 'move');
1468 // If the table is NOT a read-only table, then show these links:
1469 if ($this->isEditable($table)) {
1470 // "Revert" link (history/undo)
1471 $moduleUrl = BackendUtility
::getModuleUrl('record_history', ['element' => $table . ':' . $row['uid']]);
1472 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue($moduleUrl) . ',\'#latest\');';
1473 $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1474 . htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
1475 . $this->iconFactory
->getIcon('actions-document-history-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1476 $this->addActionToCellGroup($cells, $historyAction, 'history');
1478 if (ExtensionManagementUtility
::isLoaded('version') && !ExtensionManagementUtility
::isLoaded('workspaces')) {
1479 $vers = BackendUtility
::selectVersionsOfRecord($table, $row['uid'], 'uid', $this->getBackendUserAuthentication()->workspace
, false, $row);
1480 // If table can be versionized.
1481 if (is_array($vers)) {
1482 $href = BackendUtility
::getModuleUrl('web_txversionM1', [
1483 'table' => $table, 'uid' => $row['uid']
1485 $versionAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1486 . htmlspecialchars($this->getLanguageService()->getLL('displayVersions')) . '">'
1487 . $this->iconFactory
->getIcon('actions-version-page-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1488 $this->addActionToCellGroup($cells, $versionAction, 'version');
1491 // "Edit Perms" link:
1492 if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility
::isLoaded('beuser')) {
1493 $href = BackendUtility
::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&return_id=' . $row['uid'] . '&edit=1';
1494 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1495 . htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
1496 . $this->iconFactory
->getIcon('status-status-locked', Icon
::SIZE_SMALL
)->render() . '</a>';
1497 $this->addActionToCellGroup($cells, $permsAction, 'perms');
1499 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
1500 // or if default values can depend on previous record):
1501 if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] ||
$GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
1502 if ($table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT ||
$table === 'pages' && $this->calcPerms
& Permission
::PAGE_NEW
) {
1503 if ($this->showNewRecLink($table)) {
1504 $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ?
$row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
1505 $icon = ($table == 'pages' ?
$this->iconFactory
->getIcon('actions-page-new', Icon
::SIZE_SMALL
) : $this->iconFactory
->getIcon('actions-add', Icon
::SIZE_SMALL
));
1506 $titleLabel = 'new';
1507 if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1508 $titleLabel .= ($table === 'pages' ?
'Page' : 'Record');
1510 $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1511 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
1512 . $icon->render() . '</a>';
1513 $this->addActionToCellGroup($cells, $newAction, 'new');
1518 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField
&& !$this->searchLevels
) {
1519 if (isset($this->currentTable
['prev'][$row['uid']])) {
1521 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['prev'][$row['uid']];
1522 $moveUpAction = '<a class="btn btn-default" href="#" onclick="'
1523 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
1524 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
1525 . $this->iconFactory
->getIcon('actions-move-up', Icon
::SIZE_SMALL
)->render() . '</a>';
1527 $moveUpAction = $this->spaceIcon
;
1529 $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
1531 if ($this->currentTable
['next'][$row['uid']]) {
1533 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['next'][$row['uid']];
1534 $moveDownAction = '<a class="btn btn-default" href="#" onclick="'
1535 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
1536 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
1537 . $this->iconFactory
->getIcon('actions-move-down', Icon
::SIZE_SMALL
)->render() . '</a>';
1539 $moveDownAction = $this->spaceIcon
;
1541 $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
1543 // "Hide/Unhide" links:
1544 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1547 !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
1548 && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
1549 ||
$this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
1551 if (!$permsEdit ||
$this->isRecordCurrentBackendUser($table, $row)) {
1552 $hideAction = $this->spaceIcon
;
1554 $hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table == 'pages' ?
'Page' : '')));
1555 $unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table == 'pages' ?
'Page' : '')));
1556 if ($row[$hiddenField]) {
1557 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
1558 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
1559 . ' data-params="' . htmlspecialchars($params) . '"'
1560 . ' title="' . $unhideTitle . '"'
1561 . ' data-toggle-title="' . $hideTitle . '">'
1562 . $this->iconFactory
->getIcon('actions-edit-unhide', Icon
::SIZE_SMALL
)->render() . '</a>';
1564 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
1565 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
1566 . ' data-params="' . htmlspecialchars($params) . '"'
1567 . ' title="' . $hideTitle . '"'
1568 . ' data-toggle-title="' . $unhideTitle . '">'
1569 . $this->iconFactory
->getIcon('actions-edit-hide', Icon
::SIZE_SMALL
)->render() . '</a>';
1572 $this->addActionToCellGroup($cells, $hideAction, 'hide');
1575 $disableDeleteTS = $this->getBackendUserAuthentication()->getTSConfig('options.disableDelete');
1576 $disableDelete = (bool) trim(isset($disableDeleteTS['properties'][$table]) ?
$disableDeleteTS['properties'][$table] : $disableDeleteTS['value']);
1577 if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission
::PAGE_DELETE ||
$table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT
)) {
1578 // Check if the record version is in "deleted" state, because that will switch the action to "restore"
1579 if ($this->getBackendUserAuthentication()->workspace
> 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
1580 $actionName = 'restore';
1583 $actionName = 'delete';
1584 $refCountMsg = BackendUtility
::referenceCount(
1587 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord'),
1588 $this->getReferenceCount($table, $row['uid'])) . BackendUtility
::translationCount($table, $row['uid'],
1589 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')
1593 if ($this->isRecordCurrentBackendUser($table, $row)) {
1594 $deleteAction = $this->spaceIcon
;
1596 $title = BackendUtility
::getRecordTitle($table, $row);
1597 $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
1599 $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
1600 $icon = $this->iconFactory
->getIcon('actions-edit-' . $actionName, Icon
::SIZE_SMALL
)->render();
1601 $linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
1602 $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
1603 . ' data-l10parent="' . htmlspecialchars($row['l10n_parent']) . '"'
1604 . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
1605 . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
1606 . '>' . $icon . '</a>';
1609 $deleteAction = $this->spaceIcon
;
1611 $this->addActionToCellGroup($cells, $deleteAction, 'delete');
1612 // "Levels" links: Moving pages into new levels...
1613 if ($permsEdit && $table == 'pages' && !$this->searchLevels
) {
1614 // Up (Paste as the page right after the current parent page)
1615 if ($this->calcPerms
& Permission
::PAGE_NEW
) {
1616 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id
;
1617 $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
1618 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
1619 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
1620 . $this->iconFactory
->getIcon('actions-move-left', Icon
::SIZE_SMALL
)->render() . '</a>';
1621 $this->addActionToCellGroup($cells, $moveLeftAction, 'moveLeft');
1623 // Down (Paste as subpage to the page right above)
1624 if ($this->currentTable
['prevUid'][$row['uid']]) {
1625 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $this->currentTable
['prevUid'][$row['uid']]));
1626 if ($localCalcPerms & Permission
::PAGE_NEW
) {
1627 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['prevUid'][$row['uid']];
1628 $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
1629 . htmlspecialchars('return jumpToUrl(' . BackendUtility
::getLinkToDataHandlerAction($params, -1) . ');')
1630 . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
1631 . $this->iconFactory
->getIcon('actions-move-right', Icon
::SIZE_SMALL
)->render() . '</a>';
1633 $moveRightAction = $this->spaceIcon
;
1636 $moveRightAction = $this->spaceIcon
;
1638 $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
1642 * @hook recStatInfoHooks: Allows to insert HTML before record icons on various places
1644 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1646 $_params = [$table, $row['uid']];
1647 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1648 $stat .= GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1650 $this->addActionToCellGroup($cells, $stat, 'stat');
1653 * @hook makeControl: Allows to change control icons of records in list-module
1654 * @usage This hook method gets passed the current $cells array as third parameter.
1655 * This array contains values for the icons/actions generated for each record in Web>List.
1656 * Each array entry is accessible by an index-key.
1657 * The order of the icons is depending on the order of those array entries.
1659 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1660 // for compatibility reason, we move all icons to the rootlevel
1661 // before calling the hooks
1662 foreach ($cells as $section => $actions) {
1663 foreach ($actions as $actionKey => $action) {
1664 $cells[$actionKey] = $action;
1667 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1668 $hookObject = GeneralUtility
::getUserObj($classData);
1669 if (!$hookObject instanceof RecordListHookInterface
) {
1670 throw new \
UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface
::class, 1195567840);
1672 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1674 // now sort icons again into primary and secondary sections
1675 // after all hooks are processed
1676 $hookCells = $cells;
1677 foreach ($hookCells as $key => $value) {
1678 if ($key === 'primary' ||
$key === 'secondary') {
1681 $this->addActionToCellGroup($cells, $value, $key);
1684 $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
1685 foreach ($cells as $classification => $actions) {
1686 $visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS
['bigControlPanel'] ?
'collapsed' : 'expanded');
1687 if ($visibilityClass === 'collapsed') {
1689 foreach ($actions as $action) {
1690 $cellOutput .= $action;
1692 $output .= ' <div class="btn-group">' .
1693 '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
1694 '<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>' .
1697 $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
1704 * Creates the clipboard panel for a single record in the listing.
1706 * @param string $table The table
1707 * @param mixed[] $row The record for which to make the clipboard panel.
1708 * @throws \UnexpectedValueException
1709 * @return string HTML table with the clipboard panel (unless disabled)
1711 public function makeClip($table, $row)
1713 // Return blank, if disabled:
1714 if (!$this->getModule()->MOD_SETTINGS
['clipBoard']) {
1718 $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon
);
1719 //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1720 $isL10nOverlay = $this->localizationView
&& $table != 'pages_language_overlay' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1721 // Return blank, if disabled:
1722 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1723 // For the "Normal" pad:
1724 if ($this->clipObj
->current
=== 'normal') {
1725 // Show copy/cut icons:
1726 $isSel = (string)$this->clipObj
->isSelected($table, $row['uid']);
1727 if ($isL10nOverlay ||
!$this->overlayEditLockPermissions($table, $row)) {
1728 $cells['copy'] = $this->spaceIcon
;
1729 $cells['cut'] = $this->spaceIcon
;
1731 $copyIcon = $this->iconFactory
->getIcon('actions-edit-copy', Icon
::SIZE_SMALL
);
1732 $cutIcon = $this->iconFactory
->getIcon('actions-edit-cut', Icon
::SIZE_SMALL
);
1734 if ($isSel === 'copy') {
1735 $copyIcon = $this->iconFactory
->getIcon('actions-edit-copy-release', Icon
::SIZE_SMALL
);
1736 } elseif ($isSel === 'cut') {
1737 $cutIcon = $this->iconFactory
->getIcon('actions-edit-cut-release', Icon
::SIZE_SMALL
);
1740 $cells['copy'] = '<a class="btn btn-default" href="#" onclick="'
1741 . htmlspecialchars('return jumpSelf(' . GeneralUtility
::quoteJSvalue($this->clipObj
->selUrlDB($table, $row['uid'], 1, ($isSel === 'copy'), ['returnUrl' => ''])) . ');')
1742 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy')) . '">'
1743 . $copyIcon->render() . '</a>';
1745 // Check permission to cut page or content
1746 if ($table == 'pages') {
1747 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $row['uid']));
1748 $permsEdit = $localCalcPerms & Permission
::PAGE_EDIT
;
1750 $permsEdit = $this->calcPerms
& Permission
::CONTENT_EDIT
;
1752 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1754 // If the listed table is 'pages' we have to request the permission settings for each page:
1755 if ($table == 'pages') {
1757 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
1758 . htmlspecialchars('return jumpSelf(' . GeneralUtility
::quoteJSvalue($this->clipObj
->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
1759 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut')) . '">'
1760 . $cutIcon->render() . '</a>';
1762 $cells['cut'] = $this->spaceIcon
;
1765 if ($table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT
) {
1766 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
1767 . htmlspecialchars('return jumpSelf(' . GeneralUtility
::quoteJSvalue($this->clipObj
->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
1768 . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut')) . '">'
1769 . $cutIcon->render() . '</a>';
1771 $cells['cut'] = $this->spaceIcon
;
1776 // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1777 // Setting name of the element in ->CBnames array:
1778 $n = $table . '|' . $row['uid'];
1779 $this->CBnames
[] = $n;
1780 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1781 $checked = $this->clipObj
->isSelected($table, $row['uid']) ?
'checked="checked" ' : '';
1782 // If the "duplicateField" value is set then select all elements which are duplicates...
1783 if ($this->duplicateField
&& isset($row[$this->duplicateField
])) {
1785 if (in_array($row[$this->duplicateField
], $this->duplicateStack
)) {
1786 $checked = 'checked="checked" ';
1788 $this->duplicateStack
[] = $row[$this->duplicateField
];
1790 // Adding the checkbox to the panel:
1791 $cells['select'] = $isL10nOverlay
1793 : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
1794 . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
1796 // Now, looking for selected elements from the current table:
1797 $elFromTable = $this->clipObj
->elFromTable($table);
1798 if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1799 // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
1800 $cells['pasteAfter'] = $isL10nOverlay ||
!$this->overlayEditLockPermissions($table, $row)
1802 : '<a class="btn btn-default t3js-modal-trigger"'
1803 . ' href="' . htmlspecialchars($this->clipObj
->pasteUrl($table, -$row['uid'])) . '"'
1804 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
1805 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
1806 . ' data-content="' . htmlspecialchars($this->clipObj
->confirmMsgText($table, $row, 'after', $elFromTable)) . '"'
1807 . ' data-severity="warning">'
1808 . $this->iconFactory
->getIcon('actions-document-paste-after', Icon
::SIZE_SMALL
)->render() . '</a>';
1810 // Now, looking for elements in general:
1811 $elFromTable = $this->clipObj
->elFromTable('');
1812 if ($table == 'pages' && !empty($elFromTable)) {
1813 $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"'
1814 . ' href="' . htmlspecialchars($this->clipObj
->pasteUrl('', $row['uid'])) . '"'
1815 . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
1816 . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
1817 . ' data-content="' . htmlspecialchars($this->clipObj
->confirmMsgText($table, $row, 'into', $elFromTable)) . '"'
1818 . ' data-severity="warning">'
1819 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render() . '</a>';
1822 * @hook makeClip: Allows to change clip-icons of records in list-module
1823 * @usage This hook method gets passed the current $cells array as third parameter.
1824 * This array contains values for the clipboard icons generated for each record in Web>List.
1825 * Each array entry is accessible by an index-key.
1826 * The order of the icons is depending on the order of those array entries.
1828 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1829 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1830 $hookObject = GeneralUtility
::getUserObj($classData);
1831 if (!$hookObject instanceof RecordListHookInterface
) {
1832 throw new \
UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface
::class, 1195567845);
1834 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1837 // Compile items into a DIV-element:
1838 return '<!-- CLIPBOARD PANEL: ' . $table . ':' . $row['uid'] . ' -->
1839 <div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1843 * Creates the HTML for a reference count for the record with the UID $uid
1844 * in the table $tableName.
1846 * @param string $tableName
1848 * @return string HTML of reference a link, will be empty if there are no
1850 protected function createReferenceHtml($tableName, $uid)
1852 $referenceCount = GeneralUtility
::makeInstance(ConnectionPool
::class)
1853 ->getConnectionForTable('sys_refindex')
1858 'ref_table' => $tableName,
1859 'ref_uid' => (int)$uid,
1864 return $this->generateReferenceToolTip(
1866 GeneralUtility
::quoteJSvalue($tableName) . ', ' . GeneralUtility
::quoteJSvalue($uid)
1871 * Creates the localization panel
1873 * @param string $table The table
1874 * @param mixed[] $row The record for which to make the localization panel.
1875 * @return string[] Array with key 0/1 with content for column 1 and 2
1877 public function makeLocalizationPanel($table, $row)
1883 // Reset translations
1884 $this->translations
= [];
1886 // Language title and icon:
1887 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
1888 // Guard clause so we can quickly return if a record is localized to "all languages"
1889 // It should only be possible to localize a record off default (uid 0)
1890 // Reasoning: The Parent is for ALL languages... why overlay with a localization?
1891 if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) {
1895 $translations = $this->translateTools
->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList
);
1896 if (is_array($translations)) {
1897 $this->translations
= $translations['translations'];
1898 // Traverse page translations and add icon for each language that does NOT yet exist:
1900 foreach ($this->pageOverlays
as $lUid_OnPage => $lsysRec) {
1901 if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
1902 $url = $this->listURL();
1903 $href = BackendUtility
::getLinkToDataHandlerAction(
1904 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1905 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1907 $language = BackendUtility
::getRecord('sys_language', $lUid_OnPage, 'title');
1908 if ($this->languageIconTitles
[$lUid_OnPage]['flagIcon']) {
1909 $lC = $this->iconFactory
->getIcon($this->languageIconTitles
[$lUid_OnPage]['flagIcon'], Icon
::SIZE_SMALL
)->render();
1911 $lC = $this->languageIconTitles
[$lUid_OnPage]['title'];
1913 $lC = '<a href="' . htmlspecialchars($href) . '" title="'
1914 . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> ';
1921 } elseif ($row['l18n_parent']) {
1922 $out[0] = ' ' . $out[0];
1928 * Creates a checkbox list for selecting fields to display from a table:
1930 * @param string $table Table name
1931 * @param bool $formFields If TRUE, form-fields will be wrapped around the table.
1932 * @return string HTML table with the selector check box (name: displayFields['.$table.'][])
1934 public function fieldSelectBox($table, $formFields = true)
1936 $lang = $this->getLanguageService();
1938 $formElements = ['', ''];
1940 $formElements = ['<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>'];
1942 // Load already selected fields, if any:
1943 $setFields = is_array($this->setFields
[$table]) ?
$this->setFields
[$table] : [];
1944 // Request fields from table:
1945 $fields = $this->makeFieldList($table, false, true);
1946 // Add pseudo "control" fields
1947 $fields[] = '_PATH_';
1948 $fields[] = '_REF_';
1949 $fields[] = '_LOCALIZATION_';
1950 $fields[] = '_CONTROL_';
1951 $fields[] = '_CLIPBOARD_';
1952 // Create a checkbox for each field:
1954 $checkAllChecked = true;
1955 foreach ($fields as $fieldName) {
1956 // Determine, if checkbox should be checked
1957 if (in_array($fieldName, $setFields, true) ||
$fieldName === $this->fieldArray
[0]) {
1958 $checked = ' checked="checked"';
1960 $checkAllChecked = false;
1964 $fieldLabel = is_array($GLOBALS['TCA'][$table]['columns'][$fieldName])
1965 ?
rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']), ':')
1967 $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
1968 . $table . '][]" value="' . $fieldName . '" ' . $checked
1969 . ($fieldName === $this->fieldArray
[0] ?
' disabled="disabled"' : '') . '></td><td class="col-title">'
1970 . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($fieldLabel) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
1972 // Table with the field selector::
1973 $content = $formElements[0] . '
1974 <input type="hidden" name="displayFields[' . $table . '][]" value="">
1975 <div class="table-fit table-scrollable">
1976 <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
1979 <th class="col-checkbox checkbox" colspan="2">
1980 <label><input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ?
' checked="checked"' : '') . '>
1981 ' . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.toggleall')) . '</label>
1986 ' . implode('', $checkboxes) . '
1990 <input type="submit" name="search" class="btn btn-default" value="'
1991 . htmlspecialchars($lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.setFields')) . '"/>
1992 ' . $formElements[1];
1993 return '<div class="fieldSelectBox">' . $content . '</div>';
1996 /*********************************
2000 *********************************/
2002 * Creates a link around $string. The link contains an onclick action
2003 * which submits the script with some clipboard action.
2004 * Currently, this is used for setting elements / delete elements.
2006 * @param string $string The HTML content to link (image/text)
2007 * @param string $table Table name
2008 * @param string $cmd Clipboard command (eg. "setCB" or "delete")
2009 * @param string $warning Warning text, if any ("delete" uses this for confirmation
2010 * @param string $title title attribute for the anchor
2011 * @return string <a> tag wrapped link.
2013 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '', $title = '')
2015 $jsCode = 'document.dblistForm.cmd.value=' . GeneralUtility
::quoteJSvalue($cmd)
2016 . ';document.dblistForm.cmd_table.value='
2017 . GeneralUtility
::quoteJSvalue($table)
2018 . ';document.dblistForm.submit();';
2021 if ($title !== '') {
2022 $attributes['title'] = $title;
2025 $attributes['class'] = 'btn btn-default t3js-modal-trigger';
2026 $attributes['data-href'] = 'javascript:' . $jsCode;
2027 $attributes['data-severity'] = 'warning';
2028 $attributes['data-title'] = $title;
2029 $attributes['data-content'] = $warning;
2031 $attributes['class'] = 'btn btn-default';
2032 $attributes['onclick'] = $jsCode . 'return false;';
2035 $attributesString = '';
2036 foreach ($attributes as $key => $value) {
2037 $attributesString .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
2039 return '<a href="#" ' . $attributesString . '>' . $string . '</a>';
2043 * Returns TRUE if a numeric clipboard pad is selected/active
2047 public function clipNumPane()
2049 return in_array('_CLIPBOARD_', $this->fieldArray
) && $this->clipObj
->current
!= 'normal';
2053 * Creates a sort-by link on the input string ($code).
2054 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
2055 * Also some fields will not be possible to sort (including if single-table-view is disabled).
2057 * @param string $code The string to link (text)
2058 * @param string $field The fieldname represented by the title ($code)
2059 * @param string $table Table name
2060 * @return string Linked $code variable
2062 public function addSortLink($code, $field, $table)
2064 // Certain circumstances just return string right away (no links):
2065 if ($field == '_CONTROL_' ||
$field == '_LOCALIZATION_' ||
$field == '_CLIPBOARD_' ||
$field == '_REF_' ||
$this->disableSingleTableView
) {
2068 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
2069 if ($field == '_PATH_') {
2072 // Create the sort link:
2073 $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
2074 . '&sortField=' . $field . '&sortRev=' . ($this->sortRev ||
$this->sortField
!= $field ?
0 : 1);
2075 $sortArrow = $this->sortField
=== $field
2076 ?
$this->iconFactory
->getIcon('status-status-sorting-' . ($this->sortRev ?
'desc' : 'asc'), Icon
::SIZE_SMALL
)->render()
2078 // Return linked field:
2079 return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
2083 * Returns the path for a certain pid
2084 * The result is cached internally for the session, thus you can call
2085 * this function as much as you like without performance problems.
2087 * @param int $pid The page id for which to get the path
2088 * @return mixed[] The path.
2090 public function recPath($pid)
2092 if (!isset($this->recPath_cache
[$pid])) {
2093 $this->recPath_cache
[$pid] = BackendUtility
::getRecordPath($pid, $this->perms_clause
, 20);
2095 return $this->recPath_cache
[$pid];
2099 * Returns TRUE if a link for creating new records should be displayed for $table
2101 * @param string $table Table name
2102 * @return bool Returns TRUE if a link for creating new records should be displayed for $table
2103 * @see \TYPO3\CMS\Backend\Controller\NewRecordController::showNewRecLink
2105 public function showNewRecLink($table)
2107 // No deny/allow tables are set:
2108 if (empty($this->allowedNewTables
) && empty($this->deniedNewTables
)) {
2111 return !in_array($table, $this->deniedNewTables
)
2112 && (empty($this->allowedNewTables
) ||
in_array($table, $this->allowedNewTables
));
2116 * Creates the "&returnUrl" parameter for links - this is used when the script links
2117 * to other scripts and passes its own URL with the link so other scripts can return to the listing again.
2118 * Uses REQUEST_URI as value.
2122 public function makeReturnUrl()
2124 return '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI'));
2127 /************************************
2129 * CSV related functions
2131 ************************************/
2133 * Initializes internal csvLines array with the header of field names
2137 protected function initCSV()
2139 $this->addHeaderRowToCSV();
2143 * Add header line with field names as CSV line
2147 protected function addHeaderRowToCSV()
2149 // Add header row, control fields will be reduced inside addToCSV()
2150 $this->addToCSV(array_combine($this->fieldArray
, $this->fieldArray
));
2154 * Adds selected columns of one table row as CSV line.
2156 * @param mixed[] $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
2159 protected function addToCSV(array $row = [])
2161 $rowReducedByControlFields = self
::removeControlFieldsFromFieldRow($row);
2162 $rowReducedToSelectedColumns = array_intersect_key($rowReducedByControlFields, array_flip($this->fieldArray
));
2163 $this->setCsvRow($rowReducedToSelectedColumns);
2167 * Remove control fields from row for CSV export
2169 * @param mixed[] $row fieldNames => fieldValues
2170 * @return mixed[] Input array reduces by control fields
2172 protected static function removeControlFieldsFromFieldRow(array $row = [])
2174 // Possible control fields in a list row
2183 return array_diff_key($row, array_flip($controlFields));
2187 * Adds input row of values to the internal csvLines array as a CSV formatted line
2189 * @param mixed[] $csvRow Array with values to be listed.
2192 public function setCsvRow($csvRow)
2194 $this->csvLines
[] = GeneralUtility
::csvValues($csvRow);
2198 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
2199 * This function exits!
2201 * @param string $prefix Filename prefix:
2202 * @return void EXITS php execution!
2204 public function outputCSV($prefix)
2206 // Setting filename:
2207 $filename = $prefix . '_' . date('dmy-Hi') . '.csv';
2208 // Creating output header:
2209 header('Content-Type: application/octet-stream');
2210 header('Content-Disposition: attachment; filename=' . $filename);
2211 // Cache-Control header is needed here to solve an issue with browser IE and
2212 // versions lower than 9. See for more information: http://support.microsoft.com/kb/323308
2213 header("Cache-Control: ''");
2214 // Printing the content of the CSV lines:
2215 echo implode(CRLF
, $this->csvLines
);
2221 * add action into correct section
2223 * @param array $cells
2224 * @param string $action
2225 * @param string $actionKey
2227 public function addActionToCellGroup(&$cells, $action, $actionKey)
2231 'view', 'edit', 'hide', 'delete', 'stat'
2234 'viewBig', 'history', 'perms', 'new', 'move', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'version'
2237 $classification = in_array($actionKey, $cellsMap['primary']) ?
'primary' : 'secondary';
2238 $cells[$classification][$actionKey] = $action;
2239 unset($cells[$actionKey]);
2243 * Check if the record represents the current backend user
2245 * @param string $table
2249 protected function isRecordCurrentBackendUser($table, $row)
2251 return $table === 'be_users' && (int)$row['uid'] === $this->getBackendUserAuthentication()->user
['uid'];
2255 * @param bool $isEditable
2257 public function setIsEditable($isEditable)
2259 $this->editable
= $isEditable;
2263 * Check if the table is readonly or editable
2264 * @param string $table
2267 public function isEditable($table)
2269 return $GLOBALS['TCA'][$table]['ctrl']['readOnly'] ||
$this->editable
;
2273 * Check if the current record is locked by editlock. Pages are locked if their editlock flag is set,
2274 * records are if they are locked themselves or if the page they are on is locked (a page’s editlock
2275 * is transitive for its content elements).
2277 * @param string $table
2279 * @param bool $editPermission
2282 protected function overlayEditLockPermissions($table, $row = [], $editPermission = true)
2284 if ($editPermission && !$this->getBackendUserAuthentication()->isAdmin()) {
2285 // If no $row is submitted we only check for general edit lock of current page (except for table "pages")
2287 return $table === 'pages' ?
true : !$this->pageRow
['editlock'];
2289 if (($table === 'pages' && $row['editlock']) ||
($table !== 'pages' && $this->pageRow
['editlock'])) {
2290 $editPermission = false;
2291 } elseif (isset($GLOBALS['TCA'][$table]['ctrl']['editlock']) && $row[$GLOBALS['TCA'][$table]['ctrl']['editlock']]) {
2292 $editPermission = false;
2295 return $editPermission;
2299 * Check whether or not the current backend user is an admin or the current page is
2300 * locked by editlock.
2304 protected function editLockPermissions()
2306 return $this->getBackendUserAuthentication()->isAdmin() ||
!$this->pageRow
['editlock'];
2310 * @return BaseScriptClass
2312 protected function getModule()
2314 return $GLOBALS['SOBE'];
2318 * @return DocumentTemplate
2320 protected function getDocumentTemplate()
2322 return $GLOBALS['TBE_TEMPLATE'];