‪TYPO3CMS  11.5
TableListViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
24 
64 {
70  protected ‪$escapeOutput = false;
71 
75  protected ‪$configurationManager;
76 
81  {
82  $this->configurationManager = ‪$configurationManager;
83  }
84 
90  public function ‪initializeArguments()
91  {
92  parent::initializeArguments();
93  $this->registerArgument('tableName', 'string', 'name of the database table', true);
94  $this->registerArgument('fieldList', 'array', 'list of fields to be displayed. If empty, only the title column (configured in $TCA[$tableName][\'ctrl\'][\'title\']) is shown', false, []);
95  $this->registerArgument('storagePid', 'int', 'by default, records are fetched from the storage PID configured in persistence.storagePid. With this argument, the storage PID can be overwritten');
96  $this->registerArgument('levels', 'int', 'corresponds to the level selector of the TYPO3 list module. By default only records from the current storagePid are fetched', false, 0);
97  $this->registerArgument('filter', 'string', 'corresponds to the "Search String" textbox of the TYPO3 list module. If not empty, only records matching the string will be fetched', false, '');
98  $this->registerArgument('recordsPerPage', 'int', 'amount of records to be displayed at once. Defaults to $TCA[$tableName][\'interface\'][\'maxSingleDBListItems\'] or (if that\'s not set) to 100', false, 0);
99  $this->registerArgument('sortField', 'string', 'table field to sort the results by', false, '');
100  $this->registerArgument('sortDescending', 'bool', 'if TRUE records will be sorted in descending order', false, false);
101  $this->registerArgument('readOnly', 'bool', 'if TRUE, the edit icons won\'t be shown. Otherwise edit icons will be shown, if the current BE user has edit rights for the specified table!', false, false);
102  $this->registerArgument('enableClickMenu', 'bool', 'enables context menu', false, true);
103  $this->registerArgument('enableControlPanels', 'bool', 'enables control panels', false, false);
104  $this->registerArgument('clickTitleMode', 'string', 'one of "edit", "show" (only pages, tt_content), "info');
105  }
106 
114  public function ‪render()
115  {
116  $tableName = $this->arguments['tableName'];
117  $fieldList = $this->arguments['fieldList'];
118  $storagePid = $this->arguments['storagePid'];
119  $levels = $this->arguments['levels'];
120  $filter = $this->arguments['filter'];
121  $recordsPerPage = $this->arguments['recordsPerPage'];
122  $sortField = $this->arguments['sortField'];
123  $sortDescending = $this->arguments['sortDescending'];
124  $readOnly = $this->arguments['readOnly'];
125  $enableClickMenu = $this->arguments['enableClickMenu'];
126  $clickTitleMode = $this->arguments['clickTitleMode'];
127  $enableControlPanels = $this->arguments['enableControlPanels'];
128 
129  $this->‪getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
130  $this->‪getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/RecordDownloadButton');
131  $this->‪getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ActionDispatcher');
132  if ($enableControlPanels === true) {
133  $this->‪getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/MultiRecordSelection');
134  $this->‪getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
135  }
136  // We need to include the language file, since DatabaseRecordList is heavily using ->getLL
137  $this->‪getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf');
138 
139  $pageinfo = BackendUtility::readPageAccess(GeneralUtility::_GP('id'), ‪$GLOBALS['BE_USER']->getPagePermsClause(‪Permission::PAGE_SHOW)) ?: [];
140  $dblist = GeneralUtility::makeInstance(DatabaseRecordList::class);
141  $dblist->pageRow = $pageinfo;
142  if ($readOnly) {
143  $dblist->setIsEditable(false);
144  } else {
145  $dblist->calcPerms = new ‪Permission(‪$GLOBALS['BE_USER']->calcPerms($pageinfo));
146  }
147  $dblist->disableSingleTableView = true;
148  $dblist->clickTitleMode = $clickTitleMode;
149  $dblist->clickMenuEnabled = $enableClickMenu;
150  if ($storagePid === null) {
151  $frameworkConfiguration = $this->configurationManager->getConfiguration(‪ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
152  $storagePid = $frameworkConfiguration['persistence']['storagePid'];
153  }
154  $dblist->start($storagePid, $tableName, (int)GeneralUtility::_GP('pointer'), $filter, $levels, $recordsPerPage);
155  // Column selector is disabled since fields are defined by the "fieldList" argument
156  $dblist->displayColumnSelector = false;
157  $dblist->setFields = [$tableName => $fieldList];
158  $dblist->noControlPanels = !$enableControlPanels;
159  $dblist->sortField = $sortField;
160  $dblist->sortRev = $sortDescending;
161  return $dblist->generateList();
162  }
163 
164  protected function ‪getLanguageService(): ‪LanguageService
165  {
166  return ‪$GLOBALS['LANG'];
167  }
168 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getPageRenderer
‪PageRenderer getPageRenderer()
Definition: AbstractBackendViewHelper.php:53
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\getLanguageService
‪getLanguageService()
Definition: TableListViewHelper.php:162
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:28
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:16
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:26
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\render
‪string render()
Definition: TableListViewHelper.php:112
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK
‪const CONFIGURATION_TYPE_FRAMEWORK
Definition: ConfigurationManagerInterface.php:29
‪TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList
Definition: DatabaseRecordList.php:59
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\$configurationManager
‪TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
Definition: TableListViewHelper.php:73
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:35
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\initializeArguments
‪initializeArguments()
Definition: TableListViewHelper.php:88
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\injectConfigurationManager
‪injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
Definition: TableListViewHelper.php:78
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: TableListViewHelper.php:69
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper
Definition: TableListViewHelper.php:64
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50