create TSFE object for use in backend (thanks to Christian Müller)
<?php
/**
* Initializes <code>$GLOBALS['TSFE']</code> the FE object to use in the backend
*
* @return void
*/
function buildTSFE($pid = 1) {
//needed for TSFE
require_once(PATH_t3lib.'class.t3lib_timetrack.php');
require_once(PATH_t3lib.'class.t3lib_tsparser_ext.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
require_once($GLOBALS['BACK_PATH'].'sysext/cms/tslib/class.tslib_fe.php');
require_once($GLOBALS['BACK_PATH'].'sysext/cms/tslib/class.tslib_content.php');
require_once($GLOBALS['BACK_PATH'].'sysext/cms/tslib/class.tslib_gifbuilder.php');
/* Declare */
$temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
/* Begin */
if (!is_object($GLOBALS['TT'])) {
$GLOBALS['TT'] = new t3lib_timeTrack;
$GLOBALS['TT']->start();
}
if (!is_object($GLOBALS['TSFE']) && $pid) {
//*** Builds TSFE object
$GLOBALS['TSFE'] = new $temp_TSFEclassName($GLOBALS['TYPO3_CONF_VARS'],$pid,0,0,0,0,0,0);
//*** Builds sub objects
$GLOBALS['TSFE']->tmpl = t3lib_div::makeInstance('t3lib_tsparser_ext');
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
//*** init template
$GLOBALS['TSFE']->tmpl->tt_track = 0;// Do not log time-performance
$GLOBALS['TSFE']->tmpl->init();
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pid);
//*** This generates the constants/config + hierarchy info for the
$GLOBALS['TSFE']->tmpl->runThroughTemplates($rootLine,$template_uid);
$GLOBALS['TSFE']->tmpl->generateConfig();
$GLOBALS['TSFE']->tmpl->loaded=1;
//*** Get config array and other init from pagegen
$GLOBALS['TSFE']->getConfigArray();
$GLOBALS['TSFE']->linkVars = ''.$GLOBALS['TSFE']->config['config']['linkVars'];
if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP'])
{
foreach (t3lib_div::trimExplode(',',$GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc_onlyP'],1)
as $temp_p)
{
$GLOBALS['TSFE']->pEncAllowedParamNames[$temp_p]=1;
}
}
//*** Builds a cObj
$GLOBALS['TSFE']->newCObj();
}
}
?>