TYPO3 CMS  TYPO3_7-6
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 
78 {
85  public $MCONF = [];
86 
93  public $id;
94 
101  public $CMD;
102 
110 
117  public $MOD_MENU = [
118  'function' => []
119  ];
120 
127  public $MOD_SETTINGS = [];
128 
135  public $modTSconfig;
136 
144  public $modMenu_type = '';
145 
154 
163 
171 
177  public $content = '';
178 
182  public $doc;
183 
190  public $extObj;
191 
195  protected $pageRenderer = null;
196 
203  public function init()
204  {
205  // Name might be set from outside
206  if (!$this->MCONF['name']) {
207  $this->MCONF = $GLOBALS['MCONF'];
208  }
209  $this->id = (int)GeneralUtility::_GP('id');
210  $this->CMD = GeneralUtility::_GP('CMD');
211  $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
212  $this->menuConfig();
214  }
215 
224  public function menuConfig()
225  {
226  // Page/be_user TSconfig settings and blinding of menu-items
227  $this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
228  $this->MOD_MENU['function'] = $this->mergeExternalItems($this->MCONF['name'], 'function', $this->MOD_MENU['function']);
229  $this->MOD_MENU['function'] = BackendUtility::unsetMenuItems($this->modTSconfig['properties'], $this->MOD_MENU['function'], 'menu.function');
230  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
231  }
232 
243  public function mergeExternalItems($modName, $menuKey, $menuArr)
244  {
245  $mergeArray = $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
246  if (is_array($mergeArray)) {
247  foreach ($mergeArray as $k => $v) {
248  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')) {
249  $menuArr[$k] = $this->getLanguageService()->sL($v['title']);
250  }
251  }
252  }
253  return $menuArr;
254  }
255 
264  public function handleExternalFunctionValue($MM_key = 'function', $MS_value = null)
265  {
266  if ($MS_value === null) {
267  $MS_value = $this->MOD_SETTINGS[$MM_key];
268  }
269  $this->extClassConf = $this->getExternalItemConfig($this->MCONF['name'], $MM_key, $MS_value);
270  }
271 
282  public function getExternalItemConfig($modName, $menuKey, $value = '')
283  {
284  if (isset($GLOBALS['TBE_MODULES_EXT'][$modName])) {
285  return (string)$value !== '' ? $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey][$value] : $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
286  }
287  return null;
288  }
289 
299  public function checkExtObj()
300  {
301  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
302  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
303  $this->extObj->init($this, $this->extClassConf);
304  // Re-write:
305  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
306  }
307  }
308 
314  public function checkSubExtObj()
315  {
316  if (is_object($this->extObj)) {
317  $this->extObj->checkExtObj();
318  }
319  }
320 
329  public function extObjHeader()
330  {
331  if (is_callable([$this->extObj, 'head'])) {
332  $this->extObj->head();
333  }
334  }
335 
341  public function extObjContent()
342  {
343  if ($this->extObj === null) {
344  $flashMessage = GeneralUtility::makeInstance(
345  FlashMessage::class,
346  $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:no_modules_registered'),
347  $this->getLanguageService()->getLL('title'),
349  );
351  $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
353  $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
354  $defaultFlashMessageQueue->enqueue($flashMessage);
355  } else {
356  $this->extObj->pObj = $this;
357  if (is_callable([$this->extObj, 'main'])) {
358  $this->content .= $this->extObj->main();
359  }
360  }
361  }
362 
367  protected function getLanguageService()
368  {
369  return $GLOBALS['LANG'];
370  }
371 
376  protected function getBackendUser()
377  {
378  return $GLOBALS['BE_USER'];
379  }
380 
384  protected function getDatabaseConnection()
385  {
386  return $GLOBALS['TYPO3_DB'];
387  }
388 
392  protected function getPageRenderer()
393  {
394  if ($this->pageRenderer === null) {
395  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
396  }
397 
398  return $this->pageRenderer;
399  }
400 }
getExternalItemConfig($modName, $menuKey, $value='')
mergeExternalItems($modName, $menuKey, $menuArr)
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static unsetMenuItems($modTSconfig, $itemArray, $TSref)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
handleExternalFunctionValue($MM_key='function', $MS_value=null)