silverstripe-framework/view/SSTemplateParser.php

4169 lines
149 KiB
PHP
Raw Normal View History

<?php
/*
WARNING: This file has been machine generated. Do not edit it, or your changes will be overwritten next time it is compiled.
*/
// We want this to work when run by hand too
if (defined(THIRDPARTY_PATH)) {
require_once(THIRDPARTY_PATH . '/php-peg/Parser.php');
}
else {
$base = dirname(__FILE__);
require_once($base.'/../thirdparty/php-peg/Parser.php');
}
/**
This is the exception raised when failing to parse a template. Note that we don't currently do any static analysis, so we can't know
if the template will run, just if it's malformed. It also won't catch mistakes that still look valid.
*/
class SSTemplateParseException extends Exception {
function __construct($message, $parser) {
$prior = substr($parser->string, 0, $parser->pos);
preg_match_all('/\r\n|\r|\n/', $prior, $matches);
$line = count($matches[0])+1;
parent::__construct("Parse error in template on line $line. Error was: $message");
}
}
/**
This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser to match
that string against the language structure, building up the PHP code to execute that structure as it parses
The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how parsers
build results) has one special member, 'php', which contains the php equivalent of that part of the template tree.
Some match rules generate alternate php, or other variations, so check the per-match documentation too.
Terms used:
Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with "$"
(like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo")
Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults.
Example of using a bare argument for a loop block: <% loop Foo %>
Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and
(required or forbidden depending on which block exactly) closing block marks.
Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end tag is
forbidden)
Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag
*/
class SSTemplateParser extends Parser {
/**
* @var bool - Set true by SSTemplateParser::compileString if the template should include comments intended
* for debugging (template source, included files, etc)
*/
protected $includeDebuggingComments = false;
/**
* Override the function that constructs the result arrays to also prepare a 'php' item in the array
*/
function construct($matchrule, $name, $arguments = null) {
$res = parent::construct($matchrule, $name, $arguments);
if (!isset($res['php'])) $res['php'] = '';
return $res;
}
/* Template: (Comment | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | Injection | Text)+ */
protected $match_Template_typestack = array('Template');
function match_Template ($stack = array()) {
$matchrule = "Template"; $result = $this->construct($matchrule, $matchrule, null);
$count = 0;
while (true) {
$res_46 = $result;
$pos_46 = $this->pos;
$_45 = NULL;
do {
$_43 = NULL;
do {
$res_0 = $result;
$pos_0 = $this->pos;
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_43 = TRUE; break;
}
$result = $res_0;
$this->pos = $pos_0;
$_41 = NULL;
do {
$res_2 = $result;
$pos_2 = $this->pos;
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_41 = TRUE; break;
}
$result = $res_2;
$this->pos = $pos_2;
$_39 = NULL;
do {
$res_4 = $result;
$pos_4 = $this->pos;
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_39 = TRUE; break;
}
$result = $res_4;
$this->pos = $pos_4;
$_37 = NULL;
do {
$res_6 = $result;
$pos_6 = $this->pos;
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_37 = TRUE; break;
}
$result = $res_6;
$this->pos = $pos_6;
$_35 = NULL;
do {
$res_8 = $result;
$pos_8 = $this->pos;
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_35 = TRUE; break;
}
$result = $res_8;
$this->pos = $pos_8;
$_33 = NULL;
do {
$res_10 = $result;
$pos_10 = $this->pos;
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_33 = TRUE; break;
}
$result = $res_10;
$this->pos = $pos_10;
$_31 = NULL;
do {
$res_12 = $result;
$pos_12 = $this->pos;
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_31 = TRUE; break;
}
$result = $res_12;
$this->pos = $pos_12;
$_29 = NULL;
do {
$res_14 = $result;
$pos_14 = $this->pos;
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_29 = TRUE; break;
}
$result = $res_14;
$this->pos = $pos_14;
$_27 = NULL;
do {
$res_16 = $result;
$pos_16 = $this->pos;
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_27 = TRUE; break;
}
$result = $res_16;
$this->pos = $pos_16;
$_25 = NULL;
do {
$res_18 = $result;
$pos_18 = $this->pos;
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_25 = TRUE; break;
}
$result = $res_18;
$this->pos = $pos_18;
$_23 = NULL;
do {
$res_20 = $result;
$pos_20 = $this->pos;
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_23 = TRUE; break;
}
$result = $res_20;
$this->pos = $pos_20;
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_23 = TRUE; break;
}
$result = $res_20;
$this->pos = $pos_20;
$_23 = FALSE; break;
}
while(0);
if( $_23 === TRUE ) { $_25 = TRUE; break; }
$result = $res_18;
$this->pos = $pos_18;
$_25 = FALSE; break;
}
while(0);
if( $_25 === TRUE ) { $_27 = TRUE; break; }
$result = $res_16;
$this->pos = $pos_16;
$_27 = FALSE; break;
}
while(0);
if( $_27 === TRUE ) { $_29 = TRUE; break; }
$result = $res_14;
$this->pos = $pos_14;
$_29 = FALSE; break;
}
while(0);
if( $_29 === TRUE ) { $_31 = TRUE; break; }
$result = $res_12;
$this->pos = $pos_12;
$_31 = FALSE; break;
}
while(0);
if( $_31 === TRUE ) { $_33 = TRUE; break; }
$result = $res_10;
$this->pos = $pos_10;
$_33 = FALSE; break;
}
while(0);
if( $_33 === TRUE ) { $_35 = TRUE; break; }
$result = $res_8;
$this->pos = $pos_8;
$_35 = FALSE; break;
}
while(0);
if( $_35 === TRUE ) { $_37 = TRUE; break; }
$result = $res_6;
$this->pos = $pos_6;
$_37 = FALSE; break;
}
while(0);
if( $_37 === TRUE ) { $_39 = TRUE; break; }
$result = $res_4;
$this->pos = $pos_4;
$_39 = FALSE; break;
}
while(0);
if( $_39 === TRUE ) { $_41 = TRUE; break; }
$result = $res_2;
$this->pos = $pos_2;
$_41 = FALSE; break;
}
while(0);
if( $_41 === TRUE ) { $_43 = TRUE; break; }
$result = $res_0;
$this->pos = $pos_0;
$_43 = FALSE; break;
}
while(0);
if( $_43 === FALSE) { $_45 = FALSE; break; }
$_45 = TRUE; break;
}
while(0);
if( $_45 === FALSE) {
$result = $res_46;
$this->pos = $pos_46;
unset( $res_46 );
unset( $pos_46 );
break;
}
$count += 1;
}
if ($count > 0) { return $this->finalise($result); }
else { return FALSE; }
}
function Template_STR(&$res, $sub) {
$res['php'] .= $sub['php'] . PHP_EOL ;
}
/* Word: / [A-Za-z_] [A-Za-z0-9_]* / */
protected $match_Word_typestack = array('Word');
function match_Word ($stack = array()) {
$matchrule = "Word"; $result = $this->construct($matchrule, $matchrule, null);
if (( $subres = $this->rx( '/ [A-Za-z_] [A-Za-z0-9_]* /' ) ) !== FALSE) {
$result["text"] .= $subres;
return $this->finalise($result);
}
else { return FALSE; }
}
/* Number: / [0-9]+ / */
protected $match_Number_typestack = array('Number');
function match_Number ($stack = array()) {
$matchrule = "Number"; $result = $this->construct($matchrule, $matchrule, null);
if (( $subres = $this->rx( '/ [0-9]+ /' ) ) !== FALSE) {
$result["text"] .= $subres;
return $this->finalise($result);
}
else { return FALSE; }
}
/* Value: / [A-Za-z0-9_]+ / */
protected $match_Value_typestack = array('Value');
function match_Value ($stack = array()) {
$matchrule = "Value"; $result = $this->construct($matchrule, $matchrule, null);
if (( $subres = $this->rx( '/ [A-Za-z0-9_]+ /' ) ) !== FALSE) {
$result["text"] .= $subres;
return $this->finalise($result);
}
else { return FALSE; }
}
/* CallArguments: :Argument ( < "," < :Argument )* */
protected $match_CallArguments_typestack = array('CallArguments');
function match_CallArguments ($stack = array()) {
$matchrule = "CallArguments"; $result = $this->construct($matchrule, $matchrule, null);
$_57 = NULL;
do {
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Argument" );
}
else { $_57 = FALSE; break; }
while (true) {
$res_56 = $result;
$pos_56 = $this->pos;
$_55 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ',') {
$this->pos += 1;
$result["text"] .= ',';
}
else { $_55 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Argument" );
}
else { $_55 = FALSE; break; }
$_55 = TRUE; break;
}
while(0);
if( $_55 === FALSE) {
$result = $res_56;
$this->pos = $pos_56;
unset( $res_56 );
unset( $pos_56 );
break;
}
}
$_57 = TRUE; break;
}
while(0);
if( $_57 === TRUE ) { return $this->finalise($result); }
if( $_57 === FALSE) { return FALSE; }
}
/**
* Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert strings
* to numbers when needed.
*/
function CallArguments_Argument(&$res, $sub) {
if (!empty($res['php'])) $res['php'] .= ', ';
2011-02-18 05:06:11 +01:00
$res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] : str_replace('$$FINAL', 'XML_val', $sub['php']);
}
/* Call: Method:Word ( "(" < :CallArguments? > ")" )? */
protected $match_Call_typestack = array('Call');
function match_Call ($stack = array()) {
$matchrule = "Call"; $result = $this->construct($matchrule, $matchrule, null);
$_67 = NULL;
do {
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Method" );
}
else { $_67 = FALSE; break; }
$res_66 = $result;
$pos_66 = $this->pos;
$_65 = NULL;
do {
if (substr($this->string,$this->pos,1) == '(') {
$this->pos += 1;
$result["text"] .= '(';
}
else { $_65 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_62 = $result;
$pos_62 = $this->pos;
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "CallArguments" );
}
else {
$result = $res_62;
$this->pos = $pos_62;
unset( $res_62 );
unset( $pos_62 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ')') {
$this->pos += 1;
$result["text"] .= ')';
}
else { $_65 = FALSE; break; }
$_65 = TRUE; break;
}
while(0);
if( $_65 === FALSE) {
$result = $res_66;
$this->pos = $pos_66;
unset( $res_66 );
unset( $pos_66 );
}
$_67 = TRUE; break;
}
while(0);
if( $_67 === TRUE ) { return $this->finalise($result); }
if( $_67 === FALSE) { return FALSE; }
}
/* LookupStep: :Call &"." */
protected $match_LookupStep_typestack = array('LookupStep');
function match_LookupStep ($stack = array()) {
$matchrule = "LookupStep"; $result = $this->construct($matchrule, $matchrule, null);
$_71 = NULL;
do {
$matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Call" );
}
else { $_71 = FALSE; break; }
$res_70 = $result;
$pos_70 = $this->pos;
if (substr($this->string,$this->pos,1) == '.') {
$this->pos += 1;
$result["text"] .= '.';
$result = $res_70;
$this->pos = $pos_70;
}
else {
$result = $res_70;
$this->pos = $pos_70;
$_71 = FALSE; break;
}
$_71 = TRUE; break;
}
while(0);
if( $_71 === TRUE ) { return $this->finalise($result); }
if( $_71 === FALSE) { return FALSE; }
}
/* LastLookupStep: :Call */
protected $match_LastLookupStep_typestack = array('LastLookupStep');
function match_LastLookupStep ($stack = array()) {
$matchrule = "LastLookupStep"; $result = $this->construct($matchrule, $matchrule, null);
$matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Call" );
return $this->finalise($result);
}
else { return FALSE; }
}
/* Lookup: LookupStep ("." LookupStep)* "." LastLookupStep | LastLookupStep */
protected $match_Lookup_typestack = array('Lookup');
function match_Lookup ($stack = array()) {
$matchrule = "Lookup"; $result = $this->construct($matchrule, $matchrule, null);
$_85 = NULL;
do {
$res_74 = $result;
$pos_74 = $this->pos;
$_82 = NULL;
do {
$matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_82 = FALSE; break; }
while (true) {
$res_79 = $result;
$pos_79 = $this->pos;
$_78 = NULL;
do {
if (substr($this->string,$this->pos,1) == '.') {
$this->pos += 1;
$result["text"] .= '.';
}
else { $_78 = FALSE; break; }
$matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
}
else { $_78 = FALSE; break; }
$_78 = TRUE; break;
}
while(0);
if( $_78 === FALSE) {
$result = $res_79;
$this->pos = $pos_79;
unset( $res_79 );
unset( $pos_79 );
break;
}
}
if (substr($this->string,$this->pos,1) == '.') {
$this->pos += 1;
$result["text"] .= '.';
}
else { $_82 = FALSE; break; }
$matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_82 = FALSE; break; }
$_82 = TRUE; break;
}
while(0);
if( $_82 === TRUE ) { $_85 = TRUE; break; }
$result = $res_74;
$this->pos = $pos_74;
$matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_85 = TRUE; break;
}
$result = $res_74;
$this->pos = $pos_74;
$_85 = FALSE; break;
}
while(0);
if( $_85 === TRUE ) { return $this->finalise($result); }
if( $_85 === FALSE) { return FALSE; }
}
function Lookup__construct(&$res) {
2011-02-18 05:06:11 +01:00
$res['php'] = '$scope';
$res['LookupSteps'] = array();
}
/**
* The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
* get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
* depending on the context the lookup is used in.
*/
function Lookup_AddLookupStep(&$res, $sub, $method) {
$res['LookupSteps'][] = $sub;
$property = $sub['Call']['Method']['text'];
if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) {
$res['php'] .= "->$method('$property', array($arguments), true)";
}
else {
$res['php'] .= "->$method('$property', null, true)";
}
}
function Lookup_LookupStep(&$res, $sub) {
$this->Lookup_AddLookupStep($res, $sub, 'obj');
}
function Lookup_LastLookupStep(&$res, $sub) {
2011-02-18 05:06:11 +01:00
$this->Lookup_AddLookupStep($res, $sub, '$$FINAL');
}
/* SimpleInjection: '$' :Lookup */
protected $match_SimpleInjection_typestack = array('SimpleInjection');
function match_SimpleInjection ($stack = array()) {
$matchrule = "SimpleInjection"; $result = $this->construct($matchrule, $matchrule, null);
$_89 = NULL;
do {
if (substr($this->string,$this->pos,1) == '$') {
$this->pos += 1;
$result["text"] .= '$';
}
else { $_89 = FALSE; break; }
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Lookup" );
}
else { $_89 = FALSE; break; }
$_89 = TRUE; break;
}
while(0);
if( $_89 === TRUE ) { return $this->finalise($result); }
if( $_89 === FALSE) { return FALSE; }
}
/* BracketInjection: '{$' :Lookup "}" */
protected $match_BracketInjection_typestack = array('BracketInjection');
function match_BracketInjection ($stack = array()) {
$matchrule = "BracketInjection"; $result = $this->construct($matchrule, $matchrule, null);
$_94 = NULL;
do {
if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_94 = FALSE; break; }
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Lookup" );
}
else { $_94 = FALSE; break; }
if (substr($this->string,$this->pos,1) == '}') {
$this->pos += 1;
$result["text"] .= '}';
}
else { $_94 = FALSE; break; }
$_94 = TRUE; break;
}
while(0);
if( $_94 === TRUE ) { return $this->finalise($result); }
if( $_94 === FALSE) { return FALSE; }
}
/* Injection: BracketInjection | SimpleInjection */
protected $match_Injection_typestack = array('Injection');
function match_Injection ($stack = array()) {
$matchrule = "Injection"; $result = $this->construct($matchrule, $matchrule, null);
$_99 = NULL;
do {
$res_96 = $result;
$pos_96 = $this->pos;
$matcher = 'match_'.'BracketInjection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_99 = TRUE; break;
}
$result = $res_96;
$this->pos = $pos_96;
$matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_99 = TRUE; break;
}
$result = $res_96;
$this->pos = $pos_96;
$_99 = FALSE; break;
}
while(0);
if( $_99 === TRUE ) { return $this->finalise($result); }
if( $_99 === FALSE) { return FALSE; }
}
function Injection_STR(&$res, $sub) {
2011-02-18 05:06:11 +01:00
$res['php'] = '$val .= '. str_replace('$$FINAL', 'XML_val', $sub['Lookup']['php']) . ';';
}
/* DollarMarkedLookup: SimpleInjection */
protected $match_DollarMarkedLookup_typestack = array('DollarMarkedLookup');
function match_DollarMarkedLookup ($stack = array()) {
$matchrule = "DollarMarkedLookup"; $result = $this->construct($matchrule, $matchrule, null);
$matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
return $this->finalise($result);
}
else { return FALSE; }
}
function DollarMarkedLookup_STR(&$res, $sub) {
$res['Lookup'] = $sub['Lookup'];
}
/* QuotedString: q:/['"]/ String:/ (\\\\ | \\. | [^$q\\])* / '$q' */
protected $match_QuotedString_typestack = array('QuotedString');
function match_QuotedString ($stack = array()) {
$matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null);
$_105 = NULL;
do {
$stack[] = $result; $result = $this->construct( $matchrule, "q" );
if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) {
$result["text"] .= $subres;
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'q' );
}
else {
$result = array_pop($stack);
$_105 = FALSE; break;
}
$stack[] = $result; $result = $this->construct( $matchrule, "String" );
if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) {
$result["text"] .= $subres;
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'String' );
}
else {
$result = array_pop($stack);
$_105 = FALSE; break;
}
if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'q').'' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_105 = FALSE; break; }
$_105 = TRUE; break;
}
while(0);
if( $_105 === TRUE ) { return $this->finalise($result); }
if( $_105 === FALSE) { return FALSE; }
}
/* FreeString: /[^,)%!=|&]+/ */
protected $match_FreeString_typestack = array('FreeString');
function match_FreeString ($stack = array()) {
$matchrule = "FreeString"; $result = $this->construct($matchrule, $matchrule, null);
if (( $subres = $this->rx( '/[^,)%!=|&]+/' ) ) !== FALSE) {
$result["text"] .= $subres;
return $this->finalise($result);
}
else { return FALSE; }
}
/* Argument:
:DollarMarkedLookup |
:QuotedString |
:Lookup !(< FreeString)|
:FreeString */
protected $match_Argument_typestack = array('Argument');
function match_Argument ($stack = array()) {
$matchrule = "Argument"; $result = $this->construct($matchrule, $matchrule, null);
$_125 = NULL;
do {
$res_108 = $result;
$pos_108 = $this->pos;
$matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "DollarMarkedLookup" );
$_125 = TRUE; break;
}
$result = $res_108;
$this->pos = $pos_108;
$_123 = NULL;
do {
$res_110 = $result;
$pos_110 = $this->pos;
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "QuotedString" );
$_123 = TRUE; break;
}
$result = $res_110;
$this->pos = $pos_110;
$_121 = NULL;
do {
$res_112 = $result;
$pos_112 = $this->pos;
$_118 = NULL;
do {
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Lookup" );
}
else { $_118 = FALSE; break; }
$res_117 = $result;
$pos_117 = $this->pos;
$_116 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
}
else { $_116 = FALSE; break; }
$_116 = TRUE; break;
}
while(0);
if( $_116 === TRUE ) {
$result = $res_117;
$this->pos = $pos_117;
$_118 = FALSE; break;
}
if( $_116 === FALSE) {
$result = $res_117;
$this->pos = $pos_117;
}
$_118 = TRUE; break;
}
while(0);
if( $_118 === TRUE ) { $_121 = TRUE; break; }
$result = $res_112;
$this->pos = $pos_112;
$matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "FreeString" );
$_121 = TRUE; break;
}
$result = $res_112;
$this->pos = $pos_112;
$_121 = FALSE; break;
}
while(0);
if( $_121 === TRUE ) { $_123 = TRUE; break; }
$result = $res_110;
$this->pos = $pos_110;
$_123 = FALSE; break;
}
while(0);
if( $_123 === TRUE ) { $_125 = TRUE; break; }
$result = $res_108;
$this->pos = $pos_108;
$_125 = FALSE; break;
}
while(0);
if( $_125 === TRUE ) { return $this->finalise($result); }
if( $_125 === FALSE) { return FALSE; }
}
/**
* If we get a bare value, we don't know enough to determine exactly what php would be the translation, because
* we don't know if the position of use indicates a lookup or a string argument.
*
* Instead, we record 'ArgumentMode' as a member of this matches results node, which can be:
* - lookup if this argument was unambiguously a lookup (marked as such)
* - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup)
* - default if this argument needs to be handled as per 2.4
*
* In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which
* should be used by the parent if the context indicates a lookup, and 'string_php' which should be used
* if the context indicates a string
*/
function Argument_DollarMarkedLookup(&$res, $sub) {
$res['ArgumentMode'] = 'lookup';
$res['php'] = $sub['Lookup']['php'];
}
function Argument_QuotedString(&$res, $sub) {
$res['ArgumentMode'] = 'string';
$res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
}
function Argument_Lookup(&$res, $sub) {
if (count($sub['LookupSteps']) == 1 && !isset($sub['LookupSteps'][0]['Call']['Arguments'])) {
$res['ArgumentMode'] = 'default';
$res['lookup_php'] = $sub['php'];
$res['string_php'] = "'".$sub['LookupSteps'][0]['Call']['Method']['text']."'";
}
else {
$res['ArgumentMode'] = 'lookup';
$res['php'] = $sub['php'];
}
}
function Argument_FreeString(&$res, $sub) {
$res['ArgumentMode'] = 'string';
$res['php'] = "'" . str_replace("'", "\\'", rtrim($sub['text'])) . "'";
}
/* ComparisonOperator: "==" | "!=" | "=" */
protected $match_ComparisonOperator_typestack = array('ComparisonOperator');
function match_ComparisonOperator ($stack = array()) {
$matchrule = "ComparisonOperator"; $result = $this->construct($matchrule, $matchrule, null);
$_134 = NULL;
do {
$res_127 = $result;
$pos_127 = $this->pos;
if (( $subres = $this->literal( '==' ) ) !== FALSE) {
$result["text"] .= $subres;
$_134 = TRUE; break;
}
$result = $res_127;
$this->pos = $pos_127;
$_132 = NULL;
do {
$res_129 = $result;
$pos_129 = $this->pos;
if (( $subres = $this->literal( '!=' ) ) !== FALSE) {
$result["text"] .= $subres;
$_132 = TRUE; break;
}
$result = $res_129;
$this->pos = $pos_129;
if (substr($this->string,$this->pos,1) == '=') {
$this->pos += 1;
$result["text"] .= '=';
$_132 = TRUE; break;
}
$result = $res_129;
$this->pos = $pos_129;
$_132 = FALSE; break;
}
while(0);
if( $_132 === TRUE ) { $_134 = TRUE; break; }
$result = $res_127;
$this->pos = $pos_127;
$_134 = FALSE; break;
}
while(0);
if( $_134 === TRUE ) { return $this->finalise($result); }
if( $_134 === FALSE) { return FALSE; }
}
/* Comparison: Argument < ComparisonOperator > Argument */
protected $match_Comparison_typestack = array('Comparison');
function match_Comparison ($stack = array()) {
$matchrule = "Comparison"; $result = $this->construct($matchrule, $matchrule, null);
$_141 = NULL;
do {
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_141 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'ComparisonOperator'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_141 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_141 = FALSE; break; }
$_141 = TRUE; break;
}
while(0);
if( $_141 === TRUE ) { return $this->finalise($result); }
if( $_141 === FALSE) { return FALSE; }
}
function Comparison_Argument(&$res, $sub) {
if ($sub['ArgumentMode'] == 'default') {
if (!empty($res['php'])) $res['php'] .= $sub['string_php'];
2011-02-18 05:06:11 +01:00
else $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']);
}
else {
2011-02-18 05:06:11 +01:00
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
}
}
function Comparison_ComparisonOperator(&$res, $sub) {
$res['php'] .= ($sub['text'] == '=' ? '==' : $sub['text']);
}
/* PresenceCheck: (Not:'not' <)? Argument */
protected $match_PresenceCheck_typestack = array('PresenceCheck');
function match_PresenceCheck ($stack = array()) {
$matchrule = "PresenceCheck"; $result = $this->construct($matchrule, $matchrule, null);
$_148 = NULL;
do {
$res_146 = $result;
$pos_146 = $this->pos;
$_145 = NULL;
do {
$stack[] = $result; $result = $this->construct( $matchrule, "Not" );
if (( $subres = $this->literal( 'not' ) ) !== FALSE) {
$result["text"] .= $subres;
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'Not' );
}
else {
$result = array_pop($stack);
$_145 = FALSE; break;
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$_145 = TRUE; break;
}
while(0);
if( $_145 === FALSE) {
$result = $res_146;
$this->pos = $pos_146;
unset( $res_146 );
unset( $pos_146 );
}
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_148 = FALSE; break; }
$_148 = TRUE; break;
}
while(0);
if( $_148 === TRUE ) { return $this->finalise($result); }
if( $_148 === FALSE) { return FALSE; }
}
function PresenceCheck_Not(&$res, $sub) {
$res['php'] = '!';
}
function PresenceCheck_Argument(&$res, $sub) {
if ($sub['ArgumentMode'] == 'string') {
$res['php'] .= '((bool)'.$sub['php'].')';
}
else {
$php = ($sub['ArgumentMode'] == 'default' ? $sub['lookup_php'] : $sub['php']);
// TODO: kinda hacky - maybe we need a way to pass state down the parse chain so
// Lookup_LastLookupStep and Argument_BareWord can produce hasValue instead of XML_val
$res['php'] .= str_replace('$$FINAL', 'hasValue', $php);
}
}
/* IfArgumentPortion: Comparison | PresenceCheck */
protected $match_IfArgumentPortion_typestack = array('IfArgumentPortion');
function match_IfArgumentPortion ($stack = array()) {
$matchrule = "IfArgumentPortion"; $result = $this->construct($matchrule, $matchrule, null);
$_153 = NULL;
do {
$res_150 = $result;
$pos_150 = $this->pos;
$matcher = 'match_'.'Comparison'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_153 = TRUE; break;
}
$result = $res_150;
$this->pos = $pos_150;
$matcher = 'match_'.'PresenceCheck'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_153 = TRUE; break;
}
$result = $res_150;
$this->pos = $pos_150;
$_153 = FALSE; break;
}
while(0);
if( $_153 === TRUE ) { return $this->finalise($result); }
if( $_153 === FALSE) { return FALSE; }
}
function IfArgumentPortion_STR(&$res, $sub) {
$res['php'] = $sub['php'];
}
/* BooleanOperator: "||" | "&&" */
protected $match_BooleanOperator_typestack = array('BooleanOperator');
function match_BooleanOperator ($stack = array()) {
$matchrule = "BooleanOperator"; $result = $this->construct($matchrule, $matchrule, null);
$_158 = NULL;
do {
$res_155 = $result;
$pos_155 = $this->pos;
if (( $subres = $this->literal( '||' ) ) !== FALSE) {
$result["text"] .= $subres;
$_158 = TRUE; break;
}
$result = $res_155;
$this->pos = $pos_155;
if (( $subres = $this->literal( '&&' ) ) !== FALSE) {
$result["text"] .= $subres;
$_158 = TRUE; break;
}
$result = $res_155;
$this->pos = $pos_155;
$_158 = FALSE; break;
}
while(0);
if( $_158 === TRUE ) { return $this->finalise($result); }
if( $_158 === FALSE) { return FALSE; }
}
/* IfArgument: :IfArgumentPortion ( < :BooleanOperator < :IfArgumentPortion )* */
protected $match_IfArgument_typestack = array('IfArgument');
function match_IfArgument ($stack = array()) {
$matchrule = "IfArgument"; $result = $this->construct($matchrule, $matchrule, null);
$_167 = NULL;
do {
$matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "IfArgumentPortion" );
}
else { $_167 = FALSE; break; }
while (true) {
$res_166 = $result;
$pos_166 = $this->pos;
$_165 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'BooleanOperator'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "BooleanOperator" );
}
else { $_165 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "IfArgumentPortion" );
}
else { $_165 = FALSE; break; }
$_165 = TRUE; break;
}
while(0);
if( $_165 === FALSE) {
$result = $res_166;
$this->pos = $pos_166;
unset( $res_166 );
unset( $pos_166 );
break;
}
}
$_167 = TRUE; break;
}
while(0);
if( $_167 === TRUE ) { return $this->finalise($result); }
if( $_167 === FALSE) { return FALSE; }
}
function IfArgument_IfArgumentPortion(&$res, $sub) {
$res['php'] .= $sub['php'];
}
function IfArgument_BooleanOperator(&$res, $sub) {
$res['php'] .= $sub['text'];
}
/* IfPart: '<%' < 'if' [ :IfArgument > '%>' Template:$TemplateMatcher? */
protected $match_IfPart_typestack = array('IfPart');
function match_IfPart ($stack = array()) {
$matchrule = "IfPart"; $result = $this->construct($matchrule, $matchrule, null);
$_177 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_177 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'if' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_177 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_177 = FALSE; break; }
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "IfArgument" );
}
else { $_177 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_177 = FALSE; break; }
$res_176 = $result;
$pos_176 = $this->pos;
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Template" );
}
else {
$result = $res_176;
$this->pos = $pos_176;
unset( $res_176 );
unset( $pos_176 );
}
$_177 = TRUE; break;
}
while(0);
if( $_177 === TRUE ) { return $this->finalise($result); }
if( $_177 === FALSE) { return FALSE; }
}
/* ElseIfPart: '<%' < 'else_if' [ :IfArgument > '%>' Template:$TemplateMatcher */
protected $match_ElseIfPart_typestack = array('ElseIfPart');
function match_ElseIfPart ($stack = array()) {
$matchrule = "ElseIfPart"; $result = $this->construct($matchrule, $matchrule, null);
$_187 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_187 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_187 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_187 = FALSE; break; }
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "IfArgument" );
}
else { $_187 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_187 = FALSE; break; }
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Template" );
}
else { $_187 = FALSE; break; }
$_187 = TRUE; break;
}
while(0);
if( $_187 === TRUE ) { return $this->finalise($result); }
if( $_187 === FALSE) { return FALSE; }
}
/* ElsePart: '<%' < 'else' > '%>' Template:$TemplateMatcher */
protected $match_ElsePart_typestack = array('ElsePart');
function match_ElsePart ($stack = array()) {
$matchrule = "ElsePart"; $result = $this->construct($matchrule, $matchrule, null);
$_195 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_195 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'else' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_195 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_195 = FALSE; break; }
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Template" );
}
else { $_195 = FALSE; break; }
$_195 = TRUE; break;
}
while(0);
if( $_195 === TRUE ) { return $this->finalise($result); }
if( $_195 === FALSE) { return FALSE; }
}
/* If: IfPart ElseIfPart* ElsePart? '<%' < 'end_if' > '%>' */
protected $match_If_typestack = array('If');
function match_If ($stack = array()) {
$matchrule = "If"; $result = $this->construct($matchrule, $matchrule, null);
$_205 = NULL;
do {
$matcher = 'match_'.'IfPart'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_205 = FALSE; break; }
while (true) {
$res_198 = $result;
$pos_198 = $this->pos;
$matcher = 'match_'.'ElseIfPart'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else {
$result = $res_198;
$this->pos = $pos_198;
unset( $res_198 );
unset( $pos_198 );
break;
}
}
$res_199 = $result;
$pos_199 = $this->pos;
$matcher = 'match_'.'ElsePart'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else {
$result = $res_199;
$this->pos = $pos_199;
unset( $res_199 );
unset( $pos_199 );
}
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_205 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'end_if' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_205 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_205 = FALSE; break; }
$_205 = TRUE; break;
}
while(0);
if( $_205 === TRUE ) { return $this->finalise($result); }
if( $_205 === FALSE) { return FALSE; }
}
function If_IfPart(&$res, $sub) {
$res['php'] =
'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL .
'}';
}
function If_ElseIfPart(&$res, $sub) {
$res['php'] .=
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL .
$sub['Template']['php'] . PHP_EOL .
'}';
}
function If_ElsePart(&$res, $sub) {
$res['php'] .=
'else { ' . PHP_EOL .
$sub['Template']['php'] . PHP_EOL .
'}';
}
/* Require: '<%' < 'require' [ Call:(Method:Word "(" < :CallArguments > ")") > '%>' */
protected $match_Require_typestack = array('Require');
function match_Require ($stack = array()) {
$matchrule = "Require"; $result = $this->construct($matchrule, $matchrule, null);
$_221 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_221 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'require' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_221 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_221 = FALSE; break; }
$stack[] = $result; $result = $this->construct( $matchrule, "Call" );
$_217 = NULL;
do {
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Method" );
}
else { $_217 = FALSE; break; }
if (substr($this->string,$this->pos,1) == '(') {
$this->pos += 1;
$result["text"] .= '(';
}
else { $_217 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "CallArguments" );
}
else { $_217 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ')') {
$this->pos += 1;
$result["text"] .= ')';
}
else { $_217 = FALSE; break; }
$_217 = TRUE; break;
}
while(0);
if( $_217 === TRUE ) {
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'Call' );
}
if( $_217 === FALSE) {
$result = array_pop($stack);
$_221 = FALSE; break;
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_221 = FALSE; break; }
$_221 = TRUE; break;
}
while(0);
if( $_221 === TRUE ) { return $this->finalise($result); }
if( $_221 === FALSE) { return FALSE; }
}
function Require_Call(&$res, $sub) {
$res['php'] = "Requirements::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');';
}
/* CacheBlockArgument:
!( "if " | "unless " )
(
:DollarMarkedLookup |
:QuotedString |
:Lookup
) */
protected $match_CacheBlockArgument_typestack = array('CacheBlockArgument');
function match_CacheBlockArgument ($stack = array()) {
$matchrule = "CacheBlockArgument"; $result = $this->construct($matchrule, $matchrule, null);
$_241 = NULL;
do {
$res_229 = $result;
$pos_229 = $this->pos;
$_228 = NULL;
do {
$_226 = NULL;
do {
$res_223 = $result;
$pos_223 = $this->pos;
if (( $subres = $this->literal( 'if ' ) ) !== FALSE) {
$result["text"] .= $subres;
$_226 = TRUE; break;
}
$result = $res_223;
$this->pos = $pos_223;
if (( $subres = $this->literal( 'unless ' ) ) !== FALSE) {
$result["text"] .= $subres;
$_226 = TRUE; break;
}
$result = $res_223;
$this->pos = $pos_223;
$_226 = FALSE; break;
}
while(0);
if( $_226 === FALSE) { $_228 = FALSE; break; }
$_228 = TRUE; break;
}
while(0);
if( $_228 === TRUE ) {
$result = $res_229;
$this->pos = $pos_229;
$_241 = FALSE; break;
}
if( $_228 === FALSE) {
$result = $res_229;
$this->pos = $pos_229;
}
$_239 = NULL;
do {
$_237 = NULL;
do {
$res_230 = $result;
$pos_230 = $this->pos;
$matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "DollarMarkedLookup" );
$_237 = TRUE; break;
}
$result = $res_230;
$this->pos = $pos_230;
$_235 = NULL;
do {
$res_232 = $result;
$pos_232 = $this->pos;
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "QuotedString" );
$_235 = TRUE; break;
}
$result = $res_232;
$this->pos = $pos_232;
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Lookup" );
$_235 = TRUE; break;
}
$result = $res_232;
$this->pos = $pos_232;
$_235 = FALSE; break;
}
while(0);
if( $_235 === TRUE ) { $_237 = TRUE; break; }
$result = $res_230;
$this->pos = $pos_230;
$_237 = FALSE; break;
}
while(0);
if( $_237 === FALSE) { $_239 = FALSE; break; }
$_239 = TRUE; break;
}
while(0);
if( $_239 === FALSE) { $_241 = FALSE; break; }
$_241 = TRUE; break;
}
while(0);
if( $_241 === TRUE ) { return $this->finalise($result); }
if( $_241 === FALSE) { return FALSE; }
}
function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) {
$res['php'] = $sub['Lookup']['php'];
}
function CacheBlockArgument_QuotedString(&$res, $sub) {
$res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'";
}
function CacheBlockArgument_Lookup(&$res, $sub) {
$res['php'] = $sub['php'];
}
/* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */
protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments');
function match_CacheBlockArguments ($stack = array()) {
$matchrule = "CacheBlockArguments"; $result = $this->construct($matchrule, $matchrule, null);
$_250 = NULL;
do {
$matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_250 = FALSE; break; }
while (true) {
$res_249 = $result;
$pos_249 = $this->pos;
$_248 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ',') {
$this->pos += 1;
$result["text"] .= ',';
}
else { $_248 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_248 = FALSE; break; }
$_248 = TRUE; break;
}
while(0);
if( $_248 === FALSE) {
$result = $res_249;
$this->pos = $pos_249;
unset( $res_249 );
unset( $pos_249 );
break;
}
}
$_250 = TRUE; break;
}
while(0);
if( $_250 === TRUE ) { return $this->finalise($result); }
if( $_250 === FALSE) { return FALSE; }
}
function CacheBlockArguments_CacheBlockArgument(&$res, $sub) {
if (!empty($res['php'])) $res['php'] .= ".'_'.";
else $res['php'] = '';
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']);
}
/* CacheBlockTemplate: (Comment | If | Require | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | Injection | Text)+ */
protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template');
function match_CacheBlockTemplate ($stack = array()) {
$matchrule = "CacheBlockTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'CacheRestrictedTemplate'));
$count = 0;
while (true) {
$res_290 = $result;
$pos_290 = $this->pos;
$_289 = NULL;
do {
$_287 = NULL;
do {
$res_252 = $result;
$pos_252 = $this->pos;
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_287 = TRUE; break;
}
$result = $res_252;
$this->pos = $pos_252;
$_285 = NULL;
do {
$res_254 = $result;
$pos_254 = $this->pos;
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_285 = TRUE; break;
}
$result = $res_254;
$this->pos = $pos_254;
$_283 = NULL;
do {
$res_256 = $result;
$pos_256 = $this->pos;
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_283 = TRUE; break;
}
$result = $res_256;
$this->pos = $pos_256;
$_281 = NULL;
do {
$res_258 = $result;
$pos_258 = $this->pos;
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_281 = TRUE; break;
}
$result = $res_258;
$this->pos = $pos_258;
$_279 = NULL;
do {
$res_260 = $result;
$pos_260 = $this->pos;
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_279 = TRUE; break;
}
$result = $res_260;
$this->pos = $pos_260;
$_277 = NULL;
do {
$res_262 = $result;
$pos_262 = $this->pos;
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_277 = TRUE; break;
}
$result = $res_262;
$this->pos = $pos_262;
$_275 = NULL;
do {
$res_264 = $result;
$pos_264 = $this->pos;
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_275 = TRUE; break;
}
$result = $res_264;
$this->pos = $pos_264;
$_273 = NULL;
do {
$res_266 = $result;
$pos_266 = $this->pos;
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_273 = TRUE; break;
}
$result = $res_266;
$this->pos = $pos_266;
$_271 = NULL;
do {
$res_268 = $result;
$pos_268 = $this->pos;
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_271 = TRUE; break;
}
$result = $res_268;
$this->pos = $pos_268;
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_271 = TRUE; break;
}
$result = $res_268;
$this->pos = $pos_268;
$_271 = FALSE; break;
}
while(0);
if( $_271 === TRUE ) { $_273 = TRUE; break; }
$result = $res_266;
$this->pos = $pos_266;
$_273 = FALSE; break;
}
while(0);
if( $_273 === TRUE ) { $_275 = TRUE; break; }
$result = $res_264;
$this->pos = $pos_264;
$_275 = FALSE; break;
}
while(0);
if( $_275 === TRUE ) { $_277 = TRUE; break; }
$result = $res_262;
$this->pos = $pos_262;
$_277 = FALSE; break;
}
while(0);
if( $_277 === TRUE ) { $_279 = TRUE; break; }
$result = $res_260;
$this->pos = $pos_260;
$_279 = FALSE; break;
}
while(0);
if( $_279 === TRUE ) { $_281 = TRUE; break; }
$result = $res_258;
$this->pos = $pos_258;
$_281 = FALSE; break;
}
while(0);
if( $_281 === TRUE ) { $_283 = TRUE; break; }
$result = $res_256;
$this->pos = $pos_256;
$_283 = FALSE; break;
}
while(0);
if( $_283 === TRUE ) { $_285 = TRUE; break; }
$result = $res_254;
$this->pos = $pos_254;
$_285 = FALSE; break;
}
while(0);
if( $_285 === TRUE ) { $_287 = TRUE; break; }
$result = $res_252;
$this->pos = $pos_252;
$_287 = FALSE; break;
}
while(0);
if( $_287 === FALSE) { $_289 = FALSE; break; }
$_289 = TRUE; break;
}
while(0);
if( $_289 === FALSE) {
$result = $res_290;
$this->pos = $pos_290;
unset( $res_290 );
unset( $pos_290 );
break;
}
$count += 1;
}
if ($count > 0) { return $this->finalise($result); }
else { return FALSE; }
}
/* UncachedBlock:
'<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>'
Template:$TemplateMatcher?
'<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */
protected $match_UncachedBlock_typestack = array('UncachedBlock');
function match_UncachedBlock ($stack = array()) {
$matchrule = "UncachedBlock"; $result = $this->construct($matchrule, $matchrule, null);
$_327 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_327 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_327 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_295 = $result;
$pos_295 = $this->pos;
$matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else {
$result = $res_295;
$this->pos = $pos_295;
unset( $res_295 );
unset( $pos_295 );
}
$res_307 = $result;
$pos_307 = $this->pos;
$_306 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
$_302 = NULL;
do {
$_300 = NULL;
do {
$res_297 = $result;
$pos_297 = $this->pos;
if (( $subres = $this->literal( 'if' ) ) !== FALSE) {
$result["text"] .= $subres;
$_300 = TRUE; break;
}
$result = $res_297;
$this->pos = $pos_297;
if (( $subres = $this->literal( 'unless' ) ) !== FALSE) {
$result["text"] .= $subres;
$_300 = TRUE; break;
}
$result = $res_297;
$this->pos = $pos_297;
$_300 = FALSE; break;
}
while(0);
if( $_300 === FALSE) { $_302 = FALSE; break; }
$_302 = TRUE; break;
}
while(0);
if( $_302 === TRUE ) {
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'Conditional' );
}
if( $_302 === FALSE) {
$result = array_pop($stack);
$_306 = FALSE; break;
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Condition" );
}
else { $_306 = FALSE; break; }
$_306 = TRUE; break;
}
while(0);
if( $_306 === FALSE) {
$result = $res_307;
$this->pos = $pos_307;
unset( $res_307 );
unset( $pos_307 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_327 = FALSE; break; }
$res_310 = $result;
$pos_310 = $this->pos;
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Template" );
}
else {
$result = $res_310;
$this->pos = $pos_310;
unset( $res_310 );
unset( $pos_310 );
}
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_327 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_327 = FALSE; break; }
$_323 = NULL;
do {
$_321 = NULL;
do {
$res_314 = $result;
$pos_314 = $this->pos;
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_321 = TRUE; break;
}
$result = $res_314;
$this->pos = $pos_314;
$_319 = NULL;
do {
$res_316 = $result;
$pos_316 = $this->pos;
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_319 = TRUE; break;
}
$result = $res_316;
$this->pos = $pos_316;
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) {
$result["text"] .= $subres;
$_319 = TRUE; break;
}
$result = $res_316;
$this->pos = $pos_316;
$_319 = FALSE; break;
}
while(0);
if( $_319 === TRUE ) { $_321 = TRUE; break; }
$result = $res_314;
$this->pos = $pos_314;
$_321 = FALSE; break;
}
while(0);
if( $_321 === FALSE) { $_323 = FALSE; break; }
$_323 = TRUE; break;
}
while(0);
if( $_323 === FALSE) { $_327 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_327 = FALSE; break; }
$_327 = TRUE; break;
}
while(0);
if( $_327 === TRUE ) { return $this->finalise($result); }
if( $_327 === FALSE) { return FALSE; }
}
function UncachedBlock_Template(&$res, $sub){
$res['php'] = $sub['php'];
}
/* CacheRestrictedTemplate: (Comment | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | Injection | Text)+ */
protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template');
function match_CacheRestrictedTemplate ($stack = array()) {
$matchrule = "CacheRestrictedTemplate"; $result = $this->construct($matchrule, $matchrule, null);
$count = 0;
while (true) {
$res_375 = $result;
$pos_375 = $this->pos;
$_374 = NULL;
do {
$_372 = NULL;
do {
$res_329 = $result;
$pos_329 = $this->pos;
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_372 = TRUE; break;
}
$result = $res_329;
$this->pos = $pos_329;
$_370 = NULL;
do {
$res_331 = $result;
$pos_331 = $this->pos;
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_370 = TRUE; break;
}
$result = $res_331;
$this->pos = $pos_331;
$_368 = NULL;
do {
$res_333 = $result;
$pos_333 = $this->pos;
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_368 = TRUE; break;
}
$result = $res_333;
$this->pos = $pos_333;
$_366 = NULL;
do {
$res_335 = $result;
$pos_335 = $this->pos;
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_366 = TRUE; break;
}
$result = $res_335;
$this->pos = $pos_335;
$_364 = NULL;
do {
$res_337 = $result;
$pos_337 = $this->pos;
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_364 = TRUE; break;
}
$result = $res_337;
$this->pos = $pos_337;
$_362 = NULL;
do {
$res_339 = $result;
$pos_339 = $this->pos;
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_362 = TRUE; break;
}
$result = $res_339;
$this->pos = $pos_339;
$_360 = NULL;
do {
$res_341 = $result;
$pos_341 = $this->pos;
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_360 = TRUE; break;
}
$result = $res_341;
$this->pos = $pos_341;
$_358 = NULL;
do {
$res_343 = $result;
$pos_343 = $this->pos;
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_358 = TRUE; break;
}
$result = $res_343;
$this->pos = $pos_343;
$_356 = NULL;
do {
$res_345 = $result;
$pos_345 = $this->pos;
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_356 = TRUE; break;
}
$result = $res_345;
$this->pos = $pos_345;
$_354 = NULL;
do {
$res_347 = $result;
$pos_347 = $this->pos;
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_354 = TRUE; break;
}
$result = $res_347;
$this->pos = $pos_347;
$_352 = NULL;
do {
$res_349 = $result;
$pos_349 = $this->pos;
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_352 = TRUE; break;
}
$result = $res_349;
$this->pos = $pos_349;
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_352 = TRUE; break;
}
$result = $res_349;
$this->pos = $pos_349;
$_352 = FALSE; break;
}
while(0);
if( $_352 === TRUE ) { $_354 = TRUE; break; }
$result = $res_347;
$this->pos = $pos_347;
$_354 = FALSE; break;
}
while(0);
if( $_354 === TRUE ) { $_356 = TRUE; break; }
$result = $res_345;
$this->pos = $pos_345;
$_356 = FALSE; break;
}
while(0);
if( $_356 === TRUE ) { $_358 = TRUE; break; }
$result = $res_343;
$this->pos = $pos_343;
$_358 = FALSE; break;
}
while(0);
if( $_358 === TRUE ) { $_360 = TRUE; break; }
$result = $res_341;
$this->pos = $pos_341;
$_360 = FALSE; break;
}
while(0);
if( $_360 === TRUE ) { $_362 = TRUE; break; }
$result = $res_339;
$this->pos = $pos_339;
$_362 = FALSE; break;
}
while(0);
if( $_362 === TRUE ) { $_364 = TRUE; break; }
$result = $res_337;
$this->pos = $pos_337;
$_364 = FALSE; break;
}
while(0);
if( $_364 === TRUE ) { $_366 = TRUE; break; }
$result = $res_335;
$this->pos = $pos_335;
$_366 = FALSE; break;
}
while(0);
if( $_366 === TRUE ) { $_368 = TRUE; break; }
$result = $res_333;
$this->pos = $pos_333;
$_368 = FALSE; break;
}
while(0);
if( $_368 === TRUE ) { $_370 = TRUE; break; }
$result = $res_331;
$this->pos = $pos_331;
$_370 = FALSE; break;
}
while(0);
if( $_370 === TRUE ) { $_372 = TRUE; break; }
$result = $res_329;
$this->pos = $pos_329;
$_372 = FALSE; break;
}
while(0);
if( $_372 === FALSE) { $_374 = FALSE; break; }
$_374 = TRUE; break;
}
while(0);
if( $_374 === FALSE) {
$result = $res_375;
$this->pos = $pos_375;
unset( $res_375 );
unset( $pos_375 );
break;
}
$count += 1;
}
if ($count > 0) { return $this->finalise($result); }
else { return FALSE; }
}
function CacheRestrictedTemplate_CacheBlock(&$res, $sub) {
throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks that are within cache blocks', $this);
}
function CacheRestrictedTemplate_UncachedBlock(&$res, $sub) {
throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks that are within cache blocks', $this);
}
/* CacheBlock:
'<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>'
(CacheBlock | UncachedBlock | CacheBlockTemplate)*
'<%' < 'end_' ("cached"|"uncached"|"cacheblock") > '%>' */
protected $match_CacheBlock_typestack = array('CacheBlock');
function match_CacheBlock ($stack = array()) {
$matchrule = "CacheBlock"; $result = $this->construct($matchrule, $matchrule, null);
$_430 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_430 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" );
$_383 = NULL;
do {
$_381 = NULL;
do {
$res_378 = $result;
$pos_378 = $this->pos;
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_381 = TRUE; break;
}
$result = $res_378;
$this->pos = $pos_378;
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) {
$result["text"] .= $subres;
$_381 = TRUE; break;
}
$result = $res_378;
$this->pos = $pos_378;
$_381 = FALSE; break;
}
while(0);
if( $_381 === FALSE) { $_383 = FALSE; break; }
$_383 = TRUE; break;
}
while(0);
if( $_383 === TRUE ) {
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'CacheTag' );
}
if( $_383 === FALSE) {
$result = array_pop($stack);
$_430 = FALSE; break;
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_388 = $result;
$pos_388 = $this->pos;
$_387 = NULL;
do {
$matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_387 = FALSE; break; }
$_387 = TRUE; break;
}
while(0);
if( $_387 === FALSE) {
$result = $res_388;
$this->pos = $pos_388;
unset( $res_388 );
unset( $pos_388 );
}
$res_400 = $result;
$pos_400 = $this->pos;
$_399 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
$_395 = NULL;
do {
$_393 = NULL;
do {
$res_390 = $result;
$pos_390 = $this->pos;
if (( $subres = $this->literal( 'if' ) ) !== FALSE) {
$result["text"] .= $subres;
$_393 = TRUE; break;
}
$result = $res_390;
$this->pos = $pos_390;
if (( $subres = $this->literal( 'unless' ) ) !== FALSE) {
$result["text"] .= $subres;
$_393 = TRUE; break;
}
$result = $res_390;
$this->pos = $pos_390;
$_393 = FALSE; break;
}
while(0);
if( $_393 === FALSE) { $_395 = FALSE; break; }
$_395 = TRUE; break;
}
while(0);
if( $_395 === TRUE ) {
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'Conditional' );
}
if( $_395 === FALSE) {
$result = array_pop($stack);
$_399 = FALSE; break;
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Condition" );
}
else { $_399 = FALSE; break; }
$_399 = TRUE; break;
}
while(0);
if( $_399 === FALSE) {
$result = $res_400;
$this->pos = $pos_400;
unset( $res_400 );
unset( $pos_400 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_430 = FALSE; break; }
while (true) {
$res_413 = $result;
$pos_413 = $this->pos;
$_412 = NULL;
do {
$_410 = NULL;
do {
$res_403 = $result;
$pos_403 = $this->pos;
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_410 = TRUE; break;
}
$result = $res_403;
$this->pos = $pos_403;
$_408 = NULL;
do {
$res_405 = $result;
$pos_405 = $this->pos;
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_408 = TRUE; break;
}
$result = $res_405;
$this->pos = $pos_405;
$matcher = 'match_'.'CacheBlockTemplate'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_408 = TRUE; break;
}
$result = $res_405;
$this->pos = $pos_405;
$_408 = FALSE; break;
}
while(0);
if( $_408 === TRUE ) { $_410 = TRUE; break; }
$result = $res_403;
$this->pos = $pos_403;
$_410 = FALSE; break;
}
while(0);
if( $_410 === FALSE) { $_412 = FALSE; break; }
$_412 = TRUE; break;
}
while(0);
if( $_412 === FALSE) {
$result = $res_413;
$this->pos = $pos_413;
unset( $res_413 );
unset( $pos_413 );
break;
}
}
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_430 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_430 = FALSE; break; }
$_426 = NULL;
do {
$_424 = NULL;
do {
$res_417 = $result;
$pos_417 = $this->pos;
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_424 = TRUE; break;
}
$result = $res_417;
$this->pos = $pos_417;
$_422 = NULL;
do {
$res_419 = $result;
$pos_419 = $this->pos;
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_422 = TRUE; break;
}
$result = $res_419;
$this->pos = $pos_419;
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) {
$result["text"] .= $subres;
$_422 = TRUE; break;
}
$result = $res_419;
$this->pos = $pos_419;
$_422 = FALSE; break;
}
while(0);
if( $_422 === TRUE ) { $_424 = TRUE; break; }
$result = $res_417;
$this->pos = $pos_417;
$_424 = FALSE; break;
}
while(0);
if( $_424 === FALSE) { $_426 = FALSE; break; }
$_426 = TRUE; break;
}
while(0);
if( $_426 === FALSE) { $_430 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_430 = FALSE; break; }
$_430 = TRUE; break;
}
while(0);
if( $_430 === TRUE ) { return $this->finalise($result); }
if( $_430 === FALSE) { return FALSE; }
}
function CacheBlock__construct(&$res){
$res['subblocks'] = 0;
}
function CacheBlock_CacheBlockArguments(&$res, $sub){
$res['key'] = !empty($sub['php']) ? $sub['php'] : '';
}
function CacheBlock_Condition(&$res, $sub){
$res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && ';
}
function CacheBlock_CacheBlock(&$res, $sub){
$res['php'] .= $sub['php'];
}
function CacheBlock_UncachedBlock(&$res, $sub){
$res['php'] .= $sub['php'];
}
function CacheBlock_CacheBlockTemplate(&$res, $sub){
// Get the block counter
$block = ++$res['subblocks'];
// Build the key for this block from the passed cache key, the block index, and the sha hash of the template itself
$key = "'" . sha1($sub['php']) . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") . ".'_$block'";
// Get any condition
$condition = isset($res['condition']) ? $res['condition'] : '';
$res['php'] .= 'if ('.$condition.'($partial = $cache->load('.$key.'))) $val .= $partial;' . PHP_EOL;
$res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL;
$res['php'] .= $sub['php'] . PHP_EOL;
$res['php'] .= $condition . ' $cache->save($val); $val = $oldval . $val;' . PHP_EOL;
$res['php'] .= '}';
}
/* OldTPart: "_t" < "(" < QuotedString (< "," < CallArguments)? > ")" */
protected $match_OldTPart_typestack = array('OldTPart');
function match_OldTPart ($stack = array()) {
$matchrule = "OldTPart"; $result = $this->construct($matchrule, $matchrule, null);
$_445 = NULL;
do {
if (( $subres = $this->literal( '_t' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_445 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == '(') {
$this->pos += 1;
$result["text"] .= '(';
}
else { $_445 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_445 = FALSE; break; }
$res_442 = $result;
$pos_442 = $this->pos;
$_441 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ',') {
$this->pos += 1;
$result["text"] .= ',';
}
else { $_441 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_441 = FALSE; break; }
$_441 = TRUE; break;
}
while(0);
if( $_441 === FALSE) {
$result = $res_442;
$this->pos = $pos_442;
unset( $res_442 );
unset( $pos_442 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ')') {
$this->pos += 1;
$result["text"] .= ')';
}
else { $_445 = FALSE; break; }
$_445 = TRUE; break;
}
while(0);
if( $_445 === TRUE ) { return $this->finalise($result); }
if( $_445 === FALSE) { return FALSE; }
}
function OldTPart__construct(&$res) {
$res['php'] = "_t(";
}
function OldTPart_QuotedString(&$res, $sub) {
$entity = $sub['String']['text'];
if (strpos($entity, '.') === false) {
$res['php'] .= "\$scope->XML_val('I18NNamespace').'.$entity'";
}
else {
$res['php'] .= "'$entity'";
}
}
function OldTPart_CallArguments(&$res, $sub) {
$res['php'] .= ',' . $sub['php'];
}
function OldTPart__finalise(&$res) {
$res['php'] .= ')';
}
/* OldTTag: "<%" < OldTPart > "%>" */
protected $match_OldTTag_typestack = array('OldTTag');
function match_OldTTag ($stack = array()) {
$matchrule = "OldTTag"; $result = $this->construct($matchrule, $matchrule, null);
$_452 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_452 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_452 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_452 = FALSE; break; }
$_452 = TRUE; break;
}
while(0);
if( $_452 === TRUE ) { return $this->finalise($result); }
if( $_452 === FALSE) { return FALSE; }
}
function OldTTag_OldTPart(&$res, $sub) {
$res['php'] = $sub['php'];
}
/* OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>" */
protected $match_OldSprintfTag_typestack = array('OldSprintfTag');
function match_OldSprintfTag ($stack = array()) {
$matchrule = "OldSprintfTag"; $result = $this->construct($matchrule, $matchrule, null);
$_469 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'sprintf' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == '(') {
$this->pos += 1;
$result["text"] .= '(';
}
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ',') {
$this->pos += 1;
$result["text"] .= ',';
}
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ')') {
$this->pos += 1;
$result["text"] .= ')';
}
else { $_469 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_469 = FALSE; break; }
$_469 = TRUE; break;
}
while(0);
if( $_469 === TRUE ) { return $this->finalise($result); }
if( $_469 === FALSE) { return FALSE; }
}
function OldSprintfTag__construct(&$res) {
$res['php'] = "sprintf(";
}
function OldSprintfTag_OldTPart(&$res, $sub) {
$res['php'] .= $sub['php'];
}
function OldSprintfTag_CallArguments(&$res, $sub) {
$res['php'] .= ',' . $sub['php'] . ')';
}
/* OldI18NTag: OldSprintfTag | OldTTag */
protected $match_OldI18NTag_typestack = array('OldI18NTag');
function match_OldI18NTag ($stack = array()) {
$matchrule = "OldI18NTag"; $result = $this->construct($matchrule, $matchrule, null);
$_474 = NULL;
do {
$res_471 = $result;
$pos_471 = $this->pos;
$matcher = 'match_'.'OldSprintfTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_474 = TRUE; break;
}
$result = $res_471;
$this->pos = $pos_471;
$matcher = 'match_'.'OldTTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_474 = TRUE; break;
}
$result = $res_471;
$this->pos = $pos_471;
$_474 = FALSE; break;
}
while(0);
if( $_474 === TRUE ) { return $this->finalise($result); }
if( $_474 === FALSE) { return FALSE; }
}
function OldI18NTag_STR(&$res, $sub) {
$res['php'] = '$val .= ' . $sub['php'] . ';';
}
/* NamedArgument: Name:Word "=" Value:Argument */
protected $match_NamedArgument_typestack = array('NamedArgument');
function match_NamedArgument ($stack = array()) {
$matchrule = "NamedArgument"; $result = $this->construct($matchrule, $matchrule, null);
$_479 = NULL;
do {
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Name" );
}
else { $_479 = FALSE; break; }
if (substr($this->string,$this->pos,1) == '=') {
$this->pos += 1;
$result["text"] .= '=';
}
else { $_479 = FALSE; break; }
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Value" );
}
else { $_479 = FALSE; break; }
$_479 = TRUE; break;
}
while(0);
if( $_479 === TRUE ) { return $this->finalise($result); }
if( $_479 === FALSE) { return FALSE; }
}
function NamedArgument_Name(&$res, $sub) {
$res['php'] = "'" . $sub['text'] . "' => ";
}
function NamedArgument_Value(&$res, $sub) {
$res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] : str_replace('$$FINAL', 'XML_val', $sub['php']);
}
/* Include: "<%" < "include" < Template:Word < (NamedArgument ( < "," < NamedArgument )*)? > "%>" */
protected $match_Include_typestack = array('Include');
function match_Include ($stack = array()) {
$matchrule = "Include"; $result = $this->construct($matchrule, $matchrule, null);
$_498 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_498 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'include' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_498 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Template" );
}
else { $_498 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_495 = $result;
$pos_495 = $this->pos;
$_494 = NULL;
do {
$matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) { $this->store( $result, $subres ); }
else { $_494 = FALSE; break; }
while (true) {
$res_493 = $result;
$pos_493 = $this->pos;
$_492 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ',') {
$this->pos += 1;
$result["text"] .= ',';
}
else { $_492 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
}
else { $_492 = FALSE; break; }
$_492 = TRUE; break;
}
while(0);
if( $_492 === FALSE) {
$result = $res_493;
$this->pos = $pos_493;
unset( $res_493 );
unset( $pos_493 );
break;
}
}
$_494 = TRUE; break;
}
while(0);
if( $_494 === FALSE) {
$result = $res_495;
$this->pos = $pos_495;
unset( $res_495 );
unset( $pos_495 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_498 = FALSE; break; }
$_498 = TRUE; break;
}
while(0);
if( $_498 === TRUE ) { return $this->finalise($result); }
if( $_498 === FALSE) { return FALSE; }
}
function Include__construct(&$res){
$res['arguments'] = array();
}
function Include_Template(&$res, $sub){
$res['template'] = "'" . $sub['text'] . "'";
}
function Include_NamedArgument(&$res, $sub){
$res['arguments'][] = $sub['php'];
}
function Include__finalise(&$res){
$template = $res['template'];
$arguments = $res['arguments'];
$res['php'] = '$val .= SSViewer::execute_template('.$template.', $scope->getItem(), array('.implode(',', $arguments)."));\n";
if($this->includeDebuggingComments) { // Add include filename comments on dev sites
$res['php'] =
'$val .= \'<!-- include '.addslashes($template).' -->\';'. "\n".
$res['php'].
'$val .= \'<!-- end include '.addslashes($template).' -->\';'. "\n";
}
}
/* BlockArguments: :Argument ( < "," < :Argument)* */
protected $match_BlockArguments_typestack = array('BlockArguments');
function match_BlockArguments ($stack = array()) {
$matchrule = "BlockArguments"; $result = $this->construct($matchrule, $matchrule, null);
$_507 = NULL;
do {
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Argument" );
}
else { $_507 = FALSE; break; }
while (true) {
$res_506 = $result;
$pos_506 = $this->pos;
$_505 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (substr($this->string,$this->pos,1) == ',') {
$this->pos += 1;
$result["text"] .= ',';
}
else { $_505 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Argument" );
}
else { $_505 = FALSE; break; }
$_505 = TRUE; break;
}
while(0);
if( $_505 === FALSE) {
$result = $res_506;
$this->pos = $pos_506;
unset( $res_506 );
unset( $pos_506 );
break;
}
}
$_507 = TRUE; break;
}
while(0);
if( $_507 === TRUE ) { return $this->finalise($result); }
if( $_507 === FALSE) { return FALSE; }
}
/* NotBlockTag: "end_" | (("if" | "else_if" | "else" | "require" | "cached" | "uncached" | "cacheblock" | "include") ] ) */
protected $match_NotBlockTag_typestack = array('NotBlockTag');
function match_NotBlockTag ($stack = array()) {
$matchrule = "NotBlockTag"; $result = $this->construct($matchrule, $matchrule, null);
$_545 = NULL;
do {
$res_509 = $result;
$pos_509 = $this->pos;
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) {
$result["text"] .= $subres;
$_545 = TRUE; break;
}
$result = $res_509;
$this->pos = $pos_509;
$_543 = NULL;
do {
$_540 = NULL;
do {
$_538 = NULL;
do {
$res_511 = $result;
$pos_511 = $this->pos;
if (( $subres = $this->literal( 'if' ) ) !== FALSE) {
$result["text"] .= $subres;
$_538 = TRUE; break;
}
$result = $res_511;
$this->pos = $pos_511;
$_536 = NULL;
do {
$res_513 = $result;
$pos_513 = $this->pos;
if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) {
$result["text"] .= $subres;
$_536 = TRUE; break;
}
$result = $res_513;
$this->pos = $pos_513;
$_534 = NULL;
do {
$res_515 = $result;
$pos_515 = $this->pos;
if (( $subres = $this->literal( 'else' ) ) !== FALSE) {
$result["text"] .= $subres;
$_534 = TRUE; break;
}
$result = $res_515;
$this->pos = $pos_515;
$_532 = NULL;
do {
$res_517 = $result;
$pos_517 = $this->pos;
if (( $subres = $this->literal( 'require' ) ) !== FALSE) {
$result["text"] .= $subres;
$_532 = TRUE; break;
}
$result = $res_517;
$this->pos = $pos_517;
$_530 = NULL;
do {
$res_519 = $result;
$pos_519 = $this->pos;
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_530 = TRUE; break;
}
$result = $res_519;
$this->pos = $pos_519;
$_528 = NULL;
do {
$res_521 = $result;
$pos_521 = $this->pos;
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) {
$result["text"] .= $subres;
$_528 = TRUE; break;
}
$result = $res_521;
$this->pos = $pos_521;
$_526 = NULL;
do {
$res_523 = $result;
$pos_523 = $this->pos;
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) {
$result["text"] .= $subres;
$_526 = TRUE; break;
}
$result = $res_523;
$this->pos = $pos_523;
if (( $subres = $this->literal( 'include' ) ) !== FALSE) {
$result["text"] .= $subres;
$_526 = TRUE; break;
}
$result = $res_523;
$this->pos = $pos_523;
$_526 = FALSE; break;
}
while(0);
if( $_526 === TRUE ) { $_528 = TRUE; break; }
$result = $res_521;
$this->pos = $pos_521;
$_528 = FALSE; break;
}
while(0);
if( $_528 === TRUE ) { $_530 = TRUE; break; }
$result = $res_519;
$this->pos = $pos_519;
$_530 = FALSE; break;
}
while(0);
if( $_530 === TRUE ) { $_532 = TRUE; break; }
$result = $res_517;
$this->pos = $pos_517;
$_532 = FALSE; break;
}
while(0);
if( $_532 === TRUE ) { $_534 = TRUE; break; }
$result = $res_515;
$this->pos = $pos_515;
$_534 = FALSE; break;
}
while(0);
if( $_534 === TRUE ) { $_536 = TRUE; break; }
$result = $res_513;
$this->pos = $pos_513;
$_536 = FALSE; break;
}
while(0);
if( $_536 === TRUE ) { $_538 = TRUE; break; }
$result = $res_511;
$this->pos = $pos_511;
$_538 = FALSE; break;
}
while(0);
if( $_538 === FALSE) { $_540 = FALSE; break; }
$_540 = TRUE; break;
}
while(0);
if( $_540 === FALSE) { $_543 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_543 = FALSE; break; }
$_543 = TRUE; break;
}
while(0);
if( $_543 === TRUE ) { $_545 = TRUE; break; }
$result = $res_509;
$this->pos = $pos_509;
$_545 = FALSE; break;
}
while(0);
if( $_545 === TRUE ) { return $this->finalise($result); }
if( $_545 === FALSE) { return FALSE; }
}
/* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher? '<%' < 'end_' '$BlockName' > '%>' */
protected $match_ClosedBlock_typestack = array('ClosedBlock');
function match_ClosedBlock ($stack = array()) {
$matchrule = "ClosedBlock"; $result = $this->construct($matchrule, $matchrule, null);
$_565 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_565 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_549 = $result;
$pos_549 = $this->pos;
$matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$result = $res_549;
$this->pos = $pos_549;
$_565 = FALSE; break;
}
else {
$result = $res_549;
$this->pos = $pos_549;
}
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "BlockName" );
}
else { $_565 = FALSE; break; }
$res_555 = $result;
$pos_555 = $this->pos;
$_554 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_554 = FALSE; break; }
$matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "BlockArguments" );
}
else { $_554 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_554 = FALSE; break; }
$_554 = TRUE; break;
}
while(0);
if( $_554 === FALSE) {
$result = $res_555;
$this->pos = $pos_555;
unset( $res_555 );
unset( $pos_555 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$stack[] = $result; $result = $this->construct( $matchrule, "Zap" );
if (( $subres = $this->literal( '%>' ) ) !== FALSE) {
$result["text"] .= $subres;
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'Zap' );
}
else {
$result = array_pop($stack);
$_565 = FALSE; break;
}
$res_558 = $result;
$pos_558 = $this->pos;
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Template" );
}
else {
$result = $res_558;
$this->pos = $pos_558;
unset( $res_558 );
unset( $pos_558 );
}
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_565 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_565 = FALSE; break; }
if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'BlockName').'' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_565 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_565 = FALSE; break; }
$_565 = TRUE; break;
}
while(0);
if( $_565 === TRUE ) { return $this->finalise($result); }
if( $_565 === FALSE) { return FALSE; }
}
/**
* As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule
* builds up two important elements in the match result array:
* 'ArgumentCount' - how many arguments were passed in the opening tag
* 'Arguments' an array of the Argument match rule result arrays
*
* Once a block has successfully been matched against, it will then look for the actual handler, which should
* be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the
* tag name, first letter captialized (i.e Control, Loop, With, etc).
*
* This function will be called with the match rule result array as it's first argument. It should return
* the php result of this block as it's return value, or throw an error if incorrect arguments were passed.
*/
function ClosedBlock__construct(&$res) {
$res['ArgumentCount'] = 0;
}
function ClosedBlock_BlockArguments(&$res, $sub) {
if (isset($sub['Argument']['ArgumentMode'])) {
$res['Arguments'] = array($sub['Argument']);
$res['ArgumentCount'] = 1;
}
else {
$res['Arguments'] = $sub['Argument'];
$res['ArgumentCount'] = count($res['Arguments']);
}
}
function ClosedBlock__finalise(&$res) {
$blockname = $res['BlockName']['text'];
$method = 'ClosedBlock_Handle_'.$blockname;
if (method_exists($this, $method)) $res['php'] = $this->$method($res);
else {
throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are not supposed to close this block, or have mis-spelled it?', $this);
}
}
/**
2011-02-18 05:06:11 +01:00
* This is an example of a block handler function. This one handles the loop tag.
*/
2011-02-18 05:06:11 +01:00
function ClosedBlock_Handle_Loop(&$res) {
if ($res['ArgumentCount'] > 1) {
throw new SSTemplateParseException('Either no or too many arguments in control block. Must be one argument only.', $this);
}
//loop without arguments loops on the current scope
if ($res['ArgumentCount'] == 0) {
$on = '$scope->obj(\'Up\', null, true)->obj(\'Foo\', null, true)';
} else { //loop in the normal way
$arg = $res['Arguments'][0];
if ($arg['ArgumentMode'] == 'string') {
throw new SSTemplateParseException('Control block cant take string as argument.', $this);
}
$on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
}
return
2011-02-18 05:06:11 +01:00
$on . '; $scope->pushScope(); while (($key = $scope->next()) !== false) {' . PHP_EOL .
$res['Template']['php'] . PHP_EOL .
'}; $scope->popScope(); ';
}
/**
* The deprecated closed block handler for control blocks
* @deprecated
*/
function ClosedBlock_Handle_Control(&$res) {
Deprecation::notice('3.1', 'Use <% with %> or <% loop %> instead.');
2011-02-18 05:06:11 +01:00
return $this->ClosedBlock_Handle_Loop($res);
}
/**
* The closed block handler for with blocks
*/
function ClosedBlock_Handle_With(&$res) {
if ($res['ArgumentCount'] != 1) {
throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one argument only.', $this);
}
$arg = $res['Arguments'][0];
if ($arg['ArgumentMode'] == 'string') {
throw new SSTemplateParseException('Control block cant take string as argument.', $this);
}
$on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']);
return
2011-02-18 05:06:11 +01:00
$on . '; $scope->pushScope();' . PHP_EOL .
$res['Template']['php'] . PHP_EOL .
2011-02-18 05:06:11 +01:00
'; $scope->popScope(); ';
}
/* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */
protected $match_OpenBlock_typestack = array('OpenBlock');
function match_OpenBlock ($stack = array()) {
$matchrule = "OpenBlock"; $result = $this->construct($matchrule, $matchrule, null);
$_578 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_578 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_569 = $result;
$pos_569 = $this->pos;
$matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$result = $res_569;
$this->pos = $pos_569;
$_578 = FALSE; break;
}
else {
$result = $res_569;
$this->pos = $pos_569;
}
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "BlockName" );
}
else { $_578 = FALSE; break; }
$res_575 = $result;
$pos_575 = $this->pos;
$_574 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_574 = FALSE; break; }
$matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "BlockArguments" );
}
else { $_574 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_574 = FALSE; break; }
$_574 = TRUE; break;
}
while(0);
if( $_574 === FALSE) {
$result = $res_575;
$this->pos = $pos_575;
unset( $res_575 );
unset( $pos_575 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_578 = FALSE; break; }
$_578 = TRUE; break;
}
while(0);
if( $_578 === TRUE ) { return $this->finalise($result); }
if( $_578 === FALSE) { return FALSE; }
}
function OpenBlock__construct(&$res) {
$res['ArgumentCount'] = 0;
}
function OpenBlock_BlockArguments(&$res, $sub) {
if (isset($sub['Argument']['ArgumentMode'])) {
$res['Arguments'] = array($sub['Argument']);
$res['ArgumentCount'] = 1;
}
else {
$res['Arguments'] = $sub['Argument'];
$res['ArgumentCount'] = count($res['Arguments']);
}
}
function OpenBlock__finalise(&$res) {
$blockname = $res['BlockName']['text'];
$method = 'OpenBlock_Handle_'.$blockname;
if (method_exists($this, $method)) $res['php'] = $this->$method($res);
else {
throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed the closing tag or have mis-spelled it?', $this);
}
}
/**
* This is an open block handler, for the <% debug %> utility tag
*/
function OpenBlock_Handle_Debug(&$res) {
2011-02-18 05:06:11 +01:00
if ($res['ArgumentCount'] == 0) return '$scope->debug();';
else if ($res['ArgumentCount'] == 1) {
$arg = $res['Arguments'][0];
if ($arg['ArgumentMode'] == 'string') return 'Debug::show('.$arg['php'].');';
$php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php'];
return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');';
}
else {
throw new SSTemplateParseException('Debug takes 0 or 1 argument only.', $this);
}
}
/**
* This is an open block handler, for the <% base_tag %> tag
*/
function OpenBlock_Handle_Base_tag(&$res) {
if ($res['ArgumentCount'] != 0) throw new SSTemplateParseException('Base_tag takes no arguments', $this);
return '$val .= SSViewer::get_base_tag($val);';
}
/**
* This is an open block handler, for the <% current_page %> tag
*/
function OpenBlock_Handle_Current_page(&$res) {
if ($res['ArgumentCount'] != 0) throw new SSTemplateParseException('Current_page takes no arguments', $this);
return '$val .= $_SERVER[SCRIPT_URL];';
}
/* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */
protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock');
function match_MismatchedEndBlock ($stack = array()) {
$matchrule = "MismatchedEndBlock"; $result = $this->construct($matchrule, $matchrule, null);
$_586 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_586 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_586 = FALSE; break; }
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Word" );
}
else { $_586 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_586 = FALSE; break; }
$_586 = TRUE; break;
}
while(0);
if( $_586 === TRUE ) { return $this->finalise($result); }
if( $_586 === FALSE) { return FALSE; }
}
function MismatchedEndBlock__finalise(&$res) {
$blockname = $res['Word']['text'];
throw new SSTemplateParseException('Unexpected close tag end_'.$blockname.' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this);
}
/* MalformedOpenTag: '<%' < !NotBlockTag Tag:Word !( ( [ :BlockArguments ] )? > '%>' ) */
protected $match_MalformedOpenTag_typestack = array('MalformedOpenTag');
function match_MalformedOpenTag ($stack = array()) {
$matchrule = "MalformedOpenTag"; $result = $this->construct($matchrule, $matchrule, null);
$_601 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_601 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$res_590 = $result;
$pos_590 = $this->pos;
$matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$result = $res_590;
$this->pos = $pos_590;
$_601 = FALSE; break;
}
else {
$result = $res_590;
$this->pos = $pos_590;
}
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Tag" );
}
else { $_601 = FALSE; break; }
$res_600 = $result;
$pos_600 = $this->pos;
$_599 = NULL;
do {
$res_596 = $result;
$pos_596 = $this->pos;
$_595 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_595 = FALSE; break; }
$matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "BlockArguments" );
}
else { $_595 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_595 = FALSE; break; }
$_595 = TRUE; break;
}
while(0);
if( $_595 === FALSE) {
$result = $res_596;
$this->pos = $pos_596;
unset( $res_596 );
unset( $pos_596 );
}
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_599 = FALSE; break; }
$_599 = TRUE; break;
}
while(0);
if( $_599 === TRUE ) {
$result = $res_600;
$this->pos = $pos_600;
$_601 = FALSE; break;
}
if( $_599 === FALSE) {
$result = $res_600;
$this->pos = $pos_600;
}
$_601 = TRUE; break;
}
while(0);
if( $_601 === TRUE ) { return $this->finalise($result); }
if( $_601 === FALSE) { return FALSE; }
}
function MalformedOpenTag__finalise(&$res) {
$tag = $res['Tag']['text'];
throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?", $this);
}
/* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */
protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag');
function match_MalformedCloseTag ($stack = array()) {
$matchrule = "MalformedCloseTag"; $result = $this->construct($matchrule, $matchrule, null);
$_613 = NULL;
do {
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_613 = FALSE; break; }
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
$stack[] = $result; $result = $this->construct( $matchrule, "Tag" );
$_607 = NULL;
do {
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_607 = FALSE; break; }
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres, "Word" );
}
else { $_607 = FALSE; break; }
$_607 = TRUE; break;
}
while(0);
if( $_607 === TRUE ) {
$subres = $result; $result = array_pop($stack);
$this->store( $result, $subres, 'Tag' );
}
if( $_607 === FALSE) {
$result = array_pop($stack);
$_613 = FALSE; break;
}
$res_612 = $result;
$pos_612 = $this->pos;
$_611 = NULL;
do {
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_611 = FALSE; break; }
$_611 = TRUE; break;
}
while(0);
if( $_611 === TRUE ) {
$result = $res_612;
$this->pos = $pos_612;
$_613 = FALSE; break;
}
if( $_611 === FALSE) {
$result = $res_612;
$this->pos = $pos_612;
}
$_613 = TRUE; break;
}
while(0);
if( $_613 === TRUE ) { return $this->finalise($result); }
if( $_613 === FALSE) { return FALSE; }
}
function MalformedCloseTag__finalise(&$res) {
$tag = $res['Tag']['text'];
throw new SSTemplateParseException("Malformed closing block tag $tag. Perhaps you have tried to pass an argument to one?", $this);
}
/* MalformedBlock: MalformedOpenTag | MalformedCloseTag */
protected $match_MalformedBlock_typestack = array('MalformedBlock');
function match_MalformedBlock ($stack = array()) {
$matchrule = "MalformedBlock"; $result = $this->construct($matchrule, $matchrule, null);
$_618 = NULL;
do {
$res_615 = $result;
$pos_615 = $this->pos;
$matcher = 'match_'.'MalformedOpenTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_618 = TRUE; break;
}
$result = $res_615;
$this->pos = $pos_615;
$matcher = 'match_'.'MalformedCloseTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_618 = TRUE; break;
}
$result = $res_615;
$this->pos = $pos_615;
$_618 = FALSE; break;
}
while(0);
if( $_618 === TRUE ) { return $this->finalise($result); }
if( $_618 === FALSE) { return FALSE; }
}
/* Comment: "<%--" (!"--%>" /./)+ "--%>" */
protected $match_Comment_typestack = array('Comment');
function match_Comment ($stack = array()) {
$matchrule = "Comment"; $result = $this->construct($matchrule, $matchrule, null);
$_626 = NULL;
do {
if (( $subres = $this->literal( '<%--' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_626 = FALSE; break; }
$count = 0;
while (true) {
$res_624 = $result;
$pos_624 = $this->pos;
$_623 = NULL;
do {
$res_621 = $result;
$pos_621 = $this->pos;
if (( $subres = $this->literal( '--%>' ) ) !== FALSE) {
$result["text"] .= $subres;
$result = $res_621;
$this->pos = $pos_621;
$_623 = FALSE; break;
}
else {
$result = $res_621;
$this->pos = $pos_621;
}
if (( $subres = $this->rx( '/./' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_623 = FALSE; break; }
$_623 = TRUE; break;
}
while(0);
if( $_623 === FALSE) {
$result = $res_624;
$this->pos = $pos_624;
unset( $res_624 );
unset( $pos_624 );
break;
}
$count += 1;
}
if ($count > 0) { }
else { $_626 = FALSE; break; }
if (( $subres = $this->literal( '--%>' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_626 = FALSE; break; }
$_626 = TRUE; break;
}
while(0);
if( $_626 === TRUE ) { return $this->finalise($result); }
if( $_626 === FALSE) { return FALSE; }
}
function Comment__construct(&$res) {
$res['php'] = '';
}
/* TopTemplate: (Comment | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | OpenBlock | MalformedBlock | MismatchedEndBlock | Injection | Text)+ */
protected $match_TopTemplate_typestack = array('TopTemplate','Template');
function match_TopTemplate ($stack = array()) {
$matchrule = "TopTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'Template'));
$count = 0;
while (true) {
$res_678 = $result;
$pos_678 = $this->pos;
$_677 = NULL;
do {
$_675 = NULL;
do {
$res_628 = $result;
$pos_628 = $this->pos;
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_675 = TRUE; break;
}
$result = $res_628;
$this->pos = $pos_628;
$_673 = NULL;
do {
$res_630 = $result;
$pos_630 = $this->pos;
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_673 = TRUE; break;
}
$result = $res_630;
$this->pos = $pos_630;
$_671 = NULL;
do {
$res_632 = $result;
$pos_632 = $this->pos;
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_671 = TRUE; break;
}
$result = $res_632;
$this->pos = $pos_632;
$_669 = NULL;
do {
$res_634 = $result;
$pos_634 = $this->pos;
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_669 = TRUE; break;
}
$result = $res_634;
$this->pos = $pos_634;
$_667 = NULL;
do {
$res_636 = $result;
$pos_636 = $this->pos;
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_667 = TRUE; break;
}
$result = $res_636;
$this->pos = $pos_636;
$_665 = NULL;
do {
$res_638 = $result;
$pos_638 = $this->pos;
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_665 = TRUE; break;
}
$result = $res_638;
$this->pos = $pos_638;
$_663 = NULL;
do {
$res_640 = $result;
$pos_640 = $this->pos;
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_663 = TRUE; break;
}
$result = $res_640;
$this->pos = $pos_640;
$_661 = NULL;
do {
$res_642 = $result;
$pos_642 = $this->pos;
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_661 = TRUE; break;
}
$result = $res_642;
$this->pos = $pos_642;
$_659 = NULL;
do {
$res_644 = $result;
$pos_644 = $this->pos;
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_659 = TRUE; break;
}
$result = $res_644;
$this->pos = $pos_644;
$_657 = NULL;
do {
$res_646 = $result;
$pos_646 = $this->pos;
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_657 = TRUE; break;
}
$result = $res_646;
$this->pos = $pos_646;
$_655 = NULL;
do {
$res_648 = $result;
$pos_648 = $this->pos;
$matcher = 'match_'.'MismatchedEndBlock'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_655 = TRUE; break;
}
$result = $res_648;
$this->pos = $pos_648;
$_653 = NULL;
do {
$res_650 = $result;
$pos_650 = $this->pos;
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_653 = TRUE; break;
}
$result = $res_650;
$this->pos = $pos_650;
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos;
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) );
if ($subres !== FALSE) {
$this->store( $result, $subres );
$_653 = TRUE; break;
}
$result = $res_650;
$this->pos = $pos_650;
$_653 = FALSE; break;
}
while(0);
if( $_653 === TRUE ) { $_655 = TRUE; break; }
$result = $res_648;
$this->pos = $pos_648;
$_655 = FALSE; break;
}
while(0);
if( $_655 === TRUE ) { $_657 = TRUE; break; }
$result = $res_646;
$this->pos = $pos_646;
$_657 = FALSE; break;
}
while(0);
if( $_657 === TRUE ) { $_659 = TRUE; break; }
$result = $res_644;
$this->pos = $pos_644;
$_659 = FALSE; break;
}
while(0);
if( $_659 === TRUE ) { $_661 = TRUE; break; }
$result = $res_642;
$this->pos = $pos_642;
$_661 = FALSE; break;
}
while(0);
if( $_661 === TRUE ) { $_663 = TRUE; break; }
$result = $res_640;
$this->pos = $pos_640;
$_663 = FALSE; break;
}
while(0);
if( $_663 === TRUE ) { $_665 = TRUE; break; }
$result = $res_638;
$this->pos = $pos_638;
$_665 = FALSE; break;
}
while(0);
if( $_665 === TRUE ) { $_667 = TRUE; break; }
$result = $res_636;
$this->pos = $pos_636;
$_667 = FALSE; break;
}
while(0);
if( $_667 === TRUE ) { $_669 = TRUE; break; }
$result = $res_634;
$this->pos = $pos_634;
$_669 = FALSE; break;
}
while(0);
if( $_669 === TRUE ) { $_671 = TRUE; break; }
$result = $res_632;
$this->pos = $pos_632;
$_671 = FALSE; break;
}
while(0);
if( $_671 === TRUE ) { $_673 = TRUE; break; }
$result = $res_630;
$this->pos = $pos_630;
$_673 = FALSE; break;
}
while(0);
if( $_673 === TRUE ) { $_675 = TRUE; break; }
$result = $res_628;
$this->pos = $pos_628;
$_675 = FALSE; break;
}
while(0);
if( $_675 === FALSE) { $_677 = FALSE; break; }
$_677 = TRUE; break;
}
while(0);
if( $_677 === FALSE) {
$result = $res_678;
$this->pos = $pos_678;
unset( $res_678 );
unset( $pos_678 );
break;
}
$count += 1;
}
if ($count > 0) { return $this->finalise($result); }
else { return FALSE; }
}
/**
* The TopTemplate also includes the opening stanza to start off the template
*/
function TopTemplate__construct(&$res) {
$res['php'] = "<?php" . PHP_EOL;
}
/* Text: (
/ [^<${\\]+ / |
/ (\\.) / |
'<' !'%' |
'$' !(/[A-Za-z_]/) |
'{' !'$' |
'{$' !(/[A-Za-z_]/)
)+ */
protected $match_Text_typestack = array('Text');
function match_Text ($stack = array()) {
$matchrule = "Text"; $result = $this->construct($matchrule, $matchrule, null);
$count = 0;
while (true) {
$res_717 = $result;
$pos_717 = $this->pos;
$_716 = NULL;
do {
$_714 = NULL;
do {
$res_679 = $result;
$pos_679 = $this->pos;
if (( $subres = $this->rx( '/ [^<${\\\\]+ /' ) ) !== FALSE) {
$result["text"] .= $subres;
$_714 = TRUE; break;
}
$result = $res_679;
$this->pos = $pos_679;
$_712 = NULL;
do {
$res_681 = $result;
$pos_681 = $this->pos;
if (( $subres = $this->rx( '/ (\\\\.) /' ) ) !== FALSE) {
$result["text"] .= $subres;
$_712 = TRUE; break;
}
$result = $res_681;
$this->pos = $pos_681;
$_710 = NULL;
do {
$res_683 = $result;
$pos_683 = $this->pos;
$_686 = NULL;
do {
if (substr($this->string,$this->pos,1) == '<') {
$this->pos += 1;
$result["text"] .= '<';
}
else { $_686 = FALSE; break; }
$res_685 = $result;
$pos_685 = $this->pos;
if (substr($this->string,$this->pos,1) == '%') {
$this->pos += 1;
$result["text"] .= '%';
$result = $res_685;
$this->pos = $pos_685;
$_686 = FALSE; break;
}
else {
$result = $res_685;
$this->pos = $pos_685;
}
$_686 = TRUE; break;
}
while(0);
if( $_686 === TRUE ) { $_710 = TRUE; break; }
$result = $res_683;
$this->pos = $pos_683;
$_708 = NULL;
do {
$res_688 = $result;
$pos_688 = $this->pos;
$_693 = NULL;
do {
if (substr($this->string,$this->pos,1) == '$') {
$this->pos += 1;
$result["text"] .= '$';
}
else { $_693 = FALSE; break; }
$res_692 = $result;
$pos_692 = $this->pos;
$_691 = NULL;
do {
if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_691 = FALSE; break; }
$_691 = TRUE; break;
}
while(0);
if( $_691 === TRUE ) {
$result = $res_692;
$this->pos = $pos_692;
$_693 = FALSE; break;
}
if( $_691 === FALSE) {
$result = $res_692;
$this->pos = $pos_692;
}
$_693 = TRUE; break;
}
while(0);
if( $_693 === TRUE ) { $_708 = TRUE; break; }
$result = $res_688;
$this->pos = $pos_688;
$_706 = NULL;
do {
$res_695 = $result;
$pos_695 = $this->pos;
$_698 = NULL;
do {
if (substr($this->string,$this->pos,1) == '{') {
$this->pos += 1;
$result["text"] .= '{';
}
else { $_698 = FALSE; break; }
$res_697 = $result;
$pos_697 = $this->pos;
if (substr($this->string,$this->pos,1) == '$') {
$this->pos += 1;
$result["text"] .= '$';
$result = $res_697;
$this->pos = $pos_697;
$_698 = FALSE; break;
}
else {
$result = $res_697;
$this->pos = $pos_697;
}
$_698 = TRUE; break;
}
while(0);
if( $_698 === TRUE ) { $_706 = TRUE; break; }
$result = $res_695;
$this->pos = $pos_695;
$_704 = NULL;
do {
if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_704 = FALSE; break; }
$res_703 = $result;
$pos_703 = $this->pos;
$_702 = NULL;
do {
if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { $result["text"] .= $subres; }
else { $_702 = FALSE; break; }
$_702 = TRUE; break;
}
while(0);
if( $_702 === TRUE ) {
$result = $res_703;
$this->pos = $pos_703;
$_704 = FALSE; break;
}
if( $_702 === FALSE) {
$result = $res_703;
$this->pos = $pos_703;
}
$_704 = TRUE; break;
}
while(0);
if( $_704 === TRUE ) { $_706 = TRUE; break; }
$result = $res_695;
$this->pos = $pos_695;
$_706 = FALSE; break;
}
while(0);
if( $_706 === TRUE ) { $_708 = TRUE; break; }
$result = $res_688;
$this->pos = $pos_688;
$_708 = FALSE; break;
}
while(0);
if( $_708 === TRUE ) { $_710 = TRUE; break; }
$result = $res_683;
$this->pos = $pos_683;
$_710 = FALSE; break;
}
while(0);
if( $_710 === TRUE ) { $_712 = TRUE; break; }
$result = $res_681;
$this->pos = $pos_681;
$_712 = FALSE; break;
}
while(0);
if( $_712 === TRUE ) { $_714 = TRUE; break; }
$result = $res_679;
$this->pos = $pos_679;
$_714 = FALSE; break;
}
while(0);
if( $_714 === FALSE) { $_716 = FALSE; break; }
$_716 = TRUE; break;
}
while(0);
if( $_716 === FALSE) {
$result = $res_717;
$this->pos = $pos_717;
unset( $res_717 );
unset( $pos_717 );
break;
}
$count += 1;
}
if ($count > 0) { return $this->finalise($result); }
else { return FALSE; }
}
/**
* We convert text
*/
function Text__finalise(&$res) {
$text = $res['text'];
// Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes
$text = stripslashes($text);
$text = addcslashes($text, '\'\\');
// TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this non-dynamically calculated
$text = preg_replace(
'/href\s*\=\s*\"\#/',
'href="\' . (SSViewer::$options[\'rewriteHashlinks\'] ? strip_tags( $_SERVER[\'REQUEST_URI\'] ) : "") . \'#',
$text
);
$res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL;
}
/******************
* Here ends the parser itself. Below are utility methods to use the parser
*/
/**
* Compiles some passed template source code into the php code that will execute as per the template source.
*
* @static
* @throws SSTemplateParseException
* @param $string - The source of the template
* @param string $templateName - The name of the template, normally the filename the template source was loaded from
* @param bool $includeDebuggingComments - True is debugging comments should be included in the output
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
*/
static function compileString($string, $templateName = "", $includeDebuggingComments=false) {
if (!trim($string)) {
$code = '';
}
else {
// Construct a parser instance
$parser = new SSTemplateParser($string);
$parser->includeDebuggingComments = $includeDebuggingComments;
// Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF (and other encodings) properly
if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $parser->pos = 3;
// Match the source against the parser
$result = $parser->match_TopTemplate();
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $parser);
// Get the result
$code = $result['php'];
}
// Include top level debugging comments if desired
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) {
// If this template is a full HTML page, then put the comments just inside the HTML tag to prevent any IE glitches
if(stripos($code, "<html") !== false) {
$code = preg_replace('/(<html[^>]*>)/i', "\\1<!-- template $templateName -->", $code);
$code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->\\1", $code);
} else {
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName . ' -->\';' . "\n", $code);
$code .= "\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';';
}
}
return $code;
}
/**
* Compiles some file that contains template source code, and returns the php code that will execute as per that
* source
*
* @static
* @param $template - A file path that contains template source code
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source
*/
static function compileFile($template) {
return self::compileString(file_get_contents($template), $template);
}
}