TYPO3 CMS  TYPO3_8-7
DatabaseRecordList.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
35 
40 {
41  // *********
42  // External:
43  // *********
44 
51  public $allowedNewTables = [];
52 
59  public $deniedNewTables = [];
60 
68  public $newWizards = false;
69 
76 
82  public $showClipboard = false;
83 
89  public $noControlPanels = false;
90 
96  public $clickMenuEnabled = true;
97 
104 
110  public $spaceIcon;
111 
117  public $disableSingleTableView = false;
118 
119  // *********
120  // Internal:
121  // *********
122 
128  public $pageRow = [];
129 
135  protected $csvLines = [];
136 
142  public $csvOutput = false;
143 
149  public $clipObj;
150 
156  public $CBnames = [];
157 
163  protected $referenceCount = [];
164 
171 
179 
183  public $pageinfo;
184 
190  public $MOD_MENU;
191 
197  protected $editable = true;
198 
202  protected $iconFactory;
203 
207  public function __construct()
208  {
209  parent::__construct();
210  $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
211  }
212 
219  public function getButtons()
220  {
221  $module = $this->getModule();
222  $backendUser = $this->getBackendUserAuthentication();
223  $lang = $this->getLanguageService();
224  $buttons = [
225  'csh' => '',
226  'view' => '',
227  'edit' => '',
228  'hide_unhide' => '',
229  'move' => '',
230  'new_record' => '',
231  'paste' => '',
232  'level_up' => '',
233  'cache' => '',
234  'reload' => '',
235  'shortcut' => '',
236  'back' => '',
237  'csv' => '',
238  'export' => ''
239  ];
240  // Get users permissions for this page record:
241  $localCalcPerms = $backendUser->calcPerms($this->pageRow);
242  // CSH
243  if ((string)$this->id === '') {
244  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_noId');
245  } elseif (!$this->id) {
246  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module_root');
247  } else {
248  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'list_module');
249  }
250  if (isset($this->id)) {
251  // View Exclude doktypes 254,255 Configuration:
252  // mod.web_list.noViewWithDokTypes = 254,255
253  if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
254  $noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], true);
255  } else {
256  //default exclusion: doktype 254 (folder), 255 (recycler)
257  $noViewDokTypes = [
258  PageRepository::DOKTYPE_SYSFOLDER,
259  PageRepository::DOKTYPE_RECYCLER
260  ];
261  }
262  if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
263  $onClick = htmlspecialchars(BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id)));
264  $buttons['view'] = '<a href="#" onclick="' . $onClick . '" title="'
265  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'
266  . $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
267  }
268  // New record on pages that are not locked by editlock
269  if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
270  $onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id])) . ');');
271  $buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
272  . htmlspecialchars($lang->getLL('newRecordGeneral')) . '">'
273  . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</a>';
274  }
275  // If edit permissions are set, see
276  // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
277  if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions() && $this->getBackendUserAuthentication()->checkLanguageAccess(0)) {
278  // Edit
279  $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
280  $onClick = htmlspecialchars(BackendUtility::editOnClick($params, '', -1));
281  $buttons['edit'] = '<a href="#" onclick="' . $onClick . '" title="' . htmlspecialchars($lang->getLL('editPage')) . '">'
282  . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL)->render()
283  . '</a>';
284  }
285  // Paste
286  if (($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
287  $elFromTable = $this->clipObj->elFromTable('');
288  if (!empty($elFromTable)) {
289  $confirmText = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
290  $buttons['paste'] = '<a'
291  . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $this->id)) . '"'
292  . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
293  . ' class="t3js-modal-trigger"'
294  . ' data-severity="warning"'
295  . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
296  . ' data-content="' . htmlspecialchars($confirmText) . '"'
297  . '>'
298  . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
299  . '</a>';
300  }
301  }
302  // Cache
303  $buttons['cache'] = '<a href="' . htmlspecialchars(($this->listURL() . '&clear_cache=1')) . '" title="'
304  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache')) . '">'
305  . $this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL)->render() . '</a>';
306  if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
307  || (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
308  && !$module->modTSconfig['properties']['noExportRecordsLinks']))
309  ) {
310  // CSV
311  $buttons['csv'] = '<a href="' . htmlspecialchars(($this->listURL() . '&csv=1')) . '" title="'
312  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.csv')) . '">'
313  . $this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL)->render() . '</a>';
314  // Export
315  if (ExtensionManagementUtility::isLoaded('impexp')) {
316  $url = BackendUtility::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
317  $buttons['export'] = '<a href="' . htmlspecialchars($url . '&tx_impexp[list][]='
318  . rawurlencode($this->table . ':' . $this->id)) . '" title="'
319  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export')) . '">'
320  . $this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL)->render() . '</a>';
321  }
322  }
323  // Reload
324  $buttons['reload'] = '<a href="' . htmlspecialchars($this->listURL()) . '" title="'
325  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload')) . '">'
326  . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a>';
327  // Shortcut
328  if ($backendUser->mayMakeShortcut()) {
329  $buttons['shortcut'] = $this->getDocumentTemplate()->makeShortcutIcon(
330  'id, M, imagemode, pointer, table, search_field, search_levels, showLimit, sortField, sortRev',
331  implode(',', array_keys($this->MOD_MENU)),
332  'web_list'
333  );
334  }
335  // Back
336  if ($this->returnUrl) {
337  $href = htmlspecialchars(GeneralUtility::linkThisUrl($this->returnUrl, ['id' => $this->id]));
338  $buttons['back'] = '<a href="' . $href . '" class="typo3-goBack" title="'
339  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack')) . '">'
340  . $this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL)->render() . '</a>';
341  }
342  }
343  return $buttons;
344  }
345 
353  {
354  $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
355  $module = $this->getModule();
356  $backendUser = $this->getBackendUserAuthentication();
357  $lang = $this->getLanguageService();
358  // Get users permissions for this page record:
359  $localCalcPerms = $backendUser->calcPerms($this->pageRow);
360  // CSH
361  if ((string)$this->id === '') {
362  $fieldName = 'list_module_noId';
363  } elseif (!$this->id) {
364  $fieldName = 'list_module_root';
365  } else {
366  $fieldName = 'list_module';
367  }
368  $cshButton = $buttonBar->makeHelpButton()
369  ->setModuleName('xMOD_csh_corebe')
370  ->setFieldName($fieldName);
371  $buttonBar->addButton($cshButton);
372  if (isset($this->id)) {
373  // View Exclude doktypes 254,255 Configuration:
374  // mod.web_list.noViewWithDokTypes = 254,255
375  if (isset($module->modTSconfig['properties']['noViewWithDokTypes'])) {
376  $noViewDokTypes = GeneralUtility::trimExplode(',', $module->modTSconfig['properties']['noViewWithDokTypes'], true);
377  } else {
378  //default exclusion: doktype 254 (folder), 255 (recycler)
379  $noViewDokTypes = [
380  PageRepository::DOKTYPE_SYSFOLDER,
381  PageRepository::DOKTYPE_RECYCLER
382  ];
383  }
384  // New record on pages that are not locked by editlock
385  if (!$module->modTSconfig['properties']['noCreateRecordsLink'] && $this->editLockPermissions()) {
386  $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id])) . ');';
387  $newRecordButton = $buttonBar->makeLinkButton()
388  ->setHref('#')
389  ->setOnClick($onClick)
390  ->setTitle($lang->getLL('newRecordGeneral'))
391  ->setIcon($this->iconFactory->getIcon('actions-document-new', Icon::SIZE_SMALL));
392  $buttonBar->addButton($newRecordButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
393  }
394  if (!in_array($this->pageRow['doktype'], $noViewDokTypes)) {
395  $onClick = BackendUtility::viewOnClick($this->id, '', BackendUtility::BEgetRootLine($this->id));
396  $viewButton = $buttonBar->makeLinkButton()
397  ->setHref('#')
398  ->setOnClick($onClick)
399  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage'))
400  ->setIcon($this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL));
401  $buttonBar->addButton($viewButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
402  }
403  // If edit permissions are set, see
404  // \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
405  if ($localCalcPerms & Permission::PAGE_EDIT && !empty($this->id) && $this->editLockPermissions()) {
406  // Edit
407  $params = '&edit[pages][' . $this->pageRow['uid'] . ']=edit';
408  $onClick = BackendUtility::editOnClick($params, '', -1);
409  $editButton = $buttonBar->makeLinkButton()
410  ->setHref('#')
411  ->setOnClick($onClick)
412  ->setTitle($lang->getLL('editPage'))
413  ->setIcon($this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL));
414  $buttonBar->addButton($editButton, ButtonBar::BUTTON_POSITION_LEFT, 20);
415  }
416  // Paste
417  if ($this->showClipboard && ($localCalcPerms & Permission::PAGE_NEW || $localCalcPerms & Permission::CONTENT_EDIT) && $this->editLockPermissions()) {
418  $elFromTable = $this->clipObj->elFromTable('');
419  if (!empty($elFromTable)) {
420  $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
421  $pasteButton = $buttonBar->makeLinkButton()
422  ->setHref($this->clipObj->pasteUrl('', $this->id))
423  ->setTitle($lang->getLL('clip_paste'))
424  ->setClasses('t3js-modal-trigger')
425  ->setDataAttributes([
426  'severity' => 'warning',
427  'content' => $confirmMessage,
428  'title' => $lang->getLL('clip_paste')
429  ])
430  ->setIcon($this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL));
431  $buttonBar->addButton($pasteButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
432  }
433  }
434  // Cache
435  $clearCacheButton = $buttonBar->makeLinkButton()
436  ->setHref($this->listURL() . '&clear_cache=1')
437  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clear_cache'))
438  ->setIcon($this->iconFactory->getIcon('actions-system-cache-clear', Icon::SIZE_SMALL));
439  $buttonBar->addButton($clearCacheButton, ButtonBar::BUTTON_POSITION_RIGHT);
440  if ($this->table && (!isset($module->modTSconfig['properties']['noExportRecordsLinks'])
441  || (isset($module->modTSconfig['properties']['noExportRecordsLinks'])
442  && !$module->modTSconfig['properties']['noExportRecordsLinks']))
443  ) {
444  // CSV
445  $csvButton = $buttonBar->makeLinkButton()
446  ->setHref($this->listURL() . '&csv=1')
447  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.csv'))
448  ->setIcon($this->iconFactory->getIcon('actions-document-export-csv', Icon::SIZE_SMALL));
449  $buttonBar->addButton($csvButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
450  // Export
451  if (ExtensionManagementUtility::isLoaded('impexp')) {
452  $url = BackendUtility::getModuleUrl('xMOD_tximpexp', ['tx_impexp[action]' => 'export']);
453  $exportButton = $buttonBar->makeLinkButton()
454  ->setHref($url . '&tx_impexp[list][]=' . rawurlencode($this->table . ':' . $this->id))
455  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.export'))
456  ->setIcon($this->iconFactory->getIcon('actions-document-export-t3d', Icon::SIZE_SMALL));
457  $buttonBar->addButton($exportButton, ButtonBar::BUTTON_POSITION_LEFT, 40);
458  }
459  }
460  // Reload
461  $reloadButton = $buttonBar->makeLinkButton()
462  ->setHref($this->listURL())
463  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.reload'))
464  ->setIcon($this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL));
465  $buttonBar->addButton($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT);
466  // Shortcut
467  if ($backendUser->mayMakeShortcut()) {
468  $shortCutButton = $buttonBar->makeShortcutButton()
469  ->setModuleName('web_list')
470  ->setGetVariables([
471  'id',
472  'M',
473  'imagemode',
474  'pointer',
475  'table',
476  'search_field',
477  'search_levels',
478  'showLimit',
479  'sortField',
480  'sortRev'
481  ])
482  ->setSetVariables(array_keys($this->MOD_MENU));
483  $buttonBar->addButton($shortCutButton, ButtonBar::BUTTON_POSITION_RIGHT);
484  }
485  // Back
486  if ($this->returnUrl) {
487  $backButton = $buttonBar->makeLinkButton()
488  ->setHref($this->returnUrl)
489  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.goBack'))
490  ->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
491  $buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT);
492  }
493  }
494  }
495 
505  public function getTable($table, $id, $rowList = '')
506  {
507  $rowListArray = GeneralUtility::trimExplode(',', $rowList, true);
508  // if no columns have been specified, show description (if configured)
509  if (!empty($GLOBALS['TCA'][$table]['ctrl']['descriptionColumn']) && empty($rowListArray)) {
510  $rowListArray[] = $GLOBALS['TCA'][$table]['ctrl']['descriptionColumn'];
511  }
512  $backendUser = $this->getBackendUserAuthentication();
513  $lang = $this->getLanguageService();
514  // Init
515  $addWhere = '';
516  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
517  $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
518  $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
519  $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField']
520  && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']
521  && $table !== 'pages_language_overlay';
522  $tableCollapsed = (bool)$this->tablesCollapsed[$table];
523  // prepare space icon
524  $this->spaceIcon = '<span class="btn btn-default disabled">' . $this->iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
525  // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
526  $this->fieldArray = [];
527  // title Column
528  // Add title column
529  $this->fieldArray[] = $titleCol;
530  // Control-Panel
531  if (!GeneralUtility::inList($rowList, '_CONTROL_')) {
532  $this->fieldArray[] = '_CONTROL_';
533  }
534  // Clipboard
535  if ($this->showClipboard) {
536  $this->fieldArray[] = '_CLIPBOARD_';
537  }
538  // Ref
539  if (!$this->dontShowClipControlPanels) {
540  $this->fieldArray[] = '_REF_';
541  }
542  // Path
543  if ($this->searchLevels) {
544  $this->fieldArray[] = '_PATH_';
545  }
546  // Localization
547  if ($this->localizationView && $l10nEnabled) {
548  $this->fieldArray[] = '_LOCALIZATION_';
549  $this->fieldArray[] = '_LOCALIZATION_b';
550  // Only restrict to the default language if no search request is in place
551  if ($this->searchString === '') {
552  $addWhere = (string)$queryBuilder->expr()->orX(
553  $queryBuilder->expr()->lte($GLOBALS['TCA'][$table]['ctrl']['languageField'], 0),
554  $queryBuilder->expr()->eq($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'], 0)
555  );
556  }
557  }
558  // Cleaning up:
559  $this->fieldArray = array_unique(array_merge($this->fieldArray, $rowListArray));
560  if ($this->noControlPanels) {
561  $tempArray = array_flip($this->fieldArray);
562  unset($tempArray['_CONTROL_']);
563  unset($tempArray['_CLIPBOARD_']);
564  $this->fieldArray = array_keys($tempArray);
565  }
566  // Creating the list of fields to include in the SQL query:
567  $selectFields = $this->fieldArray;
568  $selectFields[] = 'uid';
569  $selectFields[] = 'pid';
570  // adding column for thumbnails
571  if ($thumbsCol) {
572  $selectFields[] = $thumbsCol;
573  }
574  if ($table === 'pages') {
575  $selectFields[] = 'module';
576  $selectFields[] = 'extendToSubpages';
577  $selectFields[] = 'nav_hide';
578  $selectFields[] = 'doktype';
579  $selectFields[] = 'shortcut';
580  $selectFields[] = 'shortcut_mode';
581  $selectFields[] = 'mount_pid';
582  }
583  if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
584  $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
585  }
586  foreach (['type', 'typeicon_column', 'editlock'] as $field) {
587  if ($GLOBALS['TCA'][$table]['ctrl'][$field]) {
588  $selectFields[] = $GLOBALS['TCA'][$table]['ctrl'][$field];
589  }
590  }
591  if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
592  $selectFields[] = 't3ver_id';
593  $selectFields[] = 't3ver_state';
594  $selectFields[] = 't3ver_wsid';
595  }
596  if ($l10nEnabled) {
597  $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
598  $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
599  }
600  if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
601  $selectFields = array_merge(
602  $selectFields,
603  GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], true)
604  );
605  }
606  // Unique list!
607  $selectFields = array_unique($selectFields);
608  $fieldListFields = $this->makeFieldList($table, 1);
609  if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
610  $message = sprintf($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessage'), $table, $table);
611  $messageTitle = $lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:missingTcaColumnsMessageTitle');
613  $flashMessage = GeneralUtility::makeInstance(
614  FlashMessage::class,
615  $message,
616  $messageTitle,
618  true
619  );
621  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
623  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
624  $defaultFlashMessageQueue->enqueue($flashMessage);
625  }
626  // Making sure that the fields in the field-list ARE in the field-list from TCA!
627  $selectFields = array_intersect($selectFields, $fieldListFields);
628  // Implode it into a list of fields for the SQL-statement.
629  $selFieldList = implode(',', $selectFields);
630  $this->selFieldList = $selFieldList;
631  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
632  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
633  $hookObject = GeneralUtility::getUserObj($classData);
634  if (!$hookObject instanceof RecordListGetTableHookInterface) {
635  throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListGetTableHookInterface::class, 1195114460);
636  }
637  $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
638  }
639  }
640  $additionalConstraints = empty($addWhere) ? [] : [QueryHelper::stripLogicalOperatorPrefix($addWhere)];
642 
643  // Create the SQL query for selecting the elements in the listing:
644  // do not do paging when outputting as CSV
645  if ($this->csvOutput) {
646  $this->iLimit = 0;
647  }
648  if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
649  // Get the two previous rows for sorting if displaying page > 1
650  $this->firstElementNumber = $this->firstElementNumber - 2;
651  $this->iLimit = $this->iLimit + 2;
652  // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
653  $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
654  $this->firstElementNumber = $this->firstElementNumber + 2;
655  $this->iLimit = $this->iLimit - 2;
656  } else {
657  // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
658  $queryBuilder = $this->getQueryBuilder($table, $id, $additionalConstraints);
659  }
660 
661  // Finding the total amount of records on the page
662  // (API function from TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList)
663  $this->setTotalItems($table, $id, $additionalConstraints);
664 
665  // Init:
666  $queryResult = $queryBuilder->execute();
667  $dbCount = 0;
668  $out = '';
669  $tableHeader = '';
670  $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
671  // If the count query returned any number of records, we perform the real query,
672  // selecting records.
673  if ($this->totalItems) {
674  // Fetch records only if not in single table mode
676  $dbCount = $this->totalItems;
677  } else {
678  // Set the showLimit to the number of records when outputting as CSV
679  if ($this->csvOutput) {
680  $this->showLimit = $this->totalItems;
681  $this->iLimit = $this->totalItems;
682  }
683  $dbCount = $queryResult->rowCount();
684  }
685  }
686  // If any records was selected, render the list:
687  if ($dbCount) {
688  $tableTitle = htmlspecialchars($lang->sL($GLOBALS['TCA'][$table]['ctrl']['title']));
689  if ($tableTitle === '') {
690  $tableTitle = $table;
691  }
692  // Header line is drawn
693  $theData = [];
694  if ($this->disableSingleTableView) {
695  $theData[$titleCol] = '<span class="c-table">' . BackendUtility::wrapInHelp($table, '', $tableTitle)
696  . '</span> (<span class="t3js-table-total-items">' . $this->totalItems . '</span>)';
697  } else {
698  $icon = $this->table
699  ? '<span title="' . htmlspecialchars($lang->getLL('contractView')) . '">' . $this->iconFactory->getIcon('actions-view-table-collapse', Icon::SIZE_SMALL)->render() . '</span>'
700  : '<span title="' . htmlspecialchars($lang->getLL('expandView')) . '">' . $this->iconFactory->getIcon('actions-view-table-expand', Icon::SIZE_SMALL)->render() . '</span>';
701  $theData[$titleCol] = $this->linkWrapTable($table, $tableTitle . ' (<span class="t3js-table-total-items">' . $this->totalItems . '</span>) ' . $icon);
702  }
704  $tableHeader .= BackendUtility::wrapInHelp($table, '', $theData[$titleCol]);
705  } else {
706  // Render collapse button if in multi table mode
707  $collapseIcon = '';
708  if (!$this->table) {
709  $href = htmlspecialchars(($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')));
710  $title = $tableCollapsed
711  ? htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.expandTable'))
712  : htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.collapseTable'));
713  $icon = '<span class="collapseIcon">' . $this->iconFactory->getIcon(($tableCollapsed ? 'actions-view-list-expand' : 'actions-view-list-collapse'), Icon::SIZE_SMALL)->render() . '</span>';
714  $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>';
715  }
716  $tableHeader .= $theData[$titleCol] . $collapseIcon;
717  }
718  // Render table rows only if in multi table view or if in single table view
719  $rowOutput = '';
720  if (!$listOnlyInSingleTableMode || $this->table) {
721  // Fixing an order table for sortby tables
722  $this->currentTable = [];
723  $currentIdList = [];
724  $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
725  $prevUid = 0;
726  $prevPrevUid = 0;
727  // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
728  if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
729  $row = $queryResult->fetch();
730  $prevPrevUid = -((int)$row['uid']);
731  $row = $queryResult->fetch();
732  $prevUid = $row['uid'];
733  }
734  $accRows = [];
735  // Accumulate rows here
736  while ($row = $queryResult->fetch()) {
737  if (!$this->isRowListingConditionFulfilled($table, $row)) {
738  continue;
739  }
740  // In offline workspace, look for alternative record:
741  BackendUtility::workspaceOL($table, $row, $backendUser->workspace, true);
742  if (is_array($row)) {
743  $accRows[] = $row;
744  $currentIdList[] = $row['uid'];
745  if ($doSort) {
746  if ($prevUid) {
747  $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
748  $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
749  $this->currentTable['prevUid'][$row['uid']] = $prevUid;
750  }
751  $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
752  $prevUid = $row['uid'];
753  }
754  }
755  }
756  $this->totalRowCount = count($accRows);
757  // CSV initiated
758  if ($this->csvOutput) {
759  $this->initCSV();
760  }
761  // Render items:
762  $this->CBnames = [];
763  $this->duplicateStack = [];
764  $this->eCounter = $this->firstElementNumber;
765  $cc = 0;
766  foreach ($accRows as $row) {
767  // Render item row if counter < limit
768  if ($cc < $this->iLimit) {
769  $cc++;
770  $this->translations = false;
771  $rowOutput .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
772  // If localization view is enabled and no search happened it means that the selected
773  // records are either default or All language and here we will not select translations
774  // which point to the main record:
775  if ($this->localizationView && $l10nEnabled && $this->searchString === '') {
776  // For each available translation, render the record:
777  if (is_array($this->translations)) {
778  foreach ($this->translations as $lRow) {
779  // $lRow isn't always what we want - if record was moved we've to work with the
780  // placeholder records otherwise the list is messed up a bit
781  if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
782  $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
783  ->getQueryBuilderForTable($table);
784  $queryBuilder->getRestrictions()
785  ->removeAll()
786  ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
787  $predicates = [
788  $queryBuilder->expr()->eq(
789  't3ver_move_id',
790  $queryBuilder->createNamedParameter((int)$lRow['uid'], \PDO::PARAM_INT)
791  ),
792  $queryBuilder->expr()->eq(
793  'pid',
794  $queryBuilder->createNamedParameter((int)$row['_MOVE_PLH_pid'], \PDO::PARAM_INT)
795  ),
796  $queryBuilder->expr()->eq(
797  't3ver_wsid',
798  $queryBuilder->createNamedParameter((int)$row['t3ver_wsid'], \PDO::PARAM_INT)
799  ),
800  ];
801 
802  $tmpRow = $queryBuilder
803  ->select(...$selFieldList)
804  ->from($table)
805  ->andWhere(...$predicates)
806  ->execute()
807  ->fetch();
808 
809  $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
810  }
811  // In offline workspace, look for alternative record:
812  BackendUtility::workspaceOL($table, $lRow, $backendUser->workspace, true);
813  if (is_array($lRow) && $backendUser->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
814  $currentIdList[] = $lRow['uid'];
815  $rowOutput .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
816  }
817  }
818  }
819  }
820  }
821  // Counter of total rows incremented:
822  $this->eCounter++;
823  }
824  // Record navigation is added to the beginning and end of the table if in single
825  // table mode
826  if ($this->table) {
827  $rowOutput = $this->renderListNavigation('top') . $rowOutput . $this->renderListNavigation('bottom');
828  } else {
829  // Show that there are more records than shown
830  if ($this->totalItems > $this->itemsLimitPerTable) {
831  $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
832  $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
833  $colspan = $this->showIcon ? count($this->fieldArray) + 1 : count($this->fieldArray);
834  $rowOutput .= '<tr><td colspan="' . $colspan . '">
835  <a href="' . htmlspecialchars(($this->listURL() . '&table=' . rawurlencode($table))) . '" class="btn btn-default">'
836  . '<span class="t3-icon fa fa-chevron-down"></span> <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
837  </td></tr>';
838  }
839  }
840  // The header row for the table is now created:
841  $out .= $this->renderListHeader($table, $currentIdList);
842  }
843 
844  $collapseClass = $tableCollapsed && !$this->table ? 'collapse' : 'collapse in';
845  $dataState = $tableCollapsed && !$this->table ? 'collapsed' : 'expanded';
846 
847  // The list of records is added after the header:
848  $out .= $rowOutput;
849  // ... and it is all wrapped in a table:
850  $out = '
851 
852 
853 
854  <!--
855  DB listing of elements: "' . htmlspecialchars($table) . '"
856  -->
857  <div class="panel panel-space panel-default recordlist">
858  <div class="panel-heading">
859  ' . $tableHeader . '
860  </div>
861  <div class="' . $collapseClass . '" data-state="' . $dataState . '" id="recordlist-' . htmlspecialchars($table) . '">
862  <div class="table-fit">
863  <table data-table="' . htmlspecialchars($table) . '" class="table table-striped table-hover' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
864  ' . $out . '
865  </table>
866  </div>
867  </div>
868  </div>
869  ';
870  // Output csv if...
871  // This ends the page with exit.
872  if ($this->csvOutput) {
873  $this->outputCSV($table);
874  }
875  }
876  // Return content:
877  return $out;
878  }
879 
889  protected function isRowListingConditionFulfilled($table, $row)
890  {
891  return true;
892  }
893 
907  public function renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent = 0)
908  {
909  if (!is_array($row)) {
910  return '';
911  }
912  $rowOutput = '';
913  $id_orig = null;
914  // If in search mode, make sure the preview will show the correct page
915  if ((string)$this->searchString !== '') {
916  $id_orig = $this->id;
917  $this->id = $row['pid'];
918  }
919 
920  $tagAttributes = [
921  'class' => ['t3js-entity'],
922  'data-table' => $table,
923  'title' => 'id=' . $row['uid'],
924  ];
925 
926  // Add active class to record of current link
927  if (
928  isset($this->currentLink['tableNames'])
929  && (int)$this->currentLink['uid'] === (int)$row['uid']
930  && GeneralUtility::inList($this->currentLink['tableNames'], $table)
931  ) {
932  $tagAttributes['class'][] = 'active';
933  }
934  // Add special classes for first and last row
935  if ($cc == 1 && $indent == 0) {
936  $tagAttributes['class'][] = 'firstcol';
937  }
938  if ($cc == $this->totalRowCount || $cc == $this->iLimit) {
939  $tagAttributes['class'][] = 'lastcol';
940  }
941  // Overriding with versions background color if any:
942  if (!empty($row['_CSSCLASS'])) {
943  $tagAttributes['class'] = [$row['_CSSCLASS']];
944  }
945  // Incr. counter.
946  $this->counter++;
947  // The icon with link
948  $toolTip = BackendUtility::getRecordToolTip($row, $table);
949  $additionalStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : '';
950  $iconImg = '<span ' . $toolTip . ' ' . $additionalStyle . '>'
951  . $this->iconFactory->getIconForRecord($table, $row, Icon::SIZE_SMALL)->render()
952  . '</span>';
953  $theIcon = $this->clickMenuEnabled ? BackendUtility::wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
954  // Preparing and getting the data-array
955  $theData = [];
956  $localizationMarkerClass = '';
957  foreach ($this->fieldArray as $fCol) {
958  if ($fCol == $titleCol) {
959  $recTitle = BackendUtility::getRecordTitle($table, $row, false, true);
960  $warning = '';
961  // If the record is edit-locked by another user, we will show a little warning sign:
962  $lockInfo = BackendUtility::isRecordLocked($table, $row['uid']);
963  if ($lockInfo) {
964  $warning = '<span data-toggle="tooltip" data-placement="right" data-title="' . htmlspecialchars($lockInfo['msg']) . '">'
965  . $this->iconFactory->getIcon('status-warning-in-use', Icon::SIZE_SMALL)->render() . '</span>';
966  }
967  $theData[$fCol] = $theData['__label'] = $warning . $this->linkWrapItems($table, $row['uid'], $recTitle, $row);
968  // Render thumbnails, if:
969  // - a thumbnail column exists
970  // - there is content in it
971  // - the thumbnail column is visible for the current type
972  $type = 0;
973  if (isset($GLOBALS['TCA'][$table]['ctrl']['type'])) {
974  $typeColumn = $GLOBALS['TCA'][$table]['ctrl']['type'];
975  $type = $row[$typeColumn];
976  }
977  // If current type doesn't exist, set it to 0 (or to 1 for historical reasons,
978  // if 0 doesn't exist)
979  if (!isset($GLOBALS['TCA'][$table]['types'][$type])) {
980  $type = isset($GLOBALS['TCA'][$table]['types'][0]) ? 0 : 1;
981  }
982  $visibleColumns = $this->getVisibleColumns($GLOBALS['TCA'][$table], $type);
983 
984  if ($this->thumbs &&
985  trim($row[$thumbsCol]) &&
986  preg_match('/(^|(.*(;|,)?))' . $thumbsCol . '(((;|,).*)|$)/', $visibleColumns) === 1
987  ) {
988  $thumbCode = '<br />' . $this->thumbCode($row, $table, $thumbsCol);
989  $theData[$fCol] .= $thumbCode;
990  $theData['__label'] .= $thumbCode;
991  }
992  if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
993  && $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] != 0
994  && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0
995  ) {
996  // It's a translated record with a language parent
997  $localizationMarkerClass = ' localization';
998  }
999  } elseif ($fCol === 'pid') {
1000  $theData[$fCol] = $row[$fCol];
1001  } elseif ($fCol === '_PATH_') {
1002  $theData[$fCol] = $this->recPath($row['pid']);
1003  } elseif ($fCol === '_REF_') {
1004  $theData[$fCol] = $this->createReferenceHtml($table, $row['uid']);
1005  } elseif ($fCol === '_CONTROL_') {
1006  $theData[$fCol] = $this->makeControl($table, $row);
1007  } elseif ($fCol === '_CLIPBOARD_') {
1008  $theData[$fCol] = $this->makeClip($table, $row);
1009  } elseif ($fCol === '_LOCALIZATION_') {
1010  list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row);
1011  $theData[$fCol] = $lC1;
1012  $theData[$fCol . 'b'] = '<div class="btn-group">' . $lC2 . '</div>';
1013  } elseif ($fCol === '_LOCALIZATION_b') {
1014  // deliberately empty
1015  } else {
1016  $pageId = $table === 'pages' ? $row['uid'] : $row['pid'];
1017  $tmpProc = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'], true, $pageId);
1018  $theData[$fCol] = $this->linkUrlMail(htmlspecialchars($tmpProc), $row[$fCol]);
1019  if ($this->csvOutput) {
1020  $row[$fCol] = BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 0, $row['uid']);
1021  }
1022  }
1023  }
1024  // Reset the ID if it was overwritten
1025  if ((string)$this->searchString !== '') {
1026  $this->id = $id_orig;
1027  }
1028  // Add row to CSV list:
1029  if ($this->csvOutput) {
1030  $this->addToCSV($row);
1031  }
1032  // Add classes to table cells
1033  $this->addElement_tdCssClass[$titleCol] = 'col-title col-responsive' . $localizationMarkerClass;
1034  $this->addElement_tdCssClass['__label'] = $this->addElement_tdCssClass[$titleCol];
1035  $this->addElement_tdCssClass['_CONTROL_'] = 'col-control';
1036  if ($this->getModule()->MOD_SETTINGS['clipBoard']) {
1037  $this->addElement_tdCssClass['_CLIPBOARD_'] = 'col-clipboard';
1038  }
1039  $this->addElement_tdCssClass['_PATH_'] = 'col-path';
1040  $this->addElement_tdCssClass['_LOCALIZATION_'] = 'col-localizationa';
1041  $this->addElement_tdCssClass['_LOCALIZATION_b'] = 'col-localizationb';
1042  // Create element in table cells:
1043  $theData['uid'] = $row['uid'];
1044  if (isset($GLOBALS['TCA'][$table]['ctrl']['languageField'])
1045  && isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'])
1046  && $table !== 'pages_language_overlay'
1047  ) {
1048  $theData['_l10nparent_'] = $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']];
1049  }
1050 
1051  $tagAttributes = array_map(
1052  function ($attributeValue) {
1053  if (is_array($attributeValue)) {
1054  return implode(' ', $attributeValue);
1055  }
1056  return $attributeValue;
1057  },
1058  $tagAttributes
1059  );
1060 
1061  $rowOutput .= $this->addElement(1, $theIcon, $theData, GeneralUtility::implodeAttributes($tagAttributes, true));
1062  // Finally, return table row element:
1063  return $rowOutput;
1064  }
1065 
1074  protected function getReferenceCount($tableName, $uid)
1075  {
1076  if (!isset($this->referenceCount[$tableName][$uid])) {
1077  $numberOfReferences = GeneralUtility::makeInstance(ConnectionPool::class)
1078  ->getConnectionForTable('sys_refindex')
1079  ->count(
1080  '*',
1081  'sys_refindex',
1082  [
1083  'ref_table' => $tableName,
1084  'ref_uid' => (int)$uid,
1085  'deleted' => 0
1086  ]
1087  );
1088  $this->referenceCount[$tableName][$uid] = $numberOfReferences;
1089  }
1090  return $this->referenceCount[$tableName][$uid];
1091  }
1092 
1103  public function renderListHeader($table, $currentIdList)
1104  {
1105  $lang = $this->getLanguageService();
1106  // Init:
1107  $theData = [];
1108  $icon = '';
1109  // Traverse the fields:
1110  foreach ($this->fieldArray as $fCol) {
1111  // Calculate users permissions to edit records in the table:
1112  $permsEdit = $this->calcPerms & ($table === 'pages' ? 2 : 16) && $this->overlayEditLockPermissions($table);
1113  switch ((string)$fCol) {
1114  case '_PATH_':
1115  // Path
1116  $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels._PATH_')) . ']</i>';
1117  break;
1118  case '_REF_':
1119  // References
1120  $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_file_list.xlf:c__REF_')) . ']</i>';
1121  break;
1122  case '_LOCALIZATION_':
1123  // Path
1124  $theData[$fCol] = '<i>[' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels._LOCALIZATION_')) . ']</i>';
1125  break;
1126  case '_LOCALIZATION_b':
1127  // Path
1128  $theData[$fCol] = htmlspecialchars($lang->getLL('Localize'));
1129  break;
1130  case '_CLIPBOARD_':
1131  if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
1132  break;
1133  }
1134  // Clipboard:
1135  $cells = [];
1136  // If there are elements on the clipboard for this table, and the parent page is not locked by editlock
1137  // then display the "paste into" icon:
1138  $elFromTable = $this->clipObj->elFromTable($table);
1139  if (!empty($elFromTable) && $this->overlayEditLockPermissions($table)) {
1140  $href = htmlspecialchars($this->clipObj->pasteUrl($table, $this->id));
1141  $confirmMessage = $this->clipObj->confirmMsgText('pages', $this->pageRow, 'into', $elFromTable);
1142  $cells['pasteAfter'] = '<a class="btn btn-default t3js-modal-trigger"'
1143  . ' href="' . $href . '"'
1144  . ' title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1145  . ' data-title="' . htmlspecialchars($lang->getLL('clip_paste')) . '"'
1146  . ' data-content="' . htmlspecialchars($confirmMessage) . '"'
1147  . ' data-severity="warning">'
1148  . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render()
1149  . '</a>';
1150  }
1151  // If the numeric clipboard pads are enabled, display the control icons for that:
1152  if ($this->clipObj->current !== 'normal') {
1153  // The "select" link:
1154  $spriteIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL)->render();
1155  $cells['copyMarked'] = $this->linkClipboardHeaderIcon($spriteIcon, $table, 'setCB', '', $lang->getLL('clip_selectMarked'));
1156  // The "edit marked" link:
1157  $editUri = BackendUtility::getModuleUrl('record_edit')
1158  . '&edit[' . $table . '][{entityIdentifiers:editList}]=edit'
1159  . '&returnUrl={T3_THIS_LOCATION}';
1160  $cells['edit'] = '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1161  . ' data-uri="' . htmlspecialchars($editUri) . '"'
1162  . ' title="' . htmlspecialchars($lang->getLL('clip_editMarked')) . '">'
1163  . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1164  // The "Delete marked" link:
1165  $cells['delete'] = $this->linkClipboardHeaderIcon(
1166  $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render(),
1167  $table,
1168  'delete',
1169  sprintf($lang->getLL('clip_deleteMarkedWarning'), $lang->sL($GLOBALS['TCA'][$table]['ctrl']['title'])),
1170  $lang->getLL('clip_deleteMarked')
1171  );
1172  // The "Select all" link:
1173  $onClick = htmlspecialchars(('checkOffCB(' . GeneralUtility::quoteJSvalue(implode(',', $this->CBnames)) . ', this); return false;'));
1174  $cells['markAll'] = '<a class="btn btn-default" rel="" href="#" onclick="' . $onClick . '" title="'
1175  . htmlspecialchars($lang->getLL('clip_markRecords')) . '">'
1176  . $this->iconFactory->getIcon('actions-document-select', Icon::SIZE_SMALL)->render() . '</a>';
1177  } else {
1178  $cells['empty'] = '';
1179  }
1187  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1188  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1189  $hookObject = GeneralUtility::getUserObj($classData);
1190  if (!$hookObject instanceof RecordListHookInterface) {
1191  throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, 1195567850);
1192  }
1193  $cells = $hookObject->renderListHeaderActions($table, $currentIdList, $cells, $this);
1194  }
1195  }
1196  $theData[$fCol] = '';
1197  if (isset($cells['edit']) && isset($cells['delete'])) {
1198  $theData[$fCol] .= '<div class="btn-group" role="group">' . $cells['edit'] . $cells['delete'] . '</div>';
1199  unset($cells['edit'], $cells['delete']);
1200  }
1201  $theData[$fCol] .= '<div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1202  break;
1203  case '_CONTROL_':
1204  // Control panel:
1205  if ($this->isEditable($table)) {
1206  // If new records can be created on this page, add links:
1207  $permsAdditional = ($table === 'pages' ? 8 : 16);
1208  if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) {
1209  $spriteIcon = $table === 'pages'
1210  ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL)
1211  : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL);
1212  if ($table === 'tt_content' && $this->newWizards) {
1213  // If mod.newContentElementWizard.override is set, use that extension's create new content wizard instead:
1214  $tmpTSc = BackendUtility::getModTSconfig($this->pageinfo['uid'], 'mod');
1215  $newContentElementWizard = isset($tmpTSc['properties']['newContentElementWizard.']['override'])
1216  ? $tmpTSc['properties']['newContentElementWizard.']['override']
1217  : 'new_content_element';
1218  $newContentWizScriptPath = BackendUtility::getModuleUrl($newContentElementWizard, ['id' => $this->id]);
1219 
1220  $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($newContentWizScriptPath) . ');';
1221  $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1222  . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1223  } elseif ($table === 'pages' && $this->newWizards) {
1224  $parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
1225  $href = BackendUtility::getModuleUrl('db_new', $parameters);
1226  $icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . htmlspecialchars($lang->getLL('new')) . '">'
1227  . $spriteIcon->render() . '</a>';
1228  } else {
1229  $params = '&edit[' . $table . '][' . $this->id . ']=new';
1230  if ($table === 'pages_language_overlay') {
1231  $params .= '&overrideVals[pages_language_overlay][doktype]=' . (int)$this->pageRow['doktype'];
1232  }
1233  $icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1234  . '" title="' . htmlspecialchars($lang->getLL('new')) . '">' . $spriteIcon->render() . '</a>';
1235  }
1236  }
1237  // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
1238  if ($permsEdit && $this->table && is_array($currentIdList)) {
1239  $entityIdentifiers = 'entityIdentifiers';
1240  if ($this->clipNumPane()) {
1241  $entityIdentifiers .= ':editList';
1242  }
1243  $editUri = BackendUtility::getModuleUrl('record_edit')
1244  . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1245  . '&columnsOnly=' . implode(',', $this->fieldArray)
1246  . '&returnUrl={T3_THIS_LOCATION}';
1247  $icon .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1248  . ' data-uri="' . htmlspecialchars($editUri) . '"'
1249  . ' title="' . htmlspecialchars($lang->getLL('editShownColumns')) . '">'
1250  . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1251  $icon = '<div class="btn-group" role="group">' . $icon . '</div>';
1252  }
1253  // Add an empty entry, so column count fits again after moving this into $icon
1254  $theData[$fCol] = '&nbsp;';
1255  }
1256  break;
1257  default:
1258  // Regular fields header:
1259  $theData[$fCol] = '';
1260 
1261  // Check if $fCol is really a field and get the label and remove the colons
1262  // at the end
1263  $sortLabel = BackendUtility::getItemLabel($table, $fCol);
1264  if ($sortLabel !== null) {
1265  $sortLabel = htmlspecialchars($lang->sL($sortLabel));
1266  $sortLabel = rtrim(trim($sortLabel), ':');
1267  } else {
1268  // No TCA field, only output the $fCol variable with square brackets []
1269  $sortLabel = htmlspecialchars($fCol);
1270  $sortLabel = '<i>[' . rtrim(trim($sortLabel), ':') . ']</i>';
1271  }
1272 
1273  if ($this->table && is_array($currentIdList)) {
1274  // If the numeric clipboard pads are selected, show duplicate sorting link:
1275  if ($this->clipNumPane()) {
1276  $theData[$fCol] .= '<a class="btn btn-default" href="' . htmlspecialchars($this->listURL('', '-1') . '&duplicateField=' . $fCol)
1277  . '" title="' . htmlspecialchars($lang->getLL('clip_duplicates')) . '">'
1278  . $this->iconFactory->getIcon('actions-document-duplicates-select', Icon::SIZE_SMALL)->render() . '</a>';
1279  }
1280  // If the table can be edited, add link for editing THIS field for all
1281  // listed records:
1282  if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
1283  $entityIdentifiers = 'entityIdentifiers';
1284  if ($this->clipNumPane()) {
1285  $entityIdentifiers .= ':editList';
1286  }
1287  $editUri = BackendUtility::getModuleUrl('record_edit')
1288  . '&edit[' . $table . '][{' . $entityIdentifiers . '}]=edit'
1289  . '&columnsOnly=' . $fCol
1290  . '&returnUrl={T3_THIS_LOCATION}';
1291  $iTitle = sprintf($lang->getLL('editThisColumn'), $sortLabel);
1292  $theData[$fCol] .= '<a class="btn btn-default t3js-record-edit-multiple" href="#"'
1293  . ' data-uri="' . htmlspecialchars($editUri) . '"'
1294  . ' title="' . htmlspecialchars($iTitle) . '">'
1295  . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
1296  }
1297  if (strlen($theData[$fCol]) > 0) {
1298  $theData[$fCol] = '<div class="btn-group" role="group">' . $theData[$fCol] . '</div> ';
1299  }
1300  }
1301  $theData[$fCol] .= $this->addSortLink($sortLabel, $fCol, $table);
1302  }
1303  }
1310  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1311  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1312  $hookObject = GeneralUtility::getUserObj($classData);
1313  if (!$hookObject instanceof RecordListHookInterface) {
1314  throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, 1195567855);
1315  }
1316  $theData = $hookObject->renderListHeader($table, $currentIdList, $theData, $this);
1317  }
1318  }
1319 
1320  // Create and return header table row:
1321  return '<thead>' . $this->addElement(1, $icon, $theData, '', '', '', 'th') . '</thead>';
1322  }
1323 
1330  protected function getPointerForPage($page)
1331  {
1332  return ($page - 1) * $this->iLimit;
1333  }
1334 
1341  protected function renderListNavigation($renderPart = 'top')
1342  {
1343  $totalPages = ceil($this->totalItems / $this->iLimit);
1344  // Show page selector if not all records fit into one page
1345  if ($totalPages <= 1) {
1346  return '';
1347  }
1348  $content = '';
1349  $listURL = $this->listURL('', $this->table, 'firstElementNumber');
1350  // 1 = first page
1351  // 0 = first element
1352  $currentPage = floor($this->firstElementNumber / $this->iLimit) + 1;
1353  // Compile first, previous, next, last and refresh buttons
1354  if ($currentPage > 1) {
1355  $labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:first'));
1356  $labelPrevious = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:previous'));
1357  $first = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage(1) . '" title="' . $labelFirst . '">'
1358  . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</a></li>';
1359  $previous = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage - 1) . '" title="' . $labelPrevious . '">'
1360  . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</a></li>';
1361  } else {
1362  $first = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-first', Icon::SIZE_SMALL)->render() . '</span></li>';
1363  $previous = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-previous', Icon::SIZE_SMALL)->render() . '</span></li>';
1364  }
1365  if ($currentPage < $totalPages) {
1366  $labelNext = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:next'));
1367  $labelLast = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:last'));
1368  $next = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($currentPage + 1) . '" title="' . $labelNext . '">'
1369  . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</a></li>';
1370  $last = '<li><a href="' . $listURL . '&pointer=' . $this->getPointerForPage($totalPages) . '" title="' . $labelLast . '">'
1371  . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</a></li>';
1372  } else {
1373  $next = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-next', Icon::SIZE_SMALL)->render() . '</span></li>';
1374  $last = '<li class="disabled"><span>' . $this->iconFactory->getIcon('actions-view-paging-last', Icon::SIZE_SMALL)->render() . '</span></li>';
1375  }
1376  $reload = '<li><a href="#" onclick="document.dblistForm.action=' . GeneralUtility::quoteJSvalue($listURL
1377  . '&pointer=') . '+calculatePointer(document.getElementById(' . GeneralUtility::quoteJSvalue('jumpPage-' . $renderPart)
1378  . ').value); document.dblistForm.submit(); return true;" title="'
1379  . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:reload')) . '">'
1380  . $this->iconFactory->getIcon('actions-refresh', Icon::SIZE_SMALL)->render() . '</a></li>';
1381  if ($renderPart === 'top') {
1382  // Add js to traverse a page select input to a pointer value
1383  $content = '
1384 <script type="text/javascript">
1385 /*<![CDATA[*/
1386  function calculatePointer(page) {
1387  if (page > ' . $totalPages . ') {
1388  page = ' . $totalPages . ';
1389  }
1390  if (page < 1) {
1391  page = 1;
1392  }
1393  return (page - 1) * ' . $this->iLimit . ';
1394  }
1395 /*]]>*/
1396 </script>
1397 ';
1398  }
1399  $pageNumberInput = '
1400  <input type="number" min="1" max="' . $totalPages . '" value="' . $currentPage . '" size="3" class="form-control input-sm paginator-input" id="jumpPage-' . $renderPart . '" name="jumpPage-'
1401  . $renderPart . '" onkeyup="if (event.keyCode == 13) { document.dblistForm.action=' . htmlspecialchars(GeneralUtility::quoteJSvalue($listURL . '&pointer='))
1402  . '+calculatePointer(this.value); document.dblistForm.submit(); } return true;" />
1403  ';
1404  $pageIndicatorText = sprintf(
1405  $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:pageIndicator'),
1406  $pageNumberInput,
1407  $totalPages
1408  );
1409  $pageIndicator = '<li><span>' . $pageIndicatorText . '</span></li>';
1410  if ($this->totalItems > $this->firstElementNumber + $this->iLimit) {
1411  $lastElementNumber = $this->firstElementNumber + $this->iLimit;
1412  } else {
1413  $lastElementNumber = $this->totalItems;
1414  }
1415  $rangeIndicator = '<li><span>' . sprintf($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_mod_web_list.xlf:rangeIndicator'), ($this->firstElementNumber + 1), $lastElementNumber) . '</span></li>';
1416 
1417  $titleColumn = $this->fieldArray[0];
1418  $data = [
1419  $titleColumn => $content . '
1420  <nav class="pagination-wrap">
1421  <ul class="pagination pagination-block">
1422  ' . $first . '
1423  ' . $previous . '
1424  ' . $rangeIndicator . '
1425  ' . $pageIndicator . '
1426  ' . $next . '
1427  ' . $last . '
1428  ' . $reload . '
1429  </ul>
1430  </nav>
1431  '
1432  ];
1433  return $this->addElement(1, '', $data);
1434  }
1435 
1436  /*********************************
1437  *
1438  * Rendering of various elements
1439  *
1440  *********************************/
1441 
1450  public function makeControl($table, $row)
1451  {
1452  $module = $this->getModule();
1453  $rowUid = $row['uid'];
1454  if (ExtensionManagementUtility::isLoaded('version') && isset($row['_ORIG_uid'])) {
1455  $rowUid = $row['_ORIG_uid'];
1456  }
1457  $cells = [
1458  'primary' => [],
1459  'secondary' => []
1460  ];
1461  // If the listed table is 'pages' we have to request the permission settings for each page:
1462  $localCalcPerms = 0;
1463  if ($table === 'pages') {
1464  $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
1465  }
1466  $permsEdit = $table === 'pages'
1467  && $this->getBackendUserAuthentication()->checkLanguageAccess(0)
1468  && $localCalcPerms & Permission::PAGE_EDIT
1469  || $table !== 'pages'
1470  && $this->calcPerms & Permission::CONTENT_EDIT
1471  && $this->getBackendUserAuthentication()->recordEditAccessInternals($table, $row);
1472  $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1473  // "Show" link (only pages and tt_content elements)
1474  if ($table === 'pages' || $table === 'tt_content') {
1475  $onClick = $this->getOnClickForRow($table, $row);
1476  $viewAction = '<a class="btn btn-default" href="#" onclick="'
1477  . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.showPage')) . '">'
1478  . $this->iconFactory->getIcon('actions-view', Icon::SIZE_SMALL)->render() . '</a>';
1479  $this->addActionToCellGroup($cells, $viewAction, 'view');
1480  }
1481  // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
1482  if ($permsEdit) {
1483  $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
1484  $iconIdentifier = 'actions-open';
1485  if ($table === 'pages') {
1486  $iconIdentifier = 'actions-page-open';
1487  }
1488  $overlayIdentifier = !$this->isEditable($table) ? 'overlay-readonly' : null;
1489  $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1490  . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('edit')) . '">' . $this->iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL, $overlayIdentifier)->render() . '</a>';
1491  } else {
1492  $editAction = $this->spaceIcon;
1493  }
1494  $this->addActionToCellGroup($cells, $editAction, 'edit');
1495  // "Info": (All records)
1496  $onClick = 'top.launchView(' . GeneralUtility::quoteJSvalue($table) . ', ' . (int)$row['uid'] . '); return false;';
1497  $viewBigAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('showInfo')) . '">'
1498  . $this->iconFactory->getIcon('actions-document-info', Icon::SIZE_SMALL)->render() . '</a>';
1499  $this->addActionToCellGroup($cells, $viewBigAction, 'viewBig');
1500  // "Move" wizard link for pages/tt_content elements:
1501  if ($permsEdit && ($table === 'tt_content' || $table === 'pages')) {
1502  $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('move_element') . '&table=' . $table . '&uid=' . $row['uid']) . ');';
1503  $linkTitleLL = htmlspecialchars($this->getLanguageService()->getLL('move_' . ($table === 'tt_content' ? 'record' : 'page')));
1504  $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-move', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-document-move', Icon::SIZE_SMALL));
1505  $moveAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $linkTitleLL . '">' . $icon->render() . '</a>';
1506  $this->addActionToCellGroup($cells, $moveAction, 'move');
1507  }
1508  // If the table is NOT a read-only table, then show these links:
1509  if ($this->isEditable($table)) {
1510  // "Revert" link (history/undo)
1511  $showHistoryTS = $this->getBackendUserAuthentication()->getTSConfig('options.showHistory');
1512  $showHistory = (bool)trim($showHistoryTS['properties'][$table] ?? $showHistoryTS['value'] ?? '1');
1513  if ($showHistory) {
1514  $moduleUrl = BackendUtility::getModuleUrl('record_history', ['element' => $table . ':' . $row['uid']]);
1515  $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($moduleUrl) . ',\'#latest\');';
1516  $historyAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
1517  . htmlspecialchars($this->getLanguageService()->getLL('history')) . '">'
1518  . $this->iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render() . '</a>';
1519  $this->addActionToCellGroup($cells, $historyAction, 'history');
1520  }
1521  // Versioning:
1523  $vers = BackendUtility::selectVersionsOfRecord($table, $row['uid'], 'uid', $this->getBackendUserAuthentication()->workspace, false, $row);
1524  // If table can be versionized.
1525  if (is_array($vers)) {
1526  $href = BackendUtility::getModuleUrl('web_txversionM1', [
1527  'table' => $table, 'uid' => $row['uid']
1528  ]);
1529  $versionAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1530  . htmlspecialchars($this->getLanguageService()->getLL('displayVersions')) . '">'
1531  . $this->iconFactory->getIcon('actions-version-page-open', Icon::SIZE_SMALL)->render() . '</a>';
1532  $this->addActionToCellGroup($cells, $versionAction, 'version');
1533  }
1534  }
1535  // "Edit Perms" link:
1536  if ($table === 'pages' && $this->getBackendUserAuthentication()->check('modules', 'system_BeuserTxPermission') && ExtensionManagementUtility::isLoaded('beuser')) {
1537  $href = BackendUtility::getModuleUrl('system_BeuserTxPermission') . '&id=' . $row['uid'] . '&tx_beuser_system_beusertxpermission[action]=edit' . $this->makeReturnUrl();
1538  $permsAction = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="'
1539  . htmlspecialchars($this->getLanguageService()->getLL('permissions')) . '">'
1540  . $this->iconFactory->getIcon('actions-lock', Icon::SIZE_SMALL)->render() . '</a>';
1541  $this->addActionToCellGroup($cells, $permsAction, 'perms');
1542  }
1543  // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row
1544  // or if default values can depend on previous record):
1545  if (($GLOBALS['TCA'][$table]['ctrl']['sortby'] || $GLOBALS['TCA'][$table]['ctrl']['useColumnsForDefaultValues']) && $permsEdit) {
1546  if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT || $table === 'pages' && $this->calcPerms & Permission::PAGE_NEW) {
1547  if ($this->showNewRecLink($table)) {
1548  $params = '&edit[' . $table . '][' . -($row['_MOVE_PLH'] ? $row['_MOVE_PLH_uid'] : $row['uid']) . ']=new';
1549  $icon = ($table === 'pages' ? $this->iconFactory->getIcon('actions-page-new', Icon::SIZE_SMALL) : $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL));
1550  $titleLabel = 'new';
1551  if ($GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1552  $titleLabel .= ($table === 'pages' ? 'Page' : 'Record');
1553  }
1554  $newAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
1555  . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($titleLabel)) . '">'
1556  . $icon->render() . '</a>';
1557  $this->addActionToCellGroup($cells, $newAction, 'new');
1558  }
1559  }
1560  }
1561  // "Up/Down" links
1562  if ($permsEdit && $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField && !$this->searchLevels) {
1563  if (isset($this->currentTable['prev'][$row['uid']])) {
1564  // Up
1565  $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prev'][$row['uid']];
1566  $moveUpAction = '<a class="btn btn-default" href="#" onclick="'
1567  . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
1568  . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveUp')) . '">'
1569  . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '</a>';
1570  } else {
1571  $moveUpAction = $this->spaceIcon;
1572  }
1573  $this->addActionToCellGroup($cells, $moveUpAction, 'moveUp');
1574 
1575  if ($this->currentTable['next'][$row['uid']]) {
1576  // Down
1577  $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['next'][$row['uid']];
1578  $moveDownAction = '<a class="btn btn-default" href="#" onclick="'
1579  . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
1580  . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('moveDown')) . '">'
1581  . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '</a>';
1582  } else {
1583  $moveDownAction = $this->spaceIcon;
1584  }
1585  $this->addActionToCellGroup($cells, $moveDownAction, 'moveDown');
1586  }
1587  // "Hide/Unhide" links:
1588  $hiddenField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
1589 
1590  if (
1591  !empty($GLOBALS['TCA'][$table]['columns'][$hiddenField])
1592  && (empty($GLOBALS['TCA'][$table]['columns'][$hiddenField]['exclude'])
1593  || $this->getBackendUserAuthentication()->check('non_exclude_fields', $table . ':' . $hiddenField))
1594  ) {
1595  if (!$permsEdit || $this->isRecordCurrentBackendUser($table, $row)) {
1596  $hideAction = $this->spaceIcon;
1597  } else {
1598  $hideTitle = htmlspecialchars($this->getLanguageService()->getLL('hide' . ($table === 'pages' ? 'Page' : '')));
1599  $unhideTitle = htmlspecialchars($this->getLanguageService()->getLL('unHide' . ($table === 'pages' ? 'Page' : '')));
1600  if ($row[$hiddenField]) {
1601  $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=0';
1602  $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="hidden" href="#"'
1603  . ' data-params="' . htmlspecialchars($params) . '"'
1604  . ' title="' . $unhideTitle . '"'
1605  . ' data-toggle-title="' . $hideTitle . '">'
1606  . $this->iconFactory->getIcon('actions-edit-unhide', Icon::SIZE_SMALL)->render() . '</a>';
1607  } else {
1608  $params = 'data[' . $table . '][' . $rowUid . '][' . $hiddenField . ']=1';
1609  $hideAction = '<a class="btn btn-default t3js-record-hide" data-state="visible" href="#"'
1610  . ' data-params="' . htmlspecialchars($params) . '"'
1611  . ' title="' . $hideTitle . '"'
1612  . ' data-toggle-title="' . $unhideTitle . '">'
1613  . $this->iconFactory->getIcon('actions-edit-hide', Icon::SIZE_SMALL)->render() . '</a>';
1614  }
1615  }
1616  $this->addActionToCellGroup($cells, $hideAction, 'hide');
1617  }
1618  // "Delete" link:
1619  $disableDeleteTS = $this->getBackendUserAuthentication()->getTSConfig('options.disableDelete');
1620  $disableDelete = (bool)trim(isset($disableDeleteTS['properties'][$table]) ? $disableDeleteTS['properties'][$table] : $disableDeleteTS['value']);
1621  if ($permsEdit && !$disableDelete && ($table === 'pages' && $localCalcPerms & Permission::PAGE_DELETE || $table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT)) {
1622  // Check if the record version is in "deleted" state, because that will switch the action to "restore"
1623  if ($this->getBackendUserAuthentication()->workspace > 0 && isset($row['t3ver_state']) && (int)$row['t3ver_state'] === 2) {
1624  $actionName = 'restore';
1625  $refCountMsg = '';
1626  } else {
1627  $actionName = 'delete';
1628  $refCountMsg = BackendUtility::referenceCount(
1629  $table,
1630  $row['uid'],
1631  ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
1632  $this->getReferenceCount($table, $row['uid'])
1634  $table,
1635  $row['uid'],
1636  ' ' . $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.translationsOfRecord')
1637  );
1638  }
1639 
1640  if ($this->isRecordCurrentBackendUser($table, $row)) {
1641  $deleteAction = $this->spaceIcon;
1642  } else {
1643  $title = BackendUtility::getRecordTitle($table, $row);
1644  $warningText = $this->getLanguageService()->getLL($actionName . 'Warning') . ' "' . $title . '" ' . '[' . $table . ':' . $row['uid'] . ']' . $refCountMsg;
1645 
1646  $params = 'cmd[' . $table . '][' . $row['uid'] . '][delete]=1';
1647  $icon = $this->iconFactory->getIcon('actions-edit-' . $actionName, Icon::SIZE_SMALL)->render();
1648  $linkTitle = htmlspecialchars($this->getLanguageService()->getLL($actionName));
1649  $deleteAction = '<a class="btn btn-default t3js-record-delete" href="#" '
1650  . ' data-l10parent="' . htmlspecialchars($row['l10n_parent']) . '"'
1651  . ' data-params="' . htmlspecialchars($params) . '" data-title="' . htmlspecialchars($title) . '"'
1652  . ' data-message="' . htmlspecialchars($warningText) . '" title="' . $linkTitle . '"'
1653  . '>' . $icon . '</a>';
1654  }
1655  } else {
1656  $deleteAction = $this->spaceIcon;
1657  }
1658  $this->addActionToCellGroup($cells, $deleteAction, 'delete');
1659  // "Levels" links: Moving pages into new levels...
1660  if ($permsEdit && $table === 'pages' && !$this->searchLevels) {
1661  // Up (Paste as the page right after the current parent page)
1662  if ($this->calcPerms & Permission::PAGE_NEW) {
1663  $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . -$this->id;
1664  $moveLeftAction = '<a class="btn btn-default" href="#" onclick="'
1665  . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
1666  . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('prevLevel')) . '">'
1667  . $this->iconFactory->getIcon('actions-move-left', Icon::SIZE_SMALL)->render() . '</a>';
1668  $this->addActionToCellGroup($cells, $moveLeftAction, 'moveLeft');
1669  }
1670  // Down (Paste as subpage to the page right above)
1671  if ($this->currentTable['prevUid'][$row['uid']]) {
1672  $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $this->currentTable['prevUid'][$row['uid']]));
1673  if ($localCalcPerms & Permission::PAGE_NEW) {
1674  $params = '&cmd[' . $table . '][' . $row['uid'] . '][move]=' . $this->currentTable['prevUid'][$row['uid']];
1675  $moveRightAction = '<a class="btn btn-default" href="#" onclick="'
1676  . htmlspecialchars('return jumpToUrl(' . BackendUtility::getLinkToDataHandlerAction($params, -1) . ');')
1677  . '" title="' . htmlspecialchars($this->getLanguageService()->getLL('nextLevel')) . '">'
1678  . $this->iconFactory->getIcon('actions-move-right', Icon::SIZE_SMALL)->render() . '</a>';
1679  } else {
1680  $moveRightAction = $this->spaceIcon;
1681  }
1682  } else {
1683  $moveRightAction = $this->spaceIcon;
1684  }
1685  $this->addActionToCellGroup($cells, $moveRightAction, 'moveRight');
1686  }
1687  }
1691  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1692  $stat = '';
1693  $_params = [$table, $row['uid']];
1694  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1695  $stat .= GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1696  }
1697  $this->addActionToCellGroup($cells, $stat, 'stat');
1698  }
1706  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1707  // for compatibility reason, we move all icons to the rootlevel
1708  // before calling the hooks
1709  foreach ($cells as $section => $actions) {
1710  foreach ($actions as $actionKey => $action) {
1711  $cells[$actionKey] = $action;
1712  }
1713  }
1714  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1715  $hookObject = GeneralUtility::getUserObj($classData);
1716  if (!$hookObject instanceof RecordListHookInterface) {
1717  throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, 1195567840);
1718  }
1719  $cells = $hookObject->makeControl($table, $row, $cells, $this);
1720  }
1721  // now sort icons again into primary and secondary sections
1722  // after all hooks are processed
1723  $hookCells = $cells;
1724  foreach ($hookCells as $key => $value) {
1725  if ($key === 'primary' || $key === 'secondary') {
1726  continue;
1727  }
1728  $this->addActionToCellGroup($cells, $value, $key);
1729  }
1730  }
1731  $output = '<!-- CONTROL PANEL: ' . $table . ':' . $row['uid'] . ' -->';
1732  foreach ($cells as $classification => $actions) {
1733  $visibilityClass = ($classification !== 'primary' && !$module->MOD_SETTINGS['bigControlPanel'] ? 'collapsed' : 'expanded');
1734  if ($visibilityClass === 'collapsed') {
1735  $cellOutput = '';
1736  foreach ($actions as $action) {
1737  $cellOutput .= $action;
1738  }
1739  $output .= ' <div class="btn-group">' .
1740  '<span id="actions_' . $table . '_' . $row['uid'] . '" class="btn-group collapse collapse-horizontal width">' . $cellOutput . '</span>' .
1741  '<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>' .
1742  '</div>';
1743  } else {
1744  $output .= ' <div class="btn-group" role="group">' . implode('', $actions) . '</div>';
1745  }
1746  }
1747  return $output;
1748  }
1749 
1758  public function makeClip($table, $row)
1759  {
1760  // Return blank, if disabled:
1761  if (!$this->getModule()->MOD_SETTINGS['clipBoard']) {
1762  return '';
1763  }
1764  $cells = [];
1765  $cells['pasteAfter'] = ($cells['pasteInto'] = $this->spaceIcon);
1766  //enables to hide the copy, cut and paste icons for localized records - doesn't make much sense to perform these options for them
1767  $isL10nOverlay = $this->localizationView && $table !== 'pages_language_overlay' && $row[$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']] != 0;
1768  // Return blank, if disabled:
1769  // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
1770  // For the "Normal" pad:
1771  if ($this->clipObj->current === 'normal') {
1772  // Show copy/cut icons:
1773  $isSel = (string)$this->clipObj->isSelected($table, $row['uid']);
1774  if ($isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)) {
1775  $cells['copy'] = $this->spaceIcon;
1776  $cells['cut'] = $this->spaceIcon;
1777  } else {
1778  $copyIcon = $this->iconFactory->getIcon('actions-edit-copy', Icon::SIZE_SMALL);
1779  $cutIcon = $this->iconFactory->getIcon('actions-edit-cut', Icon::SIZE_SMALL);
1780 
1781  if ($isSel === 'copy') {
1782  $copyIcon = $this->iconFactory->getIcon('actions-edit-copy-release', Icon::SIZE_SMALL);
1783  } elseif ($isSel === 'cut') {
1784  $cutIcon = $this->iconFactory->getIcon('actions-edit-cut-release', Icon::SIZE_SMALL);
1785  }
1786 
1787  $cells['copy'] = '<a class="btn btn-default" href="#" onclick="'
1788  . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $row['uid'], 1, ($isSel === 'copy'), ['returnUrl' => ''])) . ');')
1789  . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.copy')) . '">'
1790  . $copyIcon->render() . '</a>';
1791 
1792  // Check permission to cut page or content
1793  if ($table === 'pages') {
1794  $localCalcPerms = $this->getBackendUserAuthentication()->calcPerms(BackendUtility::getRecord('pages', $row['uid']));
1795  $permsEdit = $localCalcPerms & Permission::PAGE_EDIT;
1796  } else {
1797  $permsEdit = $this->calcPerms & Permission::CONTENT_EDIT;
1798  }
1799  $permsEdit = $this->overlayEditLockPermissions($table, $row, $permsEdit);
1800 
1801  // If the listed table is 'pages' we have to request the permission settings for each page:
1802  if ($table === 'pages') {
1803  if ($permsEdit) {
1804  $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
1805  . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
1806  . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
1807  . $cutIcon->render() . '</a>';
1808  } else {
1809  $cells['cut'] = $this->spaceIcon;
1810  }
1811  } else {
1812  if ($table !== 'pages' && $this->calcPerms & Permission::CONTENT_EDIT) {
1813  $cells['cut'] = '<a class="btn btn-default" href="#" onclick="'
1814  . htmlspecialchars('return jumpSelf(' . GeneralUtility::quoteJSvalue($this->clipObj->selUrlDB($table, $row['uid'], 0, ($isSel === 'cut'), ['returnUrl' => ''])) . ');')
1815  . '" title="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:cm.cut')) . '">'
1816  . $cutIcon->render() . '</a>';
1817  } else {
1818  $cells['cut'] = $this->spaceIcon;
1819  }
1820  }
1821  }
1822  } else {
1823  // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
1824  // Setting name of the element in ->CBnames array:
1825  $n = $table . '|' . $row['uid'];
1826  $this->CBnames[] = $n;
1827  // Check if the current element is selected and if so, prepare to set the checkbox as selected:
1828  $checked = $this->clipObj->isSelected($table, $row['uid']) ? 'checked="checked" ' : '';
1829  // If the "duplicateField" value is set then select all elements which are duplicates...
1830  if ($this->duplicateField && isset($row[$this->duplicateField])) {
1831  $checked = '';
1832  if (in_array($row[$this->duplicateField], $this->duplicateStack)) {
1833  $checked = 'checked="checked" ';
1834  }
1835  $this->duplicateStack[] = $row[$this->duplicateField];
1836  }
1837  // Adding the checkbox to the panel:
1838  $cells['select'] = $isL10nOverlay
1839  ? $this->spaceIcon
1840  : '<input type="hidden" name="CBH[' . $n . ']" value="0" /><label class="btn btn-default btn-checkbox"><input type="checkbox"'
1841  . ' name="CBC[' . $n . ']" value="1" ' . $checked . '/><span class="t3-icon fa"></span></label>';
1842  }
1843  // Now, looking for selected elements from the current table:
1844  $elFromTable = $this->clipObj->elFromTable($table);
1845  if (!empty($elFromTable) && $GLOBALS['TCA'][$table]['ctrl']['sortby']) {
1846  // IF elements are found, they can be individually ordered and are not locked by editlock, then add a "paste after" icon:
1847  $cells['pasteAfter'] = $isL10nOverlay || !$this->overlayEditLockPermissions($table, $row)
1848  ? $this->spaceIcon
1849  : '<a class="btn btn-default t3js-modal-trigger"'
1850  . ' href="' . htmlspecialchars($this->clipObj->pasteUrl($table, -$row['uid'])) . '"'
1851  . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
1852  . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteAfter')) . '"'
1853  . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'after', $elFromTable)) . '"'
1854  . ' data-severity="warning">'
1855  . $this->iconFactory->getIcon('actions-document-paste-after', Icon::SIZE_SMALL)->render() . '</a>';
1856  }
1857  // Now, looking for elements in general:
1858  $elFromTable = $this->clipObj->elFromTable('');
1859  if ($table === 'pages' && !empty($elFromTable)) {
1860  $cells['pasteInto'] = '<a class="btn btn-default t3js-modal-trigger"'
1861  . ' href="' . htmlspecialchars($this->clipObj->pasteUrl('', $row['uid'])) . '"'
1862  . ' title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
1863  . ' data-title="' . htmlspecialchars($this->getLanguageService()->getLL('clip_pasteInto')) . '"'
1864  . ' data-content="' . htmlspecialchars($this->clipObj->confirmMsgText($table, $row, 'into', $elFromTable)) . '"'
1865  . ' data-severity="warning">'
1866  . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '</a>';
1867  }
1875  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'])) {
1876  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['actions'] as $classData) {
1877  $hookObject = GeneralUtility::getUserObj($classData);
1878  if (!$hookObject instanceof RecordListHookInterface) {
1879  throw new \UnexpectedValueException($classData . ' must implement interface ' . RecordListHookInterface::class, 1195567845);
1880  }
1881  $cells = $hookObject->makeClip($table, $row, $cells, $this);
1882  }
1883  }
1884  // Compile items into a DIV-element:
1885  return '<!-- CLIPBOARD PANEL: ' . $table . ':' . $row['uid'] . ' -->
1886  <div class="btn-group" role="group">' . implode('', $cells) . '</div>';
1887  }
1888 
1897  protected function createReferenceHtml($tableName, $uid)
1898  {
1899  $referenceCount = GeneralUtility::makeInstance(ConnectionPool::class)
1900  ->getConnectionForTable('sys_refindex')
1901  ->count(
1902  '*',
1903  'sys_refindex',
1904  [
1905  'ref_table' => $tableName,
1906  'ref_uid' => (int)$uid,
1907  'deleted' => 0,
1908  ]
1909  );
1910 
1911  return $this->generateReferenceToolTip(
1914  );
1915  }
1916 
1924  public function makeLocalizationPanel($table, $row)
1925  {
1926  $out = [
1927  0 => '',
1928  1 => ''
1929  ];
1930  // Reset translations
1931  $this->translations = [];
1932 
1933  // Language title and icon:
1934  $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
1935  // Guard clause so we can quickly return if a record is localized to "all languages"
1936  // It should only be possible to localize a record off default (uid 0)
1937  // Reasoning: The Parent is for ALL languages... why overlay with a localization?
1938  if ((int)$row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] === -1) {
1939  return $out;
1940  }
1941 
1942  $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
1943  if (is_array($translations)) {
1944  $this->translations = $translations['translations'];
1945  // Traverse page translations and add icon for each language that does NOT yet exist:
1946  $lNew = '';
1947  foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
1948  if ($this->isEditable($table) && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
1949  $url = $this->listURL();
1951  '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
1952  $url . '&justLocalized=' . rawurlencode($table . ':' . $row['uid'] . ':' . $lUid_OnPage)
1953  );
1954  $language = BackendUtility::getRecord('sys_language', $lUid_OnPage, 'title');
1955  if ($this->languageIconTitles[$lUid_OnPage]['flagIcon']) {
1956  $lC = $this->iconFactory->getIcon($this->languageIconTitles[$lUid_OnPage]['flagIcon'], Icon::SIZE_SMALL)->render();
1957  } else {
1958  $lC = $this->languageIconTitles[$lUid_OnPage]['title'];
1959  }
1960  $lC = '<a href="' . htmlspecialchars($href) . '" title="'
1961  . htmlspecialchars($language['title']) . '" class="btn btn-default">' . $lC . '</a> ';
1962  $lNew .= $lC;
1963  }
1964  }
1965  if ($lNew) {
1966  $out[1] .= $lNew;
1967  }
1968  } elseif ($row['l18n_parent']) {
1969  $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;' . $out[0];
1970  }
1971  return $out;
1972  }
1973 
1981  public function fieldSelectBox($table, $formFields = true)
1982  {
1983  $lang = $this->getLanguageService();
1984  // Init:
1985  $formElements = ['', ''];
1986  if ($formFields) {
1987  $formElements = ['<form action="' . htmlspecialchars($this->listURL()) . '" method="post" name="fieldSelectBox">', '</form>'];
1988  }
1989  // Load already selected fields, if any:
1990  $setFields = is_array($this->setFields[$table]) ? $this->setFields[$table] : [];
1991  // Request fields from table:
1992  $fields = $this->makeFieldList($table, false, true);
1993  // Add pseudo "control" fields
1994  $fields[] = '_PATH_';
1995  $fields[] = '_REF_';
1996  $fields[] = '_LOCALIZATION_';
1997  $fields[] = '_CONTROL_';
1998  $fields[] = '_CLIPBOARD_';
1999  // Create a checkbox for each field:
2000  $checkboxes = [];
2001  $checkAllChecked = true;
2002  $tsConfig = BackendUtility::getPagesTSconfig($this->id);
2003  $tsConfigOfTable = is_array($tsConfig['TCEFORM.'][$table . '.']) ? $tsConfig['TCEFORM.'][$table . '.'] : null;
2004  foreach ($fields as $fieldName) {
2005  // Hide field if hidden
2006  if ($tsConfigOfTable && is_array($tsConfigOfTable[$fieldName . '.']) && isset($tsConfigOfTable[$fieldName . '.']['disabled']) && (int)$tsConfigOfTable[$fieldName . '.']['disabled'] === 1) {
2007  continue;
2008  }
2009  // Determine, if checkbox should be checked
2010  if (in_array($fieldName, $setFields, true) || $fieldName === $this->fieldArray[0]) {
2011  $checked = ' checked="checked"';
2012  } else {
2013  $checkAllChecked = false;
2014  $checked = '';
2015  }
2016  // Field label
2017  $fieldLabel = is_array($GLOBALS['TCA'][$table]['columns'][$fieldName])
2018  ? rtrim($lang->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']), ':')
2019  : '';
2020  $checkboxes[] = '<tr><td class="col-checkbox"><input type="checkbox" id="check-' . $fieldName . '" name="displayFields['
2021  . $table . '][]" value="' . $fieldName . '" ' . $checked
2022  . ($fieldName === $this->fieldArray[0] ? ' disabled="disabled"' : '') . '></td><td class="col-title">'
2023  . '<label class="label-block" for="check-' . $fieldName . '">' . htmlspecialchars($fieldLabel) . ' <span class="text-muted text-monospace">[' . htmlspecialchars($fieldName) . ']</span></label></td></tr>';
2024  }
2025  // Table with the field selector::
2026  $content = $formElements[0] . '
2027  <input type="hidden" name="displayFields[' . $table . '][]" value="">
2028  <div class="table-fit table-scrollable">
2029  <table border="0" cellpadding="0" cellspacing="0" class="table table-transparent table-hover">
2030  <thead>
2031  <tr>
2032  <th class="col-checkbox checkbox" colspan="2">
2033  <label><input type="checkbox" class="checkbox checkAll" ' . ($checkAllChecked ? ' checked="checked"' : '') . '>
2034  ' . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.toggleall')) . '</label>
2035  </th>
2036  </tr>
2037  </thead>
2038  <tbody>
2039  ' . implode('', $checkboxes) . '
2040  </tbody>
2041  </table>
2042  </div>
2043  <input type="submit" name="search" class="btn btn-default" value="'
2044  . htmlspecialchars($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.setFields')) . '"/>
2045  ' . $formElements[1];
2046  return '<div class="fieldSelectBox">' . $content . '</div>';
2047  }
2048 
2049  /*********************************
2050  *
2051  * Helper functions
2052  *
2053  *********************************/
2066  public function linkClipboardHeaderIcon($string, $table, $cmd, $warning = '', $title = '')
2067  {
2068  $jsCode = 'document.dblistForm.cmd.value=' . GeneralUtility::quoteJSvalue($cmd)
2069  . ';document.dblistForm.cmd_table.value='
2071  . ';document.dblistForm.submit();';
2072 
2073  $attributes = [];
2074  if ($title !== '') {
2075  $attributes['title'] = $title;
2076  }
2077  if ($warning) {
2078  $attributes['class'] = 'btn btn-default t3js-modal-trigger';
2079  $attributes['data-href'] = 'javascript:' . $jsCode;
2080  $attributes['data-severity'] = 'warning';
2081  $attributes['data-title'] = $title;
2082  $attributes['data-content'] = $warning;
2083  } else {
2084  $attributes['class'] = 'btn btn-default';
2085  $attributes['onclick'] = $jsCode . 'return false;';
2086  }
2087 
2088  $attributesString = '';
2089  foreach ($attributes as $key => $value) {
2090  $attributesString .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
2091  }
2092  return '<a href="#" ' . $attributesString . '>' . $string . '</a>';
2093  }
2094 
2100  public function clipNumPane()
2101  {
2102  return in_array('_CLIPBOARD_', $this->fieldArray) && $this->clipObj->current !== 'normal';
2103  }
2104 
2115  public function addSortLink($code, $field, $table)
2116  {
2117  // Certain circumstances just return string right away (no links):
2118  if ($field === '_CONTROL_' || $field === '_LOCALIZATION_' || $field === '_CLIPBOARD_' || $field === '_REF_' || $this->disableSingleTableView) {
2119  return $code;
2120  }
2121  // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
2122  if ($field === '_PATH_') {
2123  $field = 'pid';
2124  }
2125  // Create the sort link:
2126  $sortUrl = $this->listURL('', '-1', 'sortField,sortRev,table,firstElementNumber') . '&table=' . $table
2127  . '&sortField=' . $field . '&sortRev=' . ($this->sortRev || $this->sortField != $field ? 0 : 1);
2128  $sortArrow = $this->sortField === $field
2129  ? $this->iconFactory->getIcon('status-status-sorting-' . ($this->sortRev ? 'desc' : 'asc'), Icon::SIZE_SMALL)->render()
2130  : '';
2131  // Return linked field:
2132  return '<a href="' . htmlspecialchars($sortUrl) . '">' . $code . $sortArrow . '</a>';
2133  }
2134 
2143  public function recPath($pid)
2144  {
2145  if (!isset($this->recPath_cache[$pid])) {
2146  $this->recPath_cache[$pid] = BackendUtility::getRecordPath($pid, $this->perms_clause, 20);
2147  }
2148  return $this->recPath_cache[$pid];
2149  }
2150 
2158  public function showNewRecLink($table)
2159  {
2160  // No deny/allow tables are set:
2161  if (empty($this->allowedNewTables) && empty($this->deniedNewTables)) {
2162  return true;
2163  }
2164  return !in_array($table, $this->deniedNewTables)
2165  && (empty($this->allowedNewTables) || in_array($table, $this->allowedNewTables));
2166  }
2167 
2175  public function makeReturnUrl()
2176  {
2177  return '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
2178  }
2179 
2180  /************************************
2181  *
2182  * CSV related functions
2183  *
2184  ************************************/
2188  protected function initCSV()
2189  {
2190  $this->addHeaderRowToCSV();
2191  }
2192 
2196  protected function addHeaderRowToCSV()
2197  {
2198  // Add header row, control fields will be reduced inside addToCSV()
2199  $this->addToCSV(array_combine($this->fieldArray, $this->fieldArray));
2200  }
2201 
2207  protected function addToCSV(array $row = [])
2208  {
2209  $rowReducedByControlFields = self::removeControlFieldsFromFieldRow($row);
2210  // Get an field array without control fields but in the expected order
2211  $fieldArray = array_intersect_key(array_flip($this->fieldArray), $rowReducedByControlFields);
2212  // Overwrite fieldArray to keep the order with an array of needed fields
2213  $rowReducedToSelectedColumns = array_replace($fieldArray, array_intersect_key($rowReducedByControlFields, $fieldArray));
2214  $this->setCsvRow($rowReducedToSelectedColumns);
2215  }
2216 
2223  protected static function removeControlFieldsFromFieldRow(array $row = [])
2224  {
2225  // Possible control fields in a list row
2226  $controlFields = [
2227  '_PATH_',
2228  '_REF_',
2229  '_CONTROL_',
2230  '_CLIPBOARD_',
2231  '_LOCALIZATION_',
2232  '_LOCALIZATION_b'
2233  ];
2234  return array_diff_key($row, array_flip($controlFields));
2235  }
2236 
2242  public function setCsvRow($csvRow)
2243  {
2244  $this->csvLines[] = CsvUtility::csvValues($csvRow);
2245  }
2246 
2253  public function outputCSV($prefix)
2254  {
2255  // Setting filename:
2256  $filename = $prefix . '_' . date('dmy-Hi') . '.csv';
2257  // Creating output header:
2258  header('Content-Type: application/octet-stream');
2259  header('Content-Disposition: attachment; filename=' . $filename);
2260  // Cache-Control header is needed here to solve an issue with browser IE and
2261  // versions lower than 9. See for more information: http://support.microsoft.com/kb/323308
2262  header("Cache-Control: ''");
2263  // Printing the content of the CSV lines:
2264  echo implode(CRLF, $this->csvLines);
2265  // Exits:
2266  die;
2267  }
2268 
2276  public function addActionToCellGroup(&$cells, $action, $actionKey)
2277  {
2278  $cellsMap = [
2279  'primary' => [
2280  'view', 'edit', 'hide', 'delete', 'stat'
2281  ],
2282  'secondary' => [
2283  'viewBig', 'history', 'perms', 'new', 'move', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'version'
2284  ]
2285  ];
2286  $classification = in_array($actionKey, $cellsMap['primary']) ? 'primary' : 'secondary';
2287  $cells[$classification][$actionKey] = $action;
2288  unset($cells[$actionKey]);
2289  }
2290 
2298  protected function isRecordCurrentBackendUser($table, $row)
2299  {
2300  return $table === 'be_users' && (int)$row['uid'] === $this->getBackendUserAuthentication()->user['uid'];
2301  }
2302 
2306  public function setIsEditable($isEditable)
2307  {
2308  $this->editable = $isEditable;
2309  }
2310 
2316  public function isEditable($table)
2317  {
2318  return $GLOBALS['TCA'][$table]['ctrl']['readOnly'] || $this->editable;
2319  }
2320 
2331  protected function overlayEditLockPermissions($table, $row = [], $editPermission = true)
2332  {
2333  if ($editPermission && !$this->getBackendUserAuthentication()->isAdmin()) {
2334  // If no $row is submitted we only check for general edit lock of current page (except for table "pages")
2335  if (empty($row)) {
2336  return $table === 'pages' ? true : !$this->pageRow['editlock'];
2337  }
2338  if (($table === 'pages' && $row['editlock']) || ($table !== 'pages' && $this->pageRow['editlock'])) {
2339  $editPermission = false;
2340  } elseif (isset($GLOBALS['TCA'][$table]['ctrl']['editlock']) && $row[$GLOBALS['TCA'][$table]['ctrl']['editlock']]) {
2341  $editPermission = false;
2342  }
2343  }
2344  return $editPermission;
2345  }
2346 
2353  protected function editLockPermissions()
2354  {
2355  return $this->getBackendUserAuthentication()->isAdmin() || !$this->pageRow['editlock'];
2356  }
2357 
2368  protected function getVisibleColumns(array $tableTCA, string $type)
2369  {
2370  $visibleColumns = $tableTCA['types'][$type]['showitem'] ?? '';
2371 
2372  if (strpos($visibleColumns, '--palette--') !== false) {
2373  $matches = [];
2374  preg_match_all('/--palette--\s*;[^;]*;\s*(\w+)/', $visibleColumns, $matches, PREG_SET_ORDER);
2375  if (!empty($matches)) {
2376  foreach ($matches as $palette) {
2377  $paletteColumns = $tableTCA['palettes'][$palette[1]]['showitem'] ?? '';
2378  $paletteColumns = rtrim($paletteColumns, ", \t\r\n");
2379  $visibleColumns = str_replace($palette[0], $paletteColumns, $visibleColumns);
2380  }
2381  }
2382  }
2383 
2384  return $visibleColumns;
2385  }
2386 
2390  protected function getModule()
2391  {
2392  return $GLOBALS['SOBE'];
2393  }
2394 
2398  protected function getDocumentTemplate()
2399  {
2400  return $GLOBALS['TBE_TEMPLATE'];
2401  }
2402 }
static translationCount($table, $ref, $msg='')
static getPagesTSconfig($id, $rootLine=null, $returnPartArray=false)
overlayEditLockPermissions($table, $row=[], $editPermission=true)
static implodeAttributes(array $arr, $xhtmlSafe=false, $dontOmitBlankAttribs=false)
static wrapClickMenuOnIcon( $content, $table, $uid=0, $context='', $_addParams='', $_enDisItems='', $returnTagParameters=false)
static editOnClick($params, $_='', $requestUri='')
static getProcessedValueExtra( $table, $fN, $fV, $fixed_lgd_chars=0, $uid=0, $forceResult=true, $pid=0)
static callUserFunction($funcName, &$params, &$ref, $_='', $errorMode=0)
static viewOnClick( $pageUid, $backPath='', $rootLine=null, $anchorSection='', $alternativeUrl='', $additionalGetVars='', $switchFocus=true)
static getRecordToolTip(array $row, $table='pages')
static BEgetRootLine($uid, $clause='', $workspaceOL=false)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
static workspaceOL($table, &$row, $wsid=-99, $unsetMovePointers=false)
static makeInstance($className,... $constructorArguments)
$fields
Definition: pages.php:4
static selectVersionsOfRecord( $table, $uid, $fields=' *', $workspace=0, $includeDeletedRecords=false, $row=null)
static linkThisUrl($url, array $getParams=[])
addElement($h, $icon, $data, $rowParams='', $_='', $_2='', $colType='td')
static referenceCount($table, $ref, $msg='', $count=null)
static cshItem($table, $field, $_='', $wrap='')
static getRecordTitle($table, $row, $prep=false, $forceResult=true)
languageFlag($sys_language_uid, $addAsAdditionalText=true)
makeFieldList($table, $dontCheckUser=false, $addDateFields=false)
static getRecordPath($uid, $clause, $titleLimit, $fullTitleLimit=0)
renderListRow($table, $row, $cc, $titleCol, $thumbsCol, $indent=0)
generateReferenceToolTip($references, $launchViewParameter='')
static getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
setTotalItems(string $table, int $pageId, array $constraints)
static getLinkToDataHandlerAction($parameters, $redirectUrl='')
linkClipboardHeaderIcon($string, $table, $cmd, $warning='', $title='')
getQueryBuilder(string $table, int $pageId, array $additionalConstraints=[], array $fields=[' *'])