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\DocumentTemplate
;
20 use TYPO3\CMS\Core\Database\DatabaseConnection
;
21 use TYPO3\CMS\Core\Imaging\Icon
;
22 use TYPO3\CMS\Core\Imaging\IconFactory
;
23 use TYPO3\CMS\Core\Messaging\FlashMessage
;
24 use TYPO3\CMS\Core\Messaging\FlashMessageService
;
25 use TYPO3\CMS\Core\Type\Bitmask\Permission
;
26 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility
;
27 use TYPO3\CMS\Core\Utility\GeneralUtility
;
28 use TYPO3\CMS\Backend\Utility\BackendUtility
;
29 use TYPO3\CMS\Frontend\Page\PageRepository
;
32 * Class for rendering of Web>List module
34 class DatabaseRecordList
extends AbstractDatabaseRecordList
{
41 * Used to indicate which tables (values in the array) that can have a
42 * create-new-record link. If the array is empty, all tables are allowed.
46 public $allowedNewTables = array();
49 * Used to indicate which tables (values in the array) that cannot have a
50 * create-new-record link. If the array is empty, all tables are allowed.
54 public $deniedNewTables = array();
57 * If TRUE, the control panel will contain links to the create-new wizards for
58 * pages and tt_content elements (normally, the link goes to just creatinga new
59 * element without the wizards!).
63 public $newWizards = FALSE
;
66 * If TRUE, will disable the rendering of clipboard + control panels.
70 public $dontShowClipControlPanels = FALSE
;
73 * If TRUE, will show the clipboard in the field list.
77 public $showClipboard = FALSE
;
80 * If TRUE, will DISABLE all control panels in lists. (Takes precedence)
84 public $noControlPanels = FALSE
;
87 * If TRUE, clickmenus will be rendered
91 public $clickMenuEnabled = TRUE
;
94 * Count of record rows in view
98 public $totalRowCount;
101 * Space icon used for alignment
108 * Disable single table view
112 public $disableSingleTableView = FALSE
;
119 * Set to the page record (see writeTop())
123 public $pageRow = array();
126 * Used to accumulate CSV lines for CSV export.
130 protected $csvLines = array();
133 * If set, the listing is returned as CSV instead.
137 public $csvOutput = FALSE
;
142 * @var \TYPO3\CMS\Backend\Clipboard\Clipboard
147 * Tracking names of elements (for clipboard use)
151 public $CBnames = array();
154 * [$tablename][$uid] = number of references to this record
158 protected $referenceCount = array();
161 * Translations of the current record
165 public $translations;
168 * select fields for the query which fetches the translations of the current
173 public $selFieldList;
181 * Injected by RecordList
188 * If defined the records are editable
192 protected $editable = TRUE
;
197 protected $iconFactory;
202 public function __construct() {
203 parent
::__construct();
204 $this->iconFactory
= GeneralUtility
::makeInstance(IconFactory
::class);
208 * Create the panel of buttons for submitting the form or otherwise perform
211 * @return string[] All available buttons as an assoc. array
213 public function getButtons() {
214 $module = $this->getModule();
215 $backendUser = $this->getBackendUserAuthentication();
216 $lang = $this->getLanguageService();
233 // Get users permissions for this page record:
234 $localCalcPerms = $backendUser->calcPerms($this->pageRow
);
236 if ((string)$this->id
=== '') {
237 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module_noId');
238 } elseif (!$this->id
) {
239 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module_root');
241 $buttons['csh'] = BackendUtility
::cshItem('xMOD_csh_corebe', 'list_module');
243 if (isset($this->id
)) {
244 // View Exclude doktypes 254,255 Configuration:
245 // mod.web_list.noViewWithDokTypes = 254,255
246 if (isset($module->modTSconfig
['properties']['noViewWithDokTypes'])) {
247 $noViewDokTypes = GeneralUtility
::trimExplode(',', $module->modTSconfig
['properties']['noViewWithDokTypes'], TRUE
);
249 //default exclusion: doktype 254 (folder), 255 (recycler)
250 $noViewDokTypes = array(
251 PageRepository
::DOKTYPE_SYSFOLDER
,
252 PageRepository
::DOKTYPE_RECYCLER
255 if (!in_array($this->pageRow
['doktype'], $noViewDokTypes)) {
256 $onClick = htmlspecialchars(BackendUtility
::viewOnClick($this->id
, '', BackendUtility
::BEgetRootLine($this->id
)));
257 $buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
258 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE
) . '">'
259 . $this->iconFactory
->getIcon('actions-document-view', Icon
::SIZE_SMALL
)->render() . '</a>';
261 // New record on pages that are not locked by editlock
262 if (!$module->modTSconfig
['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
263 $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility
::quoteJSvalue(BackendUtility
::getModuleUrl('db_new', ['id' => $this->id
])) . ');');
264 $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
265 . $lang->getLL('newRecordGeneral', TRUE
) . '">'
266 . $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
)->render() . '</a>';
268 // If edit permissions are set, see
269 // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
270 if ($localCalcPerms & Permission
::PAGE_EDIT
&& !empty($this->id
) && $this->editLockPermissions()) {
272 $params = '&edit[pages][' . $this->pageRow
['uid'] . ']=edit';
273 $onClick = htmlspecialchars(BackendUtility
::editOnClick($params, '', -1));
274 $buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . $lang->getLL('editPage', TRUE
) . '">'
275 . $this->iconFactory
->getIcon('actions-page-open', Icon
::SIZE_SMALL
)->render()
279 if (($localCalcPerms & Permission
::PAGE_NEW ||
$localCalcPerms & Permission
::CONTENT_EDIT
) && $this->editLockPermissions()) {
280 $elFromTable = $this->clipObj
->elFromTable('');
281 if (!empty($elFromTable)) {
282 $onClick = htmlspecialchars(('return ' . $this->clipObj
->confirmMsg('pages', $this->pageRow
, 'into', $elFromTable)));
283 $buttons['paste'] = '<a href="' . htmlspecialchars($this->clipObj
->pasteUrl('', $this->id
))
284 . '" onclick="' . $onClick . '" title="' . $lang->getLL('clip_paste', TRUE
) . '">'
285 . $this->iconFactory
->getIcon('actions-document-paste-after', Icon
::SIZE_SMALL
)->render() . '</a>';
289 $buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
290 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.clear_cache', TRUE
) . '">'
291 . $this->iconFactory
->getIcon('actions-system-cache-clear', Icon
::SIZE_SMALL
)->render() . '</a>';
293 $this->table
&& (!isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
294 ||
(isset($module->modTSconfig
['properties']['noExportRecordsLinks'])
295 && !$module->modTSconfig
['properties']['noExportRecordsLinks']))
298 $buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
299 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.csv', TRUE
) . '">'
300 . $this->iconFactory
->getIcon('actions-document-export-csv', Icon
::SIZE_SMALL
)->render() . '</a>';
302 if (ExtensionManagementUtility
::isLoaded('impexp')) {
303 $url = BackendUtility
::getModuleUrl('xMOD_tximpexp', array('tx_impexp[action]' => 'export'));
304 $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
305 . rawurlencode($this->table
. ':' . $this->id
)) . '" title="'
306 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.export', TRUE
) . '">'
307 . $this->iconFactory
->getIcon('actions-document-export-t3d', Icon
::SIZE_SMALL
)->render() . '</a>';
311 $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
312 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.reload', TRUE
) . '">'
313 . $this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
)->render() . '</a>';
315 if ($backendUser->mayMakeShortcut()) {
316 $buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
317 'id, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
318 implode(',', array_keys($this->MOD_MENU
)),
323 if ($this->returnUrl
) {
324 $href = htmlspecialchars(GeneralUtility
::linkThisUrl($this->returnUrl
, array('id' => $this->id
)));
325 $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
326 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.goBack', TRUE
) . '">'
327 . $this->iconFactory
->getIcon('actions-view-go-back', Icon
::SIZE_SMALL
)->render() . '</a>';
334 * Creates the listing of records from a single table
336 * @param string $table Table name
337 * @param int $id Page id
338 * @param string $rowList List of fields to show in the listing. Pseudo fields will be added including the record header.
339 * @throws \UnexpectedValueException
340 * @return string HTML table with the listing for the record.
342 public function getTable($table, $id, $rowList = '') {
343 $rowListArray = GeneralUtility
::trimExplode(',', $rowList, TRUE
);
344 // if no columns have been specified, show description (if configured)
345 if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
346 array_push($rowListArray, $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']);
348 $backendUser = $this->getBackendUserAuthentication();
349 $lang = $this->getLanguageService();
350 $db = $this->getDatabaseConnection();
353 $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
354 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
355 $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
356 && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
357 && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
358 $tableCollapsed = (bool
)$this->tablesCollapsed
[$table];
359 // prepare space icon
360 $this->spaceIcon
= '<span class="btn btn-default disabled">' . $this->iconFactory
->getIcon('empty-empty', Icon
::SIZE_SMALL
)->render() . '</span>';
361 // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
362 $this->fieldArray
= array();
365 $this->fieldArray
[] = $titleCol;
367 if (!GeneralUtility
::inList($rowList, '_CONTROL_')) {
368 $this->fieldArray
[] = '_CONTROL_';
371 if ($this->showClipboard
) {
372 $this->fieldArray
[] = '_CLIPBOARD_';
375 if (!$this->dontShowClipControlPanels
) {
376 $this->fieldArray
[] = '_REF_';
379 if ($this->searchLevels
) {
380 $this->fieldArray
[] = '_PATH_';
383 if ($this->localizationView
&& $l10nEnabled) {
384 $this->fieldArray
[] = '_LOCALIZATION_';
385 $this->fieldArray
[] = '_LOCALIZATION_b';
387 ' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '<=0
389 ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
393 $this->fieldArray
= array_unique(array_merge($this->fieldArray
, $rowListArray));
394 if ($this->noControlPanels
) {
395 $tempArray = array_flip($this->fieldArray
);
396 unset($tempArray['_CONTROL_']);
397 unset($tempArray['_CLIPBOARD_']);
398 $this->fieldArray
= array_keys($tempArray);
400 // Creating the list of fields to include in the SQL query:
401 $selectFields = $this->fieldArray
;
402 $selectFields[] = 'uid';
403 $selectFields[] = 'pid';
404 // adding column for thumbnails
406 $selectFields[] = $thumbsCol;
408 if ($table == 'pages') {
409 $selectFields[] = 'module';
410 $selectFields[] = 'extendToSubpages';
411 $selectFields[] = 'nav_hide';
412 $selectFields[] = 'doktype';
413 $selectFields[] = 'shortcut';
414 $selectFields[] = 'shortcut_mode';
415 $selectFields[] = 'mount_pid';
417 if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
418 $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
420 foreach(array('type', 'typeicon_column', 'editlock') as $field) {
421 if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
422 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
425 if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
426 $selectFields[] = 't3ver_id';
427 $selectFields[] = 't3ver_state';
428 $selectFields[] = 't3ver_wsid';
431 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
432 $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
434 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
435 $selectFields = array_merge(
437 GeneralUtility
::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], TRUE
)
441 $selectFields = array_unique($selectFields);
442 $fieldListFields = $this->makeFieldList($table, 1);
443 if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
444 $message = sprintf($lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessage', TRUE
), $table, $table);
445 $messageTitle = $lang->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle', TRUE
);
446 /** @var FlashMessage $flashMessage */
447 $flashMessage = GeneralUtility
::makeInstance(
451 FlashMessage
::WARNING
,
454 /** @var $flashMessageService FlashMessageService */
455 $flashMessageService = GeneralUtility
::makeInstance(FlashMessageService
::class);
456 /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
457 $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
458 $defaultFlashMessageQueue->enqueue($flashMessage);
460 // Making sure that the fields in the field-list ARE in the field-list from TCA!
461 $selectFields = array_intersect($selectFields, $fieldListFields);
462 // Implode it into a list of fields for the SQL-statement.
463 $selFieldList = implode(',', $selectFields);
464 $this->selFieldList
= $selFieldList;
465 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
466 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
467 $hookObject = GeneralUtility
::getUserObj($classData);
468 if (!$hookObject instanceof RecordListGetTableHookInterface
) {
469 throw new \
UnexpectedValueException('$hookObject must implement interface ' . RecordListGetTableHookInterface
::class, 1195114460);
471 $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
474 // Create the SQL query for selecting the elements in the listing:
475 // do not do paging when outputting as CSV
476 if ($this->csvOutput
) {
479 if ($this->firstElementNumber
> 2 && $this->iLimit
> 0) {
480 // Get the two previous rows for sorting if displaying page > 1
481 $this->firstElementNumber
= $this->firstElementNumber
- 2;
482 $this->iLimit
= $this->iLimit +
2;
483 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
484 $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
485 $this->firstElementNumber
= $this->firstElementNumber +
2;
486 $this->iLimit
= $this->iLimit
- 2;
488 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
489 $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
492 // Finding the total amount of records on the page
493 // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
494 $this->setTotalItems($queryParts);
501 $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode
&& !$this->table
;
502 // If the count query returned any number of records, we perform the real query,
503 // selecting records.
504 if ($this->totalItems
) {
505 // Fetch records only if not in single table mode
506 if ($listOnlyInSingleTableMode) {
507 $dbCount = $this->totalItems
;
509 // Set the showLimit to the number of records when outputting as CSV
510 if ($this->csvOutput
) {
511 $this->showLimit
= $this->totalItems
;
512 $this->iLimit
= $this->totalItems
;
514 $result = $db->exec_SELECT_queryArray($queryParts);
515 $dbCount = $db->sql_num_rows($result);
518 // If any records was selected, render the list:
520 $tableTitle = $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE
);
521 if ($tableTitle === '') {
522 $tableTitle = $table;
524 // Header line is drawn
526 if ($this->disableSingleTableView
) {
527 $theData[$titleCol] = '<span class="c-table">' . BackendUtility
::wrapInHelp($table, '', $tableTitle)
528 . '</span> (<span class="t3js-table-total-items">' . $this->totalItems
. '</span>)';
531 ?
'<span title="' . $lang->getLL('contractView', TRUE
) . '">' . $this->iconFactory
->getIcon('actions-view-table-collapse', Icon
::SIZE_SMALL
)->render() . '</span>'
532 : '<span title="' . $lang->getLL('expandView', TRUE
) . '">' . $this->iconFactory
->getIcon('actions-view-table-expand', Icon
::SIZE_SMALL
)->render() . '</span>';
533 $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems
. '</span>) ' . $icon);
535 if ($listOnlyInSingleTableMode) {
536 $tableHeader .= BackendUtility
::wrapInHelp($table, '', $theData[$titleCol]);
538 // Render collapse button if in multi table mode
541 $href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ?
'0' : '1')));
542 $title = $tableCollapsed
543 ?
$lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.expandTable', TRUE
)
544 : $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.collapseTable', TRUE
);
545 $icon = '<span class="collapseIcon">' . $this->iconFactory
->getIcon(($tableCollapsed ?
'actions-view-list-expand' : 'actions-view-list-collapse'), Icon
::SIZE_SMALL
)->render() . '</span>';
546 $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>';
548 $tableHeader .= $theData[$titleCol] . $collapseIcon;
550 // Render table rows only if in multi table view or if in single table view
552 if (!$listOnlyInSingleTableMode ||
$this->table
) {
553 // Fixing an order table for sortby tables
554 $this->currentTable
= array();
555 $currentIdList = array();
556 $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField
;
559 // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
560 if ($this->firstElementNumber
> 2 && $this->iLimit
> 0) {
561 $row = $db->sql_fetch_assoc($result);
562 $prevPrevUid = -((int)$row['uid']);
563 $row = $db->sql_fetch_assoc($result);
564 $prevUid = $row['uid'];
567 // Accumulate rows here
568 while ($row = $db->sql_fetch_assoc($result)) {
569 if (!$this->isRowListingConditionFulfilled($table, $row)) {
572 // In offline workspace, look for alternative record:
573 BackendUtility
::workspaceOL($table, $row, $backendUser->workspace
, TRUE
);
574 if (is_array($row)) {
576 $currentIdList[] = $row['uid'];
579 $this->currentTable
['prev'][$row['uid']] = $prevPrevUid;
580 $this->currentTable
['next'][$prevUid] = '-' . $row['uid'];
581 $this->currentTable
['prevUid'][$row['uid']] = $prevUid;
583 $prevPrevUid = isset($this->currentTable
['prev'][$row['uid']]) ?
-$prevUid : $row['pid'];
584 $prevUid = $row['uid'];
588 $db->sql_free_result($result);
589 $this->totalRowCount
= count($accRows);
591 if ($this->csvOutput
) {
595 $this->CBnames
= array();
596 $this->duplicateStack
= array();
597 $this->eCounter
= $this->firstElementNumber
;
599 foreach ($accRows as $row) {
600 // Render item row if counter < limit
601 if ($cc < $this->iLimit
) {
603 $this->translations
= FALSE
;
604 $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
605 // If localization view is enabled it means that the selected records are
606 // either default or All language and here we will not select translations
607 // which point to the main record:
608 if ($this->localizationView
&& $l10nEnabled) {
609 // For each available translation, render the record:
610 if (is_array($this->translations
)) {
611 foreach ($this->translations
as $lRow) {
612 // $lRow isn't always what we want - if record was moved we've to work with the
613 // placeholder records otherwise the list is messed up a bit
614 if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
615 $where = 't3ver_move_id="' . (int)$lRow['uid'] . '" AND pid="' . $row['_MOVE_PLH_pid']
616 . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . BackendUtility
::deleteClause($table);
617 $tmpRow = BackendUtility
::getRecordRaw($table, $where, $selFieldList);
618 $lRow = is_array($tmpRow) ?
$tmpRow : $lRow;
620 // In offline workspace, look for alternative record:
621 BackendUtility
::workspaceOL($table, $lRow, $backendUser->workspace
, TRUE
);
622 if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
623 $currentIdList[] = $lRow['uid'];
624 $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
630 // Counter of total rows incremented:
633 // Record navigation is added to the beginning and end of the table if in single
636 $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
638 // Show that there are more records than shown
639 if ($this->totalItems
> $this->itemsLimitPerTable
) {
640 $countOnFirstPage = $this->totalItems
> $this->itemsLimitSingleTable ?
$this->itemsLimitSingleTable
: $this->totalItems
;
641 $hasMore = $this->totalItems
> $this->itemsLimitSingleTable
;
642 $colspan = $this->showIcon ?
count($this->fieldArray
) +
1 : count($this->fieldArray
);
643 $rowOutput .= '<tr><td colspan="' . $colspan . '">
644 <a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '" class="btn btn-default">'
645 . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ?
'+' : '') . ']</i></a>
649 // The header row for the table is now created:
650 $out .= $this->renderListHeader($table, $currentIdList);
653 $collapseClass = $tableCollapsed && !$this->table ?
'collapse' : 'collapse in';
654 $dataState = $tableCollapsed && !$this->table ?
'collapsed' : 'expanded';
656 // The list of records is added after the header:
658 // ... and it is all wrapped in a table:
664 DB listing of elements: "' . htmlspecialchars($table) . '"
666 <div class="panel panel-space panel-default">
667 <div class="panel-heading">
670 <div class="table-fit ' . $collapseClass . '" id="recordlist-' . htmlspecialchars($table) . '" data-state="' . $dataState . '">
671 <table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ?
' typo3-dblist-overview' : '') . '">
678 // This ends the page with exit.
679 if ($this->csvOutput
) {
680 $this->outputCSV($table);
688 * Check if all row listing conditions are fulfilled.
690 * This function serves as a dummy method to be overriden in extending classes.
692 * @param string $table Table name
693 * @param string[] $row Record
694 * @return bool True, if all conditions are fulfilled.
696 protected function isRowListingConditionFulfilled($table, $row) {
701 * Rendering a single row for the list
703 * @param string $table Table name
704 * @param mixed[] $row Current record
705 * @param int $cc Counter, counting for each time an element is rendered (used for alternating colors)
706 * @param string $titleCol Table field (column) where header value is found
707 * @param string $thumbsCol Table field (column) where (possible) thumbnails can be found
708 * @param int $indent Indent from left.
709 * @return string Table row for the element
713 public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0) {
714 if (!is_array($row)) {
719 // If in search mode, make sure the preview will show the correct page
720 if ((string)$this->searchString
!== '') {
721 $id_orig = $this->id
;
722 $this->id
= $row['pid'];
724 // Add special classes for first and last row
726 if ($cc == 1 && $indent == 0) {
727 $rowSpecial .= ' firstcol';
729 if ($cc == $this->totalRowCount ||
$cc == $this->iLimit
) {
730 $rowSpecial .= ' lastcol';
733 $row_bgColor = ' class="' . $rowSpecial . '"';
735 // Overriding with versions background color if any:
736 $row_bgColor = $row['_CSSCLASS'] ?
' class="' . $row['_CSSCLASS'] . '"' : $row_bgColor;
739 // The icon with link
740 $altText = BackendUtility
::getRecordIconAltText($row, $table);
741 $additionalStyle = $indent ?
' style="margin-left: ' . $indent . 'px;"' : '';
742 $iconImg = '<span title="' . $altText . '" ' . $additionalStyle . '>'
743 . $this->iconFactory
->getIconForRecord($table, $row, Icon
::SIZE_SMALL
)->render()
745 $theIcon = $this->clickMenuEnabled ?
$this->getModule()->doc
->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
746 // Preparing and getting the data-array
748 $localizationMarkerClass = '';
749 foreach ($this->fieldArray
as $fCol) {
750 if ($fCol == $titleCol) {
751 $recTitle = BackendUtility
::getRecordTitle($table, $row, FALSE
, TRUE
);
753 // If the record is edit-locked by another user, we will show a little warning sign:
754 $lockInfo = BackendUtility
::isRecordLocked($table, $row['uid']);
756 $warning = '<a href="#" onclick="alert('
757 . GeneralUtility
::quoteJSvalue($lockInfo['msg']) . '); return false;" title="'
758 . htmlspecialchars($lockInfo['msg']) . '">'
759 . $this->iconFactory
->getIcon('status-warning-in-use', Icon
::SIZE_SMALL
)->render() . '</a>';
761 $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
762 // Render thumbnails, if:
763 // - a thumbnail column exists
764 // - there is content in it
765 // - the thumbnail column is visible for the current type
767 if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
768 $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
769 $type = $row[$typeColumn];
771 // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
772 // if 0 doesn't exist)
773 if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
774 $type = isset($GLOBALS['TCA'][$table]['types'][0]) ?
0 : 1;
776 $visibleColumns = $GLOBALS['TCA'][$table]['types'][$type]['showitem'];
779 trim($row[$thumbsCol]) &&
780 preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
782 $theData[$fCol] .= '<br />' . $this->thumbCode($row, $table, $thumbsCol);
785 isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
786 && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
787 && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
789 // It's a translated record with a language parent
790 $localizationMarkerClass = ' localization';
792 } elseif ($fCol == 'pid') {
793 $theData[$fCol] = $row[$fCol];
794 } elseif ($fCol == '_PATH_') {
795 $theData[$fCol] = $this->recPath($row['pid']);
796 } elseif ($fCol == '_REF_') {
797 $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
798 } elseif ($fCol == '_CONTROL_') {
799 $theData[$fCol] = $this->makeControl($table, $row);
800 } elseif ($fCol == '_CLIPBOARD_') {
801 $theData[$fCol] = $this->makeClip($table, $row);
802 } elseif ($fCol == '_LOCALIZATION_') {
803 list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
804 $theData[$fCol] = $lC1;
805 $theData[$fCol . 'b'] = $lC2;
806 } elseif ($fCol == '_LOCALIZATION_b') {
807 // deliberately empty
809 $pageId = $table === 'pages' ?
$row['uid'] : $row['pid'];
810 $tmpProc = BackendUtility
::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], TRUE
, $pageId);
811 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
812 if ($this->csvOutput
) {
813 $row[$fCol] = BackendUtility
::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
817 // Reset the ID if it was overwritten
818 if ((string)$this->searchString
!== '') {
819 $this->id
= $id_orig;
821 // Add row to CSV list:
822 if ($this->csvOutput
) {
823 $this->addToCSV($row, $table);
825 // Add classes to table cells
826 $this->addElement_tdCssClass
[$titleCol] = 'col-title' . $localizationMarkerClass;
827 $this->addElement_tdCssClass
['_CONTROL_'] = 'col-control';
828 if ($this->getModule()->MOD_SETTINGS
['clipBoard']) {
829 $this->addElement_tdCssClass
['_CLIPBOARD_'] = 'col-clipboard';
831 $this->addElement_tdCssClass
['_PATH_'] = 'col-path';
832 $this->addElement_tdCssClass
['_LOCALIZATION_'] = 'col-localizationa';
833 $this->addElement_tdCssClass
['_LOCALIZATION_b'] = 'col-localizationb';
834 // Create element in table cells:
835 $theData['uid'] = $row['uid'];
837 isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
838 && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
839 && !isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'])
841 $theData['parent'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
843 $rowOutput .= $this->addelement(1, $theIcon, $theData, $row_bgColor);
844 // Finally, return table row element:
849 * Gets the number of records referencing the record with the UID $uid in
850 * the table $tableName.
852 * @param string $tableName
854 * @return int The number of references to record $uid in table
856 protected function getReferenceCount($tableName, $uid) {
857 $db = $this->getDatabaseConnection();
858 if (!isset($this->referenceCount
[$tableName][$uid])) {
859 $where = 'ref_table = ' . $db->fullQuoteStr($tableName, 'sys_refindex')
860 . ' AND ref_uid = ' . $uid . ' AND deleted = 0';
861 $numberOfReferences = $db->exec_SELECTcountRows('*', 'sys_refindex', $where);
862 $this->referenceCount
[$tableName][$uid] = $numberOfReferences;
864 return $this->referenceCount
[$tableName][$uid];
868 * Rendering the header row for a table
870 * @param string $table Table name
871 * @param int[] $currentIdList Array of the currently displayed uids of the table
872 * @throws \UnexpectedValueException
873 * @return string Header table row
877 public function renderListHeader($table, $currentIdList) {
878 $lang = $this->getLanguageService();
882 // Traverse the fields:
883 foreach ($this->fieldArray
as $fCol) {
884 // Calculate users permissions to edit records in the table:
885 $permsEdit = $this->calcPerms
& ($table == 'pages' ?
2 : 16) && $this->overlayEditLockPermissions($table);
886 switch ((string)$fCol) {
889 $theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._PATH_', TRUE
) . ']</i>';
893 $theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_mod_file_list.xlf:c__REF_', TRUE
) . ']</i>';
895 case '_LOCALIZATION_':
897 $theData[$fCol] = '<i>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels._LOCALIZATION_', TRUE
) . ']</i>';
899 case '_LOCALIZATION_b':
901 $theData[$fCol] = $lang->getLL('Localize', TRUE
);
904 if (!$this->getModule()->MOD_SETTINGS
['clipBoard']) {
909 // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
910 // then display the "paste into" icon:
911 $elFromTable = $this->clipObj
->elFromTable($table);
912 if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
913 $href = htmlspecialchars($this->clipObj
->pasteUrl($table, $this->id
));
914 $onClick = htmlspecialchars('return ' . $this->clipObj
->confirmMsg('pages', $this->pageRow
, 'into', $elFromTable));
915 $cells['pasteAfter'] = '<a class="btn btn-default" href="' . $href . '" onclick="' . $onClick
916 . '" title="' . $lang->getLL('clip_paste', TRUE
) . '">'
917 . $this->iconFactory
->getIcon('actions-document-paste-after', Icon
::SIZE_SMALL
)->render() . '</a>';
919 // If the numeric clipboard pads are enabled, display the control icons for that:
920 if ($this->clipObj
->current
!= 'normal') {
921 // The "select" link:
922 $spriteIcon = '<span title="' . $lang->getLL('clip_selectMarked', TRUE
) . '">'
923 . $this->iconFactory
->getIcon('actions-edit-copy', Icon
::SIZE_SMALL
)->render()
925 $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB');
926 // The "edit marked" link:
927 $editIdList = implode(',', $currentIdList);
928 $editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
929 $params = 'edit[' . $table . '][' . $editIdList . ']=edit';
930 $onClick = BackendUtility
::editOnClick('', '', -1);
931 $onClickArray = explode('?', $onClick, 2);
932 $lastElement = array_pop($onClickArray);
933 array_push($onClickArray, $params . '&' . $lastElement);
934 $onClick = implode('?', $onClickArray);
935 $cells['edit'] = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
936 . $lang->getLL('clip_editMarked', TRUE
) . '">'
937 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
938 // The "Delete marked" link:
939 $cells['delete'] = $this->linkClipboardHeaderIcon(
940 '<span title="' . $lang->getLL('clip_deleteMarked', TRUE
) . '">' . $this->iconFactory
->getIcon('actions-edit-delete', Icon
::SIZE_SMALL
)->render() . '</span>',
943 sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']))
945 // The "Select all" link:
946 $onClick = htmlspecialchars(('checkOffCB(\'' . implode(',', $this->CBnames
) . '\', this); return false;'));
947 $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
948 . $lang->getLL('clip_markRecords', TRUE
) . '">'
949 . $this->iconFactory
->getIcon('actions-document-select', Icon
::SIZE_SMALL
)->render() . '</a>';
951 $cells['empty'] = '';
954 * @hook renderListHeaderActions: Allows to change the clipboard icons of the Web>List table headers
955 * @usage Above each listed table in Web>List a header row is shown.
956 * This hook allows to modify the icons responsible for the clipboard functions
957 * (shown above the clipboard checkboxes when a clipboard other than "Normal" is selected),
958 * or other "Action" functions which perform operations on the listed records.
960 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
961 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
962 $hookObject = GeneralUtility
::getUserObj($classData);
963 if (!$hookObject instanceof RecordListHookInterface
) {
964 throw new \
UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface
::class, 1195567850);
966 $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
969 $theData[$fCol] = '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
973 if ($this->isEditable($table)) {
974 // If new records can be created on this page, add links:
975 $permsAdditional = ($table === 'pages' ?
8 : 16);
976 if ($this->calcPerms
& $permsAdditional && $this->showNewRecLink($table)) {
977 $spriteIcon = $table === 'pages'
978 ?
$this->iconFactory
->getIcon('actions-page-new', Icon
::SIZE_SMALL
)
979 : $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
);
980 if ($table === 'tt_content' && $this->newWizards
) {
981 // If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
982 $tmpTSc = BackendUtility
::getModTSconfig($this->pageinfo
['uid'], 'mod.web_list');
983 $tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
984 $newContentWizScriptPath = ExtensionManagementUtility
::isLoaded($tmpTSc)
985 ? ExtensionManagementUtility
::extRelPath($tmpTSc) . 'mod1/db_new_content_el.php?id=' . $this->id
986 : BackendUtility
::getModuleUrl('new_content_element', array('id' => $this->id
));
988 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue($newContentWizScriptPath) . ');';
989 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
990 . $lang->getLL('new', TRUE
) . '">' . $spriteIcon->render() . '</a>';
991 } elseif ($table == 'pages' && $this->newWizards
) {
992 $parameters = ['id' => $this->id
, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility
::getIndpEnv('REQUEST_URI')];
993 $href = BackendUtility
::getModuleUrl('db_new', $parameters);
994 $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . $lang->getLL('new', TRUE
) . '">'
995 . $spriteIcon->render() . '</a>';
997 $params = '&edit[' . $table . '][' . $this->id
. ']=new';
998 if ($table == 'pages_language_overlay') {
999 $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRow
['doktype'];
1001 $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1002 . '" title="' . $lang->getLL('new', TRUE
) . '">' . $spriteIcon->render() . '</a>';
1005 // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1006 if ($permsEdit && $this->table
&& is_array($currentIdList)) {
1007 $editIdList = implode(',', $currentIdList);
1008 if ($this->clipNumPane()) {
1009 $editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
1011 $params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . implode(',', $this->fieldArray
);
1012 $icon .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1013 . '" title="' . $lang->getLL('editShownColumns', TRUE
) . '">'
1014 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1015 $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1017 // Add an empty entry, so column count fits again after moving this into $icon
1018 $theData[$fCol] = ' ';
1022 // Regular fields header:
1023 $theData[$fCol] = '';
1025 // Check if $fCol is really a field and get the label and remove the colons
1027 $sortLabel = BackendUtility
::getItemLabel($table, $fCol);
1028 if ($sortLabel !== NULL
) {
1029 $sortLabel = $lang->sL($sortLabel, TRUE
);
1030 $sortLabel = rtrim(trim($sortLabel), ':');
1032 // No TCA field, only output the $fCol variable with square brackets []
1033 $sortLabel = htmlspecialchars($fCol);
1034 $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1037 if ($this->table
&& is_array($currentIdList)) {
1038 // If the numeric clipboard pads are selected, show duplicate sorting link:
1039 if ($this->clipNumPane()) {
1040 $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', -1) . '&duplicateField=' . $fCol)
1041 . '" title="' . $lang->getLL('clip_duplicates', TRUE
) . '">'
1042 . $this->iconFactory
->getIcon('actions-document-duplicates-select', Icon
::SIZE_SMALL
)->render() . '</a>';
1044 // If the table can be edited, add link for editing THIS field for all
1046 if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1047 $editIdList = implode(',', $currentIdList);
1048 if ($this->clipNumPane()) {
1049 $editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
1051 $params = '&edit[' . $table . '][' . $editIdList . ']=edit&columnsOnly=' . $fCol;
1052 $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1053 $theData[$fCol] .= '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1054 . '" title="' . htmlspecialchars($iTitle) . '">'
1055 . $this->iconFactory
->getIcon('actions-document-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1057 if(strlen($theData[$fCol]) > 0){
1058 $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1061 $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1065 * @hook renderListHeader: Allows to change the contents of columns/cells of the Web>List table headers
1066 * @usage Above each listed table in Web>List a header row is shown.
1067 * Containing the labels of all shown fields and additional icons to create new records for this
1068 * table or perform special clipboard tasks like mark and copy all listed records to clipboard, etc.
1070 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1071 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1072 $hookObject = GeneralUtility
::getUserObj($classData);
1073 if (!$hookObject instanceof RecordListHookInterface
) {
1074 throw new \
UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface
::class, 1195567855);
1076 $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1081 // Create and return header table row:
1082 return '<thead>' . $this->addelement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1086 * Get pointer for first element on the page
1088 * @param int $page Page number starting with 1
1089 * @return int Pointer to first element on the page (starting with 0)
1091 protected function getPointerForPage($page) {
1092 return ($page - 1) * $this->iLimit
;
1096 * Creates a page browser for tables with many records
1098 * @param string $renderPart Distinguish between 'top' and 'bottom' part of the navigation (above or below the records)
1099 * @return string Navigation HTML
1101 protected function renderListNavigation($renderPart = 'top') {
1102 $totalPages = ceil($this->totalItems
/ $this->iLimit
);
1103 // Show page selector if not all records fit into one page
1104 if ($totalPages <= 1) {
1108 $listURL = $this->listURL('', $this->table
);
1110 // 0 = first element
1111 $currentPage = floor($this->firstElementNumber
/ $this->iLimit
) +
1;
1112 // Compile first, previous, next, last and refresh buttons
1113 if ($currentPage > 1) {
1114 $labelFirst = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:first', TRUE
);
1115 $labelPrevious = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:previous', TRUE
);
1116 $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1117 . $this->iconFactory
->getIcon('actions-view-paging-first', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1118 $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1119 . $this->iconFactory
->getIcon('actions-view-paging-previous', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1121 $first = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-first', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1122 $previous = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-previous', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1124 if ($currentPage < $totalPages) {
1125 $labelNext = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:next', TRUE
);
1126 $labelLast = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:last', TRUE
);
1127 $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage +
1) . '" title="' . $labelNext . '">'
1128 . $this->iconFactory
->getIcon('actions-view-paging-next', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1129 $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1130 . $this->iconFactory
->getIcon('actions-view-paging-last', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1132 $next = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-next', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1133 $last = '<li class="disabled"><span>' . $this->iconFactory
->getIcon('actions-view-paging-last', Icon
::SIZE_SMALL
)->render() . '</span></li>';
1135 $reload = '<li><a href="#" onclick="document.dblistForm.action=\'' . $listURL
1136 . '&pointer=\'+calculatePointer(document.getElementById(\'jumpPage-' . $renderPart
1137 . '\').value); document.dblistForm.submit(); return true;" title="'
1138 . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_common.xlf:reload', TRUE
) . '">'
1139 . $this->iconFactory
->getIcon('actions-refresh', Icon
::SIZE_SMALL
)->render() . '</a></li>';
1140 if ($renderPart === 'top') {
1141 // Add js to traverse a page select input to a pointer value
1143 <script type="text/javascript">
1145 function calculatePointer(page) {
1146 if (page > ' . $totalPages . ') {
1147 page = ' . $totalPages . ';
1152 return (page - 1) * ' . $this->iLimit
. ';
1158 $pageNumberInput = '
1159 <input type="text" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1160 . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=\'' . $listURL
1161 . '&pointer=\'+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1163 $pageIndicatorText = sprintf(
1164 $this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:pageIndicator'),
1168 $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1169 if ($this->totalItems
> $this->firstElementNumber +
$this->iLimit
) {
1170 $lastElementNumber = $this->firstElementNumber +
$this->iLimit
;
1172 $lastElementNumber = $this->totalItems
;
1174 $rangeIndicator = '<li><span>' . sprintf($this->getLanguageService()->sL('LLL:EXT:lang/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber +
1), $lastElementNumber) . '</span></li>';
1176 $titleColumn = $this->fieldArray
[0];
1178 $titleColumn => $content . '
1179 <nav class="pagination-wrap">
1180 <ul class="pagination pagination-block">
1183 ' . $rangeIndicator . '
1184 ' . $pageIndicator . '
1192 return $this->addElement(1, '', $data);
1195 /*********************************
1197 * Rendering of various elements
1199 *********************************/
1202 * Creates the control panel for a single record in the listing.
1204 * @param string $table The table
1205 * @param mixed[] $row The record for which to make the control panel.
1206 * @throws \UnexpectedValueException
1207 * @return string HTML table with the control panel (unless disabled)
1209 public function makeControl($table, $row) {
1210 $module = $this->getModule();
1211 $rowUid = $row['uid'];
1212 if (ExtensionManagementUtility
::isLoaded('version') && isset($row['_ORIG_uid'])) {
1213 $rowUid = $row['_ORIG_uid'];
1216 'primary' => array(),
1217 'secondary' => array()
1219 // If the listed table is 'pages' we have to request the permission settings for each page:
1220 $localCalcPerms = 0;
1221 if ($table == 'pages') {
1222 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $row['uid']));
1224 $permsEdit = $table === 'pages' && $localCalcPerms & Permission
::PAGE_EDIT ||
$table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT
;
1225 $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1226 // "Show" link (only pages and tt_content elements)
1227 if ($table == 'pages' ||
$table == 'tt_content') {
1228 $viewAction = '<a class="btn btn-default" href="#" onclick="'
1230 BackendUtility
::viewOnClick(
1231 ($table === 'tt_content' ?
$this->id
: $row['uid']),
1234 ($table === 'tt_content' ?
'#' . $row['uid'] : '')
1236 ) . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.showPage', TRUE
) . '">'
1237 . $this->iconFactory
->getIcon('actions-document-view', Icon
::SIZE_SMALL
)->render() . '</a>';
1238 $this->addActionToCellGroup($cells, $viewAction, 'view');
1240 // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1242 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1243 $iconIdentifier = 'actions-document-open';
1244 $overlayIdentifier = !$this->isEditable($table) ?
'overlay-readonly' : NULL
;
1245 $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1246 . '" title="' . $this->getLanguageService()->getLL('edit', TRUE
) . '">' . $this->iconFactory
->getIcon($iconIdentifier, Icon
::SIZE_SMALL
, $overlayIdentifier)->render() . '</a>';
1248 $editAction = $this->spaceIcon
;
1250 $this->addActionToCellGroup($cells, $editAction, 'edit');
1251 // "Info": (All records)
1252 $onClick = 'top.launchView(\'' . $table . '\', \'' . $row['uid'] . '\'); return false;';
1253 $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $this->getLanguageService()->getLL('showInfo', TRUE
) . '">'
1254 . $this->iconFactory
->getIcon('actions-document-info', Icon
::SIZE_SMALL
)->render() . '</a>';
1255 $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1256 // "Move" wizard link for pages/tt_content elements:
1257 if ($permsEdit && ($table === 'tt_content' ||
$table === 'pages')) {
1258 $onClick = 'return jumpExt(\'' . BackendUtility
::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $row['uid'] . '\');';
1259 $linkTitleLL = $this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ?
'record' : 'page'), TRUE
);
1260 $icon = ($table == 'pages' ?
$this->iconFactory
->getIcon('actions-page-move', Icon
::SIZE_SMALL
) : $this->iconFactory
->getIcon('actions-document-move', Icon
::SIZE_SMALL
));
1261 $moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
1262 $this->addActionToCellGroup($cells, $moveAction, 'move');
1264 // If the table is NOT a read-only table, then show these links:
1265 if ($this->isEditable($table)) {
1266 // "Revert" link (history/undo)
1267 $moduleUrl = BackendUtility
::getModuleUrl('record_history', array('element' => $table . ':' . $row['uid']));
1268 $onClick = 'return jumpExt(' . GeneralUtility
::quoteJSvalue($moduleUrl) . ',\'#latest\');';
1269 $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1270 . $this->getLanguageService()->getLL('history', TRUE
) . '">'
1271 . $this->iconFactory
->getIcon('actions-document-history-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1272 $this->addActionToCellGroup($cells, $historyAction, 'history');
1274 if (ExtensionManagementUtility
::isLoaded('version') && !ExtensionManagementUtility
::isLoaded('workspaces')) {
1275 $vers = BackendUtility
::selectVersionsOfRecord($table, $row['uid'], 'uid', $this->getBackendUserAuthentication()->workspace
, FALSE
, $row);
1276 // If table can be versionized.
1277 if (is_array($vers)) {
1278 $href = BackendUtility
::getModuleUrl('web_txversionM1', array(
1279 'table' => $table, 'uid' => $row['uid']
1281 $versionAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1282 . $this->getLanguageService()->getLL('displayVersions', TRUE
) . '">'
1283 . $this->iconFactory
->getIcon('actions-version-open', Icon
::SIZE_SMALL
)->render() . '</a>';
1284 $this->addActionToCellGroup($cells, $versionAction, 'version');
1287 // "Edit Perms" link:
1288 if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility
::isLoaded('beuser')) {
1289 $href = BackendUtility
::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&return_id=' . $row['uid'] . '&edit=1';
1290 $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1291 . $this->getLanguageService()->getLL('permissions', TRUE
) . '">'
1292 . $this->iconFactory
->getIcon('status-status-locked', Icon
::SIZE_SMALL
)->render() . '</a>';
1293 $this->addActionToCellGroup($cells, $permsAction, 'perms');
1295 // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
1296 // or if default values can depend on previous record):
1297 if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] ||
$GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
1298 if ($table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT ||
$table === 'pages' && $this->calcPerms
& Permission
::PAGE_NEW
) {
1299 if ($this->showNewRecLink($table)) {
1300 $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ?
$row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
1301 $icon = ($table == 'pages' ?
$this->iconFactory
->getIcon('actions-page-new', Icon
::SIZE_SMALL
) : $this->iconFactory
->getIcon('actions-document-new', Icon
::SIZE_SMALL
));
1302 $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility
::editOnClick($params, '', -1))
1303 . '" title="' . $this->getLanguageService()->getLL('new' . ($table == 'pages ' ?
'Page' : 'Record'), TRUE
) . '">'
1304 . $icon->render() . '</a>';
1305 $this->addActionToCellGroup($cells, $newAction, 'new');
1310 if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField
&& !$this->searchLevels
) {
1311 if (isset($this->currentTable
['prev'][$row['uid']])) {
1313 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['prev'][$row['uid']];
1314 $moveUpAction = '<a class="btn btn-default" href="#" onclick="'
1315 . htmlspecialchars('return jumpToUrl(' . $module->doc
->issueCommand($params, -1) . ');')
1316 . '" title="' . $this->getLanguageService()->getLL('moveUp', TRUE
) . '">'
1317 . $this->iconFactory
->getIcon('actions-move-up', Icon
::SIZE_SMALL
)->render() . '</a>';
1319 $moveUpAction = $this->spaceIcon
;
1321 $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
1323 if ($this->currentTable
['next'][$row['uid']]) {
1325 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['next'][$row['uid']];
1326 $moveDownAction = '<a class="btn btn-default" href="#" onclick="'
1327 . htmlspecialchars('return jumpToUrl(' . $module->doc
->issueCommand($params, -1) . ');')
1328 . '" title="' . $this->getLanguageService()->getLL('moveDown', TRUE
) . '">'
1329 . $this->iconFactory
->getIcon('actions-move-down', Icon
::SIZE_SMALL
)->render() . '</a>';
1331 $moveDownAction = $this->spaceIcon
;
1333 $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
1335 // "Hide/Unhide" links:
1336 $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1339 $permsEdit && $hiddenField && $GLOBALS['TCA'][$table]['columns'][$hiddenField]
1340 && (!$GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude']
1341 ||
$this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
1343 if ($this->isRecordCurrentBackendUser($table, $row)) {
1344 $hideAction = $this->spaceIcon
;
1346 $hideTitle = $this->getLanguageService()->getLL('hide' . ($table == 'pages' ?
'Page' : ''), TRUE
);
1347 $unhideTitle = $this->getLanguageService()->getLL('unHide' . ($table == 'pages' ?
'Page' : ''), TRUE
);
1348 if ($row[$hiddenField]) {
1349 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
1350 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
1351 . ' data-params="' . htmlspecialchars($params) . '"'
1352 . ' title="' . $unhideTitle . '"'
1353 . ' data-toggle-title="' . $hideTitle . '">'
1354 . $this->iconFactory
->getIcon('actions-edit-unhide', Icon
::SIZE_SMALL
)->render() . '</a>';
1356 $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
1357 $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
1358 . ' data-params="' . htmlspecialchars($params) . '"'
1359 . ' title="' . $hideTitle . '"'
1360 . ' data-toggle-title="' . $unhideTitle . '">'
1361 . $this->iconFactory
->getIcon('actions-edit-hide', Icon
::SIZE_SMALL
)->render() . '</a>';
1364 $this->addActionToCellGroup($cells, $hideAction, 'hide');
1367 if ($permsEdit && ($table === 'pages' && $localCalcPerms & Permission
::PAGE_DELETE ||
$table !== 'pages' && $this->calcPerms
& Permission
::CONTENT_EDIT
)) {
1368 // Check if the record version is in "deleted" state, because that will switch the action to "restore"
1369 if ($this->getBackendUserAuthentication()->workspace
> 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
1370 $actionName = 'restore';
1373 $actionName = 'delete';
1374 $refCountMsg = BackendUtility
::referenceCount(
1377 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.referencesToRecord'),
1378 $this->getReferenceCount($table, $row['uid'])) . BackendUtility
::translationCount($table, $row['uid'],
1379 ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.translationsOfRecord')
1383 if ($this->isRecordCurrentBackendUser($table, $row)) {
1384 $deleteAction = $this->spaceIcon
;
1386 $titleOrig = BackendUtility
::getRecordTitle($table, $row, FALSE
, TRUE
);
1387 $title = GeneralUtility
::slashJS(GeneralUtility
::fixed_lgd_cs($titleOrig, $this->fixedL
), TRUE
);
1388 $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
1390 $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
1391 $icon = $this->iconFactory
->getIcon('actions-edit-' . $actionName, Icon
::SIZE_SMALL
)->render();
1392 $linkTitle = $this->getLanguageService()->getLL($actionName, TRUE
);
1393 $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
1394 . ' data-l10parent="' . htmlspecialchars($row['l10n_parent']) . '"'
1395 . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($titleOrig) . '"'
1396 . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
1397 . '>' . $icon . '</a>';
1400 $deleteAction = $this->spaceIcon
;
1402 $this->addActionToCellGroup($cells, $deleteAction, 'delete');
1403 // "Levels" links: Moving pages into new levels...
1404 if ($permsEdit && $table == 'pages' && !$this->searchLevels
) {
1405 // Up (Paste as the page right after the current parent page)
1406 if ($this->calcPerms
& Permission
::PAGE_NEW
) {
1407 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id
;
1408 $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
1409 . htmlspecialchars('return jumpToUrl(' . $module->doc
->issueCommand($params, -1) . ');')
1410 . '" title="' . $this->getLanguageService()->getLL('prevLevel', TRUE
) . '">'
1411 . $this->iconFactory
->getIcon('actions-move-left', Icon
::SIZE_SMALL
)->render() . '</a>';
1412 $this->addActionToCellGroup($cells, $moveLeftAction, 'moveLeft');
1414 // Down (Paste as subpage to the page right above)
1415 if ($this->currentTable
['prevUid'][$row['uid']]) {
1416 $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility
::getRecord('pages', $this->currentTable
['prevUid'][$row['uid']]));
1417 if ($localCalcPerms & Permission
::PAGE_NEW
) {
1418 $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable
['prevUid'][$row['uid']];
1419 $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
1420 . htmlspecialchars('return jumpToUrl(' . $module->doc
->issueCommand($params, -1) . ');')
1421 . '" title="' . $this->getLanguageService()->getLL('nextLevel', TRUE
) . '">'
1422 . $this->iconFactory
->getIcon('actions-move-right', Icon
::SIZE_SMALL
)->render() . '</a>';
1424 $moveRightAction = $this->spaceIcon
;
1427 $moveRightAction = $this->spaceIcon
;
1429 $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
1433 * @hook recStatInfoHooks: Allows to insert HTML before record icons on various places
1435 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1437 $_params = array($table, $row['uid']);
1438 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1439 $stat .= GeneralUtility
::callUserFunction($_funcRef, $_params, $this);
1441 $this->addActionToCellGroup($cells, $stat, 'stat');
1444 * @hook makeControl: Allows to change control icons of records in list-module
1445 * @usage This hook method gets passed the current $cells array as third parameter.
1446 * This array contains values for the icons/actions generated for each record in Web>List.
1447 * Each array entry is accessible by an index-key.
1448 * The order of the icons is depending on the order of those array entries.
1450 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1451 // for compatibility reason, we move all icons to the rootlevel
1452 // before calling the hooks
1453 foreach ($cells as $section => $actions) {
1454 foreach ($actions as $actionKey => $action) {
1455 $cells[$actionKey] = $action;
1458 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1459 $hookObject = GeneralUtility
::getUserObj($classData);
1460 if (!$hookObject instanceof RecordListHookInterface
) {
1461 throw new \
UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface
::class, 1195567840);
1463 $cells = $hookObject->makeControl($table, $row, $cells, $this);
1465 // now sort icons again into primary and secondary sections
1466 // after all hooks are processed
1467 $hookCells = $cells;
1468 foreach ($hookCells as $key => $value) {
1469 if ($key === 'primary' ||
$key === 'secondary') {
1472 $this->addActionToCellGroup($cells, $value, $key);
1475 $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
1476 foreach($cells as $classification => $actions) {
1477 $visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS
['bigControlPanel'] ?
'collapsed' : 'expanded');
1478 if ($visibilityClass === 'collapsed') {
1480 foreach ($actions as $action) {
1481 $cellOutput .= $action;
1483 $output .= ' <div class="btn-group">' .
1484 '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
1485 '<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>' .
1488 $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
1495 * Creates the clipboard panel for a single record in the listing.
1497 * @param string $table The table
1498 * @param mixed[] $row The record for which to make the clipboard panel.
1499 * @throws \UnexpectedValueException
1500 * @return string HTML table with the clipboard panel (unless disabled)
1502 public function makeClip($table, $row) {
1503 // Return blank, if disabled:
1504 if (!$this->getModule()->MOD_SETTINGS
['clipBoard']) {
1508 $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon
);
1509 //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1510 $isL10nOverlay = $this->localizationView
&& $table != 'pages_language_overlay' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1511 // Return blank, if disabled:
1512 // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1513 // For the "Normal" pad:
1514 if ($this->clipObj
->current
=== 'normal') {
1515 // Show copy/cut icons:
1516 $isSel = (string)$this->clipObj
->isSelected($table, $row['uid']);
1517 if ($isL10nOverlay ||
!$this->overlayEditLockPermissions($table, $row)) {
1518 $cells['copy'] = $this->spaceIcon
;
1519 $cells['cut'] = $this->spaceIcon
;
1521 $copyIcon = $this->iconFactory
->getIcon('actions-edit-copy', Icon
::SIZE_SMALL
);
1522 $cutIcon = $this->iconFactory
->getIcon('actions-edit-cut', Icon
::SIZE_SMALL
);
1524 if ($isSel === 'copy') {
1525 $copyIcon = $this->iconFactory
->getIcon('actions-edit-copy-release', Icon
::SIZE_SMALL
);
1526 } elseif ($isSel === 'cut') {
1527 $cutIcon = $this->iconFactory
->getIcon('actions-edit-cut-release', Icon
::SIZE_SMALL
);
1530 $cells['copy'] = '<a class="btn btn-default" href="#" onclick="'
1531 . htmlspecialchars('return jumpSelf(\'' . $this->clipObj
->selUrlDB($table, $row['uid'], 1, ($isSel === 'copy'), array('returnUrl' => '')) . '\');')
1532 . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.copy', TRUE
) . '">'
1533 . $copyIcon->render() . '</a>';
1535 $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
1536 . htmlspecialchars('return jumpSelf(\'' . $this->clipObj
->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), array('returnUrl' => '')) . '\');')
1537 . '" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:cm.cut', TRUE
) . '">'
1538 . $cutIcon->render() . '</a>';
1540 $cells['cut'] = $this->spaceIcon
;
1544 // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1545 // Setting name of the element in ->CBnames array:
1546 $n = $table . '|' . $row['uid'];
1547 $this->CBnames
[] = $n;
1548 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1549 $checked = $this->clipObj
->isSelected($table, $row['uid']) ?
'checked="checked" ' : '';
1550 // If the "duplicateField" value is set then select all elements which are duplicates...
1551 if ($this->duplicateField
&& isset($row[$this->duplicateField
])) {
1553 if (in_array($row[$this->duplicateField
], $this->duplicateStack
)) {
1554 $checked = 'checked="checked" ';
1556 $this->duplicateStack
[] = $row[$this->duplicateField
];
1558 // Adding the checkbox to the panel:
1559 $cells['select'] = $isL10nOverlay
1561 : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
1562 . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
1564 // Now, looking for selected elements from the current table:
1565 $elFromTable = $this->clipObj
->elFromTable($table);
1566 if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1567 // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
1568 $cells['pasteAfter'] = $isL10nOverlay ||
!$this->overlayEditLockPermissions($table, $row)
1570 : '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj
->pasteUrl($table, -$row['uid'])) . '" onclick="'
1571 . htmlspecialchars(('return ' . $this->clipObj
->confirmMsg($table, $row, 'after', $elFromTable)))
1572 . '" title="' . $this->getLanguageService()->getLL('clip_pasteAfter', TRUE
) . '">'
1573 . $this->iconFactory
->getIcon('actions-document-paste-after', Icon
::SIZE_SMALL
)->render() . '</a>';
1575 // Now, looking for elements in general:
1576 $elFromTable = $this->clipObj
->elFromTable('');
1577 if ($table == 'pages' && !empty($elFromTable)) {
1578 $cells['pasteInto'] = '<a class="btn btn-default" href="' . htmlspecialchars($this->clipObj
->pasteUrl('', $row['uid']))
1579 . '" onclick="' . htmlspecialchars('return ' . $this->clipObj
->confirmMsg($table, $row, 'into', $elFromTable))
1580 . '" title="' . $this->getLanguageService()->getLL('clip_pasteInto', TRUE
) . '">'
1581 . $this->iconFactory
->getIcon('actions-document-paste-into', Icon
::SIZE_SMALL
)->render() . '</a>';
1584 * @hook makeClip: Allows to change clip-icons of records in list-module
1585 * @usage This hook method gets passed the current $cells array as third parameter.
1586 * This array contains values for the clipboard icons generated for each record in Web>List.
1587 * Each array entry is accessible by an index-key.
1588 * The order of the icons is depending on the order of those array entries.
1590 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1591 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1592 $hookObject = GeneralUtility
::getUserObj($classData);
1593 if (!$hookObject instanceof RecordListHookInterface
) {
1594 throw new \
UnexpectedValueException('$hookObject must implement interface ' . RecordListHookInterface
::class, 1195567845);
1596 $cells = $hookObject->makeClip($table, $row, $cells, $this);
1599 // Compile items into a DIV-element:
1600 return '<!-- CLIPBOARD PANEL: ' . $table . ':' . $row['uid'] . ' -->
1601 <div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1605 * Creates the HTML for a reference count for the record with the UID $uid
1606 * in the table $tableName.
1608 * @param string $tableName
1610 * @return string HTML of reference a link, will be empty if there are no
1612 protected function createReferenceHtml($tableName, $uid) {
1613 $db = $this->getDatabaseConnection();
1614 $referenceCount = $db->exec_SELECTcountRows(
1617 'ref_table = ' . $db->fullQuoteStr($tableName, 'sys_refindex') .
1618 ' AND ref_uid = ' . $uid . ' AND deleted = 0'
1620 return $this->generateReferenceToolTip($referenceCount, '\'' . $tableName . '\', \'' . $uid . '\'');
1624 * Creates the localization panel
1626 * @param string $table The table
1627 * @param mixed[] $row The record for which to make the localization panel.
1628 * @return string[] Array with key 0/1 with content for column 1 and 2
1630 public function makeLocalizationPanel($table, $row) {
1635 // Reset translations
1636 $this->translations
= array();
1638 // Language title and icon:
1639 $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
1641 $translations = $this->translateTools
->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList
);
1642 if (is_array($translations)) {
1643 $this->translations
= $translations['translations'];
1644 // Traverse page translations and add icon for each language that does NOT yet exist:
1646 foreach ($this->pageOverlays
as $lUid_OnPage => $lsysRec) {
1647 if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
1648 $url = $this->listURL();
1649 $href = $this->getModule()->doc
->issueCommand(
1650 '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1651 $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1653 $language = BackendUtility
::getRecord('sys_language', $lUid_OnPage, 'title');
1654 if ($this->languageIconTitles
[$lUid_OnPage]['flagIcon']) {
1655 $lC = $this->iconFactory
->getIcon($this->languageIconTitles
[$lUid_OnPage]['flagIcon'], Icon
::SIZE_SMALL
)->render();
1657 $lC = $this->languageIconTitles
[$lUid_OnPage]['title'];
1659 $lC = '<a href="' . htmlspecialchars($href) . '" title="'
1660 . htmlspecialchars($language['title']) . '">' . $lC . '</a> ';
1667 } elseif ($row['l18n_parent']) {
1668 $out[0] = ' ' . $out[0];
1674 * Creates a checkbox list for selecting fields to display from a table:
1676 * @param string $table Table name
1677 * @param bool $formFields If TRUE, form-fields will be wrapped around the table.
1678 * @return string HTML table with the selector check box (name: displayFields['.$table.'][])
1680 public function fieldSelectBox($table, $formFields = TRUE
) {
1681 $lang = $this->getLanguageService();
1683 $formElements = array('', '');
1685 $formElements = array('<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>');
1687 // Load already selected fields, if any:
1688 $setFields = is_array($this->setFields
[$table]) ?
$this->setFields
[$table] : array();
1689 // Request fields from table:
1690 $fields = $this->makeFieldList($table, FALSE
, TRUE
);
1691 // Add pseudo "control" fields
1692 $fields[] = '_PATH_';
1693 $fields[] = '_REF_';
1694 $fields[] = '_LOCALIZATION_';
1695 $fields[] = '_CONTROL_';
1696 $fields[] = '_CLIPBOARD_';
1697 // Create a checkbox for each field:
1698 $checkboxes = array();
1699 $checkAllChecked = TRUE
;
1700 foreach ($fields as $fieldName) {
1701 // Determine, if checkbox should be checked
1702 if (in_array($fieldName, $setFields, TRUE
) ||
$fieldName === $this->fieldArray
[0]) {
1703 $checked = ' checked="checked"';
1705 $checkAllChecked = FALSE
;
1709 $fieldLabel = is_array($GLOBALS['TCA'][$table]['columns'][$fieldName])
1710 ?
rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']), ':')
1712 $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
1713 . $table . '][]" value="' . $fieldName . '"' . $checked
1714 . ($fieldName === $this->fieldArray
[0] ?
' disabled="disabled"' : '') . '></td><td class="col-title">'
1715 . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($fieldLabel) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
1717 // Table with the field selector::
1718 $content = $formElements[0] . '
1719 <input type="hidden" name="displayFields[' . $table . '][]" value="">
1720 <div class="table-fit table-scrollable">
1721 <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
1724 <th class="col-checkbox" colspan="2">
1725 <input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ?
' checked="checked"' : '') .'>
1730 ' . implode('', $checkboxes) . '
1734 <input type="submit" name="search" class="btn btn-default" value="'
1735 . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.setFields', TRUE
) . '"/>
1736 ' . $formElements[1];
1737 return '<div class="fieldSelectBox">' . $content . '</div>';
1740 /*********************************
1744 *********************************/
1746 * Creates a link around $string. The link contains an onclick action
1747 * which submits the script with some clipboard action.
1748 * Currently, this is used for setting elements / delete elements.
1750 * @param string $string The HTML content to link (image/text)
1751 * @param string $table Table name
1752 * @param string $cmd Clipboard command (eg. "setCB" or "delete")
1753 * @param string $warning Warning text, if any ("delete" uses this for confirmation)
1754 * @return string <a> tag wrapped link.
1756 public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '') {
1757 $onClickEvent = 'document.dblistForm.cmd.value=\'' . $cmd . '\';document.dblistForm.cmd_table.value=\''
1758 . $table . '\';document.dblistForm.submit();';
1760 $onClickEvent = 'if (confirm(' . GeneralUtility
::quoteJSvalue($warning) . ')){' . $onClickEvent . '}';
1762 return '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(($onClickEvent . 'return false;')) . '">' . $string . '</a>';
1766 * Returns TRUE if a numeric clipboard pad is selected/active
1770 public function clipNumPane() {
1771 return in_Array('_CLIPBOARD_', $this->fieldArray
) && $this->clipObj
->current
!= 'normal';
1775 * Creates a sort-by link on the input string ($code).
1776 * It will automatically detect if sorting should be ascending or descending depending on $this->sortRev.
1777 * Also some fields will not be possible to sort (including if single-table-view is disabled).
1779 * @param string $code The string to link (text)
1780 * @param string $field The fieldname represented by the title ($code)
1781 * @param string $table Table name
1782 * @return string Linked $code variable
1784 public function addSortLink($code, $field, $table) {
1785 // Certain circumstances just return string right away (no links):
1786 if ($field == '_CONTROL_' ||
$field == '_LOCALIZATION_' ||
$field == '_CLIPBOARD_' ||
$field == '_REF_' ||
$this->disableSingleTableView
) {
1789 // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
1790 if ($field == '_PATH_') {
1793 // Create the sort link:
1794 $sortUrl = $this->listURL('', -1, 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
1795 . '&sortField=' . $field . '&sortRev=' . ($this->sortRev ||
$this->sortField
!= $field ?
0 : 1);
1796 $sortArrow = $this->sortField
=== $field
1797 ?
$this->iconFactory
->getIcon('status-status-sorting-' . ($this->sortRev ?
'desc' : 'asc'), Icon
::SIZE_SMALL
)->render()
1799 // Return linked field:
1800 return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
1804 * Returns the path for a certain pid
1805 * The result is cached internally for the session, thus you can call
1806 * this function as much as you like without performance problems.
1808 * @param int $pid The page id for which to get the path
1809 * @return mixed[] The path.
1811 public function recPath($pid) {
1812 if (!isset($this->recPath_cache
[$pid])) {
1813 $this->recPath_cache
[$pid] = BackendUtility
::getRecordPath($pid, $this->perms_clause
, 20);
1815 return $this->recPath_cache
[$pid];
1819 * Returns TRUE if a link for creating new records should be displayed for $table
1821 * @param string $table Table name
1822 * @return bool Returns TRUE if a link for creating new records should be displayed for $table
1823 * @see \TYPO3\CMS\Backend\Controller\NewRecordController::showNewRecLink
1825 public function showNewRecLink($table) {
1826 // No deny/allow tables are set:
1827 if (empty($this->allowedNewTables
) && empty($this->deniedNewTables
)) {
1830 return !in_array($table, $this->deniedNewTables
)
1831 && (empty($this->allowedNewTables
) ||
in_array($table, $this->allowedNewTables
));
1835 * Creates the "&returnUrl" parameter for links - this is used when the script links
1836 * to other scripts and passes its own URL with the link so other scripts can return to the listing again.
1837 * Uses REQUEST_URI as value.
1841 public function makeReturnUrl() {
1842 return '&returnUrl=' . rawurlencode(GeneralUtility
::getIndpEnv('REQUEST_URI'));
1845 /************************************
1847 * CSV related functions
1849 ************************************/
1851 * Initializes internal csvLines array with the header of field names
1855 protected function initCSV() {
1856 $this->addHeaderRowToCSV();
1860 * Add header line with field names as CSV line
1864 protected function addHeaderRowToCSV() {
1865 // Add header row, control fields will be reduced inside addToCSV()
1866 $this->addToCSV(array_combine($this->fieldArray
, $this->fieldArray
));
1870 * Adds selected columns of one table row as CSV line.
1872 * @param mixed[] $row Record array, from which the values of fields found in $this->fieldArray will be listed in the CSV output.
1875 protected function addToCSV(array $row = array()) {
1876 $rowReducedByControlFields = self
::removeControlFieldsFromFieldRow($row);
1877 $rowReducedToSelectedColumns = array_intersect_key($rowReducedByControlFields, array_flip($this->fieldArray
));
1878 $this->setCsvRow($rowReducedToSelectedColumns);
1882 * Remove control fields from row for CSV export
1884 * @param mixed[] $row fieldNames => fieldValues
1885 * @return mixed[] Input array reduces by control fields
1887 static protected function removeControlFieldsFromFieldRow(array $row = array()) {
1888 // Possible control fields in a list row
1889 $controlFields = array(
1897 return array_diff_key($row, array_flip($controlFields));
1901 * Adds input row of values to the internal csvLines array as a CSV formatted line
1903 * @param mixed[] $csvRow Array with values to be listed.
1906 public function setCsvRow($csvRow) {
1907 $this->csvLines
[] = GeneralUtility
::csvValues($csvRow);
1911 * Compiles the internal csvLines array to a csv-string and outputs it to the browser.
1912 * This function exits!
1914 * @param string $prefix Filename prefix:
1915 * @return void EXITS php execution!
1917 public function outputCSV($prefix) {
1918 // Setting filename:
1919 $filename = $prefix . '_' . date('dmy-Hi') . '.csv';
1920 // Creating output header:
1921 header('Content-Type: application/octet-stream');
1922 header('Content-Disposition: attachment; filename=' . $filename);
1923 // Cache-Control header is needed here to solve an issue with browser IE and
1924 // versions lower than 9. See for more information: http://support.microsoft.com/kb/323308
1925 header("Cache-Control: ''");
1926 // Printing the content of the CSV lines:
1927 echo implode(CRLF
, $this->csvLines
);
1933 * add action into correct section
1935 * @param array $cells
1936 * @param string $action
1937 * @param string $actionKey
1939 public function addActionToCellGroup(&$cells, $action, $actionKey) {
1942 'view', 'edit', 'hide', 'delete', 'stat'
1944 'secondary' => array(
1945 'viewBig', 'history', 'perms', 'new', 'move', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'version'
1948 $classification = in_array($actionKey, $cellsMap['primary']) ?
'primary' : 'secondary';
1949 $cells[$classification][$actionKey] = $action;
1950 unset($cells[$actionKey]);
1954 * Check if the record represents the current backend user
1956 * @param string $table
1960 protected function isRecordCurrentBackendUser($table, $row) {
1961 return $table === 'be_users' && (int)$row['uid'] === $this->getBackendUserAuthentication()->user
['uid'];
1965 * @param bool $isEditable
1967 public function setIsEditable($isEditable) {
1968 $this->editable
= $isEditable;
1972 * Check if the table is readonly or editable
1973 * @param string $table
1976 public function isEditable($table) {
1977 return $GLOBALS['TCA'][$table]['ctrl']['readOnly'] ||
$this->editable
;
1981 * Check if the current record is locked by editlock. Pages are locked if their editlock flag is set,
1982 * records are if they are locked themselves or if the page they are on is locked (a page’s editlock
1983 * is transitive for its content elements).
1985 * @param string $table
1987 * @param bool $editPermission
1990 protected function overlayEditLockPermissions($table, $row = array(), $editPermission = TRUE
) {
1991 if ($editPermission && !$this->getBackendUserAuthentication()->isAdmin()) {
1992 // If no $row is submitted we only check for general edit lock of current page (except for table "pages")
1994 return $table === 'pages' ? TRUE
: !$this->pageRow
['editlock'];
1996 if (($table === 'pages' && $row['editlock']) ||
($table !== 'pages' && $this->pageRow
['editlock'])) {
1997 $editPermission = FALSE
;
1998 } elseif (isset($GLOBALS['TCA'][$table]['ctrl']['editlock']) && $row[$GLOBALS['TCA'][$table]['ctrl']['editlock']]) {
1999 $editPermission = FALSE
;
2002 return $editPermission;
2006 * Check whether or not the current backend user is an admin or the current page is
2007 * locked by editlock.
2011 protected function editLockPermissions() {
2012 return $this->getBackendUserAuthentication()->isAdmin() ||
!$this->pageRow
['editlock'];
2016 * @return DatabaseConnection
2018 protected function getDatabaseConnection() {
2019 return $GLOBALS['TYPO3_DB'];
2023 * @return BaseScriptClass
2025 protected function getModule() {
2026 return $GLOBALS['SOBE'];
2030 * @return DocumentTemplate
2032 protected function getDocumentTemplate() {
2033 return $GLOBALS['TBE_TEMPLATE'];