TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractFunctionModule.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 
25 
109 {
117  public $pObj;
118 
122  public $extObj = null;
123 
130  public $thisPath = '';
131 
138  public $localLangFile = 'locallang.xlf';
139 
147 
156  public $function_key = '';
157 
161  protected $pageRenderer = null;
162 
171  public function init(&$pObj, $conf)
172  {
173  $this->pObj = $pObj;
174  // Path of this script:
175  $reflector = new \ReflectionObject($this);
176  $this->thisPath = dirname($reflector->getFileName());
177  if (!@is_dir($this->thisPath)) {
178  throw new \RuntimeException('TYPO3 Fatal Error: Could not find path for class ' . get_class($this), 1381164687);
179  }
180  // Local lang:
181  $this->incLocalLang();
182  // Setting MOD_MENU items as we need them for logging:
183  $this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu());
184  }
185 
193  public function handleExternalFunctionValue()
194  {
195  // Must clean first to make sure the correct key is set...
196  $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
197  if ($this->function_key) {
198  $this->extClassConf = $this->pObj->getExternalItemConfig($this->pObj->MCONF['name'], $this->function_key, $this->pObj->MOD_SETTINGS[$this->function_key]);
199  }
200  }
201 
208  public function incLocalLang()
209  {
210  if (
211  $this->localLangFile
212  && (
213  @is_file(($this->thisPath . '/' . $this->localLangFile))
214  || @is_file(($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.xml'))
215  )
216  ) {
217  $LOCAL_LANG = $this->getLanguageService()->includeLLFile($this->thisPath . '/' . $this->localLangFile, false);
218  if (is_array($LOCAL_LANG)) {
219  $GLOBALS['LOCAL_LANG'] = (array)$GLOBALS['LOCAL_LANG'];
220  ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
221  }
222  }
223  }
224 
231  public function checkExtObj()
232  {
233  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
234  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
235  $this->extObj->init($this->pObj, $this->extClassConf);
236  // Re-write:
237  $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
238  }
239  }
240 
246  public function extObjContent()
247  {
248  if (is_object($this->extObj)) {
249  return $this->extObj->main();
250  }
251  }
252 
259  public function modMenu()
260  {
261  return [];
262  }
263 
267  protected function getLanguageService()
268  {
269  return $GLOBALS['LANG'];
270  }
271 
275  protected function getBackendUserAuthentication()
276  {
277  return $GLOBALS['BE_USER'];
278  }
279 
283  protected function getDocumentTemplate()
284  {
285  return $GLOBALS['TBE_TEMPLATE'];
286  }
287 
292  protected function getBackPath()
293  {
295  return '';
296  }
297 
302  protected function getDatabaseConnection()
303  {
305  return $GLOBALS['TYPO3_DB'];
306  }
307 
311  protected function getPageRenderer()
312  {
313  if ($this->pageRenderer === null) {
314  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
315  }
316 
317  return $this->pageRenderer;
318  }
319 }
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type= '', $dontValidateList= '', $setDefaultList= '')
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
if(TYPO3_MODE=== 'BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static makeInstance($className,...$constructorArguments)