‪TYPO3CMS  10.4
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 
23 
63 {
69  protected ‪$escapeOutput = false;
70 
74  protected ‪$configurationManager;
75 
80  {
81  $this->configurationManager = ‪$configurationManager;
82  }
83 
89  public function ‪initializeArguments()
90  {
91  parent::initializeArguments();
92  $this->registerArgument('tableName', 'string', 'name of the database table', true);
93  $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, []);
94  $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');
95  $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);
96  $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, '');
97  $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);
98  $this->registerArgument('sortField', 'string', 'table field to sort the results by', false, '');
99  $this->registerArgument('sortDescending', 'bool', 'if TRUE records will be sorted in descending order', false, false);
100  $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);
101  $this->registerArgument('enableClickMenu', 'bool', 'enables context menu', false, true);
102  $this->registerArgument('enableControlPanels', 'bool', 'enables control panels', false, false);
103  $this->registerArgument('clickTitleMode', 'string', 'one of "edit", "show" (only pages, tt_content), "info');
104  }
105 
113  public function ‪render()
114  {
115  $tableName = $this->arguments['tableName'];
116  $fieldList = $this->arguments['fieldList'];
117  $storagePid = $this->arguments['storagePid'];
118  $levels = $this->arguments['levels'];
119  $filter = $this->arguments['filter'];
120  $recordsPerPage = $this->arguments['recordsPerPage'];
121  $sortField = $this->arguments['sortField'];
122  $sortDescending = $this->arguments['sortDescending'];
123  $readOnly = $this->arguments['readOnly'];
124  $enableClickMenu = $this->arguments['enableClickMenu'];
125  $clickTitleMode = $this->arguments['clickTitleMode'];
126  $enableControlPanels = $this->arguments['enableControlPanels'];
127 
128  $this->‪getPageRenderer()->‪loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
129  $this->‪getPageRenderer()->‪loadRequireJsModule('TYPO3/CMS/Backend/ActionDispatcher');
130  if ($enableControlPanels === true) {
131  $this->‪getPageRenderer()->‪loadRequireJsModule('TYPO3/CMS/Backend/ContextMenu');
132  }
133 
134  $pageinfo = ‪BackendUtility::readPageAccess(GeneralUtility::_GP('id'), ‪$GLOBALS['BE_USER']->getPagePermsClause(‪Permission::PAGE_SHOW));
136  $dblist = GeneralUtility::makeInstance(DatabaseRecordList::class);
137  $dblist->pageRow = $pageinfo;
138  if ($readOnly === false) {
139  $dblist->calcPerms = ‪$GLOBALS['BE_USER']->calcPerms($pageinfo);
140  }
141  $dblist->showClipboard = false;
142  $dblist->disableSingleTableView = true;
143  $dblist->clickTitleMode = $clickTitleMode;
144  $dblist->clickMenuEnabled = $enableClickMenu;
145  if ($storagePid === null) {
146  $frameworkConfiguration = $this->configurationManager->getConfiguration(‪ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
147  $storagePid = $frameworkConfiguration['persistence']['storagePid'];
148  }
149  $dblist->start($storagePid, $tableName, (int)GeneralUtility::_GP('pointer'), $filter, $levels, $recordsPerPage);
150  $dblist->allFields = true;
151  $dblist->dontShowClipControlPanels = true;
152  $dblist->displayFields = false;
153  $dblist->setFields = [$tableName => $fieldList];
154  $dblist->noControlPanels = !$enableControlPanels;
155  $dblist->sortField = $sortField;
156  $dblist->sortRev = $sortDescending;
157  $dblist->script = $_SERVER['REQUEST_URI'];
158  $dblist->generateList();
159 
160  $js = '// @deprecated' . CRLF . 'var T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')));
161  $html = GeneralUtility::wrapJS($js) . $dblist->HTMLcode;
162 
163  return $html;
164  }
165 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getPageRenderer
‪PageRenderer getPageRenderer()
Definition: AbstractBackendViewHelper.php:53
‪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:24
‪TYPO3\CMS\Core\Page\PageRenderer\loadRequireJsModule
‪loadRequireJsModule($mainModuleName, $callBackFunction=null)
Definition: PageRenderer.php:1493
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\render
‪string render()
Definition: TableListViewHelper.php:111
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK
‪const CONFIGURATION_TYPE_FRAMEWORK
Definition: ConfigurationManagerInterface.php:29
‪TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList
Definition: DatabaseRecordList.php:57
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\$configurationManager
‪TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
Definition: TableListViewHelper.php:72
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:33
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Utility\BackendUtility\readPageAccess
‪static array false readPageAccess($id, $perms_clause)
Definition: BackendUtility.php:597
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\initializeArguments
‪initializeArguments()
Definition: TableListViewHelper.php:87
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\injectConfigurationManager
‪injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
Definition: TableListViewHelper.php:77
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: TableListViewHelper.php:68
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper
Definition: TableListViewHelper.php:63
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46