Skip to content

Instantly share code, notes, and snippets.

@corleonis
Created January 22, 2013 15:20
Show Gist options
  • Save corleonis/4595435 to your computer and use it in GitHub Desktop.
Save corleonis/4595435 to your computer and use it in GitHub Desktop.
Inits the TSFE global object in the backend of Typo3
function buildTSFE($pid = 1) {
global $BACK_PATH;
//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($BACK_PATH.'sysext/cms/tslib/class.tslib_fe.php');
require_once($BACK_PATH.'sysext/cms/tslib/class.tslib_content.php');
require_once($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 information
$GLOBALS['TSFE']->tmpl->init();
$rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pid);
$GLOBALS['TSFE']->rootLine = $rootLine;
//*** This generates the constants/config + hierarchy info for the template.
$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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment