TYPO3  7.6
BaseScriptClass.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Module;
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 
24 
77 {
84  public $MCONF = array();
85 
92  public $id;
93 
100  public $CMD;
101 
109 
116  public $MOD_MENU = array(
117  'function' => array()
118  );
119 
126  public $MOD_SETTINGS = array();
127 
134  public $modTSconfig;
135 
143  public $modMenu_type = '';
144 
153 
162 
170 
176  public $content = '';
177 
181  public $doc;
182 
189  public $extObj;
190 
194  protected $pageRenderer = null;
195 
202  public function init()
203  {
204  // Name might be set from outside
205  if (!$this->MCONF['name']) {
206  $this->MCONF = $GLOBALS['MCONF'];
207  }
208  $this->id = (int)GeneralUtility::_GP('id');
209  $this->CMD = GeneralUtility::_GP('CMD');
210  $this->perms_clause = $this->getBackendUser()->getPagePermsClause(1);
211  $this->menuConfig();
213  }
214 
223  public function menuConfig()
224  {
225  // Page/be_user TSconfig settings and blinding of menu-items
226  $this->modTSconfig = BackendUtility::getModTSconfig($this->id, 'mod.' . $this->MCONF['name']);
227  $this->MOD_MENU['function'] = $this->mergeExternalItems($this->MCONF['name'], 'function', $this->MOD_MENU['function']);
228  $this->MOD_MENU['function'] = BackendUtility::unsetMenuItems($this->modTSconfig['properties'], $this->MOD_MENU['function'], 'menu.function');
229  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
230  }
231 
242  public function mergeExternalItems($modName, $menuKey, $menuArr)
243  {
244  $mergeArray = $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
245  if (is_array($mergeArray)) {
246  foreach ($mergeArray as $k => $v) {
247  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')) {
248  $menuArr[$k] = $this->getLanguageService()->sL($v['title']);
249  }
250  }
251  }
252  return $menuArr;
253  }
254 
263  public function handleExternalFunctionValue($MM_key = 'function', $MS_value = null)
264  {
265  if ($MS_value === null) {
266  $MS_value = $this->MOD_SETTINGS[$MM_key];
267  }
268  $this->extClassConf = $this->getExternalItemConfig($this->MCONF['name'], $MM_key, $MS_value);
269  }
270 
281  public function getExternalItemConfig($modName, $menuKey, $value = '')
282  {
283  if (isset($GLOBALS['TBE_MODULES_EXT'][$modName])) {
284  return (string)$value !== '' ? $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey][$value] : $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
285  }
286  return null;
287  }
288 
298  public function checkExtObj()
299  {
300  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
301  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
302  $this->extObj->init($this, $this->extClassConf);
303  // Re-write:
304  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
305  }
306  }
307 
313  public function checkSubExtObj()
314  {
315  if (is_object($this->extObj)) {
316  $this->extObj->checkExtObj();
317  }
318  }
319 
328  public function extObjHeader()
329  {
330  if (is_callable(array($this->extObj, 'head'))) {
331  $this->extObj->head();
332  }
333  }
334 
340  public function extObjContent()
341  {
342  if ($this->extObj === null) {
343  $flashMessage = GeneralUtility::makeInstance(
344  FlashMessage::class,
345  $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang.xlf:no_modules_registered'),
346  $this->getLanguageService()->getLL('title'),
348  );
349  $this->content .= $flashMessage->render();
350  } else {
351  $this->extObj->pObj = $this;
352  if (is_callable(array($this->extObj, 'main'))) {
353  $this->content .= $this->extObj->main();
354  }
355  }
356  }
357 
362  protected function getLanguageService()
363  {
364  return $GLOBALS['LANG'];
365  }
366 
371  protected function getBackendUser()
372  {
373  return $GLOBALS['BE_USER'];
374  }
375 
379  protected function getDatabaseConnection()
380  {
381  return $GLOBALS['TYPO3_DB'];
382  }
383 
387  protected function getPageRenderer()
388  {
389  if ($this->pageRenderer === null) {
390  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
391  }
392 
393  return $this->pageRenderer;
394  }
395 }