CBTProcessor Class Reference

Template processor, for compilation and execution. More...

List of all members.

Public Member Functions

 CBTProcessor ($text, $functionObj, $ignorableDeps=array())
 Create a template processor for a given text, callback object and static dependency list.
 execute ($compile=false)
 Execute the template.
 compile ()
 Shortcut for execute(true).
 doText ($start, $end)
 Shortcut for doOpenText( $start, $end, false.
 templateEscape ($text)
 Escape text for a template if we are producing a template.
 doOpenText (&$p, $end, $needClosing=true)
 Recursive workhorse for text mode.
 doOpenFunction (&$p, $end, $needClosing=true)
 Recursive workhorse for function mode.
 doFunction ($tokens, $p)
 Execute a function, caching and returning the result value.
 error ($text, $pos=false)
 Set a flag indicating that an error has been found.
 getLastError ()
 bi_if ($condition, $trueBlock, $falseBlock=null)
 'if' built-in function
 bi_true ()
 'true' built-in function
 bi_lbrace ()
 left brace built-in
 bi_rbrace ()
 right brace built-in
 bi_escape ($val)
 escape built-in.

Public Attributes

 $mText
 $mFunctionObj
 $mCompiling = false
 $mIgnorableDeps = array()
 $mFunctionCache = array()
 $mLastError = false
 $mErrorPos = 0
 $mBuiltins
 Built-in functions.


Detailed Description

Template processor, for compilation and execution.

Definition at line 146 of file CBTProcessor.php.


Member Function Documentation

CBTProcessor::bi_escape ( val  ) 

escape built-in.

Escape text for inclusion in an HTML attribute

Definition at line 536 of file CBTProcessor.php.

CBTProcessor::bi_if ( condition,
trueBlock,
falseBlock = null 
)

'if' built-in function

Definition at line 496 of file CBTProcessor.php.

References error().

CBTProcessor::bi_lbrace (  ) 

left brace built-in

Definition at line 523 of file CBTProcessor.php.

CBTProcessor::bi_rbrace (  ) 

right brace built-in

Definition at line 528 of file CBTProcessor.php.

CBTProcessor::bi_true (  ) 

'true' built-in function

Definition at line 518 of file CBTProcessor.php.

CBTProcessor::CBTProcessor ( text,
functionObj,
ignorableDeps = array() 
)

Create a template processor for a given text, callback object and static dependency list.

Definition at line 170 of file CBTProcessor.php.

References $text.

CBTProcessor::compile (  ) 

Shortcut for execute(true).

Definition at line 213 of file CBTProcessor.php.

References $fname, $s, execute(), wfProfileIn(), and wfProfileOut().

CBTProcessor::doFunction ( tokens,
p 
)

Execute a function, caching and returning the result value.

$tokens is an array of CBTValue objects. $tokens[0] is the function name, the others are arguments. $p is the string position, and is used for error messages only.

Definition at line 400 of file CBTProcessor.php.

References $fname, error(), wfDebug(), wfProfileIn(), and wfProfileOut().

Referenced by doOpenFunction().

CBTProcessor::doOpenFunction ( &$  p,
end,
needClosing = true 
)

Recursive workhorse for function mode.

Processes function mode starting from offset $p, until either $end is reached or a closing brace is found. If $needClosing is false, a closing brace will flag an error, if $needClosing is true, the lack of a closing brace will flag an error.

The parameter $p is advanced to the position after the closing brace, or after the end. A CBTValue is returned.

Access:
private

Definition at line 320 of file CBTProcessor.php.

References $end, $i, $in, $start, doFunction(), doOpenText(), and error().

Referenced by doOpenText().

CBTProcessor::doOpenText ( &$  p,
end,
needClosing = true 
)

Recursive workhorse for text mode.

Processes text mode starting from offset $p, until either $end is reached or a closing brace is found. If $needClosing is false, a closing brace will flag an error, if $needClosing is true, the lack of a closing brace will flag an error.

The parameter $p is advanced to the position after the closing brace, or after the end. A CBTValue is returned.

Access:
private

Definition at line 251 of file CBTProcessor.php.

References $end, $fname, $in, $start, doOpenFunction(), error(), wfProfileIn(), and wfProfileOut().

Referenced by doOpenFunction(), and doText().

CBTProcessor::doText ( start,
end 
)

Shortcut for doOpenText( $start, $end, false.

Definition at line 222 of file CBTProcessor.php.

References $end, $start, and doOpenText().

Referenced by execute().

CBTProcessor::error ( text,
pos = false 
)

Set a flag indicating that an error has been found.

Definition at line 482 of file CBTProcessor.php.

References $text.

Referenced by bi_if(), doFunction(), doOpenFunction(), and doOpenText().

CBTProcessor::execute ( compile = false  ) 

Execute the template.

If $compile is true, produces an optimised template where functions with static dependencies have been replaced by their return values.

Definition at line 181 of file CBTProcessor.php.

References $fname, $text, doText(), wfProfileIn(), and wfProfileOut().

Referenced by compile().

CBTProcessor::getLastError (  ) 

Definition at line 491 of file CBTProcessor.php.

CBTProcessor::templateEscape ( text  ) 

Escape text for a template if we are producing a template.

Do nothing if we are producing plain text.

Definition at line 230 of file CBTProcessor.php.

References $text, and cbt_escape().


Member Data Documentation

CBTProcessor::$mBuiltins

Initial value:

 array(
                'if'       => 'bi_if',
                'true'     => 'bi_true',
                '['        => 'bi_lbrace',
                'lbrace'   => 'bi_lbrace',
                ']'        => 'bi_rbrace',
                'rbrace'   => 'bi_rbrace',
                'escape'   => 'bi_escape',
                '~'        => 'bi_escape',
        )
Built-in functions.

Definition at line 156 of file CBTProcessor.php.

CBTProcessor::$mCompiling = false

Definition at line 149 of file CBTProcessor.php.

CBTProcessor::$mErrorPos = 0

Definition at line 153 of file CBTProcessor.php.

CBTProcessor::$mFunctionCache = array()

Definition at line 151 of file CBTProcessor.php.

CBTProcessor::$mFunctionObj

Definition at line 147 of file CBTProcessor.php.

CBTProcessor::$mIgnorableDeps = array()

Definition at line 150 of file CBTProcessor.php.

CBTProcessor::$mLastError = false

Definition at line 152 of file CBTProcessor.php.

CBTProcessor::$mText

Definition at line 147 of file CBTProcessor.php.


The documentation for this class was generated from the following file:

Generated on Sat Sep 5 02:08:34 2009 for MediaWiki by  doxygen 1.5.9