TYPO3 CMS  TYPO3_7-6
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 
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  || @is_file(($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.php'))
216  )
217  ) {
218  $LOCAL_LANG = $this->getLanguageService()->includeLLFile($this->thisPath . '/' . $this->localLangFile, false);
219  if (is_array($LOCAL_LANG)) {
220  $GLOBALS['LOCAL_LANG'] = (array)$GLOBALS['LOCAL_LANG'];
221  ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
222  }
223  }
224  }
225 
232  public function checkExtObj()
233  {
234  if (is_array($this->extClassConf) && $this->extClassConf['name']) {
235  $this->extObj = GeneralUtility::makeInstance($this->extClassConf['name']);
236  $this->extObj->init($this->pObj, $this->extClassConf);
237  // Re-write:
238  $this->pObj->MOD_SETTINGS = BackendUtility::getModuleData($this->pObj->MOD_MENU, GeneralUtility::_GP('SET'), $this->pObj->MCONF['name']);
239  }
240  }
241 
247  public function extObjContent()
248  {
249  if (is_object($this->extObj)) {
250  return $this->extObj->main();
251  }
252  }
253 
260  public function modMenu()
261  {
262  return [];
263  }
264 
268  protected function getLanguageService()
269  {
270  return $GLOBALS['LANG'];
271  }
272 
276  protected function getBackendUserAuthentication()
277  {
278  return $GLOBALS['BE_USER'];
279  }
280 
284  protected function getDocumentTemplate()
285  {
286  return $GLOBALS['TBE_TEMPLATE'];
287  }
288 
292  protected function getBackPath()
293  {
294  return $GLOBALS['BACK_PATH'];
295  }
296 
300  protected function getDatabaseConnection()
301  {
302  return $GLOBALS['TYPO3_DB'];
303  }
304 
308  protected function getPageRenderer()
309  {
310  if ($this->pageRenderer === null) {
311  $this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
312  }
313 
314  return $this->pageRenderer;
315  }
316 }
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']