‪TYPO3CMS  9.5
TableListViewHelper.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 
20 
59 {
65  protected ‪$escapeOutput = false;
66 
70  protected ‪$configurationManager;
71 
76  {
77  $this->configurationManager = ‪$configurationManager;
78  }
79 
85  public function ‪initializeArguments()
86  {
87  parent::initializeArguments();
88  $this->registerArgument('tableName', 'string', 'name of the database table', true);
89  $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, []);
90  $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');
91  $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);
92  $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, '');
93  $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);
94  $this->registerArgument('sortField', 'string', 'table field to sort the results by', false, '');
95  $this->registerArgument('sortDescending', 'bool', 'if TRUE records will be sorted in descending order', false, false);
96  $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);
97  $this->registerArgument('enableClickMenu', 'bool', 'enables context menu', false, true);
98  $this->registerArgument('clickTitleMode', 'string', 'one of "edit", "show" (only pages, tt_content), "info');
99  }
100 
108  public function ‪render()
109  {
110  $tableName = $this->arguments['tableName'];
111  $fieldList = $this->arguments['fieldList'];
112  $storagePid = $this->arguments['storagePid'];
113  $levels = $this->arguments['levels'];
114  $filter = $this->arguments['filter'];
115  $recordsPerPage = $this->arguments['recordsPerPage'];
116  $sortField = $this->arguments['sortField'];
117  $sortDescending = $this->arguments['sortDescending'];
118  $readOnly = $this->arguments['readOnly'];
119  $enableClickMenu = $this->arguments['enableClickMenu'];
120  $clickTitleMode = $this->arguments['clickTitleMode'];
121 
122  $this->‪getPageRenderer()->‪loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
123 
124  $pageinfo = ‪BackendUtility::readPageAccess(GeneralUtility::_GP('id'), ‪$GLOBALS['BE_USER']->getPagePermsClause(‪Permission::PAGE_SHOW));
126  $dblist = GeneralUtility::makeInstance(\‪TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class);
127  $dblist->pageRow = $pageinfo;
128  if ($readOnly === false) {
129  $dblist->calcPerms = ‪$GLOBALS['BE_USER']->calcPerms($pageinfo);
130  }
131  $dblist->showClipboard = false;
132  $dblist->disableSingleTableView = true;
133  $dblist->clickTitleMode = $clickTitleMode;
134  $dblist->clickMenuEnabled = $enableClickMenu;
135  if ($storagePid === null) {
136  $frameworkConfiguration = $this->configurationManager->getConfiguration(\‪TYPO3\CMS\‪Extbase\Configuration\‪ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
137  $storagePid = $frameworkConfiguration['persistence']['storagePid'];
138  }
139  $dblist->start($storagePid, $tableName, (int)GeneralUtility::_GP('pointer'), $filter, $levels, $recordsPerPage);
140  $dblist->allFields = true;
141  $dblist->dontShowClipControlPanels = true;
142  $dblist->displayFields = false;
143  $dblist->setFields = [$tableName => $fieldList];
144  $dblist->noControlPanels = true;
145  $dblist->sortField = $sortField;
146  $dblist->sortRev = $sortDescending;
147  $dblist->script = $_SERVER['REQUEST_URI'];
148  $dblist->generateList();
149 
150  $js = 'var T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')));
151  $html = GeneralUtility::wrapJS($js) . $dblist->HTMLcode;
152 
153  return $html;
154  }
155 }
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper\getPageRenderer
‪PageRenderer getPageRenderer()
Definition: AbstractBackendViewHelper.php:54
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:22
‪TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper
Definition: AbstractBackendViewHelper.php:27
‪TYPO3\CMS\Fluid\ViewHelpers\Be
Definition: AbstractBackendViewHelper.php:2
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\injectConfigurationManager
‪injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
Definition: TableListViewHelper.php:73
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:23
‪TYPO3\CMS\Core\Page\PageRenderer\loadRequireJsModule
‪loadRequireJsModule($mainModuleName, $callBackFunction=null)
Definition: PageRenderer.php:1593
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\render
‪string render()
Definition: TableListViewHelper.php:106
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK
‪const CONFIGURATION_TYPE_FRAMEWORK
Definition: ConfigurationManagerInterface.php:23
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\$configurationManager
‪TYPO3 CMS Extbase Configuration ConfigurationManagerInterface $configurationManager
Definition: TableListViewHelper.php:68
‪TYPO3\CMS\Core\Type\Bitmask\Permission\PAGE_SHOW
‪const PAGE_SHOW
Definition: Permission.php:32
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\initializeArguments
‪initializeArguments()
Definition: TableListViewHelper.php:83
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: TableListViewHelper.php:64
‪TYPO3\CMS\Fluid\ViewHelpers\Be\TableListViewHelper
Definition: TableListViewHelper.php:59
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Utility\BackendUtility\readPageAccess
‪static array bool readPageAccess($id, $perms_clause)
Definition: BackendUtility.php:635