2 namespace TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching;
88 if (!empty($rootline)) {
137 $normalizedExpression = preg_replace(array(
138 '/\\]\\s*(OR|\\|\\|)?\\s*\\[/i',
139 '/\\]\\s*(AND|&&)\\s*\\[/i'
143 ), trim($expression));
144 return $normalizedExpression;
156 if ($this->simulateMatchResult) {
160 if (!empty($this->simulateMatchConditions)) {
161 return in_array($expression, $this->simulateMatchConditions);
164 if (!isset($this->pageId)) {
168 if (!isset($this->rootline)) {
174 if ($normalizedExpression[0] ===
'[' && substr($normalizedExpression, -1) ===
']') {
175 $innerExpression = substr($normalizedExpression, 1, -1);
176 $orParts = explode(
']||[', $innerExpression);
177 foreach ($orParts as $orPart) {
178 $andParts = explode(
']&&[', $orPart);
179 foreach ($andParts as $andPart) {
182 if ($result ===
false) {
187 if ($result ===
true) {
206 'Usage of client related conditions (browser, device, version, system, useragent) is deprecated since 7.0.'
211 switch ($keyParts[0]) {
212 case 'applicationContext':
215 foreach ($values as $applicationContext) {
229 foreach ($browserInfo[
'all'] as $key => $value) {
230 $all .= $key . $value .
' ';
232 foreach ($values as $test) {
233 if (stripos($all, $test) !==
false) {
241 foreach ($values as $test) {
242 if (strcspn($test,
'=<>') == 0) {
245 if (doubleval(substr($test, 1)) == $browserInfo[
'version']) {
250 if (doubleval(substr($test, 1)) > $browserInfo[
'version']) {
255 if (doubleval(substr($test, 1)) < $browserInfo[
'version']) {
260 }
elseif (strpos(
' ' . $browserInfo[
'version'], $test) == 1) {
270 $allSystems =
' ' . implode(
' ', $browserInfo[
'all_systems']);
271 foreach ($values as $test) {
272 if (stripos($allSystems, $test) !==
false) {
279 if (!isset($this->deviceInfo)) {
283 foreach ($values as $test) {
284 if ($this->deviceInfo == $test) {
291 $test = trim($value);
303 foreach ($values as $test) {
304 if (preg_match(
'/^\\*.+\\*$/', $test)) {
306 if (in_array(substr($test, 1, -1), $allLanguages)) {
316 if ($value ===
'devIP') {
317 $value = trim(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'devIPmask']);
333 $theEvalTime =
$GLOBALS[
'SIM_EXEC_TIME'];
336 $theTestValue = date(
'H', $theEvalTime);
339 $theTestValue = date(
'i', $theEvalTime);
342 $theTestValue = date(
'm', $theEvalTime);
345 $theTestValue = date(
'Y', $theEvalTime);
348 $theTestValue = date(
'w', $theEvalTime);
351 $theTestValue = date(
'd', $theEvalTime);
354 $theTestValue = date(
'z', $theEvalTime);
357 $theTestValue = (int)$theTestValue;
360 foreach ($values as $test) {
361 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($test)) {
370 case 'compatVersion':
376 foreach ($values as $test) {
377 if ($test ==
'*' || (
string)$this->
getUserId() === (
string)$test) {
381 }
elseif ($value ===
'') {
389 $property = $keyParts[1];
390 if (!empty($page) && isset($page[$property]) && (
string)$page[$property] === (
string)$value) {
398 foreach ($values as $test) {
399 $point = strcspn($test,
'!=<>');
400 $theVarName = substr($test, 0, $point);
402 $testValue = substr($test, $point);
411 foreach ($values as $test) {
412 $point = strcspn($test,
'=');
413 $theVarName = substr($test, 0, $point);
414 $nv = (string)$this->
getVariable(trim($theVarName));
415 $testValue = substr($test, $point + 1);
424 preg_match_all(
'/^\s*([^\(\s]+)\s*(?:\((.*)\))?\s*$/', $value, $matches);
425 $funcName = $matches[1][0];
427 if (is_callable($funcName) && call_user_func_array($funcName, $funcValues)) {
444 protected function evaluateCustomDefinedCondition($condition)
446 $conditionResult = null;
452 if (class_exists($conditionClassName)) {
456 if (($conditionObject instanceof \TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\
AbstractCondition) ===
false) {
457 throw new \TYPO3\CMS\Core\Configuration\TypoScript\Exception\InvalidTypoScriptConditionException(
458 '"' . $conditionClassName .
'" is not a valid TypoScript Condition object.',
464 $conditionObject->setConditionMatcherInstance($this);
465 $conditionResult = $conditionObject->matchCondition($conditionParameters);
468 return $conditionResult;
480 $arguments = trim($arguments);
481 while ($arguments !==
'') {
482 if ($arguments[0] ===
',') {
484 $arguments = substr($arguments, 1);
486 $pos = strcspn($arguments,
',\'"');
489 $quote = $arguments[0];
490 $segment = preg_replace(
'/^(.*?[^\\\])' . $quote .
'.*$/',
'\1', substr($arguments, 1));
491 $segment = str_replace(
'\\' . $quote, $quote, $segment);
492 $result[] = $segment;
493 $offset = strpos($arguments,
',', strlen($segment) + 2);
494 if ($offset ===
false) {
495 $offset = strlen($arguments);
497 $arguments = substr($arguments, $offset);
499 $result[] = trim(substr($arguments, 0, $pos));
500 $arguments = substr($arguments, $pos + 1);
503 $arguments = trim($arguments);
517 if (count($vars) === 1) {
520 $splitAgain = explode(
'|', $vars[1], 2);
521 $k = trim($splitAgain[0]);
523 switch ((
string)trim($vars[0])) {
537 return trim($vars[1]);
543 if (count($splitAgain) > 1) {
544 if (is_array($value) && trim($splitAgain[1]) !==
'') {
545 $value = $this->
getGlobal($splitAgain[1], $value);
564 if (preg_match(
'/^(!?=+|<=?|>=?)\\s*([^\\s]*)\\s*$/', $test, $matches)) {
565 $operator = $matches[1];
566 $rightValue = $matches[2];
569 return $leftValue >= doubleval($rightValue);
572 return $leftValue <= doubleval($rightValue);
579 foreach ($rightValueParts as $rightValueSingle) {
580 if ($leftValue == doubleval($rightValueSingle)) {
585 return $found ===
false;
588 return $leftValue < doubleval($rightValue);
591 return $leftValue > doubleval($rightValue);
599 foreach ($rightValueParts as $rightValueSingle) {
600 if ($leftValue == $rightValueSingle) {
621 if ($haystack === $needle) {
624 if (preg_match(
'/^\\/.+\\/$/', $needle)) {
628 $needle = str_replace(array(
'*',
'?'), array(
'###MANY###',
'###ONE###'), $needle);
629 $regex =
'/^' . preg_quote($needle,
'/') .
'$/';
631 $regex = str_replace(array(
'###MANY###',
'###ONE###'), array(
'.*',
'.'), $regex);
633 $result = (bool)preg_match($regex, $haystack);
646 return \TYPO3\CMS\Core\Utility\ClientUtility::getBrowserInfo($userAgent);
658 return \TYPO3\CMS\Core\Utility\ClientUtility::getDeviceType($userAgent);
671 $vars = explode(
'|', $var);
674 $theVar = isset($source) ? $source[$k] :
$GLOBALS[$k];
675 for ($a = 1; $a < $c; $a++) {
676 if (!isset($theVar)) {
679 $key = trim($vars[$a]);
680 if (is_object($theVar)) {
681 $theVar = $theVar->{$key};
682 }
elseif (is_array($theVar)) {
683 $theVar = $theVar[$key];
688 if (!is_array($theVar) && !is_object($theVar)) {
702 abstract protected function evaluateCondition($string);
716 abstract protected function getVariable($name);
723 abstract protected function getGroupList();
730 abstract protected function determinePageId();
737 abstract protected function getPage();
744 abstract protected function determineRootline();
751 abstract protected function getUserId();
758 abstract protected function isUserLoggedIn();
766 abstract protected function log($message);