Project

General

Profile

Feature #14427 » bug568.diff

Administrator Admin, 2005-05-05 16:43

View differences:

class.t3lib_matchcondition.php 2005-05-05 16:38:19.000000000 +0200
var $altRootLine=array();
/**
* Evaluates several TypoScript conditions given as input, eg. "[browser=net]&&[...(other conditions)...]"
* This allows you to combine them with either && (and) and || (or)
* ([XYZ][ZYX] is still interpreted as OR)
*
* @param string The conditions to match against its criterias.
* @return boolean Returns true or false based on the evaluation.
*/
function match($condition_line) {
if ($this->matchAll) {
return true;
}
if (count($this->matchAlternative)) {
return in_array($condition_line, $this->matchAlternative);
}
// Getting the value from inside of the wrapping
// square brackets of the condition line:
$insideSqrBrackets = trim(ereg_replace('\]$','',substr($condition_line,1)));
// The "weak" operator, OR, takes precedence:
// backwards compatible [XYZ][ZYX] does still work as OR
$ORparts = split('\][[:space:]]*(\|\|){0,1}[[:space:]]*\[',$insideSqrBrackets);
reset($ORparts);
foreach($ORparts as $andString) {
$resBool = false;
// Splits by the "&&" and operator:
$ANDparts = split('\][[:space:]]*\&\&[[:space:]]*\[',$andString);
reset($ANDparts);
foreach($ANDparts as $condStr) {
$resBool = $this->evalConditionStr($condStr);
if (!$resBool) {
break;
}
}
if ($resBool) {
break;
}
}
return $resBool;
}
/**
* Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"
*
* @param string The condition to match against its criterias.
......
* @see t3lib_tsparser::parse()
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=292&cHash=c6c7d43d2f
*/
function match($string) {
if ($this->matchAll) return true;
if (count($this->matchAlternative)) {
return in_array($string,$this->matchAlternative);
}
function evalConditionStr($string) {
if (!$this->browserInfoArray) {
$this->browserInfoArray = $this->browserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
}
$browserInfo = $this->browserInfoArray;
$string = trim($string);
$string = substr($string,1,strlen($string)-2);
$parts = explode('][',$string);
reset($parts);
while(list(,$val)=each($parts)) {
$pcs = explode('=',$val,2);
$pcs = explode('=',$string,2);
$switchKey = trim($pcs[0]);
switch($switchKey) {
case 'browser':
......
break;
}
}
}
/**
* Will evaluate a $value based on an operator: "<", ">" or "=" (default)
(3-3/3)