TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher Class Reference
Inheritance diagram for TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher:
TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher

Public Member Functions

 setPageId ($pageId)
 
 getPageId ()
 
 setRootline (array $rootline)
 
 getRootline ()
 
 setSimulateMatchResult ($simulateMatchResult)
 
 setSimulateMatchConditions (array $simulateMatchConditions)
 
 match ($expression)
 

Protected Member Functions

 normalizeExpression ($expression)
 
 evaluateConditionCommon ($key, $value)
 
 parseUserFuncArguments ($arguments)
 
 getVariableCommon (array $vars)
 
 compareNumber ($test, $leftValue)
 
 searchStringWildcard ($haystack, $needle)
 
 getBrowserInfo ($userAgent)
 
 getDeviceType ($userAgent)
 
 getGlobal ($var, $source=null)
 
 evaluateCondition ($string)
 
 getVariable ($name)
 
 getGroupList ()
 
 determinePageId ()
 
 getPage ()
 
 determineRootline ()
 
 getUserId ()
 
 isUserLoggedIn ()
 
 log ($message)
 

Protected Attributes

 $pageId
 
 $rootline
 
 $simulateMatchResult = false
 
 $simulateMatchConditions = []
 

Detailed Description

Matching TypoScript conditions

Used with the TypoScript parser. Matches browserinfo, IPnumbers for use with templates

Definition at line 25 of file AbstractConditionMatcher.php.

Member Function Documentation

◆ compareNumber()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::compareNumber (   $test,
  $leftValue 
)
protected

Evaluates a $leftValue based on an operator: "<", ">", "<=", ">=", "!=" or "="

Parameters
string$testThe value to compare with on the form [operator][number]. Eg. "< 123
float$leftValueThe value on the left side
Returns
bool If $value is "50" and $test is "< 123" then it will return TRUE.

Definition at line 565 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ determinePageId()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::determinePageId ( )
abstractprotected

◆ determineRootline()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::determineRootline ( )
abstractprotected

◆ evaluateCondition()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateCondition (   $string)
abstractprotected

Evaluates a TypoScript condition given as input, eg. "[browser=net][...(other conditions)...]"

Parameters
string$stringThe condition to match against its criterias.
Returns
bool Whether the condition matched
See also
::parse()

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getGlobal(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\match().

◆ evaluateConditionCommon()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::evaluateConditionCommon (   $key,
  $value 
)
protected

Evaluates a TypoScript condition given as input, eg. "[applicationContext = Production][...(other condition)...]"

Parameters
string$keyThe condition to match against its criteria.
string$value
Returns
NULL|bool Result of the evaluation; NULL if condition could not be evaluated

Definition at line 202 of file AbstractConditionMatcher.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\GeneralUtility\cmpFQDN(), TYPO3\CMS\Core\Utility\GeneralUtility\cmpIP(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\compareNumber(), TYPO3\CMS\Core\Utility\GeneralUtility\compat_version(), TYPO3\CMS\Core\Utility\GeneralUtility\deprecationLog(), TYPO3\CMS\Core\Utility\GeneralUtility\getApplicationContext(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getBrowserInfo(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getDeviceType(), TYPO3\CMS\Core\Utility\GeneralUtility\getIndpEnv(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getPage(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getUserId(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getVariable(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\isUserLoggedIn(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\parseUserFuncArguments(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\searchStringWildcard(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\evaluateCondition(), and TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\evaluateCondition().

◆ getBrowserInfo()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getBrowserInfo (   $userAgent)
protected

Generates an array with abstracted browser information

Parameters
string$userAgentThe useragent string, ::getIndpEnv('HTTP_USER_AGENT')
Returns
array Contains keys "browser", "version", "system

Definition at line 647 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ getDeviceType()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getDeviceType (   $userAgent)
protected

Gets a code for a browsing device based on the input useragent string.

Parameters
string$userAgentThe useragent string, ::getIndpEnv('HTTP_USER_AGENT')
Returns
string Code for the specific device type
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8

Definition at line 659 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ getGlobal()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getGlobal (   $var,
  $source = null 
)
protected

Return global variable where the input string $var defines array keys separated by "|" Example: $var = "HTTP_SERVER_VARS | something" will return the value $GLOBALS['HTTP_SERVER_VARS']['something'] value

Parameters
string$varGlobal var key, eg. "HTTP_GET_VAR" or "HTTP_GET_VARS|id" to get the GET parameter "id" back.
array$sourceAlternative array than $GLOBAL to get variables from.
Returns
mixed Whatever value. If none, then blank string.

Definition at line 672 of file AbstractConditionMatcher.php.

References $a, $GLOBALS, TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\determinePageId(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\determineRootline(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateCondition(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getGroupList(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getPage(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getUserId(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getVariable(), TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\isUserLoggedIn(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\log().

Referenced by TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher\getVariable(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getVariableCommon().

◆ getGroupList()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getGroupList ( )
abstractprotected

Gets the usergroup list of the current user.

Returns
string The usergroup list of the current user

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getGlobal().

◆ getPage()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getPage ( )
abstractprotected

◆ getPageId()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getPageId ( )

Gets the id of the page to evaluate conditions for.

Returns
int Id of the page

Definition at line 75 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$pageId.

◆ getRootline()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getRootline ( )

Gets the rootline.

Returns
array The rootline to be used for matching

Definition at line 98 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$rootline.

◆ getUserId()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getUserId ( )
abstractprotected

◆ getVariable()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::getVariable (   $name)
abstractprotected

Gets the value of a variable.

Examples of names:

  • TSFE:id
  • GP:firstLevel|secondLevel
  • _GET|firstLevel|secondLevel
  • LIT:someLiteralValue
Parameters
string$nameThe name of the variable to fetch the value from
Returns
mixed The value of the given variable (string) or NULL if variable did not exist

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon(), and TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getGlobal().

◆ getVariableCommon()

◆ isUserLoggedIn()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::isUserLoggedIn ( )
abstractprotected

◆ log()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::log (   $message)
abstractprotected

Sets a log message.

Parameters
string$messageThe log message to set/write
Returns
void

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\getGlobal().

◆ match()

◆ normalizeExpression()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::normalizeExpression (   $expression)
protected

Normalizes an expression and removes the first and last square bracket.

  • OR normalization: "...]OR[...", "...]||[...", "...][..." –> "...]||[..."
  • AND normalization: "...]AND[...", "...]&&[..." –> "...]&&[..."
Parameters
string$expressionThe expression to be normalized (e.g. "[A] && [B] OR [C]")
Returns
string The normalized expression (e.g. "[A]&&[B]||[C]")

Definition at line 135 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\match().

◆ parseUserFuncArguments()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::parseUserFuncArguments (   $arguments)
protected

Parses arguments to the userFunc.

Parameters
string$arguments
Returns
array

Definition at line 478 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ searchStringWildcard()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::searchStringWildcard (   $haystack,
  $needle 
)
protected

Matching two strings against each other, supporting a "*" wildcard or (if wrapped in "/") PCRE regular expressions

Parameters
string$haystackThe string in which to find $needle.
string$needleThe string to find in $haystack
Returns
bool Returns TRUE if $needle matches or is found in (according to wildcards) in $haystack. Eg. if $haystack is "Netscape 6.5" and $needle is "Net*" or "Net*ape" then it returns TRUE.

Definition at line 621 of file AbstractConditionMatcher.php.

Referenced by TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\evaluateConditionCommon().

◆ setPageId()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setPageId (   $pageId)

Sets the id of the page to evaluate conditions for.

Parameters
int$pageIdId of the page (must be positive)
Returns
void

Definition at line 63 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$pageId.

◆ setRootline()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setRootline ( array  $rootline)

Sets the rootline.

Parameters
array$rootlineThe rootline to be used for matching (must have elements)
Returns
void

Definition at line 86 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$rootline.

◆ setSimulateMatchConditions()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setSimulateMatchConditions ( array  $simulateMatchConditions)

Sets whether to simulate the behaviour and match specific conditions.

Parameters
array$simulateMatchConditionsConditions to simulate a match for
Returns
void

Definition at line 122 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$simulateMatchConditions.

◆ setSimulateMatchResult()

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::setSimulateMatchResult (   $simulateMatchResult)

Sets whether to simulate the behaviour and match all conditions.

Parameters
bool$simulateMatchResultWhether to simulate positive matches
Returns
void

Definition at line 109 of file AbstractConditionMatcher.php.

References TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher\$simulateMatchResult.

Member Data Documentation

◆ $pageId

◆ $rootline

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$rootline
protected

◆ $simulateMatchConditions

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$simulateMatchConditions = []
protected

◆ $simulateMatchResult

TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher::$simulateMatchResult = false
protected