TYPO3 CMS  TYPO3_8-7
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 
19 
45 {
51  protected $escapeOutput = false;
52 
57 
61  public function injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
62  {
63  $this->configurationManager = $configurationManager;
64  }
65 
71  public function initializeArguments()
72  {
73  parent::initializeArguments();
74  $this->registerArgument('tableName', 'string', 'name of the database table', true);
75  $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, []);
76  $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');
77  $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);
78  $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, '');
79  $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);
80  $this->registerArgument('sortField', 'string', 'table field to sort the results by', false, '');
81  $this->registerArgument('sortDescending', 'bool', 'if TRUE records will be sorted in descending order', false, false);
82  $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);
83  $this->registerArgument('enableClickMenu', 'bool', 'enables context menu', false, true);
84  $this->registerArgument('clickTitleMode', 'string', 'one of "edit", "show" (only pages, tt_content), "info');
85  }
86 
94  public function render()
95  {
96  $tableName = $this->arguments['tableName'];
97  $fieldList = $this->arguments['fieldList'];
98  $storagePid = $this->arguments['storagePid'];
99  $levels = $this->arguments['levels'];
100  $filter = $this->arguments['filter'];
101  $recordsPerPage = $this->arguments['recordsPerPage'];
102  $sortField = $this->arguments['sortField'];
103  $sortDescending = $this->arguments['sortDescending'];
104  $readOnly = $this->arguments['readOnly'];
105  $enableClickMenu = $this->arguments['enableClickMenu'];
106  $clickTitleMode = $this->arguments['clickTitleMode'];
107 
108  $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Recordlist/Recordlist');
109 
110  $pageinfo = BackendUtility::readPageAccess(GeneralUtility::_GP('id'), $GLOBALS['BE_USER']->getPagePermsClause(1));
112  $dblist = GeneralUtility::makeInstance(\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList::class);
113  $dblist->pageRow = $pageinfo;
114  if ($readOnly === false) {
115  $dblist->calcPerms = $GLOBALS['BE_USER']->calcPerms($pageinfo);
116  }
117  $dblist->showClipboard = false;
118  $dblist->disableSingleTableView = true;
119  $dblist->clickTitleMode = $clickTitleMode;
120  $dblist->clickMenuEnabled = $enableClickMenu;
121  if ($storagePid === null) {
122  $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
123  $storagePid = $frameworkConfiguration['persistence']['storagePid'];
124  }
125  $dblist->start($storagePid, $tableName, (int)GeneralUtility::_GP('pointer'), $filter, $levels, $recordsPerPage);
126  $dblist->allFields = true;
127  $dblist->dontShowClipControlPanels = true;
128  $dblist->displayFields = false;
129  $dblist->setFields = [$tableName => $fieldList];
130  $dblist->noControlPanels = true;
131  $dblist->sortField = $sortField;
132  $dblist->sortRev = $sortDescending;
133  $dblist->script = $_SERVER['REQUEST_URI'];
134  $dblist->generateList();
135 
136  $js = 'var T3_THIS_LOCATION = ' . GeneralUtility::quoteJSvalue(rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')));
137  $html = GeneralUtility::wrapJS($js) . $dblist->HTMLcode;
138 
139  return $html;
140  }
141 }
static readPageAccess($id, $perms_clause)
injectConfigurationManager(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager)
static makeInstance($className,... $constructorArguments)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']