Project

General

Profile

Bug #25097 » 17664.diff

Administrator Admin, 2011-02-22 22:45

View differences:

tests/t3lib/matchcondition/t3lib_matchcondition_frontendTest.php (working copy)
}
/**
* Tests whether the browserInfo hook is called.
*
* @return void
* @test
*/
public function deprecatedBrowserInfoHookIsCalled() {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = FALSE;
$classRef = uniqid('tx_browserInfoHook');
$browserInfoHookMock = $this->getMock($classRef, array('browserInfo'));
$browserInfoHookMock->expects($this->atLeastOnce())->method('browserInfo');
$GLOBALS['T3_VAR']['getUserObj'][$classRef] = $browserInfoHookMock;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][$classRef] = $classRef;
$this->matchCondition->__construct();
$this->matchCondition->match('[browser = msie] && [version = 7] && [system = winNT]');
}
/**
* Tests whether the whichDevice hook is called.
*
* @return void
* @test
*/
public function deprecatedWhichDeviceHookIsCalled() {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = FALSE;
$classRef = uniqid('tx_whichDeviceHook');
$whichDeviceHookMock = $this->getMock($classRef, array('whichDevice'));
$whichDeviceHookMock->expects($this->atLeastOnce())->method('whichDevice');
$GLOBALS['T3_VAR']['getUserObj'][$classRef] = $whichDeviceHookMock;
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'][$classRef] = $classRef;
$this->matchCondition->__construct();
$this->matchCondition->match('[device = robot]');
}
/**
* Tests whether the language comparison matches.
* @test
*/
......
}
/**
* Tests whether user is not logged in
* @test
*/
public function loginUserConditionMatchIfUserIsNotLoggedIn() {
$GLOBALS['TSFE']->loginUser = FALSE;
$this->assertTrue($this->matchCondition->match('[loginUser = ]'));
}
/**
* Tests whether numerical comparison matches.
* @test
*/
t3lib/class.t3lib_tstemplate.php (working copy)
* @author Kasper Skårhøj <kasperYYYY@typo3.com>
* @package TYPO3
* @subpackage t3lib
* @see t3lib_tsparser.php, t3lib_matchcondition.php
* @see t3lib_tsparser, t3lib_matchcondition_abstract
*/
class t3lib_TStemplate {
t3lib/core_autoload.php (working copy)
't3lib_loaddbgroup' => PATH_t3lib . 'class.t3lib_loaddbgroup.php',
't3lib_loadmodules' => PATH_t3lib . 'class.t3lib_loadmodules.php',
't3lib_lock' => PATH_t3lib . 'class.t3lib_lock.php',
't3lib_matchcondition' => PATH_t3lib . 'class.t3lib_matchcondition.php',
't3lib_message_abstractmessage' => PATH_t3lib . 'message/class.t3lib_message_abstractmessage.php',
't3lib_message_errorpagemessage' => PATH_t3lib . 'message/class.t3lib_message_errorpagemessage.php',
't3lib_modsettings' => PATH_t3lib . 'class.t3lib_modsettings.php',
t3lib/class.t3lib_tsparser.php (working copy)
* @author Kasper Skårhøj <kasperYYYY@typo3.com>
* @package TYPO3
* @subpackage t3lib
* @see t3lib_tstemplate, t3lib_matchcondition, t3lib_BEfunc::getPagesTSconfig(), t3lib_userAuthGroup::fetchGroupData(), t3lib_TStemplate::generateConfig()
* @see t3lib_tstemplate, t3lib_BEfunc::getPagesTSconfig(), t3lib_userAuthGroup::fetchGroupData(), t3lib_TStemplate::generateConfig()
*/
class t3lib_TSparser {
var $strict = 1; // If set, then key names cannot contain characters other than [:alnum:]_\.-
......
* Start parsing the input TypoScript text piece. The result is stored in $this->setup
*
* @param string The TypoScript text
* @param object If is object (instance of t3lib_matchcondition), then this is used to match conditions found in the TypoScript code. If matchObj not specified, then no conditions will work! (Except [GLOBAL])
* @param object If is object, then this is used to match conditions found in the TypoScript code. If matchObj not specified, then no conditions will work! (Except [GLOBAL])
* @return void
*/
function parse($string, $matchObj = '') {
......
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser.php']);
}
?>
?>
t3lib/matchcondition/class.t3lib_matchcondition_frontend.php (working copy)
* @subpackage t3lib
*/
class t3lib_matchCondition_frontend extends t3lib_matchCondition_abstract {
/**
* @var array
*/
protected $deprecatedHooks = array();
/**
* Constructor for this class
*
* @return void
*/
public function __construct() {
$this->initializeDeprecatedHooks();
}
/**
* Initializes deprectated hooks that existed in t3lib_matchCondition until TYPO3 4.3.
*
* @return void
*/
protected function initializeDeprecatedHooks() {
// Hook: $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass']:
$matchConditionHooks =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['matchConditionClass'];
if (is_array($matchConditionHooks)) {
t3lib_div::deprecationLog(
'The hook $TYPO3_CONF_VARS[SC_OPTIONS][t3lib/class.t3lib_matchcondition.php][matchConditionClass] ' .
'is deprecated since TYPO3 4.3. Use the new hooks getBrowserInfo and getDeviceType in ' .
't3lib_utility_Client instead.'
);
foreach ($matchConditionHooks as $hookClass) {
$this->deprecatedHooks[] = t3lib_div::getUserObj($hookClass, '');
}
}
}
/**
* Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
*
* @param string $string: The condition to match against its criterias.
......
}
/**
* Generates an array with abstracted browser information
*
* @param string $userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT')
* @return array Contains keys "browser", "version", "system"
*/
protected function getBrowserInfo($userAgent) {
// Exceute deprecated hooks:
// @deprecated since TYPO3 4.3
foreach ($this->deprecatedHooks as $hookObj) {
if (method_exists($hookObj, 'browserInfo')) {
$result = $hookObj->browserInfo($userAgent);
if (strlen($result)) {
return $result;
}
}
}
return parent::getBrowserInfo($userAgent);
}
/**
* Gets a code for a browsing device based on the input useragent string.
*
* @param string $userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT')
* @return string Code for the specific device type
*/
protected function getDeviceType($userAgent) {
// Exceute deprecated hooks:
// @deprecated since TYPO3 4.3
foreach ($this->deprecatedHooks as $hookObj) {
if (method_exists($hookObj, 'whichDevice')) {
$result = $hookObj->whichDevice($userAgent);
if (strlen($result)) {
return $result;
}
}
}
// deprecated, see above
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['devices_class'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_matchcondition.php']['devices_class'] as $_classRef) {
$_procObj = t3lib_div::getUserObj($_classRef);
return $_procObj->whichDevice_ext($userAgent);
}
}
return parent::getDeviceType($userAgent);
}
/**
* Returns GP / ENV / TSFE vars
*
* @param string Identifier
    (1-1/1)