|
TYPO3 API
SVNRelease
|
00001 <?php 00002 00003 /*************************************************************** 00004 * Copyright notice 00005 * 00006 * (c) 2010 Rens Admiraal <rens@rensnel.nl> 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * 00018 * This script is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * This copyright notice MUST APPEAR in all copies of the script! 00024 ***************************************************************/ 00025 00026 /** 00027 * Utilities to simulate a frontend in backend context. 00028 * 00029 * ONLY USED INTERNALLY, MIGHT CHANGE WITHOUT NOTICE! 00030 * 00031 * @package Extbase 00032 * @subpackage Utility 00033 * @version $ID:$ 00034 */ 00035 class Tx_Extbase_Utility_FrontendSimulator { 00036 00037 /** 00038 * @var mixed 00039 */ 00040 protected static $tsfeBackup; 00041 00042 /** 00043 * Sets the $TSFE->cObjectDepthCounter in Backend mode 00044 * This somewhat hacky work around is currently needed because the cObjGetSingle() function of tslib_cObj relies on this setting 00045 * 00046 * @param tslib_cObj $addCObj 00047 * @return void 00048 * @author Bastian Waidelich <bastian@typo3.org> 00049 */ 00050 public static function simulateFrontendEnvironment(tslib_cObj $cObj = NULL) { 00051 self::$tsfeBackup = isset($GLOBALS['TSFE']) ? $GLOBALS['TSFE'] : NULL; 00052 $GLOBALS['TSFE'] = new stdClass(); 00053 $GLOBALS['TSFE']->cObjectDepthCounter = 100; 00054 00055 $GLOBALS['TSFE']->cObj = $cObj !== NULL ? $cObj : t3lib_div::makeInstance('tslib_cObj'); 00056 } 00057 00058 /** 00059 * Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment() 00060 * 00061 * @return void 00062 * @author Bastian Waidelich <bastian@typo3.org>( 00063 * @see simulateFrontendEnvironment() 00064 */ 00065 public static function resetFrontendEnvironment() { 00066 if (!empty(self::$tsfeBackup)) { 00067 $GLOBALS['TSFE'] = self::$tsfeBackup; 00068 } 00069 } 00070 } 00071 ?>
1.8.0