mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-06 13:34:11 +02:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b58771e31b | |||
| c226fbd3d9 | |||
| 25391749a1 | |||
| ec449734c3 | |||
| c8ecad0b06 | |||
| 5d8718f761 | |||
| 85e05458c6 | |||
| b8eb8784d4 | |||
| 5468f140fa | |||
| dcf53ca957 | |||
| ed740b967a | |||
| ac99173cea | |||
| bef7c55544 | |||
| e3123c0427 | |||
| d21921de22 | |||
| 22bccee350 | |||
| 0bdd805d6b | |||
| a74804b061 | |||
| 9f1061f5bc | |||
| 2db464a6e5 | |||
| 8ee805632d | |||
| dea56a2243 | |||
| e0dbc79204 | |||
| a3c89bb4f4 | |||
| 319e396937 | |||
| 3240b5a596 | |||
| 2b858212b7 | |||
| cf5b5c4e1f | |||
| 07c781d9cf | |||
| e4741e9dd7 | |||
| ece0e2241f | |||
| 3ac71869a6 | |||
| f791eeba11 | |||
| 962cf3d193 | |||
| a8f30dc7f6 | |||
| 4af23bc104 | |||
| 811e2e0e13 | |||
| 2ff51de3df |
+1
-3
@@ -5,11 +5,9 @@ php:
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
- php: hhvm
|
||||
|
||||
install:
|
||||
- git clone --depth=50 --branch=master git://github.com/smarty-php/smarty-phpunit.git
|
||||
|
||||
+38
-1
@@ -1,4 +1,41 @@
|
||||
===== 3.1.24.dev ===== (xx.xx.2015)
|
||||
===== 3.1.24===== (23.05.2015)
|
||||
23.05.2015
|
||||
- improvement on php_handling to allow very large PHP sections, better error handling
|
||||
- improvement allow extreme large comment sections (forum 25538)
|
||||
|
||||
21.05.2015
|
||||
- bugfix broken PHP 5.2 compatibility when compiling <?php tags https://github.com/smarty-php/smarty/issues/40
|
||||
- bugfix named {foreach} comparison like $smarty.foreach.foobar.index > 1 did compile into wrong code https://github.com/smarty-php/smarty/issues/41
|
||||
|
||||
19.05.2015
|
||||
- bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39
|
||||
- bugfix output filter trimwhitespace could run into the pcre.backtrack_limit on large output (code.google issue 220)
|
||||
- bugfix compiler could run into the pcre.backtrack_limit on larger comment or {php} tag sections (forum 25538)
|
||||
|
||||
18.05.2015
|
||||
- improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher
|
||||
compilation speed
|
||||
|
||||
16.05.2015
|
||||
- bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33
|
||||
- improvement remove not needed ?><?php transitions from compiled code
|
||||
- improvement reduce number of lexer tokens on operators and if conditions
|
||||
- improvement higher compilation speed by modified lexer/parser generator at "smarty/smarty-lexer"
|
||||
|
||||
13.05.2015
|
||||
- improvement remove not needed ?><?php transitions from compiled code
|
||||
- improvement of debugging:
|
||||
- use fresh Smarty object to display the debug console because of possible problems when the Smarty
|
||||
was extended or Smarty properties had been modified in the class source
|
||||
- display Smarty version number
|
||||
- Truncate lenght of Origin display and extend strin value display to 80 character
|
||||
- bugfix in Smarty_Security 'nl2br' should be a trusted modifier, not PHP function (code.google issue 223)
|
||||
|
||||
12.05.2015
|
||||
- bugfix {$smarty.constant.TEST} did fail on undefined constant https://github.com/smarty-php/smarty/issues/28
|
||||
- bugfix access to undefined config variable like {#undef#} did fail https://github.com/smarty-php/smarty/issues/29
|
||||
- bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33
|
||||
|
||||
===== 3.1.23 ===== (12.05.2015)
|
||||
12.05.2015
|
||||
- bugfix of smaller performance issue introduce in 3.1.22 when caching is enabled
|
||||
|
||||
@@ -91,6 +91,19 @@ class Smarty_Internal_Configfilelexer
|
||||
* @var array
|
||||
*/
|
||||
public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE');
|
||||
|
||||
/**
|
||||
* storage for assembled token patterns
|
||||
*
|
||||
* @var sring
|
||||
*/
|
||||
private $yy_global_pattern1 = null;
|
||||
private $yy_global_pattern2 = null;
|
||||
private $yy_global_pattern3 = null;
|
||||
private $yy_global_pattern4 = null;
|
||||
private $yy_global_pattern5 = null;
|
||||
private $yy_global_pattern6 = null;
|
||||
|
||||
/**
|
||||
* token names
|
||||
*
|
||||
|
||||
@@ -56,12 +56,6 @@ class Smarty_Internal_Templatelexer
|
||||
*/
|
||||
public $taglineno;
|
||||
/**
|
||||
* flag if parsing php script
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $is_phpScript = false;
|
||||
/**
|
||||
* php code type
|
||||
*
|
||||
* @var string
|
||||
@@ -108,50 +102,71 @@ class Smarty_Internal_Templatelexer
|
||||
*
|
||||
* @var Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
private $compiler = null;
|
||||
public $compiler = null;
|
||||
/**
|
||||
* literal tag nesting level
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $literal_cnt = 0;
|
||||
|
||||
/**
|
||||
* PHP start tag string
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
/**
|
||||
* trace file
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
public $yyTraceFILE;
|
||||
|
||||
/**
|
||||
* trace prompt
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
||||
public $yyTracePrompt;
|
||||
|
||||
/**
|
||||
* state names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $state_name = array(1 => 'TEXT', 2 => 'SMARTY', 3 => 'LITERAL', 4 => 'DOUBLEQUOTEDSTRING', 5 => 'CHILDBODY');
|
||||
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',
|
||||
6 => 'CHILDBODY', 7 => 'CHILDBLOCK', 8 => 'CHILDLITERAL');
|
||||
|
||||
/**
|
||||
* storage for assembled token patterns
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $yy_global_pattern1 = null;
|
||||
|
||||
private $yy_global_pattern2 = null;
|
||||
|
||||
private $yy_global_pattern3 = null;
|
||||
|
||||
private $yy_global_pattern4 = null;
|
||||
|
||||
private $yy_global_pattern5 = null;
|
||||
|
||||
private $yy_global_pattern6 = null;
|
||||
|
||||
private $yy_global_pattern7 = null;
|
||||
|
||||
private $yy_global_pattern8 = null;
|
||||
|
||||
/**
|
||||
* token names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $smarty_token_names = array( // Text for parser error messages
|
||||
'IDENTITY' => '===',
|
||||
'NONEIDENTITY' => '!==',
|
||||
'EQUALS' => '==',
|
||||
'NOTEQUALS' => '!=',
|
||||
'GREATEREQUAL' => '(>=,ge)',
|
||||
'LESSEQUAL' => '(<=,le)',
|
||||
'GREATERTHAN' => '(>,gt)',
|
||||
'LESSTHAN' => '(<,lt)',
|
||||
'MOD' => '(%,mod)',
|
||||
public $smarty_token_names = array( // Text for parser error messages
|
||||
'NOT' => '(!,not)',
|
||||
'LAND' => '(&&,and)',
|
||||
'LOR' => '(||,or)',
|
||||
'LXOR' => 'xor',
|
||||
'OPENP' => '(',
|
||||
'CLOSEP' => ')',
|
||||
'OPENB' => '[',
|
||||
@@ -172,22 +187,21 @@ class Smarty_Internal_Templatelexer
|
||||
'HATCH' => '#',
|
||||
'QUOTE' => '"',
|
||||
'BACKTICK' => '`',
|
||||
'VERT' => '|',
|
||||
'VERT' => '"|" modifier',
|
||||
'DOT' => '.',
|
||||
'COMMA' => '","',
|
||||
'ANDSYM' => '"&"',
|
||||
'QMARK' => '"?"',
|
||||
'ID' => 'identifier',
|
||||
'ID' => 'id, name',
|
||||
'TEXT' => 'text',
|
||||
'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
|
||||
'PHPSTARTTAG' => 'PHP start tag',
|
||||
'PHPENDTAG' => 'PHP end tag',
|
||||
'LITERALSTART' => 'Literal start',
|
||||
'LITERALEND' => 'Literal end',
|
||||
'LDELSLASH' => 'closing tag',
|
||||
'LDELSLASH' => '{/..} closing tag',
|
||||
'LDEL' => '{...} Smarty tag',
|
||||
'COMMENT' => 'comment',
|
||||
'AS' => 'as',
|
||||
'TO' => 'to',
|
||||
'PHP' => '"<?php", "<%", "{php}" tag',
|
||||
'LOGOP' => '"<", "==" ... logical operator',
|
||||
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
|
||||
'SCOND' => '"is even" ... if condition',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -200,25 +214,33 @@ class Smarty_Internal_Templatelexer
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->counter = 0;
|
||||
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
|
||||
if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) {
|
||||
$this->counter += strlen($match[0]);
|
||||
}
|
||||
$this->line = 1;
|
||||
$this->smarty = $compiler->smarty;
|
||||
$this->compiler = $compiler;
|
||||
$this->ldel = preg_quote($this->smarty->left_delimiter, '/');
|
||||
$this->ldel = preg_quote($this->smarty->left_delimiter, '~');
|
||||
$this->ldel_length = strlen($this->smarty->left_delimiter);
|
||||
$this->rdel = preg_quote($this->smarty->right_delimiter, '/');
|
||||
$this->rdel = preg_quote($this->smarty->right_delimiter, '~');
|
||||
$this->rdel_length = strlen($this->smarty->right_delimiter);
|
||||
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
|
||||
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
|
||||
}
|
||||
|
||||
public function PrintTrace()
|
||||
{
|
||||
public function PrintTrace()
|
||||
{
|
||||
$this->yyTraceFILE = fopen('php://output', 'w');
|
||||
$this->yyTracePrompt = '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if this tag is autoliteral
|
||||
*/
|
||||
public function isAutoLiteral ()
|
||||
{
|
||||
return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false;
|
||||
}
|
||||
|
||||
/*!lex2php
|
||||
%input $this->data
|
||||
@@ -226,92 +248,67 @@ class Smarty_Internal_Templatelexer
|
||||
%token $this->token
|
||||
%value $this->value
|
||||
%line $this->line
|
||||
linebreak = /[\t ]*[\r\n]+[\t ]*/
|
||||
text = /[\S\s]/
|
||||
textdoublequoted = /([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))/
|
||||
dollarid = /\$[0-9]*[a-zA-Z_]\w*/
|
||||
namespace = /([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+/
|
||||
all = /[\S\s]+/
|
||||
emptyjava = /\{\}/
|
||||
xmltag = /<\?xml\s+([\S\s]*?)\?>/
|
||||
php = /(<\?(?:php\s+|=)?)((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*(.)*?\*\/)|.)*?)\?>/
|
||||
phpscript = /<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*(.)*?\*\/)|.)*?)<\/script>/
|
||||
phptag = /(SMARTYldel\s*php\s*(.)*?SMARTYrdel((.)*?)SMARTYldel\s*\/php\s*SMARTYrdel)|(SMARTYldel\s*[\/]?php\s*(.)*?SMARTYrdel)/
|
||||
asp = /<%((('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*")|(\/\*(.)*?\*\/)|.)*?)%>/
|
||||
unmatched = /(<(\?(?:php\s+|=)?|(script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)|%))|\?>|%>/
|
||||
slash = /\//
|
||||
ldel = /SMARTYldel\s*/
|
||||
rdel = /\s*SMARTYrdel/
|
||||
smartyblockchildparent = /[\$]smarty\.block\.(child|parent)/
|
||||
integer = /\d+/
|
||||
hex = /0[xX][0-9a-fA-F]+/
|
||||
math = /\s*(\*|\/|\%)\s*/
|
||||
comment = /SMARTYldel\*([\S\s]*?)\*SMARTYrdel/
|
||||
incdec = /\+\+|\-\-/
|
||||
unimath = /\s*(\+|\-)\s*/
|
||||
openP = /\s*\(\s*/
|
||||
closeP = /\s*\)/
|
||||
openB = /\[\s*/
|
||||
closeB = /\s*\]/
|
||||
dollar = /\$/
|
||||
dot = /\./
|
||||
comma = /\s*\,\s*/
|
||||
doublecolon = /\:\:/
|
||||
colon = /\s*\:\s*/
|
||||
at = /@/
|
||||
hatch = /#/
|
||||
semicolon = /\s*\;/
|
||||
equal = /\s*=\s*/
|
||||
space = /\s+/
|
||||
ptr = /\s*\->\s*/
|
||||
aptr = /\s*=>\s*/
|
||||
singlequotestring = /'[^'\\]*(?:\\.[^'\\]*)*'/
|
||||
backtick = /`/
|
||||
backtickdollar = /`\$/
|
||||
vert = /\|/
|
||||
andsym = /\s*\&\s*/
|
||||
qmark = /\s*\?\s*/
|
||||
constant = /([_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*)(?![0-9A-Z_]*[a-z])/
|
||||
attr = /\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*=\s*/
|
||||
id = /[0-9]*[a-zA-Z_]\w*/
|
||||
literal = /literal/
|
||||
strip = /strip/
|
||||
equals = /\s*==\s*|\s+eq\s+/
|
||||
notequals = /\s*!=\s*|\s*<>\s*|\s+(ne|neq)\s+/
|
||||
greaterthan = /\s*>\s*|\s+gt\s+/
|
||||
lessthan = /\s*<\s*|\s+lt\s+/
|
||||
greaterequal = /\s*>=\s*|\s+(ge|gte)\s+/
|
||||
lessequal = /\s*<=\s*|\s+(le|lte)\s+/
|
||||
mod = /\s+mod\s+/
|
||||
identity = /\s*===\s*/
|
||||
noneidentity = /\s*!==\s*/
|
||||
isoddby = /\s+is\s+odd\s+by\s+/
|
||||
isnotoddby = /\s+is\s+not\s+odd\s+by\s+/
|
||||
isodd = /\s+is\s+odd/
|
||||
isnotodd = /\s+is\s+not\s+odd/
|
||||
isevenby = /\s+is\s+even\s+by\s+/
|
||||
isnotevenby = /\s+is\s+not\s+even\s+by\s+/
|
||||
iseven = /\s+is\s+even/
|
||||
isnoteven = /\s+is\s+not\s+even/
|
||||
isdivby = /\s+is\s+div\s+by\s+/
|
||||
isnotdivby = /\s+is\s+not\s+div\s+by\s+/
|
||||
isin = /\s+is\s+in\s+/
|
||||
as = /\s+as\s+/
|
||||
to = /\s+to\s+/
|
||||
step = /\s+step\s+/
|
||||
block = /block/
|
||||
if = /(if|elseif|else if|while)\s+/
|
||||
for = /for\s+/
|
||||
foreach = /foreach(?![^\s])/
|
||||
setfilter = /setfilter\s+/
|
||||
instanceof = /\s+instanceof\s+/
|
||||
not = /!\s*|not\s+/
|
||||
land = /\s*\&\&\s*|\s*and\s+/
|
||||
lor = /\s*\|\|\s*|\s*or\s+/
|
||||
lxor = /\s*xor\s+/
|
||||
typecast = /\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\)\s*/
|
||||
double_quote = /"/
|
||||
single_quote = /'/
|
||||
linebreak = ~[\t ]*[\r\n]+[\t ]*~
|
||||
text = ~[\S\s]~
|
||||
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))~
|
||||
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
|
||||
all = ~[\S\s]+~
|
||||
emptyjava = ~[{][}]~
|
||||
phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])|(SMARTYldel\s*php(.*?)SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
|
||||
slash = ~[/]~
|
||||
ldel = ~SMARTYldel\s*~
|
||||
rdel = ~\s*SMARTYrdel~
|
||||
nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~
|
||||
notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~
|
||||
smartyblockchildparent = ~[\$]smarty\.block\.(child|parent)~
|
||||
integer = ~\d+~
|
||||
hex = ~0[xX][0-9a-fA-F]+~
|
||||
math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~
|
||||
comment = ~SMARTYldel[*]~
|
||||
incdec = ~([+]|[-]){2}~
|
||||
unimath = ~\s*([+]|[-])\s*~
|
||||
openP = ~\s*[(]\s*~
|
||||
closeP = ~\s*[)]~
|
||||
openB = ~\[\s*~
|
||||
closeB = ~\s*\]~
|
||||
dollar = ~[$]~
|
||||
dot = ~[.]~
|
||||
comma = ~\s*[,]\s*~
|
||||
doublecolon = ~[:]{2}~
|
||||
colon = ~\s*[:]\s*~
|
||||
at = ~[@]~
|
||||
hatch = ~[#]~
|
||||
semicolon = ~\s*[;]\s*~
|
||||
equal = ~\s*[=]\s*~
|
||||
space = ~\s+~
|
||||
ptr = ~\s*[-][>]\s*~
|
||||
aptr = ~\s*[=][>]\s*~
|
||||
singlequotestring = ~'[^'\\]*(?:\\.[^'\\]*)*'~
|
||||
backtick = ~[`]~
|
||||
vert = ~[|]~
|
||||
qmark = ~\s*[?]\s*~
|
||||
constant = ~([_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*)(?![0-9A-Z_]*[a-z])~
|
||||
attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~
|
||||
id = ~[0-9]*[a-zA-Z_]\w*~
|
||||
literal = ~literal~
|
||||
strip = ~strip~
|
||||
lop = ~\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*~
|
||||
tlop = ~\s+(eq|ne|neg|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\s+(not\s+)?(odd|even|div)\s+by))\s+~
|
||||
scond = ~\s+is\s+(not\s+)?(odd|even)~
|
||||
isin = ~\s+is\s+in\s+~
|
||||
as = ~\s+as\s+~
|
||||
to = ~\s+to\s+~
|
||||
step = ~\s+step\s+~
|
||||
block = ~block~
|
||||
if = ~(if|elseif|else if|while)\s+~
|
||||
for = ~for\s+~
|
||||
foreach = ~foreach(?![^\s])~
|
||||
setfilter = ~setfilter\s+~
|
||||
instanceof = ~\s+instanceof\s+~
|
||||
not = ~([!]\s*)|(not\s+)~
|
||||
typecast = ~[(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\s*~
|
||||
double_quote = ~["]~
|
||||
single_quote = ~[']~
|
||||
*/
|
||||
/*!lex2php
|
||||
%statename TEXT
|
||||
@@ -319,21 +316,19 @@ class Smarty_Internal_Templatelexer
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
comment {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_COMMENT;
|
||||
preg_match("~[*]{$this->rdel}~",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1] + strlen($match[0][0]);
|
||||
} else {
|
||||
$this->compiler->trigger_template_error ("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
|
||||
}
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
return false;
|
||||
}
|
||||
ldel strip rdel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_STRIPON;
|
||||
}
|
||||
}
|
||||
ldel slash strip rdel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
|
||||
}
|
||||
phpstart {
|
||||
$obj = new Smarty_Internal_Compile_Private_Php();
|
||||
$obj->parsePhp($this);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
}
|
||||
ldel literal rdel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
@@ -343,110 +338,81 @@ class Smarty_Internal_Templatelexer
|
||||
$this->yypushstate(self::LITERAL);
|
||||
}
|
||||
}
|
||||
ldel if {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel for {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel foreach {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel setfilter {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
phptag {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
$this->phpType = 'tag';
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel slash {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
$this->yypushstate(self::TAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rdel {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
xmltag {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
asp {
|
||||
$this->phpType = 'asp';
|
||||
$this->taglineno = $this->line;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
}
|
||||
php {
|
||||
$this->phpType = 'php';
|
||||
$this->taglineno = $this->line;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
}
|
||||
phpscript {
|
||||
$this->phpType = 'script';
|
||||
$this->taglineno = $this->line;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
}
|
||||
unmatched {
|
||||
$this->phpType = 'unmatched';
|
||||
$this->taglineno = $this->line;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_PHP;
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
preg_match("/{$this->ldel}|<\?|<%|\?>|%>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
preg_match("~($this->ldel)|([<]script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|([<][?])|([<][%])|([?][>])|([%][>])~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
}
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/*!lex2php
|
||||
%statename SMARTY
|
||||
%statename TAG
|
||||
ldel if {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yybegin(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel for {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yybegin(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel foreach {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yybegin(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel setfilter {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
|
||||
$this->yybegin(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel id nocacherdel {
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel slash notblockid rdel {
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel dollar id nocacherdel {
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel slash {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yybegin(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
ldel {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yybegin(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
*/
|
||||
/*!lex2php
|
||||
%statename TAGBODY
|
||||
rdel {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
|
||||
$this->yypopstate();
|
||||
}
|
||||
double_quote {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
|
||||
$this->yypushstate(self::DOUBLEQUOTEDSTRING);
|
||||
@@ -458,13 +424,12 @@ class Smarty_Internal_Templatelexer
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
dollar id {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
|
||||
}
|
||||
dollar {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
|
||||
}
|
||||
rdel {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
|
||||
$this->yypopstate();
|
||||
}
|
||||
isin {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISIN;
|
||||
}
|
||||
@@ -480,76 +445,18 @@ class Smarty_Internal_Templatelexer
|
||||
instanceof {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
|
||||
}
|
||||
identity{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
|
||||
lop {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LOGOP;
|
||||
}
|
||||
noneidentity{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
|
||||
tlop {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
|
||||
}
|
||||
equals{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_EQUALS;
|
||||
}
|
||||
notequals{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
|
||||
}
|
||||
greaterequal{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
|
||||
}
|
||||
lessequal{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
|
||||
}
|
||||
greaterthan{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
|
||||
}
|
||||
lessthan{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
|
||||
}
|
||||
mod{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_MOD;
|
||||
scond {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
|
||||
}
|
||||
not{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_NOT;
|
||||
}
|
||||
land {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LAND;
|
||||
}
|
||||
lor {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LOR;
|
||||
}
|
||||
lxor {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LXOR;
|
||||
}
|
||||
isoddby {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
|
||||
}
|
||||
isnotoddby {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
|
||||
}
|
||||
|
||||
isodd {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISODD;
|
||||
}
|
||||
isnotodd {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
|
||||
}
|
||||
isevenby {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
|
||||
}
|
||||
isnotevenby {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
|
||||
}
|
||||
iseven{
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
|
||||
}
|
||||
isnoteven {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
|
||||
}
|
||||
isdivby {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
|
||||
}
|
||||
isnotdivby {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
|
||||
}
|
||||
typecast {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
|
||||
}
|
||||
@@ -562,7 +469,6 @@ class Smarty_Internal_Templatelexer
|
||||
openB {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
|
||||
}
|
||||
|
||||
closeB {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
|
||||
}
|
||||
@@ -593,7 +499,7 @@ class Smarty_Internal_Templatelexer
|
||||
attr {
|
||||
// resolve conflicts with shorttag and right_delimiter starting with '='
|
||||
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
|
||||
preg_match("/\s+/",$this->value,$match);
|
||||
preg_match("~\s+~",$this->value,$match);
|
||||
$this->value = $match[0];
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
|
||||
} else {
|
||||
@@ -631,9 +537,6 @@ class Smarty_Internal_Templatelexer
|
||||
colon {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_COLON;
|
||||
}
|
||||
andsym {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
|
||||
}
|
||||
qmark {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
|
||||
}
|
||||
@@ -643,49 +546,12 @@ class Smarty_Internal_Templatelexer
|
||||
space {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
|
||||
}
|
||||
ldel if {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel for {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel foreach {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel slash {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
$this->yypushstate(self::TAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
text {
|
||||
@@ -710,7 +576,7 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
preg_match("/{$this->ldel}\/?literal{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
} else {
|
||||
@@ -722,72 +588,50 @@ class Smarty_Internal_Templatelexer
|
||||
*/
|
||||
/*!lex2php
|
||||
%statename DOUBLEQUOTEDSTRING
|
||||
ldel if {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel for {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel foreach {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
}
|
||||
ldel literal rdel {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
ldel slash literal rdel {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
|
||||
ldel slash {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
$this->yypushstate(self::TAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ldel id {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->yypushstate(self::TAG);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ldel {
|
||||
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->taglineno = $this->line;
|
||||
$this->yypushstate(self::TAGBODY);
|
||||
}
|
||||
}
|
||||
double_quote {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
backtickdollar {
|
||||
backtick dollar {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
|
||||
$this->value = substr($this->value,0,-1);
|
||||
$this->yypushstate(self::SMARTY);
|
||||
$this->yypushstate(self::TAGBODY);
|
||||
$this->taglineno = $this->line;
|
||||
}
|
||||
dollarid {
|
||||
dollar id {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
|
||||
}
|
||||
|
||||
dollar {
|
||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
}
|
||||
@@ -826,7 +670,7 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
preg_match("/SMARTYldel\s*((\/)?strip\s*SMARTYrdel|block\s+)/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
preg_match("~SMARTYldel\s*(([/])?strip\s*SMARTYrdel|block\s+)~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
}
|
||||
@@ -871,7 +715,7 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
preg_match("/SMARTYldel\s*(literal\s*SMARTYrdel|(\/)?block(\s|SMARTYrdel)|[\$]smarty\.block\.(child|parent))/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
preg_match("~SMARTYldel\s*(literal\s*SMARTYrdel|([/])?block(\s|SMARTYrdel)|[\$]smarty\.block\.(child|parent))~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
}
|
||||
@@ -899,7 +743,7 @@ class Smarty_Internal_Templatelexer
|
||||
}
|
||||
text {
|
||||
$to = strlen($this->data);
|
||||
preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
preg_match("~{$this->ldel}[/]?literal\s*{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
} else {
|
||||
|
||||
@@ -124,13 +124,6 @@ class Smarty_Internal_Templateparser
|
||||
*/
|
||||
private $security = null;
|
||||
|
||||
/**
|
||||
* PHP tag handling mode
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $php_handling = 0;
|
||||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
@@ -143,13 +136,7 @@ class Smarty_Internal_Templateparser
|
||||
$this->compiler = $compiler;
|
||||
$this->template = $this->compiler->template;
|
||||
$this->smarty = $this->template->smarty;
|
||||
$this->compiler->has_variable_string = false;
|
||||
$this->compiler->prefix_code = array();
|
||||
if ($this->security = isset($this->smarty->security_policy)) {
|
||||
$this->php_handling = $this->smarty->security_policy->php_handling;
|
||||
} else {
|
||||
$this->php_handling = $this->smarty->php_handling;
|
||||
}
|
||||
$this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false;
|
||||
$this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template($this);
|
||||
}
|
||||
|
||||
@@ -162,6 +149,25 @@ class Smarty_Internal_Templateparser
|
||||
{
|
||||
$this->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($this, $code));
|
||||
}
|
||||
|
||||
/**
|
||||
* merge PHP code with prefix code and return parse tree tag object
|
||||
*
|
||||
* @param string $code
|
||||
*
|
||||
* @return Smarty_Internal_ParseTree_Tag
|
||||
*/
|
||||
public function mergePrefixCode($code)
|
||||
{
|
||||
$tmp ='';
|
||||
foreach ($this->compiler->prefix_code as $preCode) {
|
||||
$tmp = empty($tmp) ? $preCode : $this->compiler->appendCode($tmp, $preCode);
|
||||
}
|
||||
$this->compiler->prefix_code=array();
|
||||
$tmp = empty($tmp) ? $code : $this->compiler->appendCode($tmp, $code);
|
||||
return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp,true));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
%token_prefix TP_
|
||||
@@ -221,22 +227,16 @@ template ::= .
|
||||
// template elements
|
||||
//
|
||||
// Smarty tag
|
||||
template_element(res)::= smartytag(st) RDEL. {
|
||||
if ($this->compiler->has_code) {
|
||||
$tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
|
||||
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.st,true));
|
||||
} else {
|
||||
res = null;
|
||||
}
|
||||
template_element(res)::= smartytag(st). {
|
||||
if ($this->compiler->has_code) {
|
||||
res = $this->mergePrefixCode(st);
|
||||
} else {
|
||||
res = null;
|
||||
}
|
||||
$this->compiler->has_variable_string = false;
|
||||
$this->block_nesting_level = count($this->compiler->_tag_stack);
|
||||
}
|
||||
|
||||
// comments
|
||||
template_element(res)::= COMMENT(c). {
|
||||
res = null;
|
||||
}
|
||||
|
||||
// Literal
|
||||
template_element(res) ::= literal(l). {
|
||||
res = new Smarty_Internal_ParseTree_Text($this, l);
|
||||
@@ -252,17 +252,6 @@ template_element(res)::= PHP(o). {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// XML tag
|
||||
template_element(res)::= XMLTAG(x). {
|
||||
$this->compiler->tag_nocache = true;
|
||||
$xml = x;
|
||||
$save = $this->template->has_nocache_code;
|
||||
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{$xml}';?>", $this->compiler, true));
|
||||
$this->template->has_nocache_code = $save;
|
||||
}
|
||||
|
||||
// template text
|
||||
template_element(res)::= text_content(t). {
|
||||
res = $this->compiler->processText(t);
|
||||
@@ -318,28 +307,49 @@ literal_element(res) ::= LITERAL(l). {
|
||||
res = l;
|
||||
}
|
||||
|
||||
smartytag(res) ::= tag(t) RDEL. {
|
||||
res = t;
|
||||
}
|
||||
//
|
||||
// output tags start here
|
||||
//
|
||||
smartytag(res) ::= SIMPELOUTPUT(i). {
|
||||
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $');
|
||||
if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
|
||||
res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\'')));
|
||||
} else {
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$this->compiler->compileVariable('\''.$var.'\'')));
|
||||
}
|
||||
}
|
||||
|
||||
// output with optional attributes
|
||||
smartytag(res) ::= LDEL value(e). {
|
||||
tag(res) ::= LDEL variable(e). {
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL value(e) modifierlist(l) attributes(a). {
|
||||
tag(res) ::= LDEL variable(e) modifierlist(l) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e, 'modifierlist'=>l));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL value(e) attributes(a). {
|
||||
tag(res) ::= LDEL variable(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
|
||||
}
|
||||
tag(res) ::= LDEL value(e). {
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
|
||||
}
|
||||
tag(res) ::= LDEL value(e) modifierlist(l) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e, 'modifierlist'=>l));
|
||||
}
|
||||
|
||||
tag(res) ::= LDEL value(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL expr(e) modifierlist(l) attributes(a). {
|
||||
tag(res) ::= LDEL expr(e) modifierlist(l) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e,'modifierlist'=>l));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL expr(e) attributes(a). {
|
||||
tag(res) ::= LDEL expr(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
|
||||
}
|
||||
|
||||
@@ -348,37 +358,59 @@ smartytag(res) ::= LDEL expr(e) attributes(a). {
|
||||
//
|
||||
|
||||
// assign new style
|
||||
smartytag(res) ::= LDEL DOLLAR ID(i) EQUAL value(e). {
|
||||
res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>"'".i."'")));
|
||||
tag(res) ::= LDEL DOLLARID(i) EQUAL value(e). {
|
||||
res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL DOLLAR ID(i) EQUAL expr(e). {
|
||||
res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>"'".i."'")));
|
||||
tag(res) ::= LDEL DOLLARID(i) EQUAL expr(e). {
|
||||
res = $this->compiler->compileTag('assign',array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL DOLLAR ID(i) EQUAL expr(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>"'".i."'")),a));
|
||||
tag(res) ::= LDEL DOLLARID(i) EQUAL expr(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>'\''.substr(i,1).'\'')),a));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDEL varindexed(vi) EQUAL expr(e) attributes(a). {
|
||||
tag(res) ::= LDEL varindexed(vi) EQUAL expr(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('assign',array_merge(array(array('value'=>e),array('var'=>vi['var'])),a),array('smarty_internal_index'=>vi['smarty_internal_index']));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// simple tag like {name}
|
||||
smartytag(res)::= SIMPLETAG(t). {
|
||||
$tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length));
|
||||
if ($tag == 'strip') {
|
||||
$this->strip = true;
|
||||
res = null;;
|
||||
} else {
|
||||
if (defined($tag)) {
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant($tag, $this->compiler);
|
||||
}
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$tag));
|
||||
} else {
|
||||
if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) {
|
||||
res = $this->compiler->compileTag($match[1],array('nocache'));
|
||||
} else {
|
||||
res = $this->compiler->compileTag($tag,array());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tag with optional Smarty2 style attributes
|
||||
smartytag(res) ::= LDEL ID(i) attributes(a). {
|
||||
tag(res) ::= LDEL ID(i) attributes(a). {
|
||||
if (defined(i)) {
|
||||
if (isset($this->smarty->security_policy)) {
|
||||
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant(i, $this->compiler);
|
||||
}
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i));
|
||||
} else {
|
||||
res = $this->compiler->compileTag(i,a);
|
||||
}
|
||||
}
|
||||
smartytag(res) ::= LDEL ID(i). {
|
||||
tag(res) ::= LDEL ID(i). {
|
||||
if (defined(i)) {
|
||||
if (isset($this->smarty->security_policy)) {
|
||||
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant(i, $this->compiler);
|
||||
}
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>i));
|
||||
} else {
|
||||
@@ -388,10 +420,10 @@ smartytag(res) ::= LDEL ID(i). {
|
||||
|
||||
|
||||
// tag with modifier and optional Smarty2 style attributes
|
||||
smartytag(res) ::= LDEL ID(i) modifierlist(l)attributes(a). {
|
||||
tag(res) ::= LDEL ID(i) modifierlist(l)attributes(a). {
|
||||
if (defined(i)) {
|
||||
if (isset($this->smarty->security_policy)) {
|
||||
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant(i, $this->compiler);
|
||||
}
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i, 'modifierlist'=>l));
|
||||
} else {
|
||||
@@ -401,39 +433,39 @@ smartytag(res) ::= LDEL ID(i) modifierlist(l)attributes(a). {
|
||||
}
|
||||
|
||||
// registered object tag
|
||||
smartytag(res) ::= LDEL ID(i) PTR ID(m) attributes(a). {
|
||||
tag(res) ::= LDEL ID(i) PTR ID(m) attributes(a). {
|
||||
res = $this->compiler->compileTag(i,a,array('object_method'=>m));
|
||||
}
|
||||
|
||||
// registered object tag with modifiers
|
||||
smartytag(res) ::= LDEL ID(i) PTR ID(me) modifierlist(l) attributes(a). {
|
||||
tag(res) ::= LDEL ID(i) PTR ID(me) modifierlist(l) attributes(a). {
|
||||
res = '<?php ob_start();?>'.$this->compiler->compileTag(i,a,array('object_method'=>me)).'<?php echo ';
|
||||
res .= $this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>l,'value'=>'ob_get_clean()')).';?>';
|
||||
}
|
||||
|
||||
// {if}, {elseif} and {while} tag
|
||||
smartytag(res) ::= LDELIF(i) expr(ie). {
|
||||
tag(res) ::= LDELIF(i) expr(ie). {
|
||||
$tag = trim(substr(i,$this->lex->ldel_length));
|
||||
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELIF(i) expr(ie) attributes(a). {
|
||||
tag(res) ::= LDELIF(i) expr(ie) attributes(a). {
|
||||
$tag = trim(substr(i,$this->lex->ldel_length));
|
||||
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELIF(i) statement(ie). {
|
||||
tag(res) ::= LDELIF(i) statement(ie). {
|
||||
$tag = trim(substr(i,$this->lex->ldel_length));
|
||||
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELIF(i) statement(ie) attributes(a). {
|
||||
tag(res) ::= LDELIF(i) statement(ie) attributes(a). {
|
||||
$tag = trim(substr(i,$this->lex->ldel_length));
|
||||
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie));
|
||||
}
|
||||
|
||||
// {for} tag
|
||||
smartytag(res) ::= LDELFOR statements(st) SEMICOLON optspace expr(ie) SEMICOLON optspace DOLLAR varvar(v2) foraction(e2) attributes(a). {
|
||||
tag(res) ::= LDELFOR statements(st) SEMICOLON expr(ie) SEMICOLON varindexed(v2) foraction(e2) attributes(a). {
|
||||
res = $this->compiler->compileTag('for',array_merge(a,array(array('start'=>st),array('ifexp'=>ie),array('var'=>v2),array('step'=>e2))),1);
|
||||
}
|
||||
|
||||
@@ -445,47 +477,47 @@ smartytag(res) ::= LDELFOR statements(st) SEMICOLON optspace expr(ie) SEMICOLO
|
||||
res = e;
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELFOR statement(st) TO expr(v) attributes(a). {
|
||||
tag(res) ::= LDELFOR statement(st) TO expr(v) attributes(a). {
|
||||
res = $this->compiler->compileTag('for',array_merge(a,array(array('start'=>st),array('to'=>v))),0);
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELFOR statement(st) TO expr(v) STEP expr(v2) attributes(a). {
|
||||
tag(res) ::= LDELFOR statement(st) TO expr(v) STEP expr(v2) attributes(a). {
|
||||
res = $this->compiler->compileTag('for',array_merge(a,array(array('start'=>st),array('to'=>v),array('step'=>v2))),0);
|
||||
}
|
||||
|
||||
// {foreach} tag
|
||||
smartytag(res) ::= LDELFOREACH attributes(a). {
|
||||
tag(res) ::= LDELFOREACH attributes(a). {
|
||||
res = $this->compiler->compileTag('foreach',a);
|
||||
}
|
||||
|
||||
// {foreach $array as $var} tag
|
||||
smartytag(res) ::= LDELFOREACH SPACE value(v1) AS DOLLAR varvar(v0) attributes(a). {
|
||||
tag(res) ::= LDELFOREACH SPACE value(v1) AS varvar(v0) attributes(a). {
|
||||
res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>v1),array('item'=>v0))));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELFOREACH SPACE value(v1) AS DOLLAR varvar(v2) APTR DOLLAR varvar(v0) attributes(a). {
|
||||
tag(res) ::= LDELFOREACH SPACE value(v1) AS varvar(v2) APTR varvar(v0) attributes(a). {
|
||||
res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>v1),array('item'=>v0),array('key'=>v2))));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELFOREACH SPACE expr(e) AS DOLLAR varvar(v0) attributes(a). {
|
||||
tag(res) ::= LDELFOREACH SPACE expr(e) AS varvar(v0) attributes(a). {
|
||||
res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>e),array('item'=>v0))));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELFOREACH SPACE expr(e) AS DOLLAR varvar(v1) APTR DOLLAR varvar(v0) attributes(a). {
|
||||
tag(res) ::= LDELFOREACH SPACE expr(e) AS varvar(v1) APTR varvar(v0) attributes(a). {
|
||||
res = $this->compiler->compileTag('foreach',array_merge(a,array(array('from'=>e),array('item'=>v0),array('key'=>v1))));
|
||||
}
|
||||
|
||||
// {setfilter}
|
||||
smartytag(res) ::= LDELSETFILTER ID(m) modparameters(p). {
|
||||
tag(res) ::= LDELSETFILTER ID(m) modparameters(p). {
|
||||
res = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array(array_merge(array(m),p))));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELSETFILTER ID(m) modparameters(p) modifierlist(l). {
|
||||
tag(res) ::= LDELSETFILTER ID(m) modparameters(p) modifierlist(l). {
|
||||
res = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array_merge(array(array_merge(array(m),p)),l)));
|
||||
}
|
||||
|
||||
// {$smarty.block.child} or {$smarty.block.parent}
|
||||
smartytag(res) ::= LDEL SMARTYBLOCKCHILDPARENT(i). {
|
||||
tag(res) ::= LDEL SMARTYBLOCKCHILDPARENT(i). {
|
||||
$j = strrpos(i,'.');
|
||||
if (i[$j+1] == 'c') {
|
||||
// {$smarty.block.child}
|
||||
@@ -498,20 +530,29 @@ smartytag(res) ::= LDEL SMARTYBLOCKCHILDPARENT(i). {
|
||||
|
||||
|
||||
// end of block tag {/....}
|
||||
smartytag(res) ::= LDELSLASH ID(i). {
|
||||
smartytag(res)::= CLOSETAG(t). {
|
||||
$tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length), ' /');
|
||||
if ($tag == 'strip') {
|
||||
$this->strip = false;
|
||||
res = null;
|
||||
} else {
|
||||
res = $this->compiler->compileTag($tag.'close',array());
|
||||
}
|
||||
}
|
||||
tag(res) ::= LDELSLASH ID(i). {
|
||||
res = $this->compiler->compileTag(i.'close',array());
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELSLASH ID(i) modifierlist(l). {
|
||||
tag(res) ::= LDELSLASH ID(i) modifierlist(l). {
|
||||
res = $this->compiler->compileTag(i.'close',array(),array('modifier_list'=>l));
|
||||
}
|
||||
|
||||
// end of block object tag {/....}
|
||||
smartytag(res) ::= LDELSLASH ID(i) PTR ID(m). {
|
||||
tag(res) ::= LDELSLASH ID(i) PTR ID(m). {
|
||||
res = $this->compiler->compileTag(i.'close',array(),array('object_method'=>m));
|
||||
}
|
||||
|
||||
smartytag(res) ::= LDELSLASH ID(i) PTR ID(m) modifierlist(l). {
|
||||
tag(res) ::= LDELSLASH ID(i) PTR ID(m) modifierlist(l). {
|
||||
res = $this->compiler->compileTag(i.'close',array(),array('object_method'=>m, 'modifier_list'=>l));
|
||||
}
|
||||
|
||||
@@ -537,12 +578,12 @@ attributes(res) ::= . {
|
||||
// attribute
|
||||
attribute(res) ::= SPACE ID(v) EQUAL ID(id). {
|
||||
if (defined(id)) {
|
||||
if (isset($this->smarty->security_policy)) {
|
||||
$this->smarty->security_policy->isTrustedConstant(id, $this->compiler);
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant(id, $this->compiler);
|
||||
}
|
||||
res = array(v=>id);
|
||||
} else {
|
||||
res = array(v=>"'".id."'");
|
||||
res = array(v=>'\''.id.'\'');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +596,7 @@ attribute(res) ::= ATTR(v) value(e). {
|
||||
}
|
||||
|
||||
attribute(res) ::= SPACE ID(v). {
|
||||
res = "'".v."'";
|
||||
res = '\''.v.'\'';
|
||||
}
|
||||
|
||||
attribute(res) ::= SPACE expr(e). {
|
||||
@@ -584,8 +625,11 @@ statements(res) ::= statements(s1) COMMA statement(s). {
|
||||
res = s1;
|
||||
}
|
||||
|
||||
statement(res) ::= DOLLAR varvar(v) EQUAL expr(e). {
|
||||
res = array('var' => v, 'value'=>e);
|
||||
statement(res) ::= DOLLARID(i) EQUAL INTEGER(e). {
|
||||
res = array('var' => '\''.substr(i,1).'\'', 'value'=>e);
|
||||
}
|
||||
statement(res) ::= DOLLARID(i) EQUAL expr(e). {
|
||||
res = array('var' => '\''.substr(i,1).'\'', 'value'=>e);
|
||||
}
|
||||
|
||||
statement(res) ::= varindexed(vi) EQUAL expr(e). {
|
||||
@@ -612,8 +656,8 @@ expr(res) ::= ternary(v). {
|
||||
}
|
||||
|
||||
// resources/streams
|
||||
expr(res) ::= DOLLAR ID(i) COLON ID(i2). {
|
||||
res = '$_smarty_tpl->getStreamVariable(\''. i .'://'. i2 . '\')';
|
||||
expr(res) ::= DOLLARID(i) COLON ID(i2). {
|
||||
res = '$_smarty_tpl->getStreamVariable(\''.substr(i,1).'://' . i2 . '\')';
|
||||
}
|
||||
|
||||
// arithmetic expression
|
||||
@@ -625,11 +669,6 @@ expr(res) ::= expr(e) UNIMATH(m) value(v). {
|
||||
res = e . trim(m) . v;
|
||||
}
|
||||
|
||||
// bit operation
|
||||
expr(res) ::= expr(e) ANDSYM(m) value(v). {
|
||||
res = e . trim(m) . v;
|
||||
}
|
||||
|
||||
// array
|
||||
expr(res) ::= array(a). {
|
||||
res = a;
|
||||
@@ -642,8 +681,11 @@ expr(res) ::= expr(e) modifierlist(l). {
|
||||
|
||||
// if expression
|
||||
// simple expression
|
||||
expr(res) ::= expr(e1) ifcond(c) expr(e2). {
|
||||
res = e1.c.e2;
|
||||
expr(res) ::= expr(e1) lop(c) expr(e2). {
|
||||
res = (isset(c['pre']) ? c['pre'] : '') . e1.c['op'].e2 . (isset(c['pre']) ? ')' : '');
|
||||
}
|
||||
expr(res) ::= expr(e1) scond(c). {
|
||||
res = c . e1 . ')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISIN array(a). {
|
||||
@@ -654,60 +696,16 @@ expr(res) ::= expr(e1) ISIN value(v). {
|
||||
res = 'in_array('.e1.',(array)'.v.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) lop(o) expr(e2). {
|
||||
res = e1.o.e2;
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISDIVBY expr(e2). {
|
||||
res = '!('.e1.' % '.e2.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISNOTDIVBY expr(e2). {
|
||||
res = '('.e1.' % '.e2.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISEVEN. {
|
||||
res = '!(1 & '.e1.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISNOTEVEN. {
|
||||
res = '(1 & '.e1.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISEVENBY expr(e2). {
|
||||
res = '!(1 & '.e1.' / '.e2.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISNOTEVENBY expr(e2). {
|
||||
res = '(1 & '.e1.' / '.e2.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISODD. {
|
||||
res = '(1 & '.e1.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISNOTODD. {
|
||||
res = '!(1 & '.e1.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISODDBY expr(e2). {
|
||||
res = '(1 & '.e1.' / '.e2.')';
|
||||
}
|
||||
|
||||
expr(res) ::= expr(e1) ISNOTODDBY expr(e2). {
|
||||
res = '!(1 & '.e1.' / '.e2.')';
|
||||
}
|
||||
|
||||
expr(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
|
||||
res = v1.i.v2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ternary
|
||||
//
|
||||
ternary(res) ::= OPENP expr(v) CLOSEP QMARK DOLLAR ID(e1) COLON expr(e2). {
|
||||
res = v.' ? '. $this->compiler->compileVariable("'".e1."'") . ' : '.e2;
|
||||
ternary(res) ::= OPENP expr(v) CLOSEP QMARK DOLLARID(e1) COLON expr(e2). {
|
||||
res = v.' ? '. $this->compiler->compileVariable('\''.substr(e1,1).'\'') . ' : '.e2;
|
||||
}
|
||||
|
||||
ternary(res) ::= OPENP expr(v) CLOSEP QMARK expr(e1) COLON expr(e2). {
|
||||
@@ -761,12 +759,12 @@ value(res) ::= DOT INTEGER(n1). {
|
||||
// ID, true, false, null
|
||||
value(res) ::= ID(id). {
|
||||
if (defined(id)) {
|
||||
if (isset($this->smarty->security_policy)) {
|
||||
$this->smarty->security_policy->isTrustedConstant(id, $this->compiler);
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant(id, $this->compiler);
|
||||
}
|
||||
res = id;
|
||||
} else {
|
||||
res = "'".id."'";
|
||||
res = '\''.id.'\'';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -799,13 +797,13 @@ value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
|
||||
$this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.' = '. $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>';
|
||||
}
|
||||
res = '$_tmp'.self::$prefix_number.'::'.r[0].r[1];
|
||||
|
||||
}
|
||||
|
||||
// Smarty tag
|
||||
value(res) ::= smartytag(st) RDEL. {
|
||||
value(res) ::= smartytag(st). {
|
||||
self::$prefix_number++;
|
||||
$this->compiler->prefix_code[] = '<?php ob_start();?>'.st.'<?php $_tmp'.self::$prefix_number.'=ob_get_clean();?>';
|
||||
$tmp = $this->compiler->appendCode('<?php ob_start();?>', st);
|
||||
$this->compiler->prefix_code[] = $this->compiler->appendCode($tmp, '<?php $_tmp'.self::$prefix_number.'=ob_get_clean();?>');
|
||||
res = '$_tmp'.self::$prefix_number;
|
||||
}
|
||||
|
||||
@@ -820,7 +818,7 @@ value(res) ::= NAMESPACE(c). {
|
||||
|
||||
// static class access
|
||||
value(res) ::= ns1(c)DOUBLECOLON static_class_access(s). {
|
||||
if (!in_array(strtolower(c), array('self', 'parent')) && (!$this->security || $this->smarty->security_policy->isTrustedStaticClassAccess(c, s, $this->compiler))) {
|
||||
if (!in_array(strtolower(c), array('self', 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess(c, s, $this->compiler))) {
|
||||
if (isset($this->smarty->registered_classes[c])) {
|
||||
res = $this->smarty->registered_classes[c].'::'.s[0].s[1];
|
||||
} else {
|
||||
@@ -842,9 +840,9 @@ ns1(res) ::= NAMESPACE(i). {
|
||||
res = i;
|
||||
}
|
||||
|
||||
ns1(res) ::= variable(v). {
|
||||
res = v;
|
||||
}
|
||||
//ns1(res) ::= variable(v). {
|
||||
// res = v;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -853,6 +851,9 @@ ns1(res) ::= variable(v). {
|
||||
// variables
|
||||
//
|
||||
// Smarty variable (optional array)
|
||||
variable(res) ::= DOLLARID(i). {
|
||||
res = $this->compiler->compileVariable('\''.substr(i,1).'\'');
|
||||
}
|
||||
variable(res) ::= varindexed(vi). {
|
||||
if (vi['var'] == '\'smarty\'') {
|
||||
$smarty_var = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']);
|
||||
@@ -866,7 +867,7 @@ variable(res) ::= varindexed(vi). {
|
||||
}
|
||||
|
||||
// variable with property
|
||||
variable(res) ::= DOLLAR varvar(v) AT ID(p). {
|
||||
variable(res) ::= varvar(v) AT ID(p). {
|
||||
res = '$_smarty_tpl->tpl_vars['. v .']->'.p;
|
||||
}
|
||||
|
||||
@@ -892,7 +893,10 @@ variable(res) ::= HATCH variable(v) HATCH arrayindex(a). {
|
||||
res = '(is_array($tmp = $_smarty_tpl->getConfigVariable( '. v .')) ? $tmp'.a.' : null)';
|
||||
}
|
||||
|
||||
varindexed(res) ::= DOLLAR varvar(v) arrayindex(a). {
|
||||
varindexed(res) ::= DOLLARID(i) arrayindex(a). {
|
||||
res = array('var'=>'\''.substr(i,1).'\'', 'smarty_internal_index'=>a);
|
||||
}
|
||||
varindexed(res) ::= varvar(v) arrayindex(a). {
|
||||
res = array('var'=>v, 'smarty_internal_index'=>a);
|
||||
}
|
||||
|
||||
@@ -911,32 +915,35 @@ arrayindex ::= . {
|
||||
|
||||
// single index definition
|
||||
// Smarty2 style index
|
||||
indexdef(res) ::= DOT DOLLAR varvar(v). {
|
||||
indexdef(res) ::= DOT DOLLARID(i). {
|
||||
res = '['.$this->compiler->compileVariable('\''.substr(i,1).'\'').']';
|
||||
}
|
||||
indexdef(res) ::= DOT varvar(v). {
|
||||
res = '['.$this->compiler->compileVariable(v).']';
|
||||
}
|
||||
|
||||
indexdef(res) ::= DOT DOLLAR varvar(v) AT ID(p). {
|
||||
indexdef(res) ::= DOT varvar(v) AT ID(p). {
|
||||
res = '['.$this->compiler->compileVariable(v).'->'.p.']';
|
||||
}
|
||||
|
||||
indexdef(res) ::= DOT ID(i). {
|
||||
if (defined(i)) {
|
||||
if (isset($this->smarty->security_policy)) {
|
||||
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
|
||||
if ($this->security) {
|
||||
$this->security->isTrustedConstant(i, $this->compiler);
|
||||
}
|
||||
res = "[". i ."]";
|
||||
res = '['. i .']';
|
||||
} else {
|
||||
res = "['". i ."']";
|
||||
}
|
||||
}
|
||||
|
||||
indexdef(res) ::= DOT INTEGER(n). {
|
||||
res = "[". n ."]";
|
||||
res = '['. n .']';
|
||||
}
|
||||
|
||||
|
||||
indexdef(res) ::= DOT LDEL expr(e) RDEL. {
|
||||
res = "[". e ."]";
|
||||
res = '['. e .']';
|
||||
}
|
||||
|
||||
// section tag index
|
||||
@@ -947,10 +954,25 @@ indexdef(res) ::= OPENB ID(i)CLOSEB. {
|
||||
indexdef(res) ::= OPENB ID(i) DOT ID(i2) CLOSEB. {
|
||||
res = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.i.'\'][\''.i2.'\']').']';
|
||||
}
|
||||
indexdef(res) ::= OPENB SINGLEQUOTESTRING(s) CLOSEB. {
|
||||
res = '['.s.']';
|
||||
}
|
||||
indexdef(res) ::= OPENB INTEGER(n) CLOSEB. {
|
||||
res = '['.n.']';
|
||||
}
|
||||
indexdef(res) ::= OPENB DOLLARID(i) CLOSEB. {
|
||||
res = '['.$this->compiler->compileVariable('\''.substr(i,1).'\'').']';;
|
||||
}
|
||||
indexdef(res) ::= OPENB variable(v) CLOSEB. {
|
||||
res = '['.v.']';
|
||||
}
|
||||
indexdef(res) ::= OPENB value(v) CLOSEB. {
|
||||
res = '['.v.']';
|
||||
}
|
||||
|
||||
// PHP style index
|
||||
indexdef(res) ::= OPENB expr(e) CLOSEB. {
|
||||
res = "[". e ."]";
|
||||
res = '['. e .']';
|
||||
}
|
||||
|
||||
// for assign append array
|
||||
@@ -962,9 +984,14 @@ indexdef(res) ::= OPENB CLOSEB. {
|
||||
//
|
||||
// variable variable names
|
||||
//
|
||||
|
||||
// singel identifier element
|
||||
varvar(res) ::= varvarele(v). {
|
||||
res = v;
|
||||
varvar(res) ::= DOLLARID(i). {
|
||||
res = '\''.substr(i,1).'\'';
|
||||
}
|
||||
// single $
|
||||
varvar(res) ::= DOLLAR. {
|
||||
res = "''";
|
||||
}
|
||||
|
||||
// sequence of identifier elements
|
||||
@@ -976,6 +1003,10 @@ varvar(res) ::= varvar(v1) varvarele(v2). {
|
||||
varvarele(res) ::= ID(s). {
|
||||
res = '\''.s.'\'';
|
||||
}
|
||||
varvarele(res) ::= SIMPELOUTPUT(i). {
|
||||
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $');
|
||||
res = $this->compiler->compileVariable('\''.$var.'\'');
|
||||
}
|
||||
|
||||
// variable sections of element
|
||||
varvarele(res) ::= LDEL expr(e) RDEL. {
|
||||
@@ -1011,7 +1042,7 @@ objectelement(res)::= PTR ID(i) arrayindex(a). {
|
||||
res = '->'.i.a;
|
||||
}
|
||||
|
||||
objectelement(res)::= PTR DOLLAR varvar(v) arrayindex(a). {
|
||||
objectelement(res)::= PTR varvar(v) arrayindex(a). {
|
||||
if ($this->security) {
|
||||
$this->compiler->trigger_template_error (self::Err2);
|
||||
}
|
||||
@@ -1042,7 +1073,7 @@ objectelement(res)::= PTR method(f). {
|
||||
// function
|
||||
//
|
||||
function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
|
||||
if (!$this->security || $this->smarty->security_policy->isTrustedPhpFunction(f, $this->compiler)) {
|
||||
if (!$this->security || $this->security->isTrustedPhpFunction(f, $this->compiler)) {
|
||||
if (strcasecmp(f,'isset') === 0 || strcasecmp(f,'empty') === 0 || strcasecmp(f,'array') === 0 || is_callable(f)) {
|
||||
$func_name = strtolower(f);
|
||||
if ($func_name == 'isset') {
|
||||
@@ -1087,12 +1118,12 @@ method(res) ::= ID(f) OPENP params(p) CLOSEP. {
|
||||
res = f . "(". implode(',',p) .")";
|
||||
}
|
||||
|
||||
method(res) ::= DOLLAR ID(f) OPENP params(p) CLOSEP. {
|
||||
method(res) ::= DOLLARID(f) OPENP params(p) CLOSEP. {
|
||||
if ($this->security) {
|
||||
$this->compiler->trigger_template_error (self::Err2);
|
||||
}
|
||||
self::$prefix_number++;
|
||||
$this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.'='.$this->compiler->compileVariable("'".f."'").';?>';
|
||||
$this->compiler->prefix_code[] = '<?php $_tmp'.self::$prefix_number.'='.$this->compiler->compileVariable('\''.substr(f,1).'\'').';?>';
|
||||
res = '$_tmp'.self::$prefix_number.'('. implode(',',p) .')';
|
||||
}
|
||||
|
||||
@@ -1169,63 +1200,56 @@ static_class_access(res) ::= ID(v). {
|
||||
}
|
||||
|
||||
// static class variables
|
||||
static_class_access(res) ::= DOLLAR ID(v) arrayindex(a). {
|
||||
res = array('$'.v, a, 'property');
|
||||
static_class_access(res) ::= DOLLARID(v) arrayindex(a). {
|
||||
res = array(v, a, 'property');
|
||||
}
|
||||
|
||||
// static class variables with object chain
|
||||
static_class_access(res) ::= DOLLAR ID(v) arrayindex(a) objectchain(oc). {
|
||||
res = array('$'.v, a.oc, 'property');
|
||||
static_class_access(res) ::= DOLLARID(v) arrayindex(a) objectchain(oc). {
|
||||
res = array(v, a.oc, 'property');
|
||||
}
|
||||
|
||||
|
||||
// if conditions and operators
|
||||
ifcond(res) ::= EQUALS. {
|
||||
res = '==';
|
||||
lop(res) ::= LOGOP(o). {
|
||||
res['op'] = ' '. trim(o) . ' ';
|
||||
}
|
||||
|
||||
ifcond(res) ::= NOTEQUALS. {
|
||||
res = '!=';
|
||||
lop(res) ::= TLOGOP(o). {
|
||||
static $lops = array(
|
||||
'eq' => array('op' => ' == ', 'pre' => null),
|
||||
'ne' => array('op' => ' != ', 'pre' => null),
|
||||
'neq' => array('op' => ' != ', 'pre' => null),
|
||||
'gt' => array('op' => ' > ', 'pre' => null),
|
||||
'ge' => array('op' => ' >= ', 'pre' => null),
|
||||
'gte' => array('op' => ' >= ', 'pre' => null),
|
||||
'lt' => array('op' => ' < ', 'pre' => null),
|
||||
'le' => array('op' => ' <= ', 'pre' => null),
|
||||
'lte' => array('op' => ' <= ', 'pre' => null),
|
||||
'mod' => array('op' => ' % ', 'pre' => null),
|
||||
'and' => array('op' => ' && ', 'pre' => null),
|
||||
'or' => array('op' => ' || ', 'pre' => null),
|
||||
'xor' => array('op' => ' xor ', 'pre' => null),
|
||||
'isdivby' => array('op' => ' % ', 'pre' => '!('),
|
||||
'isnotdivby' => array('op' => ' % ', 'pre' => '('),
|
||||
'isevenby' => array('op' => ' / ', 'pre' => '!(1 & '),
|
||||
'isnotevenby' => array('op' => ' / ', 'pre' => '(1 & '),
|
||||
'isoddby' => array('op' => ' / ', 'pre' => '(1 & '),
|
||||
'isnotoddby' => array('op' => ' / ', 'pre' => '!(1 & '),
|
||||
);
|
||||
$op = strtolower(str_replace(' ', '', o));
|
||||
res = $lops[$op];
|
||||
}
|
||||
|
||||
ifcond(res) ::= GREATERTHAN. {
|
||||
res = '>';
|
||||
}
|
||||
|
||||
ifcond(res) ::= LESSTHAN. {
|
||||
res = '<';
|
||||
}
|
||||
|
||||
ifcond(res) ::= GREATEREQUAL. {
|
||||
res = '>=';
|
||||
}
|
||||
|
||||
ifcond(res) ::= LESSEQUAL. {
|
||||
res = '<=';
|
||||
}
|
||||
|
||||
ifcond(res) ::= IDENTITY. {
|
||||
res = '===';
|
||||
}
|
||||
|
||||
ifcond(res) ::= NONEIDENTITY. {
|
||||
res = '!==';
|
||||
}
|
||||
|
||||
ifcond(res) ::= MOD. {
|
||||
res = '%';
|
||||
}
|
||||
|
||||
lop(res) ::= LAND. {
|
||||
res = '&&';
|
||||
}
|
||||
|
||||
lop(res) ::= LOR. {
|
||||
res = '||';
|
||||
}
|
||||
|
||||
lop(res) ::= LXOR. {
|
||||
res = ' XOR ';
|
||||
scond(res) ::= SINGLECOND(o). {
|
||||
static $scond = array (
|
||||
'iseven' => '!(1 & ',
|
||||
'isnoteven' => '(1 & ',
|
||||
'isodd' => '(1 & ',
|
||||
'isnotodd' => '!(1 & ',
|
||||
);
|
||||
$op = strtolower(str_replace(' ', '', o));
|
||||
res = $scond[$op];
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1301,7 +1325,7 @@ doublequotedcontent(res) ::= LDEL expr(e) RDEL. {
|
||||
res = new Smarty_Internal_ParseTree_Code($this, '(string)('.e.')');
|
||||
}
|
||||
|
||||
doublequotedcontent(res) ::= smartytag(st) RDEL. {
|
||||
doublequotedcontent(res) ::= smartytag(st). {
|
||||
res = new Smarty_Internal_ParseTree_Tag($this, st);
|
||||
}
|
||||
|
||||
@@ -1309,14 +1333,3 @@ doublequotedcontent(res) ::= TEXT(o). {
|
||||
res = new Smarty_Internal_ParseTree_DqContent($this, o);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// optional space
|
||||
//
|
||||
optspace(res) ::= SPACE(s). {
|
||||
res = s;
|
||||
}
|
||||
|
||||
optspace(res) ::= . {
|
||||
res = '';
|
||||
}
|
||||
|
||||
+116
-36
@@ -111,21 +111,28 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.23';
|
||||
const SMARTY_VERSION = '3.1.24';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
*/
|
||||
const SCOPE_LOCAL = 0;
|
||||
|
||||
const SCOPE_PARENT = 1;
|
||||
|
||||
const SCOPE_ROOT = 2;
|
||||
|
||||
const SCOPE_GLOBAL = 3;
|
||||
|
||||
/**
|
||||
* define caching modes
|
||||
*/
|
||||
const CACHING_OFF = 0;
|
||||
|
||||
const CACHING_LIFETIME_CURRENT = 1;
|
||||
|
||||
const CACHING_LIFETIME_SAVED = 2;
|
||||
|
||||
/**
|
||||
* define constant for clearing cache files be saved expiration datees
|
||||
*/
|
||||
@@ -135,36 +142,53 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* define compile check modes
|
||||
*/
|
||||
const COMPILECHECK_OFF = 0;
|
||||
|
||||
const COMPILECHECK_ON = 1;
|
||||
|
||||
const COMPILECHECK_CACHEMISS = 2;
|
||||
|
||||
/**
|
||||
* define debug modes
|
||||
*/
|
||||
const DEBUG_OFF = 0;
|
||||
|
||||
const DEBUG_ON = 1;
|
||||
|
||||
const DEBUG_INDIVIDUAL = 2;
|
||||
|
||||
/**
|
||||
* modes for handling of "<?php ... ?>" tags in templates.
|
||||
*/
|
||||
const PHP_PASSTHRU = 0; //-> print tags as plain text
|
||||
|
||||
const PHP_QUOTE = 1; //-> escape tags as entities
|
||||
|
||||
const PHP_REMOVE = 2; //-> escape tags as entities
|
||||
|
||||
const PHP_ALLOW = 3; //-> escape tags as entities
|
||||
|
||||
/**
|
||||
* filter types
|
||||
*/
|
||||
const FILTER_POST = 'post';
|
||||
|
||||
const FILTER_PRE = 'pre';
|
||||
|
||||
const FILTER_OUTPUT = 'output';
|
||||
|
||||
const FILTER_VARIABLE = 'variable';
|
||||
|
||||
/**
|
||||
* plugin types
|
||||
*/
|
||||
const PLUGIN_FUNCTION = 'function';
|
||||
|
||||
const PLUGIN_BLOCK = 'block';
|
||||
|
||||
const PLUGIN_COMPILER = 'compiler';
|
||||
|
||||
const PLUGIN_MODIFIER = 'modifier';
|
||||
|
||||
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
|
||||
|
||||
/**#@-*/
|
||||
@@ -178,23 +202,29 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
|
||||
*/
|
||||
public static $_previous_error_handler = null;
|
||||
|
||||
/**
|
||||
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
|
||||
*/
|
||||
public static $_muted_directories = array('./templates_c/' => null, './cache/' => null);
|
||||
public static $_muted_directories = array('./templates_c/' => null,
|
||||
'./cache/' => null);
|
||||
|
||||
/**
|
||||
* Flag denoting if Multibyte String functions are available
|
||||
*/
|
||||
public static $_MBSTRING = SMARTY_MBSTRING;
|
||||
|
||||
/**
|
||||
* The character set to adhere to (e.g. "UTF-8")
|
||||
*/
|
||||
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
|
||||
|
||||
/**
|
||||
* The date format to be used internally
|
||||
* (accepts date() and strftime())
|
||||
*/
|
||||
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
|
||||
|
||||
/**
|
||||
* Flag denoting if PCRE should run in UTF-8 mode
|
||||
*/
|
||||
@@ -215,132 +245,154 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var boolean
|
||||
*/
|
||||
public $auto_literal = true;
|
||||
|
||||
/**
|
||||
* display error on not assigned variables
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $error_unassigned = false;
|
||||
|
||||
/**
|
||||
* look up relative filepaths in include_path
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $use_include_path = false;
|
||||
|
||||
/**
|
||||
* template directory
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $template_dir = array('./templates/');
|
||||
|
||||
/**
|
||||
* joined template directory string used in cache keys
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $joined_template_dir = './templates/';
|
||||
|
||||
/**
|
||||
* joined config directory string used in cache keys
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $joined_config_dir = './configs/';
|
||||
|
||||
/**
|
||||
* default template handler
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
public $default_template_handler_func = null;
|
||||
|
||||
/**
|
||||
* default config handler
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
public $default_config_handler_func = null;
|
||||
|
||||
/**
|
||||
* default plugin handler
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
public $default_plugin_handler_func = null;
|
||||
|
||||
/**
|
||||
* compile directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $compile_dir = './templates_c/';
|
||||
|
||||
/**
|
||||
* plugins directory
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $plugins_dir = null;
|
||||
|
||||
/**
|
||||
* cache directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $cache_dir = './cache/';
|
||||
|
||||
/**
|
||||
* config directory
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $config_dir = array('./configs/');
|
||||
|
||||
/**
|
||||
* force template compiling?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $force_compile = false;
|
||||
|
||||
/**
|
||||
* check template for modifications?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $compile_check = true;
|
||||
|
||||
/**
|
||||
* use sub dirs for compiled/cached files?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $use_sub_dirs = false;
|
||||
|
||||
/**
|
||||
* allow ambiguous resources (that are made unique by the resource handler)
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $allow_ambiguous_resources = false;
|
||||
|
||||
/**
|
||||
* merge compiled includes
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $merge_compiled_includes = false;
|
||||
|
||||
/**
|
||||
* template inheritance merge compiled includes
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $inheritance_merge_compiled_includes = true;
|
||||
|
||||
/**
|
||||
* force cache file creation
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $force_cache = false;
|
||||
|
||||
/**
|
||||
* template left-delimiter
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $left_delimiter = "{";
|
||||
|
||||
/**
|
||||
* template right-delimiter
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $right_delimiter = "}";
|
||||
|
||||
/**#@+
|
||||
* security
|
||||
*/
|
||||
@@ -352,24 +404,28 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @see Smarty_Security
|
||||
*/
|
||||
public $security_class = 'Smarty_Security';
|
||||
|
||||
/**
|
||||
* implementation of security class
|
||||
*
|
||||
* @var Smarty_Security
|
||||
*/
|
||||
public $security_policy = null;
|
||||
|
||||
/**
|
||||
* controls handling of PHP-blocks
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $php_handling = self::PHP_PASSTHRU;
|
||||
|
||||
/**
|
||||
* controls if the php template file resource is allowed
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $allow_php_templates = false;
|
||||
|
||||
/**
|
||||
* Should compiled-templates be prevented from being called directly?
|
||||
* {@internal
|
||||
@@ -379,6 +435,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var boolean
|
||||
*/
|
||||
public $direct_access_security = true;
|
||||
|
||||
/**#@-*/
|
||||
/**
|
||||
* debug mode
|
||||
@@ -387,6 +444,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var boolean
|
||||
*/
|
||||
public $debugging = false;
|
||||
|
||||
/**
|
||||
* This determines if debugging is enable-able from the browser.
|
||||
* <ul>
|
||||
@@ -397,6 +455,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var string
|
||||
*/
|
||||
public $debugging_ctrl = 'NONE';
|
||||
|
||||
/**
|
||||
* Name of debugging URL-param.
|
||||
* Only used when $debugging_ctrl is set to 'URL'.
|
||||
@@ -405,12 +464,14 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var string
|
||||
*/
|
||||
public $smarty_debug_id = 'SMARTY_DEBUG';
|
||||
|
||||
/**
|
||||
* Path of debug template.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $debug_tpl = null;
|
||||
|
||||
/**
|
||||
* When set, smarty uses this value as error_reporting-level.
|
||||
*
|
||||
@@ -435,12 +496,14 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var boolean
|
||||
*/
|
||||
public $config_overwrite = true;
|
||||
|
||||
/**
|
||||
* Controls whether config values of on/true/yes and off/false/no get converted to boolean.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $config_booleanize = true;
|
||||
|
||||
/**
|
||||
* Controls whether hidden config sections/vars are read from the file.
|
||||
*
|
||||
@@ -460,12 +523,14 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var boolean
|
||||
*/
|
||||
public $compile_locking = true;
|
||||
|
||||
/**
|
||||
* Controls whether cache resources should emply locking mechanism
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $cache_locking = false;
|
||||
|
||||
/**
|
||||
* seconds to wait for acquiring a lock before ignoring the write lock
|
||||
*
|
||||
@@ -482,6 +547,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var string
|
||||
*/
|
||||
public $default_resource_type = 'file';
|
||||
|
||||
/**
|
||||
* caching type
|
||||
* Must be an element of $cache_resource_types.
|
||||
@@ -489,24 +555,28 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var string
|
||||
*/
|
||||
public $caching_type = 'file';
|
||||
|
||||
/**
|
||||
* internal config properties
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $properties = array();
|
||||
|
||||
/**
|
||||
* config type
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $default_config_type = 'file';
|
||||
|
||||
/**
|
||||
* cached template objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $source_objects = array();
|
||||
|
||||
/**
|
||||
* cached template objects
|
||||
*
|
||||
@@ -520,126 +590,150 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var bool
|
||||
*/
|
||||
public $resource_caching = false;
|
||||
|
||||
/**
|
||||
* enable template resource caching
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $template_resource_caching = true;
|
||||
|
||||
/**
|
||||
* check If-Modified-Since headers
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $cache_modified_check = false;
|
||||
|
||||
/**
|
||||
* registered plugins
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $registered_plugins = array();
|
||||
|
||||
/**
|
||||
* plugin search order
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $plugin_search_order = array('function', 'block', 'compiler', 'class');
|
||||
public $plugin_search_order = array('function',
|
||||
'block',
|
||||
'compiler',
|
||||
'class');
|
||||
|
||||
/**
|
||||
* registered objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $registered_objects = array();
|
||||
|
||||
/**
|
||||
* registered classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $registered_classes = array();
|
||||
|
||||
/**
|
||||
* registered filters
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $registered_filters = array();
|
||||
|
||||
/**
|
||||
* registered resources
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $registered_resources = array();
|
||||
|
||||
/**
|
||||
* resource handler cache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_resource_handlers = array();
|
||||
|
||||
/**
|
||||
* registered cache resources
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $registered_cache_resources = array();
|
||||
|
||||
/**
|
||||
* cache resource handler cache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_cacheresource_handlers = array();
|
||||
|
||||
/**
|
||||
* autoload filter
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $autoload_filters = array();
|
||||
|
||||
/**
|
||||
* default modifier
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $default_modifiers = array();
|
||||
|
||||
/**
|
||||
* autoescape variable output
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $escape_html = false;
|
||||
|
||||
/**
|
||||
* global internal smarty vars
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $_smarty_vars = array();
|
||||
|
||||
/**
|
||||
* start time for execution time calculation
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $start_time = 0;
|
||||
|
||||
/**
|
||||
* default file permissions
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $_file_perms = 0644;
|
||||
|
||||
/**
|
||||
* default dir permissions
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $_dir_perms = 0771;
|
||||
|
||||
/**
|
||||
* block tag hierarchy
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $_tag_stack = array();
|
||||
|
||||
/**
|
||||
* required by the compiler for BC
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $_current_file = null;
|
||||
|
||||
/**
|
||||
* internal flag to enable parser debugging
|
||||
*
|
||||
@@ -658,7 +752,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
|
||||
/**
|
||||
* Initialize new Smarty object
|
||||
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -686,8 +779,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
} else {
|
||||
$this->setPluginsDir(SMARTY_PLUGINS_DIR);
|
||||
}
|
||||
|
||||
$this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl';
|
||||
if (isset($_SERVER['SCRIPT_NAME'])) {
|
||||
Smarty::$global_tpl_vars['SCRIPT_NAME'] = new Smarty_Variable($_SERVER['SCRIPT_NAME']);
|
||||
}
|
||||
@@ -1283,9 +1374,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
}
|
||||
if ($this->debugging) {
|
||||
if ($this->debugging) {
|
||||
Smarty_Internal_Debug::register_template($tpl);
|
||||
}
|
||||
Smarty_Internal_Debug::register_template($tpl);
|
||||
}
|
||||
return $tpl;
|
||||
}
|
||||
@@ -1331,10 +1420,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
|
||||
// loop through plugin dirs and find the plugin
|
||||
foreach ($this->getPluginsDir() as $_plugin_dir) {
|
||||
$names = array(
|
||||
$_plugin_dir . $_plugin_filename,
|
||||
$_plugin_dir . strtolower($_plugin_filename),
|
||||
);
|
||||
$names = array($_plugin_dir . $_plugin_filename,
|
||||
$_plugin_dir . strtolower($_plugin_filename),);
|
||||
foreach ($names as $file) {
|
||||
if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) {
|
||||
require_once($file);
|
||||
@@ -1591,13 +1678,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$allowed = array(
|
||||
'template_dir' => 'getTemplateDir',
|
||||
'config_dir' => 'getConfigDir',
|
||||
'plugins_dir' => 'getPluginsDir',
|
||||
'compile_dir' => 'getCompileDir',
|
||||
'cache_dir' => 'getCacheDir',
|
||||
);
|
||||
$allowed = array('template_dir' => 'getTemplateDir',
|
||||
'config_dir' => 'getConfigDir',
|
||||
'plugins_dir' => 'getPluginsDir',
|
||||
'compile_dir' => 'getCompileDir',
|
||||
'cache_dir' => 'getCacheDir',);
|
||||
|
||||
if (isset($allowed[$name])) {
|
||||
return $this->{$allowed[$name]}();
|
||||
@@ -1616,13 +1701,11 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$allowed = array(
|
||||
'template_dir' => 'setTemplateDir',
|
||||
'config_dir' => 'setConfigDir',
|
||||
'plugins_dir' => 'setPluginsDir',
|
||||
'compile_dir' => 'setCompileDir',
|
||||
'cache_dir' => 'setCacheDir',
|
||||
);
|
||||
$allowed = array('template_dir' => 'setTemplateDir',
|
||||
'config_dir' => 'setConfigDir',
|
||||
'plugins_dir' => 'setPluginsDir',
|
||||
'compile_dir' => 'setCompileDir',
|
||||
'cache_dir' => 'setCacheDir',);
|
||||
|
||||
if (isset($allowed[$name])) {
|
||||
$this->{$allowed[$name]}($value);
|
||||
@@ -1652,10 +1735,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) {
|
||||
$smarty_dir = realpath(SMARTY_DIR);
|
||||
if ($smarty_dir !== false) {
|
||||
Smarty::$_muted_directories[SMARTY_DIR] = array(
|
||||
'file' => $smarty_dir,
|
||||
'length' => strlen($smarty_dir),
|
||||
);
|
||||
Smarty::$_muted_directories[SMARTY_DIR] = array('file' => $smarty_dir,
|
||||
'length' => strlen($smarty_dir),);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1669,10 +1750,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
unset(Smarty::$_muted_directories[$key]);
|
||||
continue;
|
||||
}
|
||||
$dir = array(
|
||||
'file' => $file,
|
||||
'length' => strlen($file),
|
||||
);
|
||||
$dir = array('file' => $file,
|
||||
'length' => strlen($file),);
|
||||
}
|
||||
if (!strncmp($errfile, $dir['file'], $dir['length'])) {
|
||||
$_is_muted_directory = true;
|
||||
@@ -1714,7 +1793,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
- between file_exists() and filemtime() a possible race condition is opened,
|
||||
which does not exist using the simple @filemtime() approach.
|
||||
*/
|
||||
$error_handler = array('Smarty', 'mutingErrorHandler');
|
||||
$error_handler = array('Smarty',
|
||||
'mutingErrorHandler');
|
||||
$previous = set_error_handler($error_handler);
|
||||
|
||||
// avoid dead loops
|
||||
|
||||
+7
-7
@@ -105,7 +105,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty Debug Console
|
||||
<h1>Smarty {Smarty::SMARTY_VERSION} Debug Console
|
||||
- {if isset($template_name)}{$template_name|debug_print_var nofilter} {/if}{if !empty($template_data)}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
@@ -126,11 +126,11 @@
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<td><h3><font color=blue>${$vars@key|escape:'html'}</font></h3>
|
||||
<td><h3><font color=blue>${$vars@key}</font></h3>
|
||||
{if isset($vars['nocache'])}<b>Nocache</b></br>{/if}
|
||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']}{/if}
|
||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var:10:80 nofilter}{/if}
|
||||
</td>
|
||||
<td><h3>Value</h3>{$vars['value']|debug_print_var nofilter}</td>
|
||||
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
||||
<td>{if isset($vars['attributes'])}<h3>Attributes</h3>{$vars['attributes']|debug_print_var nofilter} {/if}</td>
|
||||
{/foreach}
|
||||
</table>
|
||||
@@ -140,10 +140,10 @@
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<td><h3><font color=blue>#{$vars@key|escape:'html'}#</font></h3>
|
||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']}{/if}
|
||||
<td><h3><font color=blue>#{$vars@key}#</font></h3>
|
||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var:10:80 nofilter}{/if}
|
||||
</td>
|
||||
<td>{$vars['value']|debug_print_var nofilter}</td>
|
||||
<td>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#<(script|pre|textarea)[^>]*>.*?</\\1>#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[0][0];
|
||||
$_length = strlen($match[0][0]);
|
||||
@@ -62,7 +62,7 @@ function smarty_outputfilter_trimwhitespace($source)
|
||||
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
|
||||
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
// note: for some very weird reason trim() seems to remove spaces inside attributes.
|
||||
// maybe a \0 byte or something is interfering?
|
||||
'#^\s+<#Ss' => '<',
|
||||
|
||||
@@ -47,27 +47,48 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
|
||||
$output = "<?php ";
|
||||
if ($parameter == 1) {
|
||||
foreach ($_attr['start'] as $_statement) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]] = new Smarty_Variable;";
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n";
|
||||
if (is_array($_statement['var'])) {
|
||||
$var = $_statement['var']['var'];
|
||||
$index = $_statement['var']['smarty_internal_index'];
|
||||
} else {
|
||||
$var = $_statement['var'];
|
||||
$index = '';
|
||||
}
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable;";
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value];\n";
|
||||
}
|
||||
$output .= " if ($_attr[ifexp]) { for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$_attr[var]]->value$_attr[step]) {\n";
|
||||
if (is_array($_attr['var'])) {
|
||||
$var = $_attr['var']['var'];
|
||||
$index = $_attr['var']['smarty_internal_index'];
|
||||
} else {
|
||||
$var = $_attr['var'];
|
||||
$index = '';
|
||||
}
|
||||
$output .= " if ($_attr[ifexp]) { for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
|
||||
} else {
|
||||
$_statement = $_attr['start'];
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]] = new Smarty_Variable;";
|
||||
if (isset($_attr['step'])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->step = $_attr[step];";
|
||||
if (is_array($_statement['var'])) {
|
||||
$var = $_statement['var']['var'];
|
||||
$index = $_statement['var']['smarty_internal_index'];
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->step = 1;";
|
||||
$var = $_statement['var'];
|
||||
$index = '';
|
||||
}
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable;";
|
||||
if (isset($_attr['step'])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->step = 1;";
|
||||
}
|
||||
if (isset($_attr['max'])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$_statement[var]]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$_statement[var]]->step)),$_attr[max]);\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step)),$_attr[max]);\n";
|
||||
} else {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$_statement[var]]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$_statement[var]]->step));\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step));\n";
|
||||
}
|
||||
$output .= "if (\$_smarty_tpl->tpl_vars[$_statement[var]]->total > 0) {\n";
|
||||
$output .= "for (\$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value], \$_smarty_tpl->tpl_vars[$_statement[var]]->iteration = 1;\$_smarty_tpl->tpl_vars[$_statement[var]]->iteration <= \$_smarty_tpl->tpl_vars[$_statement[var]]->total;\$_smarty_tpl->tpl_vars[$_statement[var]]->value += \$_smarty_tpl->tpl_vars[$_statement[var]]->step, \$_smarty_tpl->tpl_vars[$_statement[var]]->iteration++) {\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->first = \$_smarty_tpl->tpl_vars[$_statement[var]]->iteration == 1;";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$_statement[var]]->last = \$_smarty_tpl->tpl_vars[$_statement[var]]->iteration == \$_smarty_tpl->tpl_vars[$_statement[var]]->total;";
|
||||
$output .= "if (\$_smarty_tpl->tpl_vars[$var]->total > 0) {\n";
|
||||
$output .= "for (\$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value], \$_smarty_tpl->tpl_vars[$var]->iteration = 1;\$_smarty_tpl->tpl_vars[$var]->iteration <= \$_smarty_tpl->tpl_vars[$var]->total;\$_smarty_tpl->tpl_vars[$var]->value{$index} += \$_smarty_tpl->tpl_vars[$var]->step, \$_smarty_tpl->tpl_vars[$var]->iteration++) {\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration == 1;";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration == \$_smarty_tpl->tpl_vars[$var]->total;";
|
||||
}
|
||||
$output .= "?>";
|
||||
|
||||
|
||||
@@ -208,7 +208,8 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
|
||||
}
|
||||
}
|
||||
}
|
||||
$output .= "\$foreachItemSav = \$_smarty_tpl->tpl_vars[$item];\n";
|
||||
$itemName = trim($item,"'\"");
|
||||
$output .= "\$foreach_{$itemName}_Sav = \$_smarty_tpl->tpl_vars[$item];\n";
|
||||
$output .= "?>";
|
||||
|
||||
return $output;
|
||||
@@ -239,8 +240,9 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
||||
|
||||
list($openTag, $nocache, $item, $key, $foo) = $this->closeTag($compiler, array('foreach'));
|
||||
$this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key, false));
|
||||
$itemName = trim($item,"'\"");
|
||||
$output = "<?php\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreachItemSav;\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n";
|
||||
$output .= "}\n";
|
||||
$output .= "if (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
|
||||
return $output;
|
||||
@@ -274,9 +276,10 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
||||
}
|
||||
|
||||
list($openTag, $compiler->nocache, $item, $key, $restore) = $this->closeTag($compiler, array('foreach', 'foreachelse'));
|
||||
$itemName = trim($item,"'\"");
|
||||
$output = "<?php\n";
|
||||
if ($restore) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreachItemSav;\n";
|
||||
$output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n";
|
||||
}
|
||||
$output .= "}\n?>";
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
@@ -23,6 +24,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $required_attributes = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
@@ -30,6 +32,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
* @see Smarty_Internal_CompileBase
|
||||
*/
|
||||
public $shorttag_order = array('name');
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
@@ -57,9 +60,8 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
}
|
||||
unset($_attr['nocache']);
|
||||
$_name = trim($_attr['name'], "'\"");
|
||||
|
||||
$save = array($_attr, $compiler->parser->current_buffer,
|
||||
$compiler->template->has_nocache_code, $compiler->template->required_plugins, $compiler->template->caching);
|
||||
$compiler->parent_compiler->templateProperties['tpl_function'][$_name] = array();
|
||||
$save = array($_attr, $compiler->parser->current_buffer, $compiler->template->has_nocache_code, $compiler->template->required_plugins, $compiler->template->caching);
|
||||
$this->openTag($compiler, 'function', $save);
|
||||
// set flag that we are compiling a template function
|
||||
$compiler->compiles_template_function = true;
|
||||
@@ -80,6 +82,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
|
||||
*/
|
||||
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Compiler object
|
||||
*
|
||||
@@ -90,11 +93,11 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
/**
|
||||
* Compiles code for the {/function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return boolean true
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
|
||||
@@ -42,9 +42,14 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($parameter['if condition']['var']['var'], "'");
|
||||
} else {
|
||||
$compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($parameter['if condition']['var'], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
}
|
||||
} else {
|
||||
$_nocache = '';
|
||||
@@ -124,9 +129,14 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($parameter['if condition']['var']['var'], "'");
|
||||
} else {
|
||||
$compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($parameter['if condition']['var'], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
}
|
||||
} else {
|
||||
$_nocache = '';
|
||||
@@ -155,22 +165,23 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
|
||||
} else {
|
||||
$tmp = '';
|
||||
foreach ($compiler->prefix_code as $code) {
|
||||
$tmp .= $code;
|
||||
}
|
||||
$tmp = $compiler->appendCode($tmp, $code);
|
||||
}
|
||||
$compiler->prefix_code = array();
|
||||
$tmp = $compiler->appendCode("<?php } else {?>", $tmp);
|
||||
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
if ($condition_by_assign) {
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
|
||||
$_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n");
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
|
||||
} else {
|
||||
$_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
|
||||
$_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});");
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
|
||||
}
|
||||
|
||||
return $_output;
|
||||
} else {
|
||||
return "<?php } else {?>{$tmp}<?php if ({$parameter['if condition']}) {?>";
|
||||
return $compiler->appendCode($tmp, "<?php if ({$parameter['if condition']}) {?>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,12 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
||||
// output will be stored in a smarty variable instead of being displayed
|
||||
$_assign = $_attr['assign'];
|
||||
// create variable to make sure that the compiler knows about its nocache status
|
||||
$compiler->template->tpl_vars[trim($_attr['assign'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($_attr['assign'], "'");
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
}
|
||||
}
|
||||
if (isset($_attr['script'])) {
|
||||
// script which must be included
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
*
|
||||
@@ -39,28 +40,30 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$compiler->has_code = false;
|
||||
$this->asp_tags = (ini_get('asp_tags') != '0');
|
||||
if ($_attr['type'] == 'tag' && !($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno);
|
||||
if ($_attr['type'] == 'xml') {
|
||||
$compiler->tag_nocache = true;
|
||||
$save = $compiler->template->has_nocache_code;
|
||||
$compiler->template->has_nocache_code = $save;
|
||||
$output = addcslashes($_attr['code'], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
|
||||
return '';
|
||||
}
|
||||
if ($_attr['type'] != 'tag') {
|
||||
if (isset($compiler->smarty->security_policy)) {
|
||||
$this->php_handling = $compiler->smarty->security_policy->php_handling;
|
||||
} else {
|
||||
$this->php_handling = $compiler->smarty->php_handling;
|
||||
}
|
||||
if ($this->php_handling == Smarty::PHP_REMOVE) {
|
||||
$output = preg_replace(array('#^(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)#', '#(\?>)|(%>)|(<\/script>)$#'), '', $_attr['code']);
|
||||
if ($compiler->php_handling == Smarty::PHP_REMOVE) {
|
||||
return '';
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
|
||||
$output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
|
||||
'quote'), $_attr['code']);
|
||||
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
|
||||
return '';
|
||||
} elseif ($this->php_handling == Smarty::PHP_QUOTE) {
|
||||
$output = preg_replace_callback(array('#^(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)#', '#(\?>)|(%>)|(<\/script>)$#'), function ($match) {return htmlspecialchars($match[0], ENT_QUOTES);}, $_attr['code']);
|
||||
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
|
||||
$compiler->tag_nocache = true;
|
||||
$save = $compiler->template->has_nocache_code;
|
||||
$compiler->template->has_nocache_code = $save;
|
||||
$output = addcslashes($_attr['code'], "'\\");
|
||||
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
|
||||
return '';
|
||||
} elseif ($this->php_handling == Smarty::PHP_PASSTHRU || ($_attr['type'] == 'asp' && !$this->asp_tags) || $_attr['type'] == 'unmatched') {
|
||||
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $_attr['code']));
|
||||
return '';
|
||||
} elseif ($this->php_handling == Smarty::PHP_ALLOW) {
|
||||
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', $compiler->lex->taglineno);
|
||||
}
|
||||
@@ -71,14 +74,12 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
}
|
||||
} else {
|
||||
$compiler->has_code = true;
|
||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
||||
$compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno);
|
||||
}
|
||||
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
||||
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
||||
if (!preg_match("#{$ldel}\\s*/\\s*php\\s*{$rdel}$#", $_attr['code'], $match)) {
|
||||
$compiler->trigger_template_error('Missing {/php} closing tag', $compiler->lex->taglineno);
|
||||
}
|
||||
if (!preg_match("#^({$ldel}\\s*php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match)) {
|
||||
$compiler->trigger_template_error('Missing {php} open tag', $compiler->lex->taglineno);
|
||||
}
|
||||
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match);
|
||||
if (!empty($match[2])) {
|
||||
if ('nocache' == trim($match[2])) {
|
||||
$compiler->tag_nocache = true;
|
||||
@@ -86,7 +87,103 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
||||
$compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", $compiler->lex->taglineno);
|
||||
}
|
||||
}
|
||||
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
|
||||
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#",
|
||||
"#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lexer code for PHP tags
|
||||
*
|
||||
* This code has been moved from lexer here fo easier debugging and maintenance
|
||||
*
|
||||
* @param $lex
|
||||
*/
|
||||
public function parsePhp($lex)
|
||||
{
|
||||
$close = 0;
|
||||
$lex->taglineno = $lex->line;
|
||||
$closeTag = '?>';
|
||||
if (strpos($lex->value, '<?xml') === 0) {
|
||||
$lex->phpType = 'xml';
|
||||
} elseif (strpos($lex->value, '<?') === 0) {
|
||||
$lex->phpType = 'php';
|
||||
} elseif (strpos($lex->value, '<%') === 0) {
|
||||
$lex->phpType = 'asp';
|
||||
$closeTag = '%>';
|
||||
} elseif (strpos($lex->value, '%>') === 0) {
|
||||
$lex->phpType = 'unmatched';
|
||||
} elseif (strpos($lex->value, '?>') === 0) {
|
||||
$lex->phpType = 'unmatched';
|
||||
} elseif (strpos($lex->value, '<s') === 0) {
|
||||
$lex->phpType = 'script';
|
||||
$closeTag = '</script>';
|
||||
} elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) {
|
||||
if ($lex->isAutoLiteral()) {
|
||||
$lex->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||
return;
|
||||
}
|
||||
$closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}";
|
||||
if ($lex->value == $closeTag) {
|
||||
$lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'");
|
||||
}
|
||||
$lex->phpType = 'tag';
|
||||
}
|
||||
if ($lex->phpType == 'unmatched') {
|
||||
return;
|
||||
}
|
||||
if (($lex->phpType == 'php' || $lex->phpType == 'asp') && ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)) {
|
||||
return;
|
||||
}
|
||||
$start = $lex->counter + strlen($lex->value);
|
||||
$body = true;
|
||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||
$close = $match[0][1];
|
||||
} else {
|
||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||
}
|
||||
while ($body) {
|
||||
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
||||
$value = $match[0][0];
|
||||
$from = $pos = $match[0][1];
|
||||
if ($pos > $close) {
|
||||
$body = false;
|
||||
} else {
|
||||
$start = $pos + strlen($value);
|
||||
$phpCommentStart = $value == '/*';
|
||||
if ($phpCommentStart) {
|
||||
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
|
||||
if ($phpCommentEnd) {
|
||||
$pos2 = $match[0][1];
|
||||
$start = $pos2 + strlen($match[0][0]);
|
||||
}
|
||||
}
|
||||
while ($close > $pos && $close < $start) {
|
||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
|
||||
$close = $match[0][1];
|
||||
$from = $close + strlen($match[0][0]);
|
||||
} else {
|
||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
||||
}
|
||||
}
|
||||
if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) {
|
||||
$lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n");
|
||||
$lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$body = false;
|
||||
}
|
||||
}
|
||||
$lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter);
|
||||
}
|
||||
|
||||
/*
|
||||
* Call back function for $php_handling = PHP_QUOTE
|
||||
*
|
||||
*/
|
||||
private function quote($match)
|
||||
{
|
||||
return htmlspecialchars($match[0], ENT_QUOTES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
case 'foreach':
|
||||
$name = trim($_index[1], "'");
|
||||
$foreachVar = "'__foreach_{$name}'";
|
||||
return "isset(\$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}]) ? \$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}] : null";
|
||||
return "(isset(\$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}]) ? \$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}] : null)";
|
||||
case 'section':
|
||||
return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
|
||||
case 'capture':
|
||||
@@ -82,7 +82,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||
break;
|
||||
}
|
||||
if (strpos($_index[1], '$') === false) {
|
||||
if (strpos($_index[1], '$') === false && strpos($_index[1], '\'') === false ) {
|
||||
return "@constant('{$_index[1]}')";
|
||||
} else {
|
||||
return "@constant({$_index[1]})";
|
||||
|
||||
@@ -42,9 +42,14 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
||||
$_nocache = ',true';
|
||||
// create nocache var to make it know for further compiling
|
||||
if (is_array($parameter['if condition']['var'])) {
|
||||
$compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($parameter['if condition']['var']['var'], "'");
|
||||
} else {
|
||||
$compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_Variable(null, true);
|
||||
$var = trim($parameter['if condition']['var'], "'");
|
||||
}
|
||||
if (isset($compiler->template->tpl_vars[$var])) {
|
||||
$compiler->template->tpl_vars[$var]->nocache = true;
|
||||
} else {
|
||||
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
|
||||
}
|
||||
} else {
|
||||
$_nocache = '';
|
||||
|
||||
@@ -1,96 +1,128 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Configfilelexer
|
||||
*
|
||||
* This is the lexer to break the config file source into tokens
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Configfilelexer
|
||||
*
|
||||
* This is the lexer to break the config file source into tokens
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty_Internal_Configfilelexer
|
||||
*
|
||||
* This is the config file lexer.
|
||||
* It is generated from the smarty_internal_configfilelexer.plex file
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty_Internal_Configfilelexer
|
||||
*
|
||||
* This is the config file lexer.
|
||||
* It is generated from the smarty_internal_configfilelexer.plex file
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Configfilelexer
|
||||
{
|
||||
|
||||
/**
|
||||
* Source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $data;
|
||||
|
||||
/**
|
||||
* byte counter
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $counter;
|
||||
|
||||
/**
|
||||
* token number
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $token;
|
||||
|
||||
/**
|
||||
* token value
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* current line
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $line;
|
||||
|
||||
/**
|
||||
* state number
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $state = 1;
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
* @var Smarty
|
||||
*/
|
||||
public $smarty = null;
|
||||
|
||||
/**
|
||||
* compiler object
|
||||
*
|
||||
* @var Smarty_Internal_Config_File_Compiler
|
||||
*/
|
||||
private $compiler = null;
|
||||
|
||||
/**
|
||||
* copy of config_booleanize
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $configBooleanize = false;
|
||||
|
||||
/**
|
||||
* trace file
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
public $yyTraceFILE;
|
||||
|
||||
/**
|
||||
* trace prompt
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $yyTracePrompt;
|
||||
|
||||
/**
|
||||
* state names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE');
|
||||
|
||||
/**
|
||||
* storage for assembled token patterns
|
||||
*
|
||||
* @var sring
|
||||
*/
|
||||
private $yy_global_pattern1 = null;
|
||||
|
||||
private $yy_global_pattern2 = null;
|
||||
|
||||
private $yy_global_pattern3 = null;
|
||||
|
||||
private $yy_global_pattern4 = null;
|
||||
|
||||
private $yy_global_pattern5 = null;
|
||||
|
||||
private $yy_global_pattern6 = null;
|
||||
|
||||
/**
|
||||
* token names
|
||||
*
|
||||
@@ -135,9 +167,8 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTracePrompt = '<br>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
private $_yy_state = 1;
|
||||
|
||||
private $_yy_stack = array();
|
||||
|
||||
public function yylex()
|
||||
@@ -148,75 +179,54 @@ class Smarty_Internal_Configfilelexer
|
||||
public function yypushstate($state)
|
||||
{
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
}
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
$this->_yy_state = $state;
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
}
|
||||
}
|
||||
|
||||
public function yypopstate()
|
||||
{
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
}
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
}
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function yybegin($state)
|
||||
{
|
||||
$this->_yy_state = $state;
|
||||
$this->_yy_state = $state;
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function yylex1()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->yy_global_pattern1)) {
|
||||
$this->yy_global_pattern1 = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter, 5) . '... state START');
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state START');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
if ($tokenMap[$this->token]) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, $this->token + 1,
|
||||
$tokenMap[$this->token]);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r1_' . $this->token}($yysubmatches);
|
||||
$r = $this->{'yy_r1_' . $this->token}();
|
||||
if ($r === null) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
@@ -229,106 +239,92 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} } else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[$this->counter]);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
const START = 1;
|
||||
function yy_r1_1($yy_subpatterns)
|
||||
|
||||
function yy_r1_1()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
|
||||
$this->yypushstate(self::COMMENT);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
|
||||
$this->yypushstate(self::COMMENT);
|
||||
}
|
||||
function yy_r1_2($yy_subpatterns)
|
||||
|
||||
function yy_r1_2()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
|
||||
$this->yypushstate(self::SECTION);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
|
||||
$this->yypushstate(self::SECTION);
|
||||
}
|
||||
function yy_r1_3($yy_subpatterns)
|
||||
|
||||
function yy_r1_3()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
|
||||
}
|
||||
function yy_r1_4($yy_subpatterns)
|
||||
|
||||
function yy_r1_4()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
|
||||
$this->yypushstate(self::VALUE);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
|
||||
$this->yypushstate(self::VALUE);
|
||||
}
|
||||
function yy_r1_5($yy_subpatterns)
|
||||
|
||||
function yy_r1_5()
|
||||
{
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
function yy_r1_6($yy_subpatterns)
|
||||
|
||||
function yy_r1_6()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
|
||||
}
|
||||
function yy_r1_7($yy_subpatterns)
|
||||
|
||||
function yy_r1_7()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_ID;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_ID;
|
||||
}
|
||||
function yy_r1_8($yy_subpatterns)
|
||||
|
||||
function yy_r1_8()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function yylex2()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
4 => 0,
|
||||
5 => 0,
|
||||
6 => 0,
|
||||
7 => 0,
|
||||
8 => 0,
|
||||
9 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->yy_global_pattern2)) {
|
||||
$this->yy_global_pattern2 = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter, 5) . '... state VALUE');
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state VALUE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
if ($tokenMap[$this->token]) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, $this->token + 1,
|
||||
$tokenMap[$this->token]);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r2_' . $this->token}($yysubmatches);
|
||||
$r = $this->{'yy_r2_' . $this->token}();
|
||||
if ($r === null) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
@@ -341,115 +337,110 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} } else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[$this->counter]);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
const VALUE = 2;
|
||||
function yy_r2_1($yy_subpatterns)
|
||||
|
||||
function yy_r2_1()
|
||||
{
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
function yy_r2_2($yy_subpatterns)
|
||||
|
||||
function yy_r2_2()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r2_3($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_INT;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r2_4($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES;
|
||||
$this->yypushstate(self::TRIPPLE);
|
||||
}
|
||||
function yy_r2_5($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r2_6($yy_subpatterns)
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r2_7($yy_subpatterns)
|
||||
{
|
||||
|
||||
if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no")) ) {
|
||||
$this->yypopstate();
|
||||
$this->yypushstate(self::NAKED_STRING_VALUE);
|
||||
return true; //reprocess in new state
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_BOOL;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
|
||||
$this->yypopstate();
|
||||
}
|
||||
}
|
||||
function yy_r2_8($yy_subpatterns)
|
||||
|
||||
function yy_r2_3()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_INT;
|
||||
$this->yypopstate();
|
||||
}
|
||||
function yy_r2_9($yy_subpatterns)
|
||||
|
||||
function yy_r2_4()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->value = "";
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES;
|
||||
$this->yypushstate(self::TRIPPLE);
|
||||
}
|
||||
|
||||
function yy_r2_5()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
function yy_r2_6()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
function yy_r2_7()
|
||||
{
|
||||
|
||||
if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))) {
|
||||
$this->yypopstate();
|
||||
$this->yypushstate(self::NAKED_STRING_VALUE);
|
||||
return true; //reprocess in new state
|
||||
} else {
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_BOOL;
|
||||
$this->yypopstate();
|
||||
}
|
||||
}
|
||||
|
||||
function yy_r2_8()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
function yy_r2_9()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->value = "";
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
public function yylex3()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->yy_global_pattern3)) {
|
||||
$this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/iS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G([^\n]+?(?=[ \t\r]*\n))/iS";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter, 5) . '... state NAKED_STRING_VALUE');
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state NAKED_STRING_VALUE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
if ($tokenMap[$this->token]) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, $this->token + 1,
|
||||
$tokenMap[$this->token]);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r3_' . $this->token}($yysubmatches);
|
||||
$r = $this->{'yy_r3_' . $this->token}();
|
||||
if ($r === null) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
@@ -462,63 +453,48 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} } else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[$this->counter]);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
const NAKED_STRING_VALUE = 3;
|
||||
function yy_r3_1($yy_subpatterns)
|
||||
|
||||
function yy_r3_1()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function yylex4()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->yy_global_pattern4)) {
|
||||
$this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter, 5) . '... state COMMENT');
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state COMMENT');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
if ($tokenMap[$this->token]) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, $this->token + 1,
|
||||
$tokenMap[$this->token]);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r4_' . $this->token}($yysubmatches);
|
||||
$r = $this->{'yy_r4_' . $this->token}();
|
||||
if ($r === null) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
@@ -531,72 +507,60 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} } else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[$this->counter]);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
const COMMENT = 4;
|
||||
function yy_r4_1($yy_subpatterns)
|
||||
|
||||
function yy_r4_1()
|
||||
{
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
function yy_r4_2($yy_subpatterns)
|
||||
|
||||
function yy_r4_2()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
|
||||
}
|
||||
function yy_r4_3($yy_subpatterns)
|
||||
|
||||
function yy_r4_3()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function yylex5()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->yy_global_pattern5)) {
|
||||
$this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/iS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/iS";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter, 5) . '... state SECTION');
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state SECTION');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
if ($tokenMap[$this->token]) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, $this->token + 1,
|
||||
$tokenMap[$this->token]);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r5_' . $this->token}($yysubmatches);
|
||||
$r = $this->{'yy_r5_' . $this->token}();
|
||||
if ($r === null) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
@@ -609,66 +573,54 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} } else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[$this->counter]);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
const SECTION = 5;
|
||||
function yy_r5_1($yy_subpatterns)
|
||||
|
||||
function yy_r5_1()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_DOT;
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_DOT;
|
||||
}
|
||||
function yy_r5_2($yy_subpatterns)
|
||||
|
||||
function yy_r5_2()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
|
||||
$this->yypopstate();
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
|
||||
$this->yypopstate();
|
||||
}
|
||||
|
||||
|
||||
public function yylex6()
|
||||
{
|
||||
$tokenMap = array (
|
||||
1 => 0,
|
||||
2 => 0,
|
||||
);
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if (!isset($this->yy_global_pattern6)) {
|
||||
$this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS";
|
||||
}
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
$yy_global_pattern = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS";
|
||||
|
||||
do {
|
||||
if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
|
||||
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
|
||||
$yysubmatches = $yymatches;
|
||||
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
|
||||
if (!count($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' .
|
||||
' an empty string. Input "' . substr($this->data,
|
||||
$this->counter, 5) . '... state TRIPPLE');
|
||||
if (empty($yymatches)) {
|
||||
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TRIPPLE');
|
||||
}
|
||||
next($yymatches); // skip global match
|
||||
$this->token = key($yymatches); // token number
|
||||
if ($tokenMap[$this->token]) {
|
||||
// extract sub-patterns for passing to lex function
|
||||
$yysubmatches = array_slice($yysubmatches, $this->token + 1,
|
||||
$tokenMap[$this->token]);
|
||||
} else {
|
||||
$yysubmatches = array();
|
||||
}
|
||||
$this->value = current($yymatches); // token value
|
||||
$r = $this->{'yy_r6_' . $this->token}($yysubmatches);
|
||||
$r = $this->{'yy_r6_' . $this->token}();
|
||||
if ($r === null) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
@@ -681,42 +633,40 @@ class Smarty_Internal_Configfilelexer
|
||||
} elseif ($r === false) {
|
||||
$this->counter += strlen($this->value);
|
||||
$this->line += substr_count($this->value, "\n");
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
if ($this->counter >= strlen($this->data)) {
|
||||
return false; // end of input
|
||||
}
|
||||
// skip this token
|
||||
continue;
|
||||
} } else {
|
||||
throw new Exception('Unexpected input at line' . $this->line .
|
||||
': ' . $this->data[$this->counter]);
|
||||
}
|
||||
} else {
|
||||
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
|
||||
} // end function
|
||||
|
||||
|
||||
const TRIPPLE = 6;
|
||||
function yy_r6_1($yy_subpatterns)
|
||||
|
||||
function yy_r6_1()
|
||||
{
|
||||
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END;
|
||||
$this->yypopstate();
|
||||
$this->yypushstate(self::START);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END;
|
||||
$this->yypopstate();
|
||||
$this->yypushstate(self::START);
|
||||
}
|
||||
function yy_r6_2($yy_subpatterns)
|
||||
|
||||
function yy_r6_2()
|
||||
{
|
||||
|
||||
$to = strlen($this->data);
|
||||
preg_match("/\"\"\"[ \t\r]*[\n#;]/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
} else {
|
||||
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
|
||||
}
|
||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
|
||||
$to = strlen($this->data);
|
||||
preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
|
||||
if (isset($match[0][1])) {
|
||||
$to = $match[0][1];
|
||||
} else {
|
||||
$this->compiler->trigger_template_error("missing or misspelled literal closing tag");
|
||||
}
|
||||
$this->value = substr($this->data, $this->counter, $to - $this->counter);
|
||||
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
class TPC_yyToken implements ArrayAccess
|
||||
{
|
||||
|
||||
public $string = '';
|
||||
|
||||
public $metadata = array();
|
||||
|
||||
public function __construct($s, $m = array())
|
||||
@@ -38,8 +41,7 @@ class TPC_yyToken implements ArrayAccess
|
||||
{
|
||||
if ($offset === null) {
|
||||
if (isset($value[0])) {
|
||||
$x = ($value instanceof TPC_yyToken) ?
|
||||
$value->metadata : $value;
|
||||
$x = ($value instanceof TPC_yyToken) ? $value->metadata : $value;
|
||||
$this->metadata = array_merge($this->metadata, $x);
|
||||
|
||||
return;
|
||||
@@ -66,28 +68,31 @@ class TPC_yyToken implements ArrayAccess
|
||||
|
||||
class TPC_yyStackEntry
|
||||
{
|
||||
|
||||
public $stateno; /* The state-number */
|
||||
public $major; /* The major token value. This is the code
|
||||
** number for the token at this stack level */
|
||||
public $minor; /* The user-supplied minor token value. This
|
||||
** is the value of the token */
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
#line 12 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Configfileparse
|
||||
*
|
||||
* This is the config file parser.
|
||||
* It is generated from the smarty_internal_configfileparser.y file
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Configfileparse
|
||||
*
|
||||
* This is the config file parser.
|
||||
* It is generated from the smarty_internal_configfileparser.y file
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Configfileparser
|
||||
{
|
||||
#line 25 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 25 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
/**
|
||||
* result status
|
||||
@@ -95,59 +100,67 @@ class Smarty_Internal_Configfileparser
|
||||
* @var bool
|
||||
*/
|
||||
public $successful = true;
|
||||
|
||||
/**
|
||||
* return value
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $retvalue = 0;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
public $yymajor;
|
||||
|
||||
/**
|
||||
* lexer object
|
||||
*
|
||||
* @var Smarty_Internal_Configfilelexer
|
||||
*/
|
||||
private $lex;
|
||||
|
||||
/**
|
||||
* internal error flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $internalError = false;
|
||||
|
||||
/**
|
||||
* compiler object
|
||||
*
|
||||
* @var Smarty_Internal_Config_File_Compiler
|
||||
*/
|
||||
public $compiler = null;
|
||||
|
||||
/**
|
||||
* smarty object
|
||||
*
|
||||
* @var Smarty
|
||||
*/
|
||||
public $smarty = null;
|
||||
|
||||
/**
|
||||
* copy of config_overwrite property
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $configOverwrite = false;
|
||||
|
||||
/**
|
||||
* copy of config_read_hidden property
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $configReadHidden = false;
|
||||
|
||||
/**
|
||||
* helper map
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $escapes_single = Array('\\' => '\\',
|
||||
'\'' => '\'');
|
||||
private static $escapes_single = Array('\\' => '\\', '\'' => '\'');
|
||||
|
||||
/**
|
||||
* constructor
|
||||
@@ -300,106 +313,86 @@ class Smarty_Internal_Configfileparser
|
||||
}
|
||||
}
|
||||
|
||||
const TPC_OPENB = 1;
|
||||
const TPC_SECTION = 2;
|
||||
const TPC_CLOSEB = 3;
|
||||
const TPC_DOT = 4;
|
||||
const TPC_ID = 5;
|
||||
const TPC_EQUAL = 6;
|
||||
const TPC_FLOAT = 7;
|
||||
const TPC_INT = 8;
|
||||
const TPC_BOOL = 9;
|
||||
const TPC_SINGLE_QUOTED_STRING = 10;
|
||||
const TPC_DOUBLE_QUOTED_STRING = 11;
|
||||
const TPC_TRIPPLE_QUOTES = 12;
|
||||
const TPC_TRIPPLE_TEXT = 13;
|
||||
const TPC_TRIPPLE_QUOTES_END = 14;
|
||||
const TPC_NAKED_STRING = 15;
|
||||
const TPC_OTHER = 16;
|
||||
const TPC_NEWLINE = 17;
|
||||
const TPC_COMMENTSTART = 18;
|
||||
const TPC_OPENB = 1;
|
||||
|
||||
const TPC_SECTION = 2;
|
||||
|
||||
const TPC_CLOSEB = 3;
|
||||
|
||||
const TPC_DOT = 4;
|
||||
|
||||
const TPC_ID = 5;
|
||||
|
||||
const TPC_EQUAL = 6;
|
||||
|
||||
const TPC_FLOAT = 7;
|
||||
|
||||
const TPC_INT = 8;
|
||||
|
||||
const TPC_BOOL = 9;
|
||||
|
||||
const TPC_SINGLE_QUOTED_STRING = 10;
|
||||
|
||||
const TPC_DOUBLE_QUOTED_STRING = 11;
|
||||
|
||||
const TPC_TRIPPLE_QUOTES = 12;
|
||||
|
||||
const TPC_TRIPPLE_TEXT = 13;
|
||||
|
||||
const TPC_TRIPPLE_QUOTES_END = 14;
|
||||
|
||||
const TPC_NAKED_STRING = 15;
|
||||
|
||||
const TPC_OTHER = 16;
|
||||
|
||||
const TPC_NEWLINE = 17;
|
||||
|
||||
const TPC_COMMENTSTART = 18;
|
||||
|
||||
const YY_NO_ACTION = 60;
|
||||
|
||||
const YY_ACCEPT_ACTION = 59;
|
||||
|
||||
const YY_ERROR_ACTION = 58;
|
||||
|
||||
const YY_SZ_ACTTAB = 38;
|
||||
static public $yy_action = array(
|
||||
29, 30, 34, 33, 24, 13, 19, 25, 35, 21,
|
||||
59, 8, 3, 1, 20, 12, 14, 31, 20, 12,
|
||||
15, 17, 23, 18, 27, 26, 4, 5, 6, 32,
|
||||
2, 11, 28, 22, 16, 9, 7, 10,
|
||||
);
|
||||
static public $yy_lookahead = array(
|
||||
7, 8, 9, 10, 11, 12, 5, 27, 15, 16,
|
||||
20, 21, 23, 23, 17, 18, 13, 14, 17, 18,
|
||||
15, 2, 17, 4, 25, 26, 6, 3, 3, 14,
|
||||
23, 1, 24, 17, 2, 25, 22, 25,
|
||||
);
|
||||
const YY_SHIFT_USE_DFLT = -8;
|
||||
|
||||
static public $yy_action = array(29, 30, 34, 33, 24, 13, 19, 25, 35, 21, 59, 8, 3, 1, 20, 12, 14, 31, 20, 12, 15, 17, 23, 18, 27, 26, 4, 5, 6, 32, 2, 11, 28, 22, 16, 9, 7, 10,);
|
||||
|
||||
static public $yy_lookahead = array(7, 8, 9, 10, 11, 12, 5, 27, 15, 16, 20, 21, 23, 23, 17, 18, 13, 14, 17, 18, 15, 2, 17, 4, 25, 26, 6, 3, 3, 14, 23, 1, 24, 17, 2, 25, 22, 25,);
|
||||
|
||||
const YY_SHIFT_USE_DFLT = - 8;
|
||||
|
||||
const YY_SHIFT_MAX = 19;
|
||||
static public $yy_shift_ofst = array(
|
||||
-8, 1, 1, 1, -7, -3, -3, 30, -8, -8,
|
||||
-8, 19, 5, 3, 15, 16, 24, 25, 32, 20,
|
||||
);
|
||||
const YY_REDUCE_USE_DFLT = -21;
|
||||
|
||||
static public $yy_shift_ofst = array(- 8, 1, 1, 1, - 7, - 3, - 3, 30, - 8, - 8, - 8, 19, 5, 3, 15, 16, 24, 25, 32, 20,);
|
||||
|
||||
const YY_REDUCE_USE_DFLT = - 21;
|
||||
|
||||
const YY_REDUCE_MAX = 10;
|
||||
static public $yy_reduce_ofst = array(
|
||||
-10, -1, -1, -1, -20, 10, 12, 8, 14, 7,
|
||||
-11,
|
||||
);
|
||||
static public $yyExpectedTokens = array(
|
||||
array(),
|
||||
array(5, 17, 18, ),
|
||||
array(5, 17, 18, ),
|
||||
array(5, 17, 18, ),
|
||||
array(7, 8, 9, 10, 11, 12, 15, 16, ),
|
||||
array(17, 18, ),
|
||||
array(17, 18, ),
|
||||
array(1, ),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(2, 4, ),
|
||||
array(15, 17, ),
|
||||
array(13, 14, ),
|
||||
array(14, ),
|
||||
array(17, ),
|
||||
array(3, ),
|
||||
array(3, ),
|
||||
array(2, ),
|
||||
array(6, ),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
);
|
||||
static public $yy_default = array(
|
||||
44, 37, 41, 40, 58, 58, 58, 36, 39, 44,
|
||||
44, 58, 58, 58, 58, 58, 58, 58, 58, 58,
|
||||
55, 54, 57, 56, 50, 45, 43, 42, 38, 46,
|
||||
47, 52, 51, 49, 48, 53,
|
||||
);
|
||||
|
||||
static public $yy_reduce_ofst = array(- 10, - 1, - 1, - 1, - 20, 10, 12, 8, 14, 7, - 11,);
|
||||
|
||||
static public $yyExpectedTokens = array(array(), array(5, 17, 18,), array(5, 17, 18,), array(5, 17, 18,), array(7, 8, 9, 10, 11, 12, 15, 16,), array(17, 18,), array(17, 18,), array(1,), array(), array(), array(), array(2, 4,), array(15, 17,), array(13, 14,), array(14,), array(17,), array(3,), array(3,), array(2,), array(6,), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),);
|
||||
|
||||
static public $yy_default = array(44, 37, 41, 40, 58, 58, 58, 36, 39, 44, 44, 58, 58, 58, 58, 58, 58, 58, 58, 58, 55, 54, 57, 56, 50, 45, 43, 42, 38, 46, 47, 52, 51, 49, 48, 53,);
|
||||
|
||||
const YYNOCODE = 29;
|
||||
|
||||
const YYSTACKDEPTH = 100;
|
||||
|
||||
const YYNSTATE = 36;
|
||||
|
||||
const YYNRULE = 22;
|
||||
|
||||
const YYERRORSYMBOL = 19;
|
||||
|
||||
const YYERRSYMDT = 'yy0';
|
||||
|
||||
const YYFALLBACK = 0;
|
||||
public static $yyFallback = array(
|
||||
);
|
||||
|
||||
public static $yyFallback = array();
|
||||
|
||||
public function Trace($TraceFILE, $zTracePrompt)
|
||||
{
|
||||
if (!$TraceFILE) {
|
||||
@@ -418,45 +411,16 @@ static public $yy_action = array(
|
||||
}
|
||||
|
||||
public $yyTraceFILE;
|
||||
|
||||
public $yyTracePrompt;
|
||||
|
||||
public $yyidx; /* Index of top element in stack */
|
||||
public $yyerrcnt; /* Shifts left before out of the error */
|
||||
public $yystack = array(); /* The parser's stack */
|
||||
|
||||
public $yyTokenName = array(
|
||||
'$', 'OPENB', 'SECTION', 'CLOSEB',
|
||||
'DOT', 'ID', 'EQUAL', 'FLOAT',
|
||||
'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING',
|
||||
'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING',
|
||||
'OTHER', 'NEWLINE', 'COMMENTSTART', 'error',
|
||||
'start', 'global_vars', 'sections', 'var_list',
|
||||
'section', 'newline', 'var', 'value',
|
||||
);
|
||||
public $yyTokenName = array('$', 'OPENB', 'SECTION', 'CLOSEB', 'DOT', 'ID', 'EQUAL', 'FLOAT', 'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', 'start', 'global_vars', 'sections', 'var_list', 'section', 'newline', 'var', 'value',);
|
||||
|
||||
public static $yyRuleName = array(
|
||||
"start ::= global_vars sections",
|
||||
"global_vars ::= var_list",
|
||||
"sections ::= sections section",
|
||||
"sections ::=",
|
||||
"section ::= OPENB SECTION CLOSEB newline var_list",
|
||||
"section ::= OPENB DOT SECTION CLOSEB newline var_list",
|
||||
"var_list ::= var_list newline",
|
||||
"var_list ::= var_list var",
|
||||
"var_list ::=",
|
||||
"var ::= ID EQUAL value",
|
||||
"value ::= FLOAT",
|
||||
"value ::= INT",
|
||||
"value ::= BOOL",
|
||||
"value ::= SINGLE_QUOTED_STRING",
|
||||
"value ::= DOUBLE_QUOTED_STRING",
|
||||
"value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END",
|
||||
"value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END",
|
||||
"value ::= NAKED_STRING",
|
||||
"value ::= OTHER",
|
||||
"newline ::= NEWLINE",
|
||||
"newline ::= COMMENTSTART NEWLINE",
|
||||
"newline ::= COMMENTSTART NAKED_STRING NEWLINE",
|
||||
);
|
||||
public static $yyRuleName = array('start ::= global_vars sections', 'global_vars ::= var_list', 'sections ::= sections section', 'sections ::=', 'section ::= OPENB SECTION CLOSEB newline var_list', 'section ::= OPENB DOT SECTION CLOSEB newline var_list', 'var_list ::= var_list newline', 'var_list ::= var_list var', 'var_list ::=', 'var ::= ID EQUAL value', 'value ::= FLOAT', 'value ::= INT', 'value ::= BOOL', 'value ::= SINGLE_QUOTED_STRING', 'value ::= DOUBLE_QUOTED_STRING', 'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END', 'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END', 'value ::= NAKED_STRING', 'value ::= OTHER', 'newline ::= NEWLINE', 'newline ::= COMMENTSTART NEWLINE', 'newline ::= COMMENTSTART NAKED_STRING NEWLINE',);
|
||||
|
||||
public function tokenName($tokenType)
|
||||
{
|
||||
@@ -473,24 +437,23 @@ static public $yy_action = array(
|
||||
public static function yy_destructor($yymajor, $yypminor)
|
||||
{
|
||||
switch ($yymajor) {
|
||||
default: break; /* If no destructor action specified: do nothing */
|
||||
default:
|
||||
break; /* If no destructor action specified: do nothing */
|
||||
}
|
||||
}
|
||||
|
||||
public function yy_pop_parser_stack()
|
||||
{
|
||||
if (!count($this->yystack)) {
|
||||
if (empty($this->yystack)) {
|
||||
return;
|
||||
}
|
||||
$yytos = array_pop($this->yystack);
|
||||
if ($this->yyTraceFILE && $this->yyidx >= 0) {
|
||||
fwrite($this->yyTraceFILE,
|
||||
$this->yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] .
|
||||
"\n");
|
||||
fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] . "\n");
|
||||
}
|
||||
$yymajor = $yytos->major;
|
||||
self::yy_destructor($yymajor, $yytos->minor);
|
||||
$this->yyidx--;
|
||||
$this->yyidx --;
|
||||
|
||||
return $yymajor;
|
||||
}
|
||||
@@ -507,10 +470,18 @@ static public $yy_action = array(
|
||||
|
||||
public function yy_get_expected_tokens($token)
|
||||
{
|
||||
static $res3 = array();
|
||||
static $res4 = array();
|
||||
$state = $this->yystack[$this->yyidx]->stateno;
|
||||
$expected = self::$yyExpectedTokens[$state];
|
||||
if (in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
return $expected;
|
||||
if (isset($res3[$state][$token])) {
|
||||
if ($res3[$state][$token]) {
|
||||
return $expected;
|
||||
}
|
||||
} else {
|
||||
if ($res3[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
return $expected;
|
||||
}
|
||||
}
|
||||
$stack = $this->yystack;
|
||||
$yyidx = $this->yyidx;
|
||||
@@ -520,7 +491,7 @@ static public $yy_action = array(
|
||||
// reduce action
|
||||
$done = 0;
|
||||
do {
|
||||
if ($done++ == 100) {
|
||||
if ($done ++ == 100) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// too much recursion prevents proper detection
|
||||
@@ -529,22 +500,26 @@ static public $yy_action = array(
|
||||
}
|
||||
$yyruleno = $yyact - self::YYNSTATE;
|
||||
$this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
|
||||
$nextstate = $this->yy_find_reduce_action(
|
||||
$this->yystack[$this->yyidx]->stateno,
|
||||
self::$yyRuleInfo[$yyruleno][0]);
|
||||
$nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
|
||||
if (isset(self::$yyExpectedTokens[$nextstate])) {
|
||||
$expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]);
|
||||
if (in_array($token,
|
||||
self::$yyExpectedTokens[$nextstate], true)) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
|
||||
return array_unique($expected);
|
||||
$expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]);
|
||||
if (isset($res4[$nextstate][$token])) {
|
||||
if ($res4[$nextstate][$token]) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return array_unique($expected);
|
||||
}
|
||||
} else {
|
||||
if ($res4[$nextstate][$token] = in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return array_unique($expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($nextstate < self::YYNSTATE) {
|
||||
// we need to shift a non-terminal
|
||||
$this->yyidx++;
|
||||
$this->yyidx ++;
|
||||
$x = new TPC_yyStackEntry;
|
||||
$x->stateno = $nextstate;
|
||||
$x->major = self::$yyRuleInfo[$yyruleno][0];
|
||||
@@ -569,20 +544,28 @@ static public $yy_action = array(
|
||||
}
|
||||
break;
|
||||
} while (true);
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
|
||||
return array_unique($expected);
|
||||
}
|
||||
|
||||
public function yy_is_expected_token($token)
|
||||
{
|
||||
static $res = array();
|
||||
static $res2 = array();
|
||||
if ($token === 0) {
|
||||
return true; // 0 is not part of this
|
||||
}
|
||||
$state = $this->yystack[$this->yyidx]->stateno;
|
||||
if (in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
return true;
|
||||
if (isset($res[$state][$token])) {
|
||||
if ($res[$state][$token]) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($res[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$stack = $this->yystack;
|
||||
$yyidx = $this->yyidx;
|
||||
@@ -592,7 +575,7 @@ static public $yy_action = array(
|
||||
// reduce action
|
||||
$done = 0;
|
||||
do {
|
||||
if ($done++ == 100) {
|
||||
if ($done ++ == 100) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
// too much recursion prevents proper detection
|
||||
@@ -601,19 +584,23 @@ static public $yy_action = array(
|
||||
}
|
||||
$yyruleno = $yyact - self::YYNSTATE;
|
||||
$this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
|
||||
$nextstate = $this->yy_find_reduce_action(
|
||||
$this->yystack[$this->yyidx]->stateno,
|
||||
self::$yyRuleInfo[$yyruleno][0]);
|
||||
if (isset(self::$yyExpectedTokens[$nextstate]) &&
|
||||
in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
|
||||
return true;
|
||||
$nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
|
||||
if (isset($res2[$nextstate][$token])) {
|
||||
if ($res2[$nextstate][$token]) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if ($res2[$nextstate][$token] = (isset(self::$yyExpectedTokens[$nextstate]) && in_array($token, self::$yyExpectedTokens[$nextstate], true))) {
|
||||
$this->yyidx = $yyidx;
|
||||
$this->yystack = $stack;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ($nextstate < self::YYNSTATE) {
|
||||
// we need to shift a non-terminal
|
||||
$this->yyidx++;
|
||||
$this->yyidx ++;
|
||||
$x = new TPC_yyStackEntry;
|
||||
$x->stateno = $nextstate;
|
||||
$x->major = self::$yyRuleInfo[$yyruleno][0];
|
||||
@@ -648,7 +635,7 @@ static public $yy_action = array(
|
||||
return true;
|
||||
}
|
||||
|
||||
public function yy_find_shift_action($iLookAhead)
|
||||
public function yy_find_shift_action($iLookAhead)
|
||||
{
|
||||
$stateno = $this->yystack[$this->yyidx]->stateno;
|
||||
|
||||
@@ -665,14 +652,10 @@ static public $yy_action = array(
|
||||
return self::YY_NO_ACTION;
|
||||
}
|
||||
$i += $iLookAhead;
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
|
||||
self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback)
|
||||
&& ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) && ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
|
||||
if ($this->yyTraceFILE) {
|
||||
fwrite($this->yyTraceFILE, $this->yyTracePrompt . "FALLBACK " .
|
||||
$this->yyTokenName[$iLookAhead] . " => " .
|
||||
$this->yyTokenName[$iFallback] . "\n");
|
||||
fwrite($this->yyTraceFILE, $this->yyTracePrompt . "FALLBACK " . $this->yyTokenName[$iLookAhead] . " => " . $this->yyTokenName[$iFallback] . "\n");
|
||||
}
|
||||
|
||||
return $this->yy_find_shift_action($iFallback);
|
||||
@@ -699,8 +682,7 @@ static public $yy_action = array(
|
||||
return self::YY_NO_ACTION;
|
||||
}
|
||||
$i += $iLookAhead;
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB ||
|
||||
self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
|
||||
return self::$yy_default[$stateno];
|
||||
} else {
|
||||
return self::$yy_action[$i];
|
||||
@@ -709,19 +691,19 @@ static public $yy_action = array(
|
||||
|
||||
public function yy_shift($yyNewState, $yyMajor, $yypMinor)
|
||||
{
|
||||
$this->yyidx++;
|
||||
$this->yyidx ++;
|
||||
if ($this->yyidx >= self::YYSTACKDEPTH) {
|
||||
$this->yyidx--;
|
||||
$this->yyidx --;
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sStack Overflow!\n", $this->yyTracePrompt);
|
||||
}
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
#line 255 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 255 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
$this->internalError = true;
|
||||
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
|
||||
$this->internalError = true;
|
||||
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -729,152 +711,132 @@ static public $yy_action = array(
|
||||
$yytos->stateno = $yyNewState;
|
||||
$yytos->major = $yyMajor;
|
||||
$yytos->minor = $yypMinor;
|
||||
array_push($this->yystack, $yytos);
|
||||
$this->yystack[] = $yytos;
|
||||
if ($this->yyTraceFILE && $this->yyidx > 0) {
|
||||
fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt,
|
||||
$yyNewState);
|
||||
fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt, $yyNewState);
|
||||
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
|
||||
for ($i = 1; $i <= $this->yyidx; $i++) {
|
||||
fprintf($this->yyTraceFILE, " %s",
|
||||
$this->yyTokenName[$this->yystack[$i]->major]);
|
||||
for ($i = 1; $i <= $this->yyidx; $i ++) {
|
||||
fprintf($this->yyTraceFILE, " %s", $this->yyTokenName[$this->yystack[$i]->major]);
|
||||
}
|
||||
fwrite($this->yyTraceFILE,"\n");
|
||||
fwrite($this->yyTraceFILE, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
public static $yyRuleInfo = array(
|
||||
array( 0 => 20, 1 => 2 ),
|
||||
array( 0 => 21, 1 => 1 ),
|
||||
array( 0 => 22, 1 => 2 ),
|
||||
array( 0 => 22, 1 => 0 ),
|
||||
array( 0 => 24, 1 => 5 ),
|
||||
array( 0 => 24, 1 => 6 ),
|
||||
array( 0 => 23, 1 => 2 ),
|
||||
array( 0 => 23, 1 => 2 ),
|
||||
array( 0 => 23, 1 => 0 ),
|
||||
array( 0 => 26, 1 => 3 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 27, 1 => 3 ),
|
||||
array( 0 => 27, 1 => 2 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 27, 1 => 1 ),
|
||||
array( 0 => 25, 1 => 1 ),
|
||||
array( 0 => 25, 1 => 2 ),
|
||||
array( 0 => 25, 1 => 3 ),
|
||||
);
|
||||
public static $yyRuleInfo = array(array(0 => 20, 1 => 2), array(0 => 21, 1 => 1), array(0 => 22, 1 => 2), array(0 => 22, 1 => 0), array(0 => 24, 1 => 5), array(0 => 24, 1 => 6), array(0 => 23, 1 => 2), array(0 => 23, 1 => 2), array(0 => 23, 1 => 0), array(0 => 26, 1 => 3), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 3), array(0 => 27, 1 => 2), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 25, 1 => 1), array(0 => 25, 1 => 2), array(0 => 25, 1 => 3),);
|
||||
|
||||
public static $yyReduceMap = array(
|
||||
0 => 0,
|
||||
2 => 0,
|
||||
3 => 0,
|
||||
19 => 0,
|
||||
20 => 0,
|
||||
21 => 0,
|
||||
1 => 1,
|
||||
4 => 4,
|
||||
5 => 5,
|
||||
6 => 6,
|
||||
7 => 7,
|
||||
8 => 8,
|
||||
9 => 9,
|
||||
10 => 10,
|
||||
11 => 11,
|
||||
12 => 12,
|
||||
13 => 13,
|
||||
14 => 14,
|
||||
15 => 15,
|
||||
16 => 16,
|
||||
17 => 17,
|
||||
18 => 17,
|
||||
);
|
||||
#line 261 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r0(){
|
||||
$this->_retvalue = null;
|
||||
public static $yyReduceMap = array(0 => 0, 2 => 0, 3 => 0, 19 => 0, 20 => 0, 21 => 0, 1 => 1, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 17,);
|
||||
|
||||
#line 261 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r0()
|
||||
{
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
#line 266 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r1(){
|
||||
$this->add_global_vars($this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = null;
|
||||
|
||||
#line 266 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r1()
|
||||
{
|
||||
$this->add_global_vars($this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
#line 280 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r4(){
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = null;
|
||||
|
||||
#line 280 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r4()
|
||||
{
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r5(){
|
||||
if ($this->configReadHidden) {
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
|
||||
#line 285 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r5()
|
||||
{
|
||||
if ($this->configReadHidden) {
|
||||
$this->add_section_vars($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
$this->_retvalue = null;
|
||||
}
|
||||
$this->_retvalue = null;
|
||||
|
||||
#line 293 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r6()
|
||||
{
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
|
||||
}
|
||||
#line 293 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r6(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
|
||||
#line 297 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r7()
|
||||
{
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + - 1]->minor, Array($this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
#line 297 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r7(){
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor, Array($this->yystack[$this->yyidx + 0]->minor));
|
||||
|
||||
#line 301 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r8()
|
||||
{
|
||||
$this->_retvalue = Array();
|
||||
}
|
||||
#line 301 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r8(){
|
||||
$this->_retvalue = Array();
|
||||
|
||||
#line 307 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r9()
|
||||
{
|
||||
$this->_retvalue = Array("key" => $this->yystack[$this->yyidx + - 2]->minor, "value" => $this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 307 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r9(){
|
||||
$this->_retvalue = Array("key" => $this->yystack[$this->yyidx + -2]->minor, "value" => $this->yystack[$this->yyidx + 0]->minor);
|
||||
|
||||
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r10()
|
||||
{
|
||||
$this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 312 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r10(){
|
||||
$this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor;
|
||||
|
||||
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r11()
|
||||
{
|
||||
$this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
#line 316 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r11(){
|
||||
$this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor;
|
||||
|
||||
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r12()
|
||||
{
|
||||
$this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 320 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r12(){
|
||||
$this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor);
|
||||
|
||||
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r13()
|
||||
{
|
||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 324 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r13(){
|
||||
$this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
|
||||
#line 328 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r14()
|
||||
{
|
||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
#line 328 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r14(){
|
||||
$this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor);
|
||||
|
||||
#line 332 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r15()
|
||||
{
|
||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + - 1]->minor);
|
||||
}
|
||||
#line 332 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r15(){
|
||||
$this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + -1]->minor);
|
||||
|
||||
#line 336 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r16()
|
||||
{
|
||||
$this->_retvalue = '';
|
||||
}
|
||||
#line 336 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r16(){
|
||||
$this->_retvalue = '';
|
||||
}
|
||||
#line 340 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r17(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
|
||||
#line 340 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
function yy_r17()
|
||||
{
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
|
||||
private $_retvalue;
|
||||
|
||||
public function yy_reduce($yyruleno)
|
||||
{
|
||||
$yymsp = $this->yystack[$this->yyidx];
|
||||
if ($this->yyTraceFILE && $yyruleno >= 0
|
||||
&& $yyruleno < count(self::$yyRuleName)) {
|
||||
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n",
|
||||
$this->yyTracePrompt, $yyruleno,
|
||||
self::$yyRuleName[$yyruleno]);
|
||||
if ($this->yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) {
|
||||
fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", $this->yyTracePrompt, $yyruleno, self::$yyRuleName[$yyruleno]);
|
||||
}
|
||||
|
||||
$this->_retvalue = $yy_lefthand_side = null;
|
||||
if (array_key_exists($yyruleno, self::$yyReduceMap)) {
|
||||
if (isset(self::$yyReduceMap[$yyruleno])) {
|
||||
// call the action
|
||||
$this->_retvalue = null;
|
||||
$this->{'yy_r' . self::$yyReduceMap[$yyruleno]}();
|
||||
@@ -883,14 +845,14 @@ static public $yy_action = array(
|
||||
$yygoto = self::$yyRuleInfo[$yyruleno][0];
|
||||
$yysize = self::$yyRuleInfo[$yyruleno][1];
|
||||
$this->yyidx -= $yysize;
|
||||
for ($i = $yysize; $i; $i--) {
|
||||
for ($i = $yysize; $i; $i --) {
|
||||
// pop all of the right-hand side parameters
|
||||
array_pop($this->yystack);
|
||||
}
|
||||
$yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto);
|
||||
if ($yyact < self::YYNSTATE) {
|
||||
if (!$this->yyTraceFILE && $yysize) {
|
||||
$this->yyidx++;
|
||||
$this->yyidx ++;
|
||||
$x = new TPC_yyStackEntry;
|
||||
$x->stateno = $yyact;
|
||||
$x->major = $yygoto;
|
||||
@@ -908,32 +870,34 @@ static public $yy_action = array(
|
||||
{
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sFail!\n", $this->yyTracePrompt);
|
||||
} while ($this->yyidx >= 0) {
|
||||
}
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
}
|
||||
|
||||
public function yy_syntax_error($yymajor, $TOKEN)
|
||||
{
|
||||
#line 248 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 248 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
$this->internalError = true;
|
||||
$this->yymajor = $yymajor;
|
||||
$this->compiler->trigger_config_file_error();
|
||||
$this->internalError = true;
|
||||
$this->yymajor = $yymajor;
|
||||
$this->compiler->trigger_config_file_error();
|
||||
}
|
||||
|
||||
public function yy_accept()
|
||||
{
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sAccept!\n", $this->yyTracePrompt);
|
||||
} while ($this->yyidx >= 0) {
|
||||
}
|
||||
while ($this->yyidx >= 0) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
#line 241 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
#line 241 "../smarty/lexer/smarty_internal_configfileparser.y"
|
||||
|
||||
$this->successful = !$this->internalError;
|
||||
$this->internalError = false;
|
||||
$this->retvalue = $this->_retvalue;
|
||||
$this->successful = !$this->internalError;
|
||||
$this->internalError = false;
|
||||
$this->retvalue = $this->_retvalue;
|
||||
}
|
||||
|
||||
public function doParse($yymajor, $yytokenvalue)
|
||||
@@ -942,30 +906,28 @@ static public $yy_action = array(
|
||||
|
||||
if ($this->yyidx === null || $this->yyidx < 0) {
|
||||
$this->yyidx = 0;
|
||||
$this->yyerrcnt = -1;
|
||||
$this->yyerrcnt = - 1;
|
||||
$x = new TPC_yyStackEntry;
|
||||
$x->stateno = 0;
|
||||
$x->major = 0;
|
||||
$this->yystack = array();
|
||||
array_push($this->yystack, $x);
|
||||
$this->yystack[] = $x;
|
||||
}
|
||||
$yyendofinput = ($yymajor==0);
|
||||
$yyendofinput = ($yymajor == 0);
|
||||
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sInput %s\n",
|
||||
$this->yyTracePrompt, $this->yyTokenName[$yymajor]);
|
||||
fprintf($this->yyTraceFILE, "%sInput %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
|
||||
}
|
||||
|
||||
do {
|
||||
$yyact = $this->yy_find_shift_action($yymajor);
|
||||
if ($yymajor < self::YYERRORSYMBOL &&
|
||||
!$this->yy_is_expected_token($yymajor)) {
|
||||
if ($yymajor < self::YYERRORSYMBOL && !$this->yy_is_expected_token($yymajor)) {
|
||||
// force a syntax error
|
||||
$yyact = self::YY_ERROR_ACTION;
|
||||
}
|
||||
if ($yyact < self::YYNSTATE) {
|
||||
$this->yy_shift($yyact, $yymajor, $yytokenvalue);
|
||||
$this->yyerrcnt--;
|
||||
$this->yyerrcnt --;
|
||||
if ($yyendofinput && $this->yyidx >= 0) {
|
||||
$yymajor = 0;
|
||||
} else {
|
||||
@@ -975,8 +937,7 @@ static public $yy_action = array(
|
||||
$this->yy_reduce($yyact - self::YYNSTATE);
|
||||
} elseif ($yyact == self::YY_ERROR_ACTION) {
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sSyntax Error!\n",
|
||||
$this->yyTracePrompt);
|
||||
fprintf($this->yyTraceFILE, "%sSyntax Error!\n", $this->yyTracePrompt);
|
||||
}
|
||||
if (self::YYERRORSYMBOL) {
|
||||
if ($this->yyerrcnt < 0) {
|
||||
@@ -985,19 +946,15 @@ static public $yy_action = array(
|
||||
$yymx = $this->yystack[$this->yyidx]->major;
|
||||
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit) {
|
||||
if ($this->yyTraceFILE) {
|
||||
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n",
|
||||
$this->yyTracePrompt, $this->yyTokenName[$yymajor]);
|
||||
fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
|
||||
}
|
||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||
$yymajor = self::YYNOCODE;
|
||||
} else {
|
||||
while ($this->yyidx >= 0 &&
|
||||
$yymx != self::YYERRORSYMBOL &&
|
||||
($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE
|
||||
){
|
||||
while ($this->yyidx >= 0 && $yymx != self::YYERRORSYMBOL && ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE) {
|
||||
$this->yy_pop_parser_stack();
|
||||
}
|
||||
if ($this->yyidx < 0 || $yymajor==0) {
|
||||
if ($this->yyidx < 0 || $yymajor == 0) {
|
||||
$this->yy_destructor($yymajor, $yytokenvalue);
|
||||
$this->yy_parse_failed();
|
||||
$yymajor = self::YYNOCODE;
|
||||
|
||||
@@ -157,7 +157,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
/**
|
||||
* End logging of cache time
|
||||
*
|
||||
* @param o\Smarty_Internal_Template $template cached template
|
||||
* @param \Smarty_Internal_Template $template cached template
|
||||
*/
|
||||
public static function end_cache(Smarty_Internal_Template $template)
|
||||
{
|
||||
@@ -196,32 +196,45 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$savedIndex = self::$index;
|
||||
self::$index = 9999;
|
||||
}
|
||||
if ($obj instanceof Smarty) {
|
||||
$smarty = $obj;
|
||||
} else {
|
||||
$smarty = $obj->smarty;
|
||||
}
|
||||
// create fresh instance of smarty for displaying the debug console
|
||||
// to avoid problems if the application did overload the Smarty class
|
||||
$debObj = new Smarty();
|
||||
// copy the working dirs from application
|
||||
$debObj->setCompileDir($smarty->getCompileDir());
|
||||
// init properties by hand as user may have edited the original Smarty class
|
||||
$debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ . '/../plugins' : $smarty->getPluginsDir());
|
||||
$debObj->force_compile = false;
|
||||
$debObj->compile_check = true;
|
||||
$debObj->left_delimiter = '{';
|
||||
$debObj->right_delimiter = '}';
|
||||
$debObj->security_policy = null;
|
||||
$debObj->debugging = false;
|
||||
$debObj->debugging_ctrl = 'NONE';
|
||||
$debObj->error_reporting = E_ALL & ~E_NOTICE;
|
||||
$debObj->debug_tpl = isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl';
|
||||
$debObj->registered_plugins = array();
|
||||
$debObj->registered_resources = array();
|
||||
$debObj->registered_filters = array();
|
||||
$debObj->autoload_filters = array();
|
||||
$debObj->default_modifiers = array();
|
||||
$debObj->escape_html = true;
|
||||
$debObj->caching = false;
|
||||
$debObj->compile_id = null;
|
||||
$debObj->cache_id = null;
|
||||
// prepare information of assigned variables
|
||||
$ptr = self::get_debug_vars($obj);
|
||||
if ($obj instanceof Smarty) {
|
||||
$smarty = clone $obj;
|
||||
} else {
|
||||
$smarty = clone $obj->smarty;
|
||||
}
|
||||
$debugging = $smarty->debugging;
|
||||
$_assigned_vars = $ptr->tpl_vars;
|
||||
ksort($_assigned_vars);
|
||||
$_config_vars = $ptr->config_vars;
|
||||
ksort($_config_vars);
|
||||
$smarty->registered_filters = array();
|
||||
$smarty->autoload_filters = array();
|
||||
$smarty->default_modifiers = array();
|
||||
$smarty->force_compile = false;
|
||||
$smarty->left_delimiter = '{';
|
||||
$smarty->right_delimiter = '}';
|
||||
$smarty->debugging = false;
|
||||
$smarty->debugging_ctrl = 'NONE';
|
||||
$smarty->force_compile = false;
|
||||
$_template = new Smarty_Internal_Template($smarty->debug_tpl, $smarty);
|
||||
$_template->caching = false;
|
||||
$_template->smarty->disableSecurity();
|
||||
$_template->cache_id = null;
|
||||
$_template->compile_id = null;
|
||||
$debugging = $smarty->debugging;
|
||||
|
||||
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
|
||||
if ($obj instanceof Smarty_Internal_Template) {
|
||||
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/**
|
||||
* Class Smarty_Internal_Extension_CodeFrame
|
||||
* Create code frame for compiled and cached templates
|
||||
|
||||
*/
|
||||
class Smarty_Internal_Extension_CodeFrame
|
||||
{
|
||||
@@ -78,11 +77,19 @@ class Smarty_Internal_Extension_CodeFrame
|
||||
$output .= "?>/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/';\n";
|
||||
}
|
||||
}
|
||||
$output .= "?>\n" . $content;
|
||||
$output .= "<?php }\n}\n?>";
|
||||
return $output;
|
||||
$output .= "?>\n";
|
||||
$output = self::appendCode($output, $content);
|
||||
return self::appendCode($output, "<?php }\n}\n?>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create code frame of compiled template function
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_template
|
||||
* @param string $content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function createFunctionFrame(Smarty_Internal_Template $_template, $content = '')
|
||||
{
|
||||
if (!isset($_template->properties['unifunc'])) {
|
||||
@@ -98,4 +105,23 @@ class Smarty_Internal_Extension_CodeFrame
|
||||
$output .= "}\n}\n?>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append code segments and remove unneeded ?> <?php transitions
|
||||
*
|
||||
* @param string $left
|
||||
* @param string $right
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function appendCode($left, $right)
|
||||
{
|
||||
if (preg_match('/\s*\?>$/', $left) && preg_match('/^<\?php\s+/', $right)) {
|
||||
$left = preg_replace('/\s*\?>$/', "\n", $left);
|
||||
$left .= preg_replace('/^<\?php\s+/', '', $right);
|
||||
} else {
|
||||
$left .= $right;
|
||||
}
|
||||
return $left;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class Smarty_Internal_Extension_Config
|
||||
// not found, try at parent
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
if ($smarty->error_unassigned && $error_enable) {
|
||||
if ($obj->error_unassigned && $error_enable) {
|
||||
// force a notice
|
||||
$x = $$variable;
|
||||
}
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
*/
|
||||
abstract class Smarty_Internal_ParseTree
|
||||
{
|
||||
|
||||
/**
|
||||
* Parser object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $parser;
|
||||
|
||||
/**
|
||||
* Buffer content
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Templateparser Parsetrees
|
||||
* These are classes to build parsetrees in the template parser
|
||||
* Smarty Internal Plugin Templateparser Parse Tree
|
||||
* These are classes to build parse trees in the template parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* @subpackage Compiler
|
||||
* @ignore
|
||||
*/
|
||||
|
||||
/**
|
||||
* Double quoted string inside a tag.
|
||||
*
|
||||
@@ -19,8 +20,8 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
|
||||
/**
|
||||
* Create parse tree buffer for double quoted string subtrees
|
||||
*
|
||||
* @param object $parser parser object
|
||||
* @param Smarty_Internal_ParseTree $subtree parsetree buffer
|
||||
* @param object $parser parser object
|
||||
* @param Smarty_Internal_ParseTree $subtree parse tree buffer
|
||||
*/
|
||||
public function __construct($parser, Smarty_Internal_ParseTree $subtree)
|
||||
{
|
||||
@@ -34,18 +35,18 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
|
||||
/**
|
||||
* Append buffer to subtree
|
||||
*
|
||||
* @param Smarty_Internal_ParseTree $subtree parsetree buffer
|
||||
* @param Smarty_Internal_ParseTree $subtree parse tree buffer
|
||||
*/
|
||||
public function append_subtree(Smarty_Internal_ParseTree $subtree)
|
||||
{
|
||||
$last_subtree = count($this->subtrees) - 1;
|
||||
if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) {
|
||||
if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
|
||||
$this->subtrees[$last_subtree]->data .= '<?php echo ' . $subtree->data . ';?>';
|
||||
$this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
|
||||
} elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
|
||||
$this->subtrees[$last_subtree]->data .= '<?php echo "' . $subtree->data . '";?>';
|
||||
$this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
|
||||
} else {
|
||||
$this->subtrees[$last_subtree]->data .= $subtree->data;
|
||||
$this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
|
||||
}
|
||||
} else {
|
||||
$this->subtrees[] = $subtree;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Templateparser Parsetrees
|
||||
* These are classes to build parsetrees in the template parser
|
||||
* Smarty Internal Plugin Templateparser Parse Tree
|
||||
* These are classes to build parse tree in the template parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
@@ -9,7 +9,6 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Raw chars as part of a double quoted string.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Templateparser Parsetrees
|
||||
* These are classes to build parsetrees in the template parser
|
||||
* Smarty Internal Plugin Templateparser Parse Tree
|
||||
* These are classes to build parse tree in the template parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
|
||||
{
|
||||
|
||||
/**
|
||||
* Saved block nesting level
|
||||
*
|
||||
@@ -56,7 +57,9 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
|
||||
public function assign_to_var()
|
||||
{
|
||||
$var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number);
|
||||
$this->parser->compiler->prefix_code[] = sprintf("<?php ob_start();?>%s<?php %s=ob_get_clean();?>", $this->data, $var);
|
||||
$tmp = $this->parser->compiler->appendCode('<?php ob_start();?>', $this->data);
|
||||
$tmp = $this->parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
|
||||
$this->parser->compiler->prefix_code[] = sprintf("%s", $tmp);
|
||||
|
||||
return $var;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Templateparser Parsetrees
|
||||
* These are classes to build parsetrees in the template parser
|
||||
* Smarty Internal Plugin Templateparser Parse Tree
|
||||
* These are classes to build parse tree in the template parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
{
|
||||
|
||||
/**
|
||||
* Array of template elements
|
||||
*
|
||||
@@ -44,8 +45,10 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
{
|
||||
if (!empty($subtree->subtrees)) {
|
||||
$this->subtrees = array_merge($this->subtrees, $subtree->subtrees);
|
||||
} else if ($subtree->data !== '') {
|
||||
$this->subtrees[] = $subtree;
|
||||
} else {
|
||||
if ($subtree->data !== '') {
|
||||
$this->subtrees[] = $subtree;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +73,7 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
if ($subtree == '') {
|
||||
continue;
|
||||
}
|
||||
$code .= preg_replace('/(<%|%>|<\?php|<\?|\?>|<\/?script)/', "<?php echo '\$1'; ?>\n", $subtree);
|
||||
$code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n", $subtree);
|
||||
continue;
|
||||
}
|
||||
if ($this->subtrees[$key] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||
@@ -80,13 +83,7 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
||||
if ($this->subtrees[$key]->data == '') {
|
||||
continue;
|
||||
}
|
||||
$newCode = $this->subtrees[$key]->to_smarty_php();
|
||||
if ((preg_match('/^\s*<\?php\s+/', $newCode) && preg_match('/\s*\?>\s*$/', $subtree))) {
|
||||
$subtree = preg_replace('/\s*\?>\s*$/', "\n", $subtree);
|
||||
$subtree .= preg_replace('/^\s*<\?php\s+/', '', $newCode);
|
||||
} else {
|
||||
$subtree .= $newCode;
|
||||
}
|
||||
$subtree = $this->parser->compiler->appendCode($subtree, $this->subtrees[$key]->to_smarty_php());
|
||||
}
|
||||
if ($subtree == '') {
|
||||
continue;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Templateparser Parsetrees
|
||||
* These are classes to build parsetrees in the template parser
|
||||
* Smarty Internal Plugin Templateparser Parse Tree
|
||||
* These are classes to build parse tree in the template parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
abstract class Smarty_Internal_TemplateCompilerBase
|
||||
{
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
@@ -128,6 +129,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
* @var string
|
||||
*/
|
||||
public $trace_filepath = '';
|
||||
|
||||
/**
|
||||
* stack for tracing file and line of nested {block} tags
|
||||
*
|
||||
@@ -205,6 +207,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public $templateFunctionCode = '';
|
||||
|
||||
/**
|
||||
* php_handling setting either from Smarty or security
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $php_handling = 0;
|
||||
|
||||
/**
|
||||
* flags for used modifier plugins
|
||||
*
|
||||
@@ -317,6 +326,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, $parent_compiler = null)
|
||||
{
|
||||
// save template object in compiler class
|
||||
$this->template = $template;
|
||||
if (isset($this->template->smarty->security_policy)) {
|
||||
$this->php_handling = $this->template->smarty->security_policy->php_handling;
|
||||
} else {
|
||||
$this->php_handling = $this->template->smarty->php_handling;
|
||||
}
|
||||
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
||||
$nocache = isset($nocache) ? $nocache : false;
|
||||
if (empty($template->properties['nocache_hash'])) {
|
||||
@@ -327,8 +343,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
// flag for nochache sections
|
||||
$this->nocache = $nocache;
|
||||
$this->tag_nocache = false;
|
||||
// save template object in compiler class
|
||||
$this->template = $template;
|
||||
// reset has nocache code flag
|
||||
$this->template->has_nocache_code = false;
|
||||
$save_source = $this->template->source;
|
||||
@@ -361,6 +375,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->inheritance_child = false;
|
||||
}
|
||||
do {
|
||||
// flag for nochache sections
|
||||
$this->nocache = $nocache;
|
||||
$this->tag_nocache = false;
|
||||
// reset has nocache code flag
|
||||
$this->template->has_nocache_code = false;
|
||||
$this->has_variable_string = false;
|
||||
$this->prefix_code = array();
|
||||
$_compiled_code = '';
|
||||
// flag for aborting current and start recompile
|
||||
$this->abort_and_recompile = false;
|
||||
@@ -466,8 +487,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->template->used_tags[] = array($tag, $args);
|
||||
}
|
||||
// check nocache option flag
|
||||
if (in_array("'nocache'", $args) || in_array(array('nocache' => 'true'), $args)
|
||||
|| in_array(array('nocache' => '"true"'), $args) || in_array(array('nocache' => "'true'"), $args)
|
||||
if (in_array("'nocache'", $args) || in_array(array('nocache' => 'true'), $args) || in_array(array('nocache' => '"true"'), $args) || in_array(array('nocache' => "'true'"), $args)
|
||||
) {
|
||||
$this->tag_nocache = true;
|
||||
}
|
||||
@@ -507,8 +527,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
// check if tag is a registered object
|
||||
if (isset($this->smarty->registered_objects[$tag]) && isset($parameter['object_method'])) {
|
||||
$method = $parameter['object_method'];
|
||||
if (!in_array($method, $this->smarty->registered_objects[$tag][3]) &&
|
||||
(empty($this->smarty->registered_objects[$tag][1]) || in_array($method, $this->smarty->registered_objects[$tag][1]))
|
||||
if (!in_array($method, $this->smarty->registered_objects[$tag][3]) && (empty($this->smarty->registered_objects[$tag][1]) || in_array($method, $this->smarty->registered_objects[$tag][1]))
|
||||
) {
|
||||
return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
|
||||
} elseif (in_array($method, $this->smarty->registered_objects[$tag][3])) {
|
||||
@@ -703,9 +722,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public function processText($text)
|
||||
{
|
||||
if ($this->inheritance_child && !$this->blockTagNestingLevel) {
|
||||
return null;
|
||||
}
|
||||
if ($this->parser->strip) {
|
||||
return new Smarty_Internal_ParseTree_Text($this->parser, preg_replace($this->stripRegEx, '', $text));
|
||||
} else {
|
||||
@@ -820,9 +836,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$callback = null;
|
||||
$script = null;
|
||||
$cacheable = true;
|
||||
$result = call_user_func_array(
|
||||
$this->smarty->default_plugin_handler_func, array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable)
|
||||
);
|
||||
$result = call_user_func_array($this->smarty->default_plugin_handler_func, array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable));
|
||||
if ($result) {
|
||||
$this->tag_nocache = $this->tag_nocache || !$cacheable;
|
||||
if ($script !== null) {
|
||||
@@ -854,6 +868,25 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append code segments and remove unneeded ?> <?php transitions
|
||||
*
|
||||
* @param string $left
|
||||
* @param string $right
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function appendCode($left, $right)
|
||||
{
|
||||
if (preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) {
|
||||
$left = preg_replace('/\s*\?>\s*$/', "\n", $left);
|
||||
$left .= preg_replace('/^\s*<\?php\s+/', '', $right);
|
||||
} else {
|
||||
$left .= $right;
|
||||
}
|
||||
return $left;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject inline code for nocache template sections
|
||||
* This method gets the content of each template element from the parser.
|
||||
@@ -870,8 +903,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
// If the template is not evaluated and we have a nocache section and or a nocache tag
|
||||
if ($is_code && !empty($content)) {
|
||||
// generate replacement code
|
||||
if ((!($this->template->source->recompiled) || $this->forceNocache) && $this->template->caching && !$this->suppressNocacheProcessing &&
|
||||
($this->nocache || $this->tag_nocache)
|
||||
if ((!($this->template->source->recompiled) || $this->forceNocache) && $this->template->caching && !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
|
||||
) {
|
||||
$this->template->has_nocache_code = true;
|
||||
$_output = addcslashes($content, '\'\\');
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -108,7 +108,6 @@ class Smarty_Security
|
||||
'count', 'sizeof',
|
||||
'in_array', 'is_array',
|
||||
'time',
|
||||
'nl2br',
|
||||
);
|
||||
/**
|
||||
* This is an array of trusted PHP modifiers.
|
||||
@@ -119,7 +118,8 @@ class Smarty_Security
|
||||
*/
|
||||
public $php_modifiers = array(
|
||||
'escape',
|
||||
'count'
|
||||
'count',
|
||||
'nl2br',
|
||||
);
|
||||
/**
|
||||
* This is an array of allowed tags.
|
||||
|
||||
Reference in New Issue
Block a user