‪TYPO3CMS  9.5
BaseScriptClass.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 
25 
72 {
79  public ‪$MCONF = [];
80 
87  public ‪$id;
88 
95  public ‪$CMD;
96 
103  public ‪$perms_clause;
104 
111  public ‪$MOD_MENU = [
112  'function' => []
113  ];
114 
121  public ‪$MOD_SETTINGS = [];
122 
129  public ‪$modTSconfig;
130 
138  public ‪$modMenu_type = '';
139 
147  public ‪$modMenu_dontValidateList = '';
148 
156  public ‪$modMenu_setDefaultList = '';
157 
164  public ‪$extClassConf;
165 
171  public ‪$content = '';
172 
176  public ‪$doc;
177 
184  public ‪$extObj;
185 
189  protected ‪$pageRenderer;
190 
194  public function ‪__construct()
195  {
196  trigger_error(
197  'Class BaseScriptClass is deprecated and will be removed in TYPO3 v10.0',
198  E_USER_DEPRECATED
199  );
200  }
201 
207  public function ‪init()
208  {
209  // Name might be set from outside
210  if (!$this->MCONF['name']) {
211  $this->MCONF = ‪$GLOBALS['MCONF'];
212  }
213  $this->id = (int)GeneralUtility::_GP('id');
214  $this->CMD = GeneralUtility::_GP('CMD');
215  $this->perms_clause = $this->‪getBackendUser()->‪getPagePermsClause(‪Permission::PAGE_SHOW);
216  $this->‪menuConfig();
218  }
219 
227  public function ‪menuConfig()
228  {
229  // Page / user TSconfig settings and blinding of menu-items
230  $this->modTSconfig['properties'] = ‪BackendUtility::getPagesTSconfig($this->id)['mod.'][$this->MCONF['name'] . '.'] ?? [];
231  $this->MOD_MENU['function'] = $this->‪mergeExternalItems($this->MCONF['name'], 'function', $this->MOD_MENU['function']);
232  $blindActions = $this->modTSconfig['properties']['menu.']['function.'] ?? [];
233  foreach ($blindActions as $key => $value) {
234  if (!$value && array_key_exists($key, $this->MOD_MENU['function'])) {
235  unset($this->MOD_MENU['function'][$key]);
236  }
237  }
238  $this->MOD_SETTINGS = ‪BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
239  }
240 
251  public function ‪mergeExternalItems($modName, $menuKey, $menuArr)
252  {
253  $mergeArray = ‪$GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
254  if (is_array($mergeArray)) {
255  foreach ($mergeArray as $k => $v) {
256  if (((string)$v['ws'] === '' || $this->‪getBackendUser()->workspace === 0 && GeneralUtility::inList($v['ws'], 'online')) || $this->‪getBackendUser()->workspace === -1 && GeneralUtility::inList($v['ws'], 'offline') || $this->‪getBackendUser()->workspace > 0 && GeneralUtility::inList($v['ws'], 'custom')) {
257  $menuArr[$k] = $this->‪getLanguageService()->‪sL($v['title']);
258  }
259  }
260  }
261  return $menuArr;
262  }
263 
271  public function ‪handleExternalFunctionValue($MM_key = 'function', $MS_value = null)
272  {
273  if ($MS_value === null) {
274  $MS_value = $this->MOD_SETTINGS[$MM_key];
275  }
276  $this->extClassConf = $this->‪getExternalItemConfig($this->MCONF['name'], $MM_key, $MS_value);
277  }
278 
289  public function ‪getExternalItemConfig($modName, $menuKey, $value = '')
290  {
291  if (isset(‪$GLOBALS['TBE_MODULES_EXT'][$modName])) {
292  return (string)$value !== '' ? ‪$GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey][$value] : ‪$GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
293  }
294  return null;
295  }
296 
305  public function ‪checkExtObj()
306  {
307  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
308  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
309  $this->extObj->init($this, $this->extClassConf);
310  // Re-write:
311  $this->MOD_SETTINGS = ‪BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
312  }
313  }
314 
318  public function ‪checkSubExtObj()
319  {
320  if (is_object($this->extObj)) {
321  $this->extObj->checkExtObj();
322  }
323  }
324 
329  public function ‪extObjHeader()
330  {
331  if (is_callable([$this->extObj, 'head'])) {
332  $this->extObj->head();
333  }
334  }
335 
339  public function ‪extObjContent()
340  {
341  if ($this->extObj === null) {
342  $flashMessage = GeneralUtility::makeInstance(
343  FlashMessage::class,
344  $this->‪getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:no_modules_registered'),
345  $this->‪getLanguageService()->getLL('title'),
347  );
349  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
351  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
352  $defaultFlashMessageQueue->enqueue($flashMessage);
353  } else {
354  $this->extObj->pObj = $this;
355  if (is_callable([$this->extObj, 'main'])) {
356  $this->content .= $this->extObj->main();
357  }
358  }
359  }
360 
366  public function ‪getExtObjContent()
367  {
368  $savedContent = ‪$this->content;
369  $this->content = '';
370  $this->‪extObjContent();
371  $newContent = ‪$this->content;
372  $this->content = $savedContent;
373  return $newContent;
374  }
375 
380  protected function ‪getLanguageService()
381  {
382  return ‪$GLOBALS['LANG'];
383  }
384 
389  protected function ‪getBackendUser()
390  {
391  return ‪$GLOBALS['BE_USER'];
392  }
393 
397  protected function ‪getPageRenderer()
398  {
399  if ($this->pageRenderer === null) {
400  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
401  }
402 
403  return ‪$this->pageRenderer;
404  }
405 }
‪TYPO3\CMS\Backend\Module\BaseScriptClass\__construct
‪__construct()
Definition: BaseScriptClass.php:179
‪TYPO3\CMS\Backend\Module\BaseScriptClass\getLanguageService
‪LanguageService getLanguageService()
Definition: BaseScriptClass.php:365
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$modMenu_type
‪string $modMenu_type
Definition: BaseScriptClass.php:130
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$extObj
‪AbstractFunctionModule $extObj
Definition: BaseScriptClass.php:170
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$content
‪string $content
Definition: BaseScriptClass.php:159
‪TYPO3\CMS\Backend\Module\BaseScriptClass\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: BaseScriptClass.php:374
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$modMenu_dontValidateList
‪string $modMenu_dontValidateList
Definition: BaseScriptClass.php:138
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getPagePermsClause
‪string getPagePermsClause($perms)
Definition: BackendUserAuthentication.php:523
‪TYPO3\CMS\Backend\Module\BaseScriptClass\getExtObjContent
‪string getExtObjContent()
Definition: BaseScriptClass.php:351
‪TYPO3\CMS\Backend\Module\BaseScriptClass\checkExtObj
‪checkExtObj()
Definition: BaseScriptClass.php:290
‪TYPO3\CMS\Backend\Module\BaseScriptClass\handleExternalFunctionValue
‪handleExternalFunctionValue($MM_key='function', $MS_value=null)
Definition: BaseScriptClass.php:256
‪TYPO3\CMS\Backend\Module\AbstractFunctionModule
Definition: AbstractFunctionModule.php:66
‪TYPO3\CMS\Backend\Module\BaseScriptClass\checkSubExtObj
‪checkSubExtObj()
Definition: BaseScriptClass.php:303
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$doc
‪TYPO3 CMS Backend Template DocumentTemplate $doc
Definition: BaseScriptClass.php:163
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$perms_clause
‪string $perms_clause
Definition: BaseScriptClass.php:99
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$MCONF
‪array $MCONF
Definition: BaseScriptClass.php:78
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$modMenu_setDefaultList
‪string $modMenu_setDefaultList
Definition: BaseScriptClass.php:146
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:158
‪TYPO3\CMS\Core\Type\Bitmask\Permission
Definition: Permission.php:23
‪TYPO3\CMS\Backend\Module\BaseScriptClass\extObjContent
‪extObjContent()
Definition: BaseScriptClass.php:324
‪TYPO3\CMS\Backend\Module\BaseScriptClass\getPageRenderer
‪PageRenderer getPageRenderer()
Definition: BaseScriptClass.php:382
‪TYPO3\CMS\Core\Page\PageRenderer
Definition: PageRenderer.php:35
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$MOD_MENU
‪array $MOD_MENU
Definition: BaseScriptClass.php:106
‪TYPO3\CMS\Backend\Module\BaseScriptClass\init
‪init()
Definition: BaseScriptClass.php:192
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$modTSconfig
‪array $modTSconfig
Definition: BaseScriptClass.php:122
‪TYPO3\CMS\Backend\Module\BaseScriptClass
Definition: BaseScriptClass.php:72
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$id
‪int $id
Definition: BaseScriptClass.php:85
‪TYPO3\CMS\Backend\Utility\BackendUtility\getModuleData
‪static array getModuleData( $MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
Definition: BackendUtility.php:3259
‪TYPO3\CMS\Backend\Module\BaseScriptClass\menuConfig
‪menuConfig()
Definition: BaseScriptClass.php:212
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪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\Backend\Module\BaseScriptClass\getExternalItemConfig
‪mixed getExternalItemConfig($modName, $menuKey, $value='')
Definition: BaseScriptClass.php:274
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$pageRenderer
‪PageRenderer $pageRenderer
Definition: BaseScriptClass.php:174
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:22
‪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\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Module\BaseScriptClass\extObjHeader
‪extObjHeader()
Definition: BaseScriptClass.php:314
‪TYPO3\CMS\Backend\Module\BaseScriptClass\mergeExternalItems
‪array mergeExternalItems($modName, $menuKey, $menuArr)
Definition: BaseScriptClass.php:236
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$MOD_SETTINGS
‪array $MOD_SETTINGS
Definition: BaseScriptClass.php:115
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$CMD
‪mixed $CMD
Definition: BaseScriptClass.php:92
‪TYPO3\CMS\Core\Messaging\FlashMessageService
Definition: FlashMessageService.php:25
‪TYPO3\CMS\Backend\Module
Definition: AbstractFunctionModule.php:2
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Backend\Module\BaseScriptClass\$extClassConf
‪array $extClassConf
Definition: BaseScriptClass.php:153