model/modx/modparser.class.php
- package
- modx
- Classes
- modParser
- modTag
- modFieldTag
- modPlaceholderTag
- modLinkTag
- modLexiconTag
Description
Represents the MODX parser responsible for processing MODX tags.
This class encapsulates all of the functions for collecting and evaluating element tags embedded in text content.
\modFieldTag
- Extends from
- \modTag
- package
- modx
- uses
- modX::$resource The modResource instance being processed by modX.
- Methods
- __construct
- getContent
- process
Description
Tag representing a modResource field from the current MODX resource.
[[*content]] Represents the content field from modResource.
Methods
__construct
__construct(
$modx
)
:
Arguments
- $modx
Details
- visibility
- public
- final
- false
- static
- false
getContent
getContent(
array $options
=
array
)
:
string
Get the raw source content of the field.
Arguments
- $options
- array
An array of options implementations can use to accept language, revision identifiers, or other information to alter the behavior of the method.
Output
- string
- The raw source content for the element.
Details
- visibility
- public
- final
- false
- static
- false
process
process(
array|string $properties
=
null, string $content
=
null
)
:
mixed
Process the modFieldTag and return the output.
Arguments
- $properties
- arraystring
An array of properties or a formatted property string. - $content
- string
Optional content to use for the element processing.
Output
- mixed
- The result of processing the tag.
Details
- visibility
- public
- final
- false
- static
- false
\modLexiconTag
- Extends from
- \modTag
- package
- modx
- Methods
- __construct
- getContent
- process
Description
Represents Lexicon tags, for localized strings.
[[%word_or_phase]] Returns the lexicon representation of 'word_or_phrase' for the currently loaded language.
Methods
__construct
__construct(
$modx
)
:
Arguments
- $modx
Details
- visibility
- public
- final
- false
- static
- false
getContent
getContent(
array $options
=
array
)
:
string
Get the raw source content of the link.
Arguments
- $options
- array
An array of options implementations can use to accept language, revision identifiers, or other information to alter the behavior of the method.
Output
- string
- The raw source content for the element.
Details
- visibility
- public
- final
- false
- static
- false
process
process(
array|string $properties
=
null, string $content
=
null
)
:
mixed
Processes a modLexiconTag, recursively processing nested tags.
Tags in the properties of the tag itself, or the content returned by the tag element are processed. Non-cacheable nested tags are only processed if this tag element is also non-cacheable.
Arguments
- $properties
- arraystring
An array of properties or a formatted property string. - $content
- string
Optional content to use for the element processing.
Output
- mixed
- The result of processing the tag.
Details
- visibility
- public
- final
- false
- static
- false
\modLinkTag
- Extends from
- \modTag
- package
- modx
- Methods
- __constructor
- process
Description
Represents link tags.
[[~12]] Creates a URL from the specified resource identifier.
Methods
__constructor
__constructor(
$modx
)
:
Arguments
- $modx
Details
- visibility
- public
- final
- false
- static
- false
process
process(
array|string $properties
=
null, string $content
=
null
)
:
mixed
Processes the modLinkTag, recursively processing nested tags.
Tags in the properties of the tag itself, or the content returned by the tag element are processed. Non-cacheable nested tags are only processed if this tag element is also non-cacheable.
Arguments
- $properties
- arraystring
An array of properties or a formatted property string. - $content
- string
Optional content to use for the element processing.
Output
- mixed
- The result of processing the tag.
Details
- visibility
- public
- final
- false
- static
- false
\modParser
- package
- modx
- Properties
- $_processingTag
- $_processingUncacheable
- $_removingUnprocessed
- $modx
- Methods
- _XType
- __construct
- collectElementTags
- getElement
- isProcessingTag
- isProcessingUncacheable
- isRemovingUnprocessed
- loadFromCache
- mergeTagOutput
- parseProperties
- parsePropertyString
- processElementTags
- processTag
- realname
Description
Represents the MODX parser responsible for processing MODX tags.
This class encapsulates all of the functions for collecting and evaluating element tags embedded in text content.
Properties
$_processingTag
$_processingTag = 'false'
Details
- visibility
- protected
- default
- false
- final
- false
- static
- false
$_processingUncacheable
$_processingUncacheable = 'false'
Details
- visibility
- protected
- default
- false
- final
- false
- static
- false
$_removingUnprocessed
$_removingUnprocessed = 'false'
Details
- visibility
- protected
- default
- false
- final
- false
- static
- false
$modx
$modx = 'null'
Details
- visibility
- public
- default
- null
- final
- false
- static
- false
Methods
_XType
_XType(
string $type
)
:
string
Converts legacy property string types to xtypes.
Arguments
- $type
- string
A property type string.
Output
- string
- A valid xtype.
Details
- visibility
- protected
- final
- false
- static
- false
- access
- protected
__construct
__construct(
$modx
)
:
Arguments
- $modx
Details
- visibility
- public
- final
- false
- static
- false
collectElementTags
collectElementTags(
string $origContent, array $matches, string $prefix
=
[[, string $suffix
=
]]
)
:
integer
Collects element tags in a string and injects them into an array.
Arguments
- $origContent
- string
The content to collect tags from. - $matches
- array
&$matches An array in which the collected tags will be stored (by reference) - $prefix
- string
The characters that define the start of a tag (default= "[["). - $suffix
- string
The characters that define the end of a tag (default= "]]").
Output
- integer
- The number of tags collected from the content.
Details
- visibility
- public
- final
- false
- static
- false
getElement
getElement(
string $class, string $name
)
:
\modElement|null
Get a modElement instance taking advantage of the modX::$sourceCache.
Arguments
- $class
- string
The modElement derivative class to load. - $name
- string
An element name or raw tagName to identify the modElement instance.
Output
- \modElement|null
- An instance of the specified modElement derivative class.
Details
- visibility
- public
- final
- false
- static
- false
isProcessingTag
isProcessingTag(
)
:
Details
- visibility
- public
- final
- false
- static
- false
isProcessingUncacheable
isProcessingUncacheable(
)
:
Details
- visibility
- public
- final
- false
- static
- false
isRemovingUnprocessed
isRemovingUnprocessed(
)
:
Details
- visibility
- public
- final
- false
- static
- false
loadFromCache
loadFromCache(
string $tag
)
:
string
Loads output cached by complete tag signature from the elementCache.
Arguments
- $tag
- string
tag The tag signature representing the element instance.
Output
- string
- The cached output from the element instance.
Details
- visibility
- public
- final
- false
- static
- false
- uses
- modX::$_elementCache Stores all cacheable content from processed elements.
mergeTagOutput
mergeTagOutput(
array $tagMap, string $content
)
:
Merges processed tag output into provided content string.
Arguments
- $tagMap
- array
An array with full tags as keys and processed output as the values. - $content
- string
The content to merge the tag output with (passed by reference).
Details
- visibility
- public
- final
- false
- static
- false
parseProperties
parseProperties(
string $propSource
)
:
array
Parses an element/tag property string or array definition.
Arguments
- $propSource
- string
A valid property string or array source to parse.
Output
- array
- An associative array of property values parsed from the property string or array definition.
Details
- visibility
- public
- final
- false
- static
- false
parsePropertyString
parsePropertyString(
string $string, boolean $valuesOnly
=
false
)
:
Parses an element/tag property string and returns an array of properties.
Arguments
- $string
- string
The property string to parse. - $valuesOnly
- boolean
Indicates only the property value should be returned.
Details
- visibility
- public
- final
- false
- static
- false
processElementTags
processElementTags(
string $parentTag, string $content, boolean $processUncacheable
=
false, boolean $removeUnprocessed
=
false, string $prefix
=
[[, string $suffix
=
]], array $tokens
=
array, integer $depth
=
0
)
:
Collects and processes any set of tags as defined by a prefix and suffix.
Arguments
- $parentTag
- string
The tag representing the element processing this tag. Pass an empty string to allow parsing without this recursion check. - $content
- string
&$content The content to process and act on (by reference). - $processUncacheable
- boolean
Determines if noncacheable tags are to be processed (default= false). - $removeUnprocessed
- boolean
Determines if unprocessed tags should be left in place in the content, or stripped out (default= false). - $prefix
- string
The characters that define the start of a tag (default= "[["). - $suffix
- string
The characters that define the end of a tag (default= "]]"). - $tokens
- array
Indicates that the parser should only process tags with the tokens included in this array. - $depth
- integer
The maximum iterations to recursively process tags returned by prior passes, 0 by default.
Details
- visibility
- public
- final
- false
- static
- false
processTag
processTag(
string $tag, $processUncacheable
=
true
)
:
mixed
Processes a modElement tag and returns the result.
Arguments
- $tag
- string
A full tag string parsed from content. - $processUncacheable
Output
- mixed
- The output of the processed element represented by the specified tag.
Details
- visibility
- public
- final
- false
- static
- false
realname
realname(
string $unfiltered
)
:
string
Gets the real name of an element containing filter modifiers.
Arguments
- $unfiltered
- string
The unfiltered name of a {@link modElement}.
Output
- string
- The name minus any filter modifiers.
Details
- visibility
- public
- final
- false
- static
- false
\modPlaceholderTag
- Extends from
- \modTag
- package
- modx
- uses
- modX::getPlaceholder() To retrieve the placeholder value.
- Methods
- __construct
- getContent
- isCacheable
- process
- setCacheable
Description
Represents placeholder tags.
[[+placeholder_key]] Represents a placeholder with name placeholder_key.
Methods
__construct
__construct(
$modx
)
:
Arguments
- $modx
Details
- visibility
- public
- final
- false
- static
- false
getContent
getContent(
array $options
=
array
)
:
string
Get the raw source content of the field.
Arguments
- $options
- array
An array of options implementations can use to accept language, revision identifiers, or other information to alter the behavior of the method.
Output
- string
- The raw source content for the element.
Details
- visibility
- public
- final
- false
- static
- false
isCacheable
isCacheable(
)
:
boolean
modPlaceholderTag instances cannot be cacheable.
Output
- boolean
- Always returns false.
Details
- visibility
- public
- final
- false
- static
- false
process
process(
array|string $properties
=
null, string $content
=
null
)
:
mixed
Processes the modPlaceholderTag, recursively processing nested tags.
Tags in the properties of the tag itself, or the content returned by the tag element are processed. Non-cacheable nested tags are only processed if this tag element is also non-cacheable.
Arguments
- $properties
- arraystring
An array of properties or a formatted property string. - $content
- string
Optional content to use for the element processing.
Output
- mixed
- The result of processing the tag.
Details
- visibility
- public
- final
- false
- static
- false
setCacheable
setCacheable(
boolean $cacheable
=
true
)
:
modPlaceholderTag instances cannot be cacheable.
Arguments
- $cacheable
- boolean
Indicates the value to set for cacheability of this element.
Details
- visibility
- public
- final
- false
- static
- false
\modTag
- abstract
- You must implement the process() method on derivatives to implement a parseable element tag. All element tags are identified by a unique single character token at the beginning of the tag string.
- package
- modx
- Properties
- $_cacheable
- $_content
- $_fields
- $_filters
- $_output
- $_processed
- $_properties
- $_propertyString
- $_result
- $_tag
- $_token
- $modx
- $name
- $properties
- Methods
- __construct
- cache
- filterInput
- filterOutput
- get
- getContent
- getInputFilter
- getOutputFilter
- getProperties
- getTag
- getToken
- isCacheable
- process
- set
- setCacheable
- setContent
- setProperties
- setTag
- setToken
Description
Abstract class representing a pseudo-element that can be parsed.
Properties
$_cacheable
$_cacheable = 'true'
Details
- visibility
- public
- default
- true
- final
- false
- static
- false
$_content
$_content = 'null'
Details
- visibility
- public
- default
- null
- final
- false
- static
- false
$_fields
$_fields = 'array'
Details
- visibility
- public
- default
- array
- final
- false
- static
- false
$_filters
$_filters = 'array'
Details
- visibility
- public
- default
- array
- final
- false
- static
- false
$_output
$_output = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
$_processed
$_processed = 'false'
Details
- visibility
- public
- default
- false
- final
- false
- static
- false
$_properties
$_properties = 'array'
Details
- visibility
- public
- default
- array
- final
- false
- static
- false
$_propertyString
$_propertyString = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
$_result
$_result = 'true'
Details
- visibility
- public
- default
- true
- final
- false
- static
- false
$_tag
$_tag = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
$_token
$_token = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
$modx
$modx = 'null'
Details
- visibility
- public
- default
- null
- final
- false
- static
- false
$name
$name = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
$properties
$properties = ''
Details
- visibility
- public
- default
- final
- false
- static
- false
Methods
__construct
__construct(
$modx
)
:
Arguments
- $modx
Details
- visibility
- public
- final
- false
- static
- false
cache
cache(
)
:
Cache the element into the elementCache by tag signature.
Details
- visibility
- public
- final
- false
- static
- false
- see
- modElement::cache()
filterInput
filterInput(
)
:
Apply an input filter to a tag.
This is called by default in {@link modTag::process()} after the tag properties have been parsed.
Details
- visibility
- public
- final
- false
- static
- false
- see
- modElement::filterInput()
filterOutput
filterOutput(
)
:
Apply an output filter to a tag.
Call this method in your {modTag::process()} implementation when it is appropriate, typically once all processing has been completed, but before any caching takes place.
Details
- visibility
- public
- final
- false
- static
- false
- see
- modElement::filterOutput()
get
get(
string $k
)
:
mixed
Generic getter method for modTag attributes.
Arguments
- $k
- string
The field key.
Output
- mixed
- The value of the field or null if it is not set.
Details
- visibility
- public
- final
- false
- static
- false
- see
- xPDOObject::get()
getContent
getContent(
array $options
=
array
)
:
string
Get the raw source content of the tag element.
Arguments
- $options
- array
An array of options implementations can use to accept language, revision identifiers, or other information to alter the behavior of the method.
Output
- string
- The raw source content for the element.
Details
- visibility
- public
- final
- false
- static
- false
getInputFilter
getInputFilter(
)
:
\modInputFilter|null
Get an input filter instance configured for this Element.
Output
- \modInputFilter|null
- An input filter instance (or null if one cannot be loaded).
Details
- visibility
- public
- final
- false
- static
- false
getOutputFilter
getOutputFilter(
)
:
\modOutputFilter|null
Get an output filter instance configured for this Element.
Output
- \modOutputFilter|null
- An output filter instance (or null if one cannot be loaded).
Details
- visibility
- public
- final
- false
- static
- false
getProperties
getProperties(
array|string $properties
=
null
)
:
array
Get the properties for this element instance for processing.
Arguments
- $properties
- arraystring
An array or string of properties to apply.
Output
- array
- A simple array of properties ready to use for processing.
Details
- visibility
- public
- final
- false
- static
- false
getTag
getTag(
)
:
Gets a tag representation of the modTag instance.
Details
- visibility
- public
- final
- false
- static
- false
getToken
getToken(
)
:
string
Returns the current token for the tag
Output
- string
- The token for the tag
Details
- visibility
- public
- final
- false
- static
- false
isCacheable
isCacheable(
)
:
boolean
Indicates if the element is cacheable.
Output
- boolean
- True if the element can be stored to or retrieved from the element cache.
Details
- visibility
- public
- final
- false
- static
- false
process
process(
array|string $properties
=
null, string $content
=
null
)
:
mixed
Process the tag and return the result.
Arguments
- $properties
- arraystring
An array of properties or a formatted property string. - $content
- string
Optional content to use for the element processing.
Output
- mixed
- The result of processing the tag.
Details
- visibility
- public
- final
- false
- static
- false
- see
- modElement::process()
set
set(
string $k, mixed $v
)
:
Generic setter method for modTag attributes.
Arguments
- $k
- string
The field key. - $v
- mixed
The value to assign to the field.
Details
- visibility
- public
- final
- false
- static
- false
- see
- xPDOObject::set()
setCacheable
setCacheable(
boolean $cacheable
=
true
)
:
Sets the runtime cacheability of the element.
Arguments
- $cacheable
- boolean
Indicates the value to set for cacheability of this element.
Details
- visibility
- public
- final
- false
- static
- false
setContent
setContent(
$content, $options
=
array
)
:
Set the raw source content for the tag element.
Arguments
- $content
- $options
Details
- visibility
- public
- final
- false
- static
- false
setProperties
setProperties(
array|string $properties, boolean $merge
=
false
)
:
boolean
Set default properties for this element instance.
Arguments
- $properties
- arraystring
A property array or property string. - $merge
- boolean
Indicates if properties should be merged with existing ones.
Output
- boolean
- true if the properties are set.
Details
- visibility
- public
- final
- false
- static
- false
setTag
setTag(
string $tag
)
:
Setter method for the tag class var.
Arguments
- $tag
- string
The tag to use for this element.
Details
- visibility
- public
- final
- false
- static
- false
setToken
setToken(
string $token
)
:
Setter method for the token class var.
Arguments
- $token
- string
The token to use for this element tag.
Details
- visibility
- public
- final
- false
- static
- false