TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AbstractConditionMatcher Class Reference
Inheritance diagram for AbstractConditionMatcher:
ConditionMatcher 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 = array()
 

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 (   $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 562 of file AbstractConditionMatcher.php.

References GeneralUtility\trimExplode().

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

determinePageId ( )
abstractprotected

Determines the current page Id.

Returns
int The current page Id

Referenced by AbstractConditionMatcher\match().

determineRootline ( )
abstractprotected

Determines the rootline for the current page.

Returns
array The rootline for the current page.

Referenced by AbstractConditionMatcher\match().

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 AbstractConditionMatcher\match().

evaluateConditionCommon (   $key,
  $value 
)
protected
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 644 of file AbstractConditionMatcher.php.

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

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 656 of file AbstractConditionMatcher.php.

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

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 669 of file AbstractConditionMatcher.php.

References $GLOBALS, and elseif.

Referenced by ConditionMatcher\getVariable(), and AbstractConditionMatcher\getVariableCommon().

getGroupList ( )
abstractprotected

Gets the usergroup list of the current user.

Returns
string The usergroup list of the current user
getPage ( )
abstractprotected

Gets the properties for the current page.

Returns
array The properties for the current page.

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

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 AbstractConditionMatcher\$pageId.

getRootline ( )

Gets the rootline.

Returns
array The rootline to be used for matching

Definition at line 98 of file AbstractConditionMatcher.php.

References AbstractConditionMatcher\$rootline.

getUserId ( )
abstractprotected

Gets the id of the current user.

Returns
int The id of the current user

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

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 AbstractConditionMatcher\evaluateConditionCommon().

getVariableCommon ( array  $vars)
protected

Get variable common

Parameters
array$vars
Returns
mixed Whatever value. If none, then NULL.

Definition at line 514 of file AbstractConditionMatcher.php.

References GeneralUtility\_GP(), GeneralUtility\_GPmerged(), AbstractConditionMatcher\getGlobal(), and GeneralUtility\getIndpEnv().

Referenced by ConditionMatcher\getVariable().

isUserLoggedIn ( )
abstractprotected

Determines if a user is logged in.

Returns
bool Determines if a user is logged in

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

log (   $message)
abstractprotected

Sets a log message.

Parameters
string$messageThe log message to set/write
Returns
void
match (   $expression)

Matches a TypoScript condition expression.

Parameters
string$expressionThe expression to match
Returns
bool Whether the expression matched

Definition at line 153 of file AbstractConditionMatcher.php.

References AbstractConditionMatcher\$simulateMatchResult, AbstractConditionMatcher\determinePageId(), AbstractConditionMatcher\determineRootline(), AbstractConditionMatcher\evaluateCondition(), and AbstractConditionMatcher\normalizeExpression().

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 AbstractConditionMatcher\match().

parseUserFuncArguments (   $arguments)
protected

Parses arguments to the userFunc.

Parameters
string$arguments
Returns
array

Definition at line 477 of file AbstractConditionMatcher.php.

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

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 618 of file AbstractConditionMatcher.php.

References elseif.

Referenced by AbstractConditionMatcher\evaluateConditionCommon().

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 AbstractConditionMatcher\$pageId.

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 AbstractConditionMatcher\$rootline.

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 AbstractConditionMatcher\$simulateMatchConditions.

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 AbstractConditionMatcher\$simulateMatchResult.

Member Data Documentation

$pageId
protected
$rootline
protected
$simulateMatchConditions = array()
protected
$simulateMatchResult = false
protected