‪TYPO3CMS  9.5
PageInformationController.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 
17 use Psr\Http\Message\ServerRequestInterface;
28 
34 {
37 
42  'pObj' => 'Using PageInformationController::$pObj is deprecated and will not be possible anymore in TYPO3 v10.0.',
43  'function_key' => 'Using PageInformationController::$function_key is deprecated, property will be removed in TYPO3 v10.0.',
44  'extClassConf' => 'Using PageInformationController::$extClassConf is deprecated, property will be removed in TYPO3 v10.0.',
45  'localLangFile' => 'Using PageInformationController::$localLangFile is deprecated, property will be removed in TYPO3 v10.0.',
46  'extObj' => 'Using PageInformationController::$extObj is deprecated, property will be removed in TYPO3 v10.0.',
47  ];
48 
52  private ‪$deprecatedPublicMethods = [
53  'modMenu' => 'Using PageInformationController::modMenu() is deprecated and will not be possible anymore in TYPO3 v10.0.',
54  'extObjContent' => 'Using PageInformationController::extObjContent() is deprecated, method will be removed in TYPO3 v10.0.',
55  ];
56 
60  protected ‪$fieldConfiguration = [];
61 
65  protected ‪$id;
66 
70  protected ‪$pObj;
71 
75  protected ‪$extObj;
76 
83  protected ‪$localLangFile = '';
84 
88  protected ‪$extClassConf;
89 
93  protected ‪$function_key = '';
94 
100  public function ‪init(‪$pObj)
101  {
102  $this->pObj = ‪$pObj;
103  // Local lang:
104  if (!empty($this->localLangFile)) {
105  // @deprecated since TYPO3 v9, will be removed in TYPO3 v10.0.
106  $this->‪getLanguageService()->‪includeLLFile($this->localLangFile);
107  }
108  $this->id = (int)GeneralUtility::_GP('id');
109  // Setting MOD_MENU items as we need them for logging:
110  $this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu());
111  }
112 
118  public function ‪main()
119  {
120  $languageService = $this->‪getLanguageService();
121  $theOutput = '<h1>' . htmlspecialchars($languageService->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:page_title')) . '</h1>';
122  $dblist = GeneralUtility::makeInstance(PageLayoutView::class);
123  $dblist->descrTable = '_MOD_web_info';
124  $dblist->thumbs = 0;
126  $uriBuilder = GeneralUtility::makeInstance(\‪TYPO3\CMS\Backend\Routing\UriBuilder::class);
127  $dblist->script = (string)$uriBuilder->buildUriFromRoute('web_info');
128  $dblist->showIcon = 0;
129  $dblist->setLMargin = 0;
130  $dblist->agePrefixes = ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
131  $dblist->pI_showUser = true;
132 
133  if (isset($this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']])) {
134  $dblist->fieldArray = $this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']]['fields'];
135  }
136 
137  // PAGES:
138  $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
139  // ONLY for the sake of dblist module which uses this value.
140  $h_func = ‪BackendUtility::getDropdownMenu($this->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
141  $h_func .= ‪BackendUtility::getDropdownMenu($this->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
142  $dblist->start($this->id, 'pages', 0);
143  $dblist->generateList();
144 
145  $theOutput .= '<div class="form-inline form-inline-spaced">'
146  . $h_func
147  . '<div class="form-group">'
148  . ‪BackendUtility::cshItem($dblist->descrTable, 'func_' . $this->pObj->MOD_SETTINGS['pages'], null, '<span class="btn btn-default btn-sm">|</span>')
149  . '</div>'
150  . '</div>'
151  . $dblist->HTMLcode;
152 
153  // Additional footer content
154  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'] ?? [] as $hook) {
155  // @todo: request object should be submitted here as soon as it is available in TYPO3 v10.0.
156  $params = [];
157  $theOutput .= GeneralUtility::callUserFunction($hook, $params, $this);
158  }
159  return $theOutput;
160  }
161 
167  protected function ‪modMenu()
168  {
169  $menu = [
170  'pages' => [],
171  'depth' => [
172  0 => ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
173  1 => ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
174  2 => ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
175  3 => ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
176  4 => ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
177  999 => ‪$GLOBALS['LANG']->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
178  ]
179  ];
180 
181  // Using $GLOBALS['TYPO3_REQUEST'] since $request is not available at this point
182  // @todo: Refactor mess and have $request available
183  $this->‪fillFieldConfiguration($this->id, ‪$GLOBALS['TYPO3_REQUEST']);
184  foreach ($this->fieldConfiguration as $key => $item) {
185  $menu['pages'][$key] = $item['label'];
186  }
187  return $menu;
188  }
189 
197  protected function ‪cleanTableNames(): string
198  {
199  // Get all table names:
200  $tableNames = array_flip(array_keys(‪$GLOBALS['TCA']));
201  // Unset common names:
202  unset($tableNames['pages']);
203  unset($tableNames['sys_filemounts']);
204  unset($tableNames['sys_action']);
205  unset($tableNames['sys_workflows']);
206  unset($tableNames['be_users']);
207  unset($tableNames['be_groups']);
208  $allowedTableNames = [];
209  // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
210  if (is_array($tableNames)) {
211  foreach ($tableNames as $k => $v) {
212  if (!‪$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->‪getBackendUser()->check('tables_select', $k)) {
213  $allowedTableNames['table_' . $k] = $k;
214  }
215  }
216  }
217  return implode(',', array_keys($allowedTableNames));
218  }
219 
226  protected function ‪fillFieldConfiguration(int $pageId, ServerRequestInterface $request)
227  {
228  $modTSconfig = ‪BackendUtility::getPagesTSconfig($pageId)['mod.']['web_info.']['fieldDefinitions.'] ?? [];
229  foreach ($modTSconfig as $key => $item) {
230  $fieldList = str_replace('###ALL_TABLES###', $this->‪cleanTableNames(), $item['fields']);
231  ‪$fields = GeneralUtility::trimExplode(',', $fieldList, true);
232  if ((int)$key === 0) {
233  // If "Basic settings" is rendered, hide the alias field on trees that have a site configuration
234  // and hide the slug field on PseudoSites. On NullSites (pid 0), show both.
235  $site = $request->getAttribute('site');
236  if ($site instanceof ‪PseudoSite) {
237  ‪$fields = array_diff(‪$fields, ['slug']);
238  } elseif ($site instanceof ‪Site && !$site instanceof ‪NullSite) {
239  ‪$fields = array_diff(‪$fields, ['alias']);
240  }
241  }
242  $key = trim($key, '.');
243  $this->fieldConfiguration[$key] = [
244  'label' => $item['label'] ? ‪$GLOBALS['LANG']->sL($item['label']) : $key,
245  'fields' => ‪$fields
246  ];
247  }
248  }
249 
255  public function ‪checkExtObj()
256  {
257  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
258  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
259  $this->extObj->init($this->pObj, $this->extClassConf);
260  // Re-write:
261  $this->pObj->MOD_SETTINGS = ‪BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), 'web_info');
262  }
263  }
264 
270  protected function ‪extObjContent()
271  {
272  if (is_object($this->extObj)) {
273  return $this->extObj->main();
274  }
275  }
276 
280  protected function ‪getBackendUser(): BackendUserAuthentication
281  {
282  return ‪$GLOBALS['BE_USER'];
283  }
284 
288  protected function ‪getLanguageService(): ‪LanguageService
289  {
290  return ‪$GLOBALS['LANG'];
291  }
292 }
‪TYPO3\CMS\Info\Controller\InfoModuleController
Definition: InfoModuleController.php:42
‪TYPO3\CMS\Core\Localization\LanguageService\includeLLFile
‪mixed includeLLFile($fileRef, $setGlobal=true, $mergeLocalOntoDefault=false)
Definition: LanguageService.php:260
‪TYPO3\CMS\Info\Controller\PageInformationController\$deprecatedPublicProperties
‪array $deprecatedPublicProperties
Definition: PageInformationController.php:38
‪TYPO3\CMS\Info\Controller\PageInformationController\$fieldConfiguration
‪array $fieldConfiguration
Definition: PageInformationController.php:55
‪TYPO3
‪TYPO3\CMS\Core\Site\Entity\NullSite
Definition: NullSite.php:31
‪TYPO3\CMS\Info\Controller\PageInformationController\getLanguageService
‪LanguageService getLanguageService()
Definition: PageInformationController.php:281
‪TYPO3\CMS\Backend\Utility\BackendUtility\cshItem
‪static string cshItem($table, $field, $_='', $wrap='')
Definition: BackendUtility.php:2565
‪$fields
‪$fields
Definition: pages.php:4
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:39
‪TYPO3\CMS\Info\Controller\PageInformationController\checkExtObj
‪checkExtObj()
Definition: PageInformationController.php:248
‪TYPO3\CMS\Info\Controller\PageInformationController\$id
‪$id
Definition: PageInformationController.php:60
‪TYPO3\CMS\Info\Controller\PageInformationController\$extObj
‪$extObj
Definition: PageInformationController.php:69
‪TYPO3\CMS\Info\Controller\PageInformationController
Definition: PageInformationController.php:34
‪TYPO3\CMS\Backend\Utility\BackendUtility\getDropdownMenu
‪static string getDropdownMenu( $mainParams, $elementName, $currentValue, $menuItems, $script='', $addParams='')
Definition: BackendUtility.php:3005
‪TYPO3\CMS\Info\Controller\PageInformationController\extObjContent
‪extObjContent()
Definition: PageInformationController.php:263
‪TYPO3\CMS\Backend\Utility\BackendUtility\getModuleData
‪static array getModuleData( $MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
Definition: BackendUtility.php:3259
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Info\Controller\PageInformationController\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: PageInformationController.php:273
‪TYPO3\CMS\Info\Controller\PageInformationController\fillFieldConfiguration
‪fillFieldConfiguration(int $pageId, ServerRequestInterface $request)
Definition: PageInformationController.php:219
‪TYPO3\CMS\Info\Controller\PageInformationController\$localLangFile
‪string $localLangFile
Definition: PageInformationController.php:76
‪TYPO3\CMS\Core\Compatibility\PublicMethodDeprecationTrait
Definition: PublicMethodDeprecationTrait.php:68
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig
‪static array getPagesTSconfig($id, $rootLine=null, $returnPartArray=false)
Definition: BackendUtility.php:864
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Info\Controller\PageInformationController\init
‪init($pObj)
Definition: PageInformationController.php:93
‪TYPO3\CMS\Backend\View\PageLayoutView
Definition: PageLayoutView.php:61
‪TYPO3\CMS\Core\Site\Entity\PseudoSite
Definition: PseudoSite.php:28
‪TYPO3\CMS\Info\Controller\PageInformationController\modMenu
‪array modMenu()
Definition: PageInformationController.php:160
‪TYPO3\CMS\Info\Controller\PageInformationController\$extClassConf
‪$extClassConf
Definition: PageInformationController.php:81
‪TYPO3\CMS\Info\Controller\PageInformationController\$pObj
‪InfoModuleController $pObj
Definition: PageInformationController.php:64
‪TYPO3\CMS\Info\Controller\PageInformationController\$deprecatedPublicMethods
‪array $deprecatedPublicMethods
Definition: PageInformationController.php:48
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Compatibility\PublicPropertyDeprecationTrait
Definition: PublicPropertyDeprecationTrait.php:66
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Info\Controller
Definition: InfoModuleController.php:2
‪TYPO3\CMS\Info\Controller\PageInformationController\cleanTableNames
‪string cleanTableNames()
Definition: PageInformationController.php:190
‪TYPO3\CMS\Info\Controller\PageInformationController\main
‪string main()
Definition: PageInformationController.php:111
‪TYPO3\CMS\Info\Controller\PageInformationController\$function_key
‪$function_key
Definition: PageInformationController.php:86