protected static function typo3($reset = false) {
        static $typo3cs = null;

        if ($reset) {
            $typo3cs = null;
            return null;
        }

        if (isset($typo3cs)) {
            return $typo3cs;
        }

        global $CFG;

        // Required files
        require_once($CFG->libdir.'/typo3/class.t3lib_cs.php');
        require_once($CFG->libdir.'/typo3/class.t3lib_div.php');
        require_once($CFG->libdir.'/typo3/interface.t3lib_singleton.php');
        require_once($CFG->libdir.'/typo3/class.t3lib_l10n_locales.php');

        // do not use mbstring or recode because it may return invalid results in some corner cases
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_convMethod'] = 'iconv';
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'iconv';

        // Tell Typo3 we are curl enabled always (mandatory since 2.0)
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] = '1';

        // And this directory must exist to allow Typo to cache conversion
        // tables when using internal functions
        make_temp_directory('typo3temp/cs');

        // Make sure typo is using our dir permissions
        $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = decoct($CFG->directorypermissions);

        // Default mask for Typo
        $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = decoct($CFG->filepermissions);

        // This full path constants must be defined too, transforming backslashes
        // to forward slashed because Typo3 requires it.
        if (!defined('PATH_t3lib')) {
            define('PATH_t3lib', str_replace('\\','/',$CFG->libdir.'/typo3/'));
            define('PATH_typo3', str_replace('\\','/',$CFG->libdir.'/typo3/'));
            define('PATH_site', str_replace('\\','/',$CFG->tempdir.'/'));
            define('TYPO3_OS', stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'');
        }

        $typo3cs = new t3lib_cs();

        return $typo3cs;
    }