TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser Class Reference
Inheritance diagram for TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser:
TYPO3\CMS\Backend\Configuration\TsConfigParser

Public Member Functions

 parse ($string, $matchObj='')
 
 nextDivider ()
 
 parseSub (array &$setup)
 
 rollParseSub ($string, array &$setup)
 
 getVal ($string, $setup)
 
 setVal ($string, array &$setup, $value, $wipeOut=false)
 
 error ($err, $num=2)
 
 doSyntaxHighlight ($string, $lineNum='', $highlightBlockMode=false)
 
 regHighLight ($code, $pointer, $strlen=-1)
 
 syntaxHighlight_print ($lineNumDat, $highlightBlockMode)
 

Static Public Member Functions

static includeFile ($filename, $cycle_counter=1, $returnFiles=false, &$newString='', array &$includedFiles=[], $optionalProperties='', $parentFilenameOrPath='')
 
static checkIncludeLines_array (array $array)
 
static extractIncludes ($string, $cycle_counter=1, array $extractedFileNames=[], $parentFilenameOrPath='')
 
static extractIncludes_array (array $array)
 

Public Attributes

 $strict = true
 
 $setup = []
 
 $raw
 
 $rawP
 
 $lastComment = ''
 
 $commentSet = false
 
 $multiLineEnabled = false
 
 $multiLineObject = ''
 
 $multiLineValue = []
 
 $inBrace = 0
 
 $lastConditionTrue = true
 
 $sections = []
 
 $sectionsMatch = []
 
 $syntaxHighLight = false
 
 $highLightData = []
 
 $highLightData_bracelevel = []
 
 $regComments = false
 
 $regLinenumbers = false
 
 $errors = []
 
 $lineNumberOffset = 0
 
 $breakPointLN = 0
 
 $highLightStyles
 
 $highLightBlockStyles = ''
 
 $highLightBlockStyles_basecolor = '#cccccc'
 
 $parentObject
 

Protected Member Functions

 executeValueModifier ($modifierName, $modifierArgument=null, $currentValue=null)
 
 parseNextKeySegment ($key)
 
 getTimeTracker ()
 
 modifyHTMLColor ($color, $R, $G, $B)
 
 modifyHTMLColorAll ($color, $all)
 

Static Protected Member Functions

static includeDirectory ($dirPath, $cycle_counter=1, $returnFiles=false, &$newString='', array &$includedFiles=[], $optionalProperties='', $parentFilenameOrPath='')
 
static typoscriptIncludeError ($error)
 

Detailed Description

The TypoScript parser

Definition at line 30 of file TypoScriptParser.php.

Member Function Documentation

◆ checkIncludeLines_array()

static TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array ( array  $array)
static

Parses the string in each value of the input array for include-commands

Parameters
array$arrayArray with TypoScript in each value
Returns
array Same array but where the values has been parsed for include-commands

Definition at line 1038 of file TypoScriptParser.php.

Referenced by TYPO3\CMS\Core\Authentication\BackendUserAuthentication\fetchGroupData(), TYPO3\CMS\Backend\Utility\BackendUtility\getPagesTSconfig(), TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController\getPagesTSconfig(), TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication\getUserTSconf(), and TYPO3\CMS\Core\TypoScript\TemplateService\processIncludes().

◆ doSyntaxHighlight()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::doSyntaxHighlight (   $string,
  $lineNum = '',
  $highlightBlockMode = false 
)

Syntax highlight a TypoScript text Will parse the content. Remember, the internal setup array may contain invalid parsed content since conditions are ignored!

Parameters
string$stringThe TypoScript text
mixed$lineNumIf blank, linenumbers are NOT printed. If array then the first key is the linenumber offset to add to the internal counter.
bool$highlightBlockModeIf set, then the highlighted output will be formatted in blocks based on the brace levels. prespace will be ignored and empty lines represented with a single no-break-space.
Returns
string HTML code for the syntax highlighted string

Definition at line 1229 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parse(), and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\syntaxHighlight_print().

◆ error()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::error (   $err,
  $num = 2 
)

Stacks errors/messages from the TypoScript parser into an internal array, $this->error If "TT" is a global object (as it is in the frontend when backend users are logged in) the message will be registered here as well.

Parameters
string$errThe error message string
int$numThe error severity (in the scale of $GLOBALS['TT']->setTSlogMessage: Approx: 2=warning, 1=info, 0=nothing, 3=fatal.)
Returns
void

Definition at line 779 of file TypoScriptParser.php.

References $GLOBALS, TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\$lineNumberOffset, TYPO3\CMS\Core\Utility\StringUtility\beginsWith(), TYPO3\CMS\Core\Utility\PathUtility\getAbsolutePathOfRelativeReferencedFileOrPath(), TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\getTimeTracker(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Utility\GeneralUtility\SYSLOG_SEVERITY_WARNING.

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parse(), and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

◆ executeValueModifier()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::executeValueModifier (   $modifierName,
  $modifierArgument = null,
  $currentValue = null 
)
protected

Executes operator functions, called from TypoScript example: page.10.value := appendString(!)

Parameters
string$modifierNameTypoScript function called
string$modifierArgumentFunction arguments; In case of multiple arguments, the method must split on its own
string$currentValueCurrent TypoScript value
Returns
string Modification result

Definition at line 530 of file TypoScriptParser.php.

References $GLOBALS, $params, TYPO3\CMS\Core\Utility\GeneralUtility\callUserFunction(), TYPO3\CMS\Core\Utility\GeneralUtility\SYSLOG_SEVERITY_WARNING, and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

◆ extractIncludes()

static TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::extractIncludes (   $string,
  $cycle_counter = 1,
array  $extractedFileNames = [],
  $parentFilenameOrPath = '' 
)
static

Search for commented INCLUDE_TYPOSCRIPT statements and save the content between the BEGIN and the END line to the specified file

Parameters
string$stringTemplate content
int$cycle_counterCounter for detecting endless loops
array$extractedFileNames
string$parentFilenameOrPath
Exceptions

Definition at line 1059 of file TypoScriptParser.php.

References TYPO3\CMS\Core\Utility\PathUtility\getAbsolutePathOfRelativeReferencedFileOrPath(), TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), TYPO3\CMS\Core\Utility\GeneralUtility\SYSLOG_SEVERITY_WARNING, TYPO3\CMS\Core\Utility\GeneralUtility\verifyFilenameAgainstDenyPattern(), and TYPO3\CMS\Core\Utility\GeneralUtility\writeFile().

◆ extractIncludes_array()

static TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::extractIncludes_array ( array  $array)
static

Processes the string in each value of the input array with extractIncludes

Parameters
array$arrayArray with TypoScript in each value
Returns
array Same array but where the values has been processed with extractIncludes

Definition at line 1207 of file TypoScriptParser.php.

Referenced by TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController\processTemplateRowBeforeSaving().

◆ getTimeTracker()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::getTimeTracker ( )
protected
Returns
TimeTracker

Definition at line 1323 of file TypoScriptParser.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\error().

◆ getVal()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::getVal (   $string,
  $setup 
)

Get a value/property pair for an object path in TypoScript, eg. "myobject.myvalue.mysubproperty". Here: Used by the "copy" operator, <

Parameters
string$stringObject path for which to get the value
array$setupGlobal setup code if $string points to a global object path. But if string is prefixed with "." then its the local setup array.
Returns
array An array with keys 0/1 being value/property respectively

Definition at line 639 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\$setup, and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseNextKeySegment().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

◆ includeDirectory()

static TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::includeDirectory (   $dirPath,
  $cycle_counter = 1,
  $returnFiles = false,
$newString = '',
array &  $includedFiles = [],
  $optionalProperties = '',
  $parentFilenameOrPath = '' 
)
staticprotected

Include all files with matching Typoscript extensions in directory $dirPath. Contents of the files are prepended to &$newstring, filename to &$includedFiles. Order of the directory items to be processed: files first, then directories, both in alphabetical order. Further include_typoscript tags in the contents of the files are processed recursively.

Parameters
string$dirPathRelative path to the directory to be included
int$cycle_counterCounter for detecting endless loops
bool$returnFilesWhen set, filenames of included files will be prepended to the array &$includedFiles
string&$newStringThe output string to which the content of the file will be prepended (referenced)
array&$includedFilesArray to which the filenames of included files will be prepended (referenced)
string$optionalProperties
string$parentFilenameOrPathThe parent file (with absolute path) or path for relative includes

Definition at line 984 of file TypoScriptParser.php.

References TYPO3\CMS\Core\Utility\PathUtility\getAbsolutePathOfRelativeReferencedFileOrPath(), TYPO3\CMS\Core\Utility\GeneralUtility\getAllFilesAndFoldersInPath(), and TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName().

◆ includeFile()

static TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::includeFile (   $filename,
  $cycle_counter = 1,
  $returnFiles = false,
$newString = '',
array &  $includedFiles = [],
  $optionalProperties = '',
  $parentFilenameOrPath = '' 
)
static

Include file $filename. Contents of the file will be prepended to &$newstring, filename to &$includedFiles Further include_typoscript tags in the contents are processed recursively

Parameters
string$filenameRelative path to the typoscript file to be included
int$cycle_counterCounter for detecting endless loops
bool$returnFilesWhen set, filenames of included files will be prepended to the array &$includedFiles
string&$newStringThe output string to which the content of the file will be prepended (referenced
array&$includedFilesArray to which the filenames of included files will be prepended (referenced)
string$optionalProperties
string$parentFilenameOrPathThe parent file (with absolute path) or path for relative includes

Definition at line 935 of file TypoScriptParser.php.

References TYPO3\CMS\Core\Utility\PathUtility\getAbsolutePathOfRelativeReferencedFileOrPath(), TYPO3\CMS\Core\Utility\GeneralUtility\getFileAbsFileName(), TYPO3\CMS\Core\Utility\GeneralUtility\getUrl(), and TYPO3\CMS\Core\Utility\GeneralUtility\verifyFilenameAgainstDenyPattern().

◆ modifyHTMLColor()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::modifyHTMLColor (   $color,
  $R,
  $G,
  $B 
)
protected

Modifies a HTML Hex color by adding/subtracting $R,$G and $B integers

Parameters
string$colorA hexadecimal color code, #xxxxxx
int$ROffset value 0-255
int$GOffset value 0-255
int$BOffset value 0-255
Returns
string A hexadecimal color code, #xxxxxx, modified according to input vars
See also
modifyHTMLColorAll()

Definition at line 1338 of file TypoScriptParser.php.

References TYPO3\CMS\Core\Utility\MathUtility\forceIntegerInRange().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\modifyHTMLColorAll().

◆ modifyHTMLColorAll()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::modifyHTMLColorAll (   $color,
  $all 
)
protected

Modifies a HTML Hex color by adding/subtracting $all integer from all R/G/B channels

Parameters
string$colorA hexadecimal color code, #xxxxxx
int$allOffset value 0-255 for all three channels.
Returns
string A hexadecimal color code, #xxxxxx, modified according to input vars
See also
modifyHTMLColor()

Definition at line 1355 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\modifyHTMLColor().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\syntaxHighlight_print().

◆ nextDivider()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::nextDivider ( )

Will search for the next condition. When found it will return the line content (the condition value) and have advanced the internal $this->rawP pointer to point to the next line after the condition.

Returns
string The condition value
See also
parse()

Definition at line 291 of file TypoScriptParser.php.

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parse().

◆ parse()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::parse (   $string,
  $matchObj = '' 
)

Start parsing the input TypoScript text piece. The result is stored in $this->setup

Parameters
string$stringThe TypoScript text
object | string$matchObjIf 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])
Returns
void

Definition at line 240 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\$syntaxHighLight, TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\error(), TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\nextDivider(), and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\doSyntaxHighlight(), and TYPO3\CMS\Backend\Configuration\TsConfigParser\parseTSconfig().

◆ parseNextKeySegment()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::parseNextKeySegment (   $key)
protected

Determines the first key segment of a TypoScript key by searching for the first unescaped dot in the given key string.

Since the escape characters are only needed to correctly determine the key segment any escape characters before the first unescaped dot are stripped from the key.

Parameters
string$keyThe key, possibly consisting of multiple key segments separated by unescaped dots
Returns
array Array with key segment and remaining part of $key

Definition at line 730 of file TypoScriptParser.php.

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\getVal(), TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\rollParseSub(), and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\setVal().

◆ parseSub()

◆ regHighLight()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::regHighLight (   $code,
  $pointer,
  $strlen = -1 
)

Registers a part of a TypoScript line for syntax highlighting.

Parameters
string$codeKey from the internal array $this->highLightStyles
int$pointerPointer to the line in $this->raw which this is about
int$strlenThe number of chars LEFT on this line before the end is reached.
Returns
void private
See also
parse()

Definition at line 1250 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\$inBrace.

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

◆ rollParseSub()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::rollParseSub (   $string,
array &  $setup 
)

Parsing of TypoScript keys inside a curly brace where the key is composite of at least two keys, thus having to recursively call itself to get the value

Parameters
string$stringThe object sub-path, eg "thisprop.another_prot
array$setupThe local setup array from the function calling this function
Returns
string Returns the exitSignal
See also
parseSub()

Definition at line 614 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseNextKeySegment(), and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

◆ setVal()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::setVal (   $string,
array &  $setup,
  $value,
  $wipeOut = false 
)

Setting a value/property of an object string in the setup array.

Parameters
string$stringThe object sub-path, eg "thisprop.another_prot
array$setupThe local setup array from the function calling this function.
array | string$valueThe value/property pair array to set. If only one of them is set, then the other is not touched (unless $wipeOut is set, which it is when copies are made which must include both value and property)
bool$wipeOutIf set, then both value and property is wiped out when a copy is made of another value.
Returns
void

Definition at line 673 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\$lastComment, and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseNextKeySegment().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\parseSub().

◆ syntaxHighlight_print()

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::syntaxHighlight_print (   $lineNumDat,
  $highlightBlockMode 
)

Formatting the TypoScript code in $this->raw based on the data collected by $this->regHighLight in $this->highLightData

Parameters
mixed$lineNumDatIf blank, linenumbers are NOT printed. If array then the first key is the linenumber offset to add to the internal counter.
bool$highlightBlockModeIf set, then the highlighted output will be formatted in blocks based on the brace levels. prespace will be ignored and empty lines represented with a single no-break-space.
Returns
string HTML content private
See also
doSyntaxHighlight()

Definition at line 1269 of file TypoScriptParser.php.

References TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\$rawP, debug(), and TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\modifyHTMLColorAll().

Referenced by TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser\doSyntaxHighlight().

◆ typoscriptIncludeError()

static TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::typoscriptIncludeError (   $error)
staticprotected

Process errors in INCLUDE_TYPOSCRIPT tags Errors are logged in sysLog and printed in the concatenated Typoscript result (as can be seen in Template Analyzer)

Parameters
string$errorText of the error message
Returns
string The error message encapsulated in comments

Definition at line 1026 of file TypoScriptParser.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\SYSLOG_SEVERITY_WARNING.

Member Data Documentation

◆ $breakPointLN

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$breakPointLN = 0

Definition at line 178 of file TypoScriptParser.php.

◆ $commentSet

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$commentSet = false

Definition at line 72 of file TypoScriptParser.php.

◆ $errors

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$errors = []

Definition at line 164 of file TypoScriptParser.php.

◆ $highLightBlockStyles

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$highLightBlockStyles = ''

Definition at line 218 of file TypoScriptParser.php.

◆ $highLightBlockStyles_basecolor

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$highLightBlockStyles_basecolor = '#cccccc'

Definition at line 225 of file TypoScriptParser.php.

◆ $highLightData

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$highLightData = []

Definition at line 136 of file TypoScriptParser.php.

◆ $highLightData_bracelevel

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$highLightData_bracelevel = []

Definition at line 143 of file TypoScriptParser.php.

◆ $highLightStyles

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$highLightStyles
Initial value:
= [
'prespace' => ['<span class="ts-prespace">', '</span>']

Definition at line 183 of file TypoScriptParser.php.

◆ $inBrace

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$inBrace = 0

◆ $lastComment

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$lastComment = ''

◆ $lastConditionTrue

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$lastConditionTrue = true

Definition at line 108 of file TypoScriptParser.php.

◆ $lineNumberOffset

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$lineNumberOffset = 0

◆ $multiLineEnabled

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$multiLineEnabled = false

Definition at line 79 of file TypoScriptParser.php.

◆ $multiLineObject

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$multiLineObject = ''

◆ $multiLineValue

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$multiLineValue = []

Definition at line 93 of file TypoScriptParser.php.

◆ $parentObject

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$parentObject

Definition at line 230 of file TypoScriptParser.php.

◆ $raw

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$raw

Definition at line 51 of file TypoScriptParser.php.

◆ $rawP

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$rawP

◆ $regComments

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$regComments = false

Definition at line 150 of file TypoScriptParser.php.

◆ $regLinenumbers

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$regLinenumbers = false

Definition at line 157 of file TypoScriptParser.php.

◆ $sections

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$sections = []

◆ $sectionsMatch

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$sectionsMatch = []

◆ $setup

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$setup = []

◆ $strict

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$strict = true

Definition at line 37 of file TypoScriptParser.php.

◆ $syntaxHighLight

TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::$syntaxHighLight = false