Project

General

Profile

Bug #22410 » 14050_cleaning_t3lib_extobjbase.patch

Administrator Admin, 2010-11-24 11:21

View differences:

t3lib/class.t3lib_extobjbase.php (revision )
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2010 Kasper Sk?rh?j (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
* Copyright notice
*
* (c) 1999-2010 Kasper Sk?rh?j (kasperYYYY@typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Contains the base class for 'Extension Objects' in backend modules.
*
......
*
*
* 145: class t3lib_extobjbase
* 197: function init(&$pObj,$conf)
* 197: function init(&$pObj,$conf)
* 221: function handleExternalFunctionValue()
* 221: function handleExternalFunctionValue()
* 237: function incLocalLang()
* 237: function incLocalLang()
* 253: function checkExtObj()
* 253: function checkExtObj()
* 268: function extObjContent()
* 268: function extObjContent()
* 279: function modMenu()
* 279: function modMenu()
*
* TOTAL FUNCTIONS: 6
* (This index is automatically created/updated by the extension "extdeveval")
......
*/
/**
* EXAMPLE: One level.
*
* This can be seen in the extension 'cms' where the info module have a function added. In 'ext_tables.php' this is done by this function call:
*
* t3lib_extMgm::insertModuleFunction(
* t3lib_extMgm::insertModuleFunction(
* 'web_info',
* 'web_info',
* 'tx_cms_webinfo_page',
* 'tx_cms_webinfo_page',
* t3lib_extMgm::extPath($_EXTKEY).'web_info/class.tx_cms_webinfo.php',
* t3lib_extMgm::extPath($_EXTKEY).'web_info/class.tx_cms_webinfo.php',
* 'LLL:EXT:cms/locallang_tca.php:mod_tx_cms_webinfo_page'
* 'LLL:EXT:cms/locallang_tca.php:mod_tx_cms_webinfo_page'
* );
* );
*
*
*
......
* The key used in TBE_MODULES_EXT is normally 'function' (for the 'function menu') but the 'func_wizards' extension uses an alternative key for its configuration: 'wiz'.
* In the 'ext_tables.php' file of an extension ('wizard_crpages') which uses the framework provided by 'func_wizards' this looks like this:
*
* t3lib_extMgm::insertModuleFunction(
* t3lib_extMgm::insertModuleFunction(
* 'web_func',
* 'web_func',
* 'tx_wizardcrpages_webfunc_2',
* 'tx_wizardcrpages_webfunc_2',
* t3lib_extMgm::extPath($_EXTKEY).'class.tx_wizardcrpages_webfunc_2.php',
* t3lib_extMgm::extPath($_EXTKEY).'class.tx_wizardcrpages_webfunc_2.php',
* 'LLL:EXT:wizard_crpages/locallang.php:wiz_crMany',
* 'LLL:EXT:wizard_crpages/locallang.php:wiz_crMany',
* 'wiz'
* 'wiz'
* );
* );
*
* But for this two-level thing to work it also requires that the parent module (the real backend module) supports it.
* This is the case for the modules web_func and web_info since they have two times inclusion sections in their index.php scripts. For example (from web_func):
*
* // Make instance:
* // Make instance:
* $SOBE = t3lib_div::makeInstance("SC_mod_web_func_index");
* $SOBE = t3lib_div::makeInstance("SC_mod_web_func_index");
* $SOBE->init();
* $SOBE->init();
*
* // Include files?
* // Include files?
* foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
* foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
* $SOBE->checkExtObj(); // Checking for first level external objects
* $SOBE->checkExtObj(); // Checking for first level external objects
*
* // Repeat Include files! - if any files has been added by second-level extensions
* // Repeat Include files! - if any files has been added by second-level extensions
* foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
* foreach($SOBE->include_once as $INC_FILE) include_once($INC_FILE);
* $SOBE->checkSubExtObj(); // Checking second level external objects
* $SOBE->checkSubExtObj(); // Checking second level external objects
*
* $SOBE->main();
* $SOBE->main();
* $SOBE->printContent();
* $SOBE->printContent();
*
* Notice that the first part is as usual: Include classes and call $SOBE->checkExtObj() to initialize any level-1 sub-modules
* But then again ->include_once is traversed IF the initialization of the level-1 modules might have added more files!!
......
*
* Anyways, the final interesting thing is to see what the framework "func_wizard" actually does:
*
* class tx_funcwizards_webfunc extends t3lib_extobjbase {
* class tx_funcwizards_webfunc extends t3lib_extobjbase {
* var $localLangFile = "locallang.php";
* var $localLangFile = "locallang.php";
* var $function_key = "wiz";
* var $function_key = "wiz";
* function init(&$pObj,$conf) {
* function init(&$pObj,$conf) {
* // OK, handles ordinary init. This includes setting up the menu array with ->modMenu
* // OK, handles ordinary init. This includes setting up the menu array with ->modMenu
* parent::init($pObj,$conf);
* parent::init($pObj,$conf);
* // Making sure that any further external classes are added to the include_once array. Notice that inclusion happens twice in the main script because of this!!!
* // Making sure that any further external classes are added to the include_once array. Notice that inclusion happens twice in the main script because of this!!!
* $this->handleExternalFunctionValue();
* $this->handleExternalFunctionValue();
* }
* }
* ....
* ....
*
* Notice that the handleExternalFunctionValue of this class (t3lib_extobjbase) is called and that the ->function_key internal var is set!
*
......
* @var t3lib_SCbase
* @see init()
*/
var $pObj; // parent SC object
var $pObj; // parent SC object
/**
* Set to the directory name of this class file.
......
var $function_key = '';
/**
* Initialize the object
*
......
* @return void
* @see t3lib_SCbase::checkExtObj()
*/
function init(&$pObj,$conf) {
function init(&$pObj, $conf) {
global $LANG;
$this->pObj = $pObj;
// Path of this script:
$this->thisPath = dirname($conf['path']);
if (!@is_dir($this->thisPath)) {
if (!@is_dir($this->thisPath)) {
throw new RuntimeException(
'TYPO3 Fatal Error: Extension "' . $this->thisPath . ' was not a directory as expected...',
1270853912
......
$this->incLocalLang();
// Setting MOD_MENU items as we need them for logging:
$this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU,$this->modMenu()); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
$this->pObj->MOD_MENU = array_merge($this->pObj->MOD_MENU, $this->modMenu()); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
}
/**
......
* @return void
* @see $function_key, tx_funcwizards_webfunc::init()
*/
function handleExternalFunctionValue() {
function handleExternalFunctionValue() {
// Must clean first to make sure the correct key is set...
$this->pObj->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->pObj->MOD_MENU, t3lib_div::_GP('SET'), $this->pObj->MCONF['name']);
if ($this->function_key) {
if ($this->function_key) {
$this->extClassConf = $this->pObj->getExternalItemConfig($this->pObj->MCONF['name'],$this->function_key,$this->pObj->MOD_SETTINGS[$this->function_key]);
$this->extClassConf = $this->pObj->getExternalItemConfig($this->pObj->MCONF['name'], $this->function_key, $this->pObj->MOD_SETTINGS[$this->function_key]);
if (is_array($this->extClassConf) && $this->extClassConf['path']) {
if (is_array($this->extClassConf) && $this->extClassConf['path']) {
$this->pObj->include_once[] = $this->extClassConf['path'];
}
}
......
*
* @return void
*/
function incLocalLang() {
function incLocalLang() {
global $LANG;
#if ($this->localLangFile && @is_file($this->thisPath.'/'.$this->localLangFile)) {
# include($this->thisPath.'/'.$this->localLangFile);
if ($this->localLangFile && (@is_file($this->thisPath.'/'.$this->localLangFile) || @is_file($this->thisPath.'/'.substr($this->localLangFile,0,-4).'.xml'))) {
if ($this->localLangFile && (@is_file($this->thisPath . '/' . $this->localLangFile) || @is_file($this->thisPath . '/' . substr($this->localLangFile, 0, -4) . '.xml'))) {
$LOCAL_LANG = $LANG->includeLLFile($this->thisPath.'/'.$this->localLangFile, FALSE);
$LOCAL_LANG = $LANG->includeLLFile($this->thisPath . '/' . $this->localLangFile, FALSE);
if (is_array($LOCAL_LANG)) {
$GLOBALS['LOCAL_LANG'] = t3lib_div::array_merge_recursive_overrule((array)$GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
$GLOBALS['LOCAL_LANG'] = t3lib_div::array_merge_recursive_overrule((array) $GLOBALS['LOCAL_LANG'], $LOCAL_LANG);
}
}
}
......
* @return void
* @see t3lib_SCbase::checkExtObj()
*/
function checkExtObj() {
function checkExtObj() {
if (is_array($this->extClassConf) && $this->extClassConf['name']) {
if (is_array($this->extClassConf) && $this->extClassConf['name']) {
$this->extObj = t3lib_div::makeInstance($this->extClassConf['name']);
$this->extObj->init($this->pObj,$this->extClassConf);
$this->extObj->init($this->pObj, $this->extClassConf);
// Re-write:
$this->pObj->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->pObj->MOD_MENU, t3lib_div::_GP('SET'), $this->pObj->MCONF['name']);
......
*
* @return void
*/
function extObjContent() {
function extObjContent() {
if (is_object($this->extObj)) return $this->extObj->main();
if (is_object($this->extObj)) {
return $this->extObj->main();
}
}
}
/**
* Dummy function - but is used to set up additional menu items for this submodule.
......
* @return array A MOD_MENU array which will be merged together with the one from the parent object
* @see init(), tx_cms_webinfo_page::modMenu()
*/
function modMenu() {
function modMenu() {
return array();
}
}
?>
(23-23/93)