Feature #19308 » 9318.diff
typo3/sysext/cms/tslib/class.tslib_eidtools.php (working copy) | ||
---|---|---|
/**
|
||
* [CLASS/FUNCTION INDEX of SCRIPT]
|
||
*
|
||
* 71: public static function initFeUser()
|
||
* 97: public static function connectDB()
|
||
* 111: public static function initLanguage($language = 'default')
|
||
* 125: public static function initTCA()
|
||
* 143: public static function initExtensionTCA($extensionKey)
|
||
* 160: private static function getTSFE()
|
||
*
|
||
*
|
||
* 74: class tslib_eidtools
|
||
* 81: function initFeUser()
|
||
* 108: function connectDB()
|
||
*
|
||
* TOTAL FUNCTIONS: 2
|
||
* TOTAL FUNCTIONS: 6
|
||
* (This index is automatically created/updated by the extension "extdeveval")
|
||
*
|
||
*/
|
||
/**
|
||
* Tools for scripts using the eID feature of index.php
|
||
*
|
||
* @author Kasper Skaarhoj <kasperYYYY@typo3.com>
|
||
* @author Dmitry Dulepov <dmitry@typo3.org>
|
||
* @package TYPO3
|
||
* @subpackage tslib
|
||
*/
|
||
class tslib_eidtools {
|
||
final class tslib_eidtools {
|
||
/**
|
||
* Load and initialize Frontend User
|
||
* Load and initialize Frontend User. Note, this process is slow because
|
||
* it creates a calls many objects. Call this method only if necessary!
|
||
*
|
||
* @return object Frontend User object (usually known as TSFE->fe_user)
|
||
*/
|
||
public static function initFeUser() {
|
||
// Include classes necessary for initializing frontend user:
|
||
// We will use tslib_fe to do that:
|
||
require_once(PATH_tslib.'class.tslib_fe.php');
|
||
require_once(PATH_t3lib.'class.t3lib_cs.php');
|
||
require_once(PATH_t3lib.'class.t3lib_userauth.php');
|
||
require_once(PATH_tslib.'class.tslib_feuserauth.php');
|
||
// Initialize the database. Do not use TSFE method as it may redirect to
|
||
// Install tool and call hooks, which do not expect to be called from eID
|
||
self::connectDB();
|
||
// Make new instance of TSFE object for initializing user:
|
||
$temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
|
||
$TSFE = new $temp_TSFEclassName($GLOBALS['TYPO3_CONF_VARS'],0,0);
|
||
$TSFE->connectToDB();
|
||
// Get TSFE instance. It knows how to initialize the user. We also
|
||
// need TCA because services may need extra tables!
|
||
self::initTCA();
|
||
$tsfe = self::getTSFE();
|
||
/* @var $tsfe tslib_fe */
|
||
// Initialize FE user:
|
||
$TSFE->initFEuser();
|
||
// Include classes necessary for initializing frontend user
|
||
require_once(PATH_t3lib . 'class.t3lib_userauth.php');
|
||
require_once(PATH_tslib . 'class.tslib_feuserauth.php');
|
||
// Return FE user object:
|
||
return $TSFE->fe_user;
|
||
$tsfe->initFEuser();
|
||
// Return FE user object:
|
||
return $tsfe->fe_user;
|
||
}
|
||
/**
|
||
... | ... | |
* @return void
|
||
*/
|
||
public static function connectDB() {
|
||
/* @var $TYPO3_DB t3lib_db */
|
||
$GLOBALS['TYPO3_DB']->connectDB();
|
||
static $dbConnected = false;
|
||
if (!$dbConnected) {
|
||
$GLOBALS['TYPO3_DB']->connectDB();
|
||
}
|
||
}
|
||
/**
|
||
* Initializes $GLOBALS['LANG'] for use in eID scripts.
|
||
*
|
||
* @param string $language TYPO3 language code
|
||
* @return void
|
||
*/
|
||
public static function initLanguage($language = 'default') {
|
||
if (!is_object($GLOBALS['LANG'])) {
|
||
require_once(PATH_t3lib . 'class.t3lib_cs.php');
|
||
require_once(t3lib_extMgm::extPath('lang', 'lang.php'));
|
||
$GLOBALS['LANG'] = t3lib_div::makeInstance('language');
|
||
$GLOBALS['LANG']->init($language);
|
||
}
|
||
}
|
||
/**
|
||
* Makes TCA available inside eID
|
||
*
|
||
* @return void
|
||
*/
|
||
public static function initTCA() {
|
||
// It is possible that $TCA is an array but it was not loaded properly.
|
||
// This happens if some badly made extension attempts to manipulate
|
||
// $TCA in the ext_localconf.php.
|
||
if (!is_array($GLOBALS['TCA']) || !isset($GLOBALS['TCA']['pages'])) {
|
||
// Load TCA using TSFE
|
||
self::getTSFE()->includeTCA(false);
|
||
}
|
||
}
|
||
/**
|
||
* Makes TCA for the extension available inside eID. Use this function if
|
||
* you need not to include the whole $TCA. However, you still need to call
|
||
* t3lib_div::loadTCA() if you want to access column array!
|
||
*
|
||
* @param string $extensionKey Extension key
|
||
* @return void
|
||
*/
|
||
public static function initExtensionTCA($extensionKey) {
|
||
$extTablesPath = t3lib_extMgm::extPath($extensionKey, 'ext_tables.php');
|
||
if (file_exists($extTablesPath)) {
|
||
$GLOBALS['_EXTKEY'] = $extensionKey;
|
||
require_once($extTablesPath);
|
||
unset($GLOBALS['_EXTKEY']);
|
||
// We do not need to save restore the value of $GLOBALS['_EXTKEY']
|
||
// because it is not defined to anything real outside of
|
||
// ext_tables.php or ext_localconf.php scope.
|
||
}
|
||
}
|
||
/**
|
||
* Creating a single static cached instance of TSFE to use with this class.
|
||
*
|
||
* @return tslib_fe New instance of tslib_fe
|
||
*/
|
||
private static function getTSFE() {
|
||
// Cached instance
|
||
static $tsfe = null;
|
||
if (is_null($tsfe)) {
|
||
require_once(PATH_tslib . 'class.tslib_fe.php');
|
||
require_once(PATH_t3lib . 'class.t3lib_cs.php');
|
||
$tsfeClassName = t3lib_div::makeInstanceClassName('tslib_fe');
|
||
$tsfe = new $tsfeClassName($GLOBALS['TYPO3_CONF_VARS'], 0, 0);
|
||
}
|
||
return $tsfe;
|
||
}
|
||
}
|
||
?>
|