Commit 0d66308a authored by Mike Gabriel's avatar Mike Gabriel

Imported Upstream version 3.1.30

parent c84bdf12
......@@ -8,15 +8,17 @@ php:
- 7.0
- hhvm
matrix:
allow_failures:
- php: hhvm
services:
- memcached
- mysql
before_script:
- travis_retry composer --prefer-source --dev install
- if [ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]; then travis_retry composer --prefer-source --dev install; fi
- if [ ${TRAVIS_PHP_VERSION:0:3} <= "5.6" ]; then phpenv config-add travis.ini; fi
- mysql -e "create database IF NOT EXISTS test;" -uroot
install:
- git clone --depth=50 --branch=master git://github.com/smarty-php/smarty-phpunit.git
- git clone --depth=50 --branch v3.1.30 git://github.com/smarty-php/smarty-phpunit.git
script:
- cd smarty-phpunit
......
......@@ -5,7 +5,7 @@ This does resolve all known existing restrictions (see below).
The $smarty::$inheritance_merge_compiled_includes property has been removed.
Any access to it is ignored.
This does enable some new features:
New features:
Any code outside root {block} tags in child templates is now executed but any output will be ignored.
......@@ -31,7 +31,16 @@ Any code outside root {block} tags in child templates is now executed but any ou
{/if}
{/block}
{block} tags can have variable names.
{block $foo}
....
{/block}
Starting with 3.1.28 you can mix inheritance by extends resuorce with the {extends} tag.
A template called by extends resoure can extend a subtemple or chain buy the {extends} tag.
NOTE There is a BC break. If you used the extends resource {extends} tags have been ignored.
THE FOLLOWING RESTRICTIONS ARE NO LONGER EXISTING:
In Smarty 3.1 template inheritance is a compile time process. All the extending of {block} tags
......
......@@ -2,6 +2,108 @@
This file contains a brief description of new features which have been added to Smarty 3.1
Smarty 3.1.30
Loop optimization {foreach} and {section}
=========================================
Smarty does optimize the {foreach} and {section} loops by removing code for not needed loop
properties.
The compiler collects needed properties by scanning the current template for $item@property,
$smarty.foreach.name.property and $smarty.section.name.property.
The compiler does not know if additional properties will be needed outside the current template scope.
Additional properties can be generated by adding them with the property attribute.
Example:
index.tpl
{foreach $from as $item properties=[iteration, index]}
{include 'sub.tpl'}
{$item.total}
{/foreach}
sub.tpl
{$item.index} {$item.iteration} {$item.total}
In above example code for the 'total' property is automatically generated as $item.total is used in
index.tpl. Code for 'iteration' and 'index' must be added with properties=[iteration, index].
New tag {make_nocache}
======================
Syntax: {make_nocache $foo}
This tag makes a variable which does exists normally only while rendering the compiled template
available in the cached template for use in not cached expressions.
Expample:
{foreach from=$list item=item}
<li>{$item.name} {make_nocache $item}{if $current==$item.id} ACTIVE{/if}</li>
{/foreach}
The {foreach} loop is rendered while processing the compiled template, but $current is a nocache
variable. Normally the {if $current==$item.id} would fail as the $item variable is unkown in the
cached template. {make_nocache $item} does make the current $item value known in thee cached template.
{make_nocache} is ignored when caching is disabled or the variable does exists as nocache variable.
NOTE: if the variable value does contain objects these must have the __set_state method implemented.
Scope Attributes
================
The scope handling has been updated to cover all cases of variable assignments in templates.
The tags {assign}, {append} direct assignments like {$foo = ...}, {$foo[...]= ...} support
the following optional scope attributes:
scope='parent' - the variable will be assigned in the current template and if the template
was included by {include} the calling template
scope='tpl_root' - the variable will be assigned in the outermost root template called by $smarty->display()
or $smarty->fetch() and is bubbled up all {include} sub-templates to the current template.
scope='smarty' - the variable will be assigned in the Smarty object and is bubbled up all {include} sub-templates
to the current template.
scope='global' - the variable will be assigned as Smarty object global variable and is bubbled up all {include}
sub-templates to the current template.
scope='root' - the variable will be assigned if a data object was used for variable definitions in the data
object or in the Smarty object otherwise and is bubbled up all {include} sub-templates to the
current template.
scope='local' - this scope has only a meaning if the tag is called within a template {function}.
The variable will be assigned in the local scope of the template function and the
template which did call the template function.
The {config_load} tag supports all of the above except the global scope.
The scope attribute can be used also with the {include} tag.
Supported scope are parent, tpl_root, smarty, global and root.
A scope used together with the {include} tag will cause that with some exceptions any variable
assignment within that sub-template will update/assign the variable in other scopes according
to the above rules. It does include also variables assigned by plugins, tags supporting the assign=foo
attribute and direct assignments in {if} and {while} like {if $foo=$bar}.
Excluded are the key and value variables of {foreach}, {for} loop variables , variables passed by attributes
in {include} and direct increments/decrements like {$foo++}, {$foo--}
Note: The scopes should be used only to the extend really need. If a variable value assigned in an included
sub-template should be returned to the calling sub-template just use {$foo='bar' scope='parent'}.
Use scopes only with variables for which it's realy needed. Avoid general scope settings with the
{include} tag as it can have a performance impact.
The {assign}, {append}, {config_load} and {$foo...=...} tags have a new option flag 'noscope'.Thi
Example: {$foo='bar' noscope} This will assign $foo only in the current template and any scope settings
at {include} is ignored.
Caching
=======
Caching does now observe the template_dir setting and will create separate cache files if required
Compiled Templates
==================
The template_dir setting is now encoded in the uid of the file name.
The content of the compiled template may depend on the template_dir search order
{include .... inline} is used or $smarty->merge_compiled_includes is enabled
APC
===
If APC is enabled force an apc_compile_file() when compiled or cached template was updated
Smarty 3.1.28
OPCACHE
......@@ -32,7 +134,7 @@ Smarty 3.1.28
The template_dir array is searched in the order of the indices. (Could be used to change the default search order)
Example:
$smarty->display('[1],[0]foo.bar');
Filter support
==============
Optional filter names
......@@ -47,7 +149,7 @@ Smarty 3.1.28
If you register multiple closures register each with a unique filter name.
- $smarty->registerFilter('pre', function($source) {return $source;}, 'closure_1');
- $smarty->registerFilter('pre', function($source) {return $source;}, 'closure_2');
Smarty 3.1.22
......@@ -120,7 +222,7 @@ Smarty 3.1.22
Debugging
=========
The layout of the debug window has been changed for better readability
New class constants
Smarty::DEBUG_OFF
Smarty::DEBUG_ON
......@@ -129,5 +231,3 @@ Smarty 3.1.22
Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual debug window.
.
This diff is collapsed.
......@@ -17,8 +17,8 @@ $smarty->cache_lifetime = 120;
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"), array("I", "J", "K", "L"),
array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
......
......@@ -32,7 +32,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
$_res = array();
$res = apc_fetch($keys);
foreach ($res as $k => $v) {
$_res[$k] = $v;
$_res[ $k ] = $v;
}
return $_res;
......
......@@ -21,7 +21,11 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
public function __construct()
{
$this->memcache = new Memcache();
if (class_exists('Memcached')) {
$this->memcache = new Memcached();
} else {
$this->memcache = new Memcache();
}
$this->memcache->addServer('127.0.0.1', 11211);
}
......@@ -39,12 +43,12 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
foreach ($keys as $k) {
$_k = sha1($k);
$_keys[] = $_k;
$lookup[$_k] = $k;
$lookup[ $_k ] = $k;
}
$_res = array();
$res = $this->memcache->get($_keys);
foreach ($res as $k => $v) {
$_res[$lookup[$k]] = $v;
$_res[ $lookup[ $k ] ] = $v;
}
return $_res;
......
......@@ -26,8 +26,11 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{
// PDO instance
protected $db;
protected $fetch;
protected $fetchTimestamp;
protected $save;
public function __construct()
......@@ -62,8 +65,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$content = $row['content'];
$mtime = strtotime($row['modified']);
$content = $row[ 'content' ];
$mtime = strtotime($row[ 'modified' ]);
} else {
$content = null;
$mtime = null;
......@@ -105,13 +108,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
*/
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$this->save->execute(array(
'id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,
));
$this->save->execute(array('id' => $id, 'name' => $name, 'cache_id' => $cache_id, 'compile_id' => $compile_id,
'content' => $content,));
return !!$this->save->rowCount();
}
......@@ -151,8 +149,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->db->quote($cache_id)
. ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
$where[] = '(cache_id = ' . $this->db->quote($cache_id) . ' OR cache_id LIKE ' .
$this->db->quote($cache_id . '|%') . ')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
......
......@@ -30,21 +30,21 @@
class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
{
protected $fetchStatements = Array('default' => 'SELECT %2$s
protected $fetchStatements = Array('default' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id IS NULL
AND compile_id IS NULL',
'withCacheId' => 'SELECT %2$s
'withCacheId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id = :cache_id
AND compile_id IS NULL',
'withCompileId' => 'SELECT %2$s
'withCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
......@@ -57,6 +57,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
AND id = :id
AND cache_id = :cache_id
AND compile_id = :compile_id');
protected $insertStatement = 'INSERT INTO %s
SET id = :id,
......@@ -76,9 +77,11 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
content = :content';
protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s';
protected $truncateStatement = 'TRUNCATE TABLE %s';
protected $fetchColumns = 'modified, content';
protected $fetchTimestampColumns = 'modified';
protected $pdo, $table, $database;
......@@ -137,13 +140,15 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
{
if (!is_null($cache_id) && !is_null($compile_id)) {
$query = $this->fetchStatements['withCacheIdAndCompileId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] AND
$args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
} elseif (is_null($cache_id) && !is_null($compile_id)) {
$query = $this->fetchStatements['withCompileId'] AND $args = Array('id' => $id, 'compile_id' => $compile_id);
$query = $this->fetchStatements[ 'withCompileId' ] AND
$args = Array('id' => $id, 'compile_id' => $compile_id);
} elseif (!is_null($cache_id) && is_null($compile_id)) {
$query = $this->fetchStatements['withCacheId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id);
$query = $this->fetchStatements[ 'withCacheId' ] AND $args = Array('id' => $id, 'cache_id' => $cache_id);
} else {
$query = $this->fetchStatements['default'] AND $args = Array('id' => $id);
$query = $this->fetchStatements[ 'default' ] AND $args = Array('id' => $id);
}
$query = sprintf($query, $columns);
......@@ -174,13 +179,13 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
{
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
$stmt ->execute();
$stmt->execute();
$row = $stmt->fetch();
$stmt ->closeCursor();
$stmt->closeCursor();
if ($row) {
$content = $this->outputContent($row['content']);
$mtime = strtotime($row['modified']);
$content = $this->outputContent($row[ 'content' ]);
$mtime = strtotime($row[ 'modified' ]);
} else {
$content = null;
$mtime = null;
......@@ -226,13 +231,13 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
$stmt = $this->pdo->prepare($this->insertStatement);
$stmt ->bindValue('id', $id);
$stmt ->bindValue('name', $name);
$stmt ->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt ->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt ->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
$stmt ->bindValue('content', $this->inputContent($content));
$stmt ->execute();
$stmt->bindValue('id', $id);
$stmt->bindValue('name', $name);
$stmt->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('expire', (int) $exp_time, PDO::PARAM_INT);
$stmt->bindValue('content', $this->inputContent($content));
$stmt->execute();
return !!$stmt->rowCount();
}
......@@ -289,8 +294,8 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = ' . $this->pdo->quote($cache_id)
. ' OR cache_id LIKE ' . $this->pdo->quote($cache_id . '|%') . ')';
$where[] = '(cache_id = ' . $this->pdo->quote($cache_id) . ' OR cache_id LIKE ' .
$this->pdo->quote($cache_id . '|%') . ')';
}
// equal test compile_id
if ($compile_id !== null) {
......
......@@ -23,7 +23,7 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
$uid = '';
$sources = array();
$timestamp = 0;
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
foreach ($source->smarty->getTemplateDir() as $key => $directory) {
try {
$s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name);
if (!$s->exists) {
......@@ -46,7 +46,7 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
$s = current($sources);
$source->components = $sources;
$source->filepath = $s->filepath;
$source->uid = sha1($uid . $_template->smarty->_joined_template_dir);
$source->uid = sha1($uid . $source->smarty->_joined_template_dir);
$source->exists = true;
$source->timestamp = $timestamp;
}
......
......@@ -21,8 +21,10 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{
// PDO instance
protected $db;
// prepared fetch() statement
protected $fetch;
// prepared fetchTimestamp() statement
protected $mtime;
......@@ -53,8 +55,8 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$source = $row['source'];
$mtime = strtotime($row['modified']);
$source = $row[ 'source' ];
$mtime = strtotime($row[ 'modified' ]);
} else {
$source = null;
$mtime = null;
......
......@@ -23,6 +23,7 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
{
// PDO instance
protected $db;
// prepared fetch() statement
protected $fetch;
......@@ -52,8 +53,8 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$source = $row['source'];
$mtime = strtotime($row['modified']);
$source = $row[ 'source' ];
$mtime = strtotime($row[ 'modified' ]);
} else {
$source = null;
$mtime = null;
......
......@@ -226,15 +226,15 @@ class Smarty_Internal_Templatelexer
{
$this->data = $data;
$this->counter = 0;
if (preg_match('~^\xEF\xBB\xBF~i', $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;
......@@ -266,7 +266,7 @@ class Smarty_Internal_Templatelexer
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
all = ~[\S\s]+~
emptyjava = ~[{][}]~
phptag = ~(SMARTYldel\s*php(.*?)SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
phptag = ~(SMARTYldel\s*php([ ].*?)?SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])~
slash = ~[/]~
ldel = ~SMARTYldel\s*~
......@@ -306,7 +306,8 @@ class Smarty_Internal_Templatelexer
literal = ~literal~
strip = ~strip~
lop = ~\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*~
tlop = ~\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\s+(not\s+)?(odd|even|div)\s+by))\s+~
slop = ~\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\s+~
tlop = ~\s+(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+~
......@@ -315,6 +316,7 @@ class Smarty_Internal_Templatelexer
block = ~block~
if = ~(if|elseif|else if|while)\s+~
for = ~for\s+~
makenocache = ~make_nocache\s+~
foreach = ~foreach(?![^\s])~
setfilter = ~setfilter\s+~
instanceof = ~\s+instanceof\s+~
......@@ -329,7 +331,7 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
comment {
preg_match("~[*]{$this->rdel}~",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
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 {
......@@ -367,7 +369,7 @@ class Smarty_Internal_Templatelexer
}
text {
$to = strlen($this->data);
preg_match("~($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<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];
}
......@@ -397,6 +399,11 @@ class Smarty_Internal_Templatelexer
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
ldel makenocache {
$this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
ldel id nocacherdel {
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
......@@ -479,6 +486,9 @@ class Smarty_Internal_Templatelexer
lop {
$this->token = Smarty_Internal_Templateparser::TP_LOGOP;
}
slop {
$this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
}
tlop {
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
}
......@@ -530,7 +540,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 {
......@@ -599,7 +609,7 @@ class Smarty_Internal_Templatelexer
}
text {
$to = strlen($this->data);
preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i",$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 {
......
......@@ -39,13 +39,6 @@ class Smarty_Internal_Templateparser
*/
public $retvalue = 0;
/**
* counter for prefix code
*
* @var int
*/
public static $prefix_number = 0;
/**
* @var
*/
......@@ -282,7 +275,7 @@ template_element(res)::= PHP(o). {
template_element(res)::= NOCACHE(c). {
$this->compiler->tag_nocache = true;
$save = $this->template->compiled->has_nocache_code;
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{c}';?>\n", $this->compiler, true));
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{c}';?>\n", true));
$this->template->compiled->has_nocache_code = $save;
}
// template text
......@@ -444,8 +437,7 @@ tag(res) ::= LDEL ID(i) modifierlist(l)attributes(a). {
}
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i, 'modifierlist'=>l));
} else {
res = '<?php ob_start();?>'.$this->compiler->compileTag(i,a).'<?php echo ';
res .= $this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>l,'value'=>'ob_get_clean()')).';?>';
res = $this->compiler->compileTag(i,a, array('modifierlist'=>l));
}
}
......@@ -456,8 +448,12 @@ tag(res) ::= LDEL ID(i) PTR ID(m) attributes(a). {
// registered object tag with modifiers
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()')).';?>';
res = $this->compiler->compileTag(i,a,array('modifierlist'=>l, 'object_method'=>me));
}
// nocache tag
tag(res) ::= LDELMAKENOCACHE DOLLARID(i). {
res = $this->compiler->compileTag('make_nocache',array(array('var'=>'\''.substr(i,1).'\'')));
}
// {if}, {elseif} and {while} tag
......@@ -697,10 +693,15 @@ expr(res) ::= expr(e) modifierlist(l). {
}
// if expression
// special conditions
expr(res) ::= expr(e1) tlop(c) value(e2). {
res = c['pre']. e1.c['op'].e2 .')';
}
// simple expression
expr(res) ::= expr(e1) lop(c) expr(e2). {
res = (isset(c['pre']) ? c['pre'] : '') . e1.c['op'].e2 . (isset(c['pre']) ? ')' : '');
res = e1.c.e2;
}
expr(res) ::= expr(e1) scond(c). {
res = c . e1 . ')';
}
......@@ -713,14 +714,6 @@ expr(res) ::= expr(e1) ISIN value(v). {
res = 'in_array('.e1.',(array)'.v.')';
}
expr(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
res = v1.i.v2;
}
expr(res) ::= variable(v1) INSTANCEOF(i) variable(v2). {
res = v1.i.v2;
}
//
// ternary
......@@ -799,6 +792,13 @@ value(res) ::= OPENP expr(e) CLOSEP. {
res = "(". e .")";
}
value(res) ::= variable(v1) INSTANCEOF(i) ns1(v2). {
res = v1.i.v2;
}
value(res) ::= variable(v1) INSTANCEOF(i) variable(v2). {
res = v1.i.v2;
}
// singele quoted string
value(res) ::= SINGLEQUOTESTRING(t). {