TYPO3 CMS  TYPO3_8-7
AbstractFunctionModule.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 
109 {
117  public $pObj;
118 
122  public $extObj = null;
123 
131  public $thisPath = '';
132 
140  public $localLangFile = '';
141 
149 
158  public $function_key = '';
159 
163  protected $pageRenderer = null;
164 
173  public function init(&$pObj, $conf)
174  {
175  $this->pObj = $pObj;
176  // Path of this script:
177  $reflector = new \ReflectionObject($this);
178  $this->thisPath = dirname($reflector->getFileName());
179  if (!@is_dir($this->thisPath)) {
180  throw new \RuntimeException('TYPO3 Fatal Error: Could not find path for class ' . get_class($this), 1381164687);
181  }
182  // Local lang:
183  if (!empty($this->localLangFile)) {
184  $this->getLanguageService()->includeLLFile($this->localLangFile);
185  }
186  // Setting MOD_MENU items as we need them for logging:
187  $this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu());
188  }
189 
196  public function handleExternalFunctionValue()
197  {
198  // Must clean first to make sure the correct key is set...
199  $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
200  if ($this->function_key) {
201  $this->extClassConf = $this->pObj->getExternalItemConfig($this->pObj->MCONF['name'], $this->function_key, $this->pObj->MOD_SETTINGS[$this->function_key]);
202  }
203  }
204 
210  public function incLocalLang()
211  {
213  if (
214  $this->localLangFile
215  && (
216  @is_file(($this->thisPath . '/' . $this->localLangFile))
217  || @is_file(($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.xml'))
218  )
219  ) {
220  $LOCAL_LANG = $this->getLanguageService()->includeLLFile($this->thisPath . '/' . $this->localLangFile, false);
221  if (is_array($LOCAL_LANG)) {
222  $GLOBALS['LOCAL_LANG'] = (array)$GLOBALS['LOCAL_LANG'];
223  ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
224  }
225  }
226  }
227 
233  public function checkExtObj()
234  {
235  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
236  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
237  $this->extObj->init($this->pObj, $this->extClassConf);
238  // Re-write:
239  $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
240  }
241  }
242 
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 makeInstance($className,... $constructorArguments)
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']