model/modx/modtemplatevar.class.php

Classes 
package
modx
todo
Refactor this to allow user-defined and configured input and output widgets.
Classes
modTemplateVar

Description

Represents a template variable element.

\modTemplateVar

Extends from
\modElement
package
modx
todo
Refactor this to allow user-defined and configured input and output widgets.
Properties
$bindings
Methods
__construct
decodeParamValue
findPolicy
getBindingDataFromValue
getContent
getDisplayParams
getRender
getRenderDirectories
getValue
hasTemplate
parseBinding
parseInput
parseInputOptions
process
processBindings
processFileBinding
processInheritBinding
remove
renderInput
renderOutput
save
setContent
setValue

Description

Represents a template variable element.

These elements are defined by some type of source content that when processed will provide output or some type of logical result based on mutable properties.

This class creates an instance of a modElement object. This should not be called directly, but rather extended for derivative modElement classes.

Properties

$bindingsSupported bindings for MODX

array $bindings = 'array'

Details

array
Supported bindings for MODX
visibility
public
default
array
final
false
static
false
access
public

Methods

__construct

__construct( \xPDO $xpdo ) : \xPDOObject

Creates a modTemplateVar instance, and sets the token of the class to *

{@inheritdoc}

Arguments
$xpdo
\xPDO
&$xpdo A reference to a valid xPDO instance.
Output
\xPDOObject
Details
visibility
public
final
false
static
false

decodeParamValue

decodeParamValue( string $s ) : string

Decodes special function-based chars from a parameter value.

Arguments
$s
string
The string to decode.
Output
string
The decoded string.
Details
visibility
public
final
false
static
false
access
public

findPolicy

findPolicy( string $context ) : array

Loads the access control policies applicable to this template variable.

{@inheritdoc}

Arguments
$context
string
A key identifying a specific context to use when searching for the applicable policies. If not provided, the current context is used.
Output
array
An array of access policies for this object; an empty array is returned if no policies are assigned to the object.
Details
visibility
public
final
false
static
false

getBindingDataFromValue

getBindingDataFromValue( mixed $value ) : array

Parses the binding data from a value

Arguments
$value
mixed
The value to parse
Output
array
An array of cmd and param for the binding
Details
visibility
public
final
false
static
false

getContent

getContent( array $options = array ) : string

Get the source content of this template variable.

{@inheritdoc}

Arguments
$options
array
Output
string
The source content.
Details
visibility
public
final
false
static
false

getDisplayParams

getDisplayParams( ) : array

Returns an array of display params for this TV

Output
array
The processed settings
Details
visibility
public
final
false
static
false

getRender

getRender( array $params, mixed $value, array $paths, string $method, integer $resourceId = 0, string $type = text ) : string

Gets the correct render given paths and type of render

Arguments
$params
array
The parameters to pass to the render
$value
mixed
The value of the TV
$paths
array
An array of paths to search
$method
string
The type of Render (input/output/properties)
$resourceId
integer
The ID of the current Resource
$type
string
The type of render to display
Output
string
Details
visibility
public
final
false
static
false

getRenderDirectories

getRenderDirectories( string $event, string $subdir ) : array

Finds the correct directories for renders

Arguments
$event
string
The plugin event to fire
$subdir
string
The subdir to search
Output
array
The found render directories
Details
visibility
public
final
false
static
false

getValue

getValue( integer $resourceId = 0 ) : mixed

Get the value of a template variable for a resource.

Arguments
$resourceId
integer
The id of the resource; 0 defaults to the default_text field for the tv.
Output
mixed
The raw value of the template variable in context of the specified resource or the default_text for the tv.
Details
visibility
public
final
false
static
false
access
public

hasTemplate

hasTemplate( mixed $templatePk ) : boolean

Check to see if the TV has access to a Template

Arguments
$templatePk
mixed
Either the ID, name or object of the Template
Output
boolean
Whether or not the TV has access to the specified Template
Details
visibility
public
final
false
static
false

parseBinding

parseBinding( string $binding_string ) : array

Parses bindings to an appropriate format.

Arguments
$binding_string
string
The binding to parse.
Output
array
The parsed binding, now in array format.
Details
visibility
public
final
false
static
false
access
public

parseInput

parseInput( mixed $src, string $delim = ||, string $type = string ) : string|array

Returns an string if a delimiter is present. Returns array if is a recordset is present.

Arguments
$src
mixed
Source object, either a recordset, PDOStatement, array or string.
$delim
string
Delimiter for string parsing.
$type
string
Type to return, either 'string' or 'array'.
Output
string|array
If delimiter present, returns string, otherwise array.
Details
visibility
public
final
false
static
false
access
public

parseInputOptions

parseInputOptions( mixed $v ) : mixed

Parses input options sent through postback.

Arguments
$v
mixed
The options to parse, either a recordset, PDOStatement, array or string.
Output
mixed
The parsed options.
Details
visibility
public
final
false
static
false
access
public

process

process( array|string $properties = null, string $content = null ) : mixed

Process the template variable and return the output.

{@inheritdoc}

Arguments
$properties
arraystring
A set of configuration properties for the element.
$content
string
Optional content to use in place of any persistent content associated with the element.
Output
mixed
The result of processing.
Details
visibility
public
final
false
static
false

processBindings

processBindings( string $value, integer $resourceId = 0, boolean $preProcess = true ) : string

Process bindings assigned to a template variable.

Arguments
$value
string
The value specified from the binding.
$resourceId
integer
The resource in which the TV is assigned.
$preProcess
boolean
Whether or not to process certain bindings.
Output
string
The processed value.
Details
visibility
public
final
false
static
false
access
public

processFileBinding

processFileBinding( string $file ) : string

Special parsing for file bindings.

Arguments
$file
string
The absolute location of the file in the binding.
Output
string
The file buffer from the read file.
Details
visibility
public
final
false
static
false
access
public

processInheritBinding

processInheritBinding( string $default, int $resourceId = null ) : string

Parse inherit binding

Arguments
$default
string
The value to default if there is no inherited value
$resourceId
int
The current Resource, if any
Output
string
The inherited value
Details
visibility
public
final
false
static
false

remove

remove( array $ancestors = array ) : boolean

Overrides modElement::remove to add custom error logging and fire modX-specific events.

{@inheritdoc}

Arguments
$ancestors
array
Keeps track of classes which have already been removed to prevent loop with circular references.
Output
boolean
Returns true on success, false on failure.
Details
visibility
public
final
false
static
false

renderInput

renderInput( integer $resourceId = 0, string $style ) : mixed

Renders input forms for the template variable.

Arguments
$resourceId
integer
The id of the resource; 0 defaults to the current resource.
$style
string
Extra style parameters. (deprecated)
Output
mixed
The rendered input for the template variable.
Details
visibility
public
final
false
static
false
access
public

renderOutput

renderOutput( integer $resourceId = 0 ) : mixed

Returns the processed output of a template variable.

Arguments
$resourceId
integer
The id of the resource; 0 defaults to the current resource.
Output
mixed
The processed output of the template variable.
Details
visibility
public
final
false
static
false
access
public

save

save( boolean|integer $cacheFlag = null ) : boolean

Overrides modElement::save to add custom error logging and fire modX-specific events.

{@inheritdoc}

Arguments
$cacheFlag
booleaninteger
Indicates if the saved object(s) should be cached and optionally, by specifying an integer value, for how many seconds before expiring. Overrides the cacheFlag for the object(s).
Output
boolean
Returns true on success, false on failure.
Details
visibility
public
final
false
static
false

setContent

setContent( string $content, array $options = array ) : string

Set the source content of this template variable.

{@inheritdoc}

Arguments
$content
string
$options
array
Output
string
True if successfully set
Details
visibility
public
final
false
static
false

setValue

setValue( integer $resourceId = 0, mixed $value = null ) :

Set the value of a template variable for a resource.

Arguments
$resourceId
integer
The id of the resource; 0 defaults to the current resource.
$value
mixed
The value to give the template variable for the specified document.
Details
visibility
public
final
false
static
false
access
public
Documentation was generated by DocBlox 0.11.2.