--- this is a major update with a couple of internal changes ---

- new config file lexer/parser (thanks to Thue Jnaus Kristensen)
- template lexer/parser fixes for PHP and {literal} handing (thanks to Thue Jnaus Kristensen)
- fix on registered plugins with different type but same name
- rewrite of plugin handling (optimized execution speed)
- closed a security hole regarding PHP code injection into cache files
- fixed bug in clear cache handling
- Renamed a couple of internal classes
- code cleanup for merging compiled templates
- couple of runtime optimizations (still not all done)
This commit is contained in:
Uwe.Tews
2009-12-27 15:06:49 +00:00
parent 5f02276a2a
commit 44dd7830dd
45 changed files with 3015 additions and 2784 deletions

16
README
View File

@@ -16,7 +16,7 @@ The file structure is similar to Smarty 2:
modifier.escape.php
...
A lot of Smarty 3 core functionality lies in the sysplugins directory, you do
A lot of Smarty 3 core functionality lies in the sysplugins directory; you do
not need to change any files here. The /libs/plugins/ folder is where Smarty
plugins are located. You can add your own here, or create a separate plugin
directory, just the same as Smarty 2. You will still need to create your own
@@ -47,7 +47,7 @@ There are many things that are new to Smarty 3. Here are the notable items:
LEXER/PARSER
============
Smarty 3 now uses a lexing tokenizer for it's parser/compiler. Basically, this
Smarty 3 now uses a lexing tokenizer for its parser/compiler. Basically, this
means Smarty has some syntax additions that make life easier such as in-template
math, shorter/intuitive function parameter options, infinite function recursion,
more accurate error handling, etc.
@@ -57,14 +57,14 @@ WHAT IS NEW IN SMARTY TEMPLATE SYNTAX
=====================================
Smarty 3 allows expressions almost anywhere. Expressions can include PHP
functions as long as they are not disabled by the security policy, object
methods and properties, etc. The {math} plugin will be no longer necessary but
functions as long as they are not disabled by the security policy, object
methods and properties, etc. The {math} plugin is no longer necessary but
is still supported for BC.
Examples:
{$x+$y} will output the sum of x and y.
{$foo = strlen($bar)} function in assignment
{assign var=foo value= $x+$y} in attributs
{assign var=foo value= $x+$y} in attributes
{$foo = myfunct( ($x+$y)*3 )} as function parameter
{$foo[$x+3]} as array index
@@ -170,8 +170,8 @@ Just as you can use PHP functions as modifiers directly, you can now access
PHP functions directly, provided they are permitted by security settings:
{time()}
There is a new {function}...{/function} block tag. This allows to reuse code
sequences like a plugin function. It can all itself recursively.
There is a new {function}...{/function} block tag. This enables reuse of code
sequences like a plugin function. It can call itself recursively.
Example:
@@ -397,7 +397,7 @@ extends another one that extends another one and so on..), but be aware that all
have to be checked for modifications at runtime so the more inheritance the more overhead you add.
Instead of defining the parent/child relationships with the {extends} tag in the child template you
can use the s resource as follow:
can use the resource as follow:
$smarty->display('extends:parent.tpl|child.tpl|grandchild.tpl');

View File

@@ -4,9 +4,9 @@ Smarty 3 is PHP 5 only. It will not work with PHP 4.
== {php} Tag ==
The {php} tag is disabled by default. The use of {php} tags is
decripated. It can be enabled with $smarty->allow_php_tag=true.
deprecated. It can be enabled with $smarty->allow_php_tag=true.
But if you scatter PHP code which belogs together into several
But if you scatter PHP code which belongs together into several
{php} tags it may not work any longer.
== Delimiters and whitespace ==
@@ -27,8 +27,8 @@ For example filename strings must be quoted
== Extending the Smarty class ==
Smarty 3 makes use of the __construct method for initialization. If you are extending
the Smarty class its constructor is not called implicitly if the your child class defines
also constructor. In order to run Smarty's constructor, a call to parent::__construct()
the Smarty class, its constructor is not called implicitly if the your child class defines
its own constructor. In order to run Smarty's constructor, a call to parent::__construct()
within your child constructor is required.
<source lang="php">
@@ -55,7 +55,7 @@ In Smarty 2, mixed case file names did work.
== Scope of Special Smarty Variables ==
In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach...
had global scope. If you had loops with same name in subtemplates you could accidentally
had global scope. If you had loops with the same name in subtemplates you could accidentally
overwrite values of parent template.
In Smarty 3 these special Smarty variable have only local scope in the template which
@@ -68,5 +68,5 @@ as parameter.
== SMARTY_RESOURCE_CHAR_SET ==
Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset.
This is now used also on modifiers like escape as default charset. If your templates use
other charsets make sure that you define the constant accordingly. Otherwise you may get
not output.
other charsets make sure that you define the constant accordingly. Otherwise you may not
get any output.

View File

@@ -1,3 +1,15 @@
12/27/2009
--- this is a major update with a couple of internal changes ---
- new config file lexer/parser (thanks to Thue Jnaus Kristensen)
- template lexer/parser fixes for PHP and {literal} handing (thanks to Thue Jnaus Kristensen)
- fix on registered plugins with different type but same name
- rewrite of plugin handling (optimized execution speed)
- closed a security hole regarding PHP code injection into cache files
- fixed bug in clear cache handling
- Renamed a couple of internal classes
- code cleanup for merging compiled templates
- couple of runtime optimizations (still not all done)
12/19/2009
- bugfix on comment lines in config files
@@ -8,7 +20,7 @@
12/16/2009
- update of changelog
- added {include file='foo.tpl' inline} inline option to merge compiled code of aubtemplate into the calling template
- added {include file='foo.tpl' inline} inline option to merge compiled code of subtemplate into the calling template
12/14/2009
- fixed sideefect of last modification (objects in array index did not work anymore)

View File

@@ -106,9 +106,9 @@ if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR
/**
* This is the main Smarty class
*/
class Smarty extends Smarty_Internal_TemplateBase {
class Smarty extends Smarty_Internal_Data {
// smarty version
public static $_version = 'Smarty3-SVN$Rev: 3286 $';
const SMARTY_VERSION = 'Smarty3-SVN$Rev: 3286 $';
// auto literal on delimiters with whitspace
public $auto_literal = true;
// display error on not assigned variables
@@ -167,7 +167,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
// config var settings
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file.
public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file.
// config vars
public $config_vars = array();
// assigned tpl vars
@@ -186,30 +186,20 @@ class Smarty extends Smarty_Internal_TemplateBase {
public $cache_resource_types = array('file');
// config type
public $default_config_type = 'file';
// class used for cacher
public $cacher_class = 'Smarty_Internal_Cacher_InlineCode';
// exception handler: array('ExceptionClass','ExceptionMethod');
public $exception_handler = null;
// cached template objects
public $template_objects = null;
// check If-Modified-Since headers
public $cache_modified_check = false;
// cached objects
public $resource_objects = array();
// registered plugins
public $registered_plugins = array();
// plugin search order
public $plugin_search_order = array('function', 'block', 'compiler', 'class');
// plugin handler object
public $plugin_handler = null;
// default plugin handler
public $default_plugin_handler_func = null;
// registered objects
public $registered_objects = array();
// registered filters
public $registered_filters = array();
// filter handler
public $filter_handler = null;
// autoload filter
public $autoload_filters = array();
// status of filter on variable output
@@ -228,8 +218,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
/**
* Class constructor, initializes basic smarty properties
*/
public function __construct()
{
public function __construct() {
// self reference needed by other classes methods
$this->smarty = $this;
@@ -239,7 +228,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
$this->start_time = $this->_get_time();
// set exception handler
if (!empty($this->exception_handler))
set_exception_handler($this->exception_handler);
set_exception_handler($this->exception_handler);
// set default dirs
$this->template_dir = array('.' . DS . 'templates' . DS);
$this->compile_dir = '.' . DS . 'templates_c' . DS;
@@ -247,12 +236,11 @@ class Smarty extends Smarty_Internal_TemplateBase {
$this->cache_dir = '.' . DS . 'cache' . DS;
$this->config_dir = '.' . DS . 'configs' . DS;
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
$this->plugin_handler = new Smarty_Internal_Plugin_Handler($this);
$this->filter_handler = new Smarty_Internal_Run_Filter($this);
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
}
else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
@@ -260,15 +248,18 @@ class Smarty extends Smarty_Internal_TemplateBase {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
}
elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
} else {
}
else {
// enable debugging for this page
$this->debugging = true;
}
} else {
}
else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
}
@@ -280,11 +271,10 @@ class Smarty extends Smarty_Internal_TemplateBase {
/**
* Class destructor
*/
public function __destruct()
{
public function __destruct() {
// restore to previous exception handler, if any
if (!empty($this->exception_handler))
restore_exception_handler();
restore_exception_handler();
}
/**
@@ -296,8 +286,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param object $ |null $parent next higher level of Smarty variables
* @return string rendered template output
*/
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null)
{
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null) {
if (is_object($cache_id)) {
$parent = $cache_id;
$cache_id = null;
@@ -313,8 +302,9 @@ class Smarty extends Smarty_Internal_TemplateBase {
? $this->error_reporting : error_reporting() &~E_NOTICE);
// return redered template
if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
$_output = $this->filter_handler->execute('output', $_template->getRenderedTemplate());
} else {
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $this);
}
else {
$_output = $_template->getRenderedTemplate();
}
$_template->rendered_content = null;
@@ -330,8 +320,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*/
public function display($template, $cache_id = null, $compile_id = null, $parent = null)
{
public function display($template, $cache_id = null, $compile_id = null, $parent = null) {
// display template
echo $this->fetch ($template, $cache_id, $compile_id, $parent);
// debug output
@@ -349,8 +338,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param mixed $compile_id compile id to be used with this template
* @return boolean cache status
*/
public function is_cached($template, $cache_id = null, $compile_id = null)
{
public function is_cached($template, $cache_id = null, $compile_id = null) {
if (!($template instanceof $this->template_class)) {
$template = $this->createTemplate ($template, $cache_id, $compile_id, $this);
}
@@ -361,13 +349,13 @@ class Smarty extends Smarty_Internal_TemplateBase {
/**
* Loads security class and enables security
*/
public function enableSecurity()
{
public function enableSecurity() {
if (isset($this->security_class)) {
$this->security_policy = new $this->security_class;
$this->security_handler = new Smarty_Internal_Security_Handler($this);
$this->security = true;
} else {
}
else {
throw new Exception('Property security_class is not defined');
}
}
@@ -377,8 +365,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*
* @param string $ |array $template_dir folder(s) of template sorces
*/
public function setTemplateDir($template_dir)
{
public function setTemplateDir($template_dir) {
$this->template_dir = (array)$template_dir;
return;
}
@@ -387,8 +374,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*
* @param string $ |array $template_dir folder(s) of template sources
*/
public function addTemplateDir($template_dir)
{
public function addTemplateDir($template_dir) {
$this->template_dir = array_merge((array)$this->template_dir, (array)$template_dir);
$this->template_dir = array_unique($this->template_dir);
return;
@@ -398,8 +384,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*
* @param string $compile_dir folder of compiled template sources
*/
public function setCompileDir($compile_dir)
{
public function setCompileDir($compile_dir) {
$this->compile_dir = $compile_dir;
return;
}
@@ -408,16 +393,14 @@ class Smarty extends Smarty_Internal_TemplateBase {
*
* @param string $cache_dir folder of cache files
*/
public function setCacheDir($cache_dir)
{
public function setCacheDir($cache_dir) {
$this->cache_dir = $cache_dir;
return;
}
/**
* Enable Caching
*/
public function enableCaching()
{
public function enableCaching() {
$this->caching = SMARTY_CACHING_LIFETIME_CURRENT;
return;
}
@@ -426,8 +409,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*
* @param integer $lifetime lifetime of cached file in seconds
*/
public function setCacheLifetime($lifetime)
{
public function setCacheLifetime($lifetime) {
$this->cache_lifetime = $lifetime;
return;
}
@@ -437,16 +419,12 @@ class Smarty extends Smarty_Internal_TemplateBase {
* plugin filename format: plugintype.pluginname.php
*
* @param string $plugin_name class plugin name to load
* @return boolean
* @return string|boolean filepath of loaded file or false
*/
public function loadPlugin($plugin_name)
{
// if class exists, exit silently (already loaded)
if (class_exists($plugin_name, false))
return true;
// if callable as function, exit silently (already loaded)
if (is_callable($plugin_name))
return true;
public function loadPlugin($plugin_name, $check = true) {
// if function or class exists, exit silently (already loaded)
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false)))
return true;
// Plugin name is expected to be: Smarty_[Type]_[Name]
$_plugin_name = strtolower($plugin_name);
$_name_parts = explode('_', $_plugin_name, 3);
@@ -457,10 +435,12 @@ class Smarty extends Smarty_Internal_TemplateBase {
}
// if type is "internal", get plugin from sysplugins
if ($_name_parts[1] == 'internal') {
if (file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php')) {
require_once(SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php');
return true;
} else {
$file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php';
if (file_exists($file)) {
require_once($file);
return $file;
}
else {
return false;
}
}
@@ -471,10 +451,10 @@ class Smarty extends Smarty_Internal_TemplateBase {
if (strpos('/\\', substr($_plugin_dir, -1)) === false) {
$_plugin_dir .= DS;
}
if (file_exists($_plugin_dir . $_plugin_filename)) {
require_once($_plugin_dir . $_plugin_filename);
return true;
$file = $_plugin_dir . $_plugin_filename;
if (file_exists($file)) {
require_once($file);
return $file;
}
}
// no plugin loaded
@@ -487,8 +467,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param mixed $handler function name or array with object/method names
* @return string previous exception handler
*/
public function setExceptionHandler($handler)
{
public function setExceptionHandler($handler) {
$this->exception_handler = $handler;
return set_exception_handler($handler);
}
@@ -498,8 +477,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
*
* @return object of cache resource
*/
public function loadCacheResource($type = null)
{
public function loadCacheResource($type = null) {
if (!isset($type)) {
$type = $this->caching_type;
}
@@ -510,12 +488,14 @@ class Smarty extends Smarty_Internal_TemplateBase {
if (in_array($type, $this->cache_resource_types)) {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
return $this->cache_resource_objects[$type] = new $cache_resource_class($this);
} else {
}
else {
// try plugins dir
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
if ($this->loadPlugin($cache_resource_class)) {
return $this->cache_resource_objects[$type] = new $cache_resource_class($this);
} else {
}
else {
throw new Exception("Unable to load cache resource '{$type}'");
}
}
@@ -527,8 +507,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param string $error_msg
* @param integer $error_type
*/
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
{
public function trigger_error($error_msg, $error_type = E_USER_WARNING) {
throw new Exception("Smarty error: $error_msg");
}
@@ -540,8 +519,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
* @param string $name unknown methode name
* @param array $args aurgument array
*/
public function __call($name, $args)
{
public function __call($name, $args) {
$name = strtolower($name);
if ($name == 'smarty') {
throw new Exception('Please use parent::__construct() to call parent constuctor');
@@ -557,8 +535,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
}
}
function smartyAutoload($class)
{
function smartyAutoload($class) {
$_class = strtolower($class);
if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') {
include SMARTY_SYSPLUGINS_DIR . $_class . '.php';

View File

@@ -20,70 +20,68 @@
* @param integer $
* @return string
*/
class Smarty_Modifier_Debug_Print_Var {
static function execute ($var, $depth = 0, $length = 40)
{
$_replace = array("\n" => '<i>\n</i>',
"\r" => '<i>\r</i>',
"\t" => '<i>\t</i>'
);
function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
{
$_replace = array("\n" => '<i>\n</i>',
"\r" => '<i>\r</i>',
"\t" => '<i>\t</i>'
);
switch (gettype($var)) {
case 'array' :
$results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; '
. self::execute($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'object' :
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
foreach ($object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
. self::execute($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'boolean' :
case 'NULL' :
case 'resource' :
if (true === $var) {
$results = 'true';
} elseif (false === $var) {
$results = 'false';
} elseif (null === $var) {
$results = 'null';
} else {
$results = htmlspecialchars((string) $var);
}
$results = '<i>' . $results . '</i>';
break;
case 'integer' :
case 'float' :
switch (gettype($var)) {
case 'array' :
$results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'object' :
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
foreach ($object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'boolean' :
case 'NULL' :
case 'resource' :
if (true === $var) {
$results = 'true';
} elseif (false === $var) {
$results = 'false';
} elseif (null === $var) {
$results = 'null';
} else {
$results = htmlspecialchars((string) $var);
break;
case 'string' :
$results = strtr($var, $_replace);
if (strlen($var) > $length) {
$results = substr($var, 0, $length - 3) . '...';
}
$results = htmlspecialchars('"' . $results . '"');
break;
case 'unknown type' :
default :
$results = strtr((string) $var, $_replace);
if (strlen($results) > $length) {
$results = substr($results, 0, $length - 3) . '...';
}
$results = htmlspecialchars($results);
}
return $results;
}
$results = '<i>' . $results . '</i>';
break;
case 'integer' :
case 'float' :
$results = htmlspecialchars((string) $var);
break;
case 'string' :
$results = strtr($var, $_replace);
if (strlen($var) > $length) {
$results = substr($var, 0, $length - 3) . '...';
}
$results = htmlspecialchars('"' . $results . '"');
break;
case 'unknown type' :
default :
$results = strtr((string) $var, $_replace);
if (strlen($results) > $length) {
$results = substr($results, 0, $length - 3) . '...';
}
$results = htmlspecialchars($results);
}
return $results;
}
?>

View File

@@ -1,93 +0,0 @@
<?php
/**
* Smarty Internal Plugin Cacher InlineCode
*
* Process nocached code.
* Version to inject nocache code directly into cache file
* if caching is disabled at render time the code is being evaluated
*
* @package Smarty
* @subpackage Cacher
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Cacher InlineCode Class
*/
class Smarty_Internal_Cacher_InlineCode {
function __construct($smarty)
{
$this->smarty = $smarty;
}
/**
* Inject inline code for nocache template sections
*
* This method gets the content of each template element from the parser.
* If the content is compiled code and it should be not cached the code is injected
* into the rendered output.
*
* @param string $content content of template element
* @param object $compiler intance of compiler class
* @param boolean $tag_nocache true if the parser detected a nocache situation
* @param boolean $is_code true if content is compiled code
* @return string content
*/
public function processNocacheCode ($content, $compiler, $is_code)
{
// If the template is not evaluated and we have a nocache section and or a nocache tag
if ($is_code) {
// generate replacement code
if ((!$compiler->template->isEvaluated() || $compiler->template->forceNocache) && $compiler->template->caching &&
($compiler->nocache || $compiler->tag_nocache)) {
$compiler->tag_nocache = false;
$_output = str_replace("'", "\'", $content);
$_output = '<?php echo \'' . $_output . '\';?>';
} else {
$_output = $content;
}
} else {
$_output = $content;
}
// if compiled code shall be grabbed
if ($compiler->template->extract_code == false) {
// return output
return $_output;
} else {
// store code in extract buffer
$compiler->template->extracted_compiled_code .= $_output;
return '';
}
}
/**
* Initialize cacher
*
* Is a noop in current implementation
*
* @param object $compiler intance of compiler class
*/
public function initCacher ($compiler)
{
return;
}
/**
* Close cacher
*
* Hook to perform any post processing on the final compiled template
* Is a noop in current implementation
*
* @param object $compiler intance of compiler class
* @param string $template_code complete compiled template
* @return string compiled template output
*/
public function closeCacher ($compiler, $template_code)
{
return $template_code;
}
}
?>

View File

@@ -38,7 +38,8 @@ class Smarty_Internal_CacheResource_File {
*/
public function getCachedTimestamp($template)
{
return ($template->getCachedFilepath() && file_exists($template->getCachedFilepath())) ? filemtime($template->getCachedFilepath()) : false ;
return @filemtime($template->getCachedFilepath());
// return ($template->getCachedFilepath() && file_exists($template->getCachedFilepath())) ? filemtime($template->getCachedFilepath()) : false ;
}
/**
@@ -63,7 +64,7 @@ class Smarty_Internal_CacheResource_File {
*/
public function writeCachedContent($template, $content)
{
if (!$template->isEvaluated()) {
if (!$template->resource_object->isEvaluated) {
return Smarty_Internal_Write_File::writeFile($template->getCachedFilepath(), $content, $this->smarty);
} else {
return false;
@@ -91,51 +92,61 @@ class Smarty_Internal_CacheResource_File {
*/
public function clear($resource_name, $cache_id, $compile_id, $exp_time)
{
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!','_',$cache_id) : null;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!','_',$compile_id) : null;
$_dir_sep = $this->smarty->use_sub_dirs ? DS : '^';
if (isset($resource_name)) {
$_resource_part = (string)abs(crc32($resource_name)) . '.' . $resource_name . '.php';
} else {
$_resource_part = null;
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$_dir_sep = $this->smarty->use_sub_dirs ? '/' : '^';
$_compile_id_offset = $this->smarty->use_sub_dirs ? 3 : 0;
$_dir = rtrim($this->smarty->cache_dir, '/\\') . DS;
$_dir_length = strlen($_dir);
if (isset($_cache_id)) {
$_cache_id_parts = explode('|', $_cache_id);
$_cache_id_parts_count = count($_cache_id_parts);
}
$_dir = $this->smarty->cache_dir;
if (strpos('/\\', substr($_dir, -1)) === false) {
$_dir .= DS;
}
if ($this->smarty->use_sub_dirs && isset($_cache_id)) {
$_dir .= str_replace('|', $_dir_sep, $_cache_id) . $_dir_sep;
}
$_compile_pos = $this->smarty->use_sub_dirs ? 5 : 2;
$_count = 0;
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) {
if (strpos($_file, '.svn') !== false) continue;
if (strpos($_file, '.svn') !== false) continue;
// directory ?
if ($_file->isDir()) {
if (!$_cache->isDot()) {
// delete folder if empty
@rmdir($_file->getPathname());
}
} else {
$_parts = explode($_dir_sep, $_file);
$_parts_count = count($_parts);
$_parts_compile_pos = $_parts_count - $_compile_pos;
if ($_parts_compile_pos < 0) {
$_parts_compile_pos = 0;
}
if ((substr_compare((string)$_file, $_dir, 0, strlen($_dir)) == 0 &&
(!isset($resource_name) || $_parts[$_parts_count-1] == $_resource_part) &&
(!isset($_compile_id) || $_parts[$_parts_compile_pos] == $_compile_id)) ||
(isset($resource_name) && (string)$_file == $_dir . $_resource_part)) {
if (isset($exp_time)) {
if (time() - @filemtime($_file) >= $exp_time) {
$_count += @unlink((string) $_file) ? 1 : 0;
}
} else {
$_count += @unlink((string) $_file) ? 1 : 0;
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string)$_file, $_dir_length)));
$_parts_count = count($_parts);
// check name
if (isset($resource_name)) {
$_filename_parts = explode('.', $_parts[$_parts_count-1]);
$_resourcename_parts = explode('.', $resource_name . '.php');
if (count($_filename_parts)-1 != count($_resourcename_parts)) {
continue;
}
for ($i = 0; $i < count($_resourcename_parts); $i++) {
if ($_filename_parts[$i + 1] != $_resourcename_parts[$i]) continue 2;
}
}
// check compile id
if (isset($_compile_id) && $_parts[$_parts_count-2 - $_compile_id_offset] != $_compile_id) {
continue;
}
// check cache id
if (isset($_cache_id)) {
// count of cache id parts
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
if ($_parts_count < $_cache_id_parts_count) {
continue;
}
for ($i = 0; $i < $_cache_id_parts_count; $i++) {
if ($_parts[$i] != $_cache_id_parts[$i]) continue 2;
}
}
// expired ?
if (isset($exp_time) && time() - @filemtime($_file) < $exp_time) {
continue;
}
$_count += @unlink((string) $_file) ? 1 : 0;
}
}
return $_count;
@@ -143,17 +154,16 @@ class Smarty_Internal_CacheResource_File {
/**
* Get system filepath to cached file
*
* @param string $resource_name template name
* @param string $source_file_path template source file path
* @param string $cache_id cache id
* @param string $compile_id compile id
* @return string filepath of cache file
*/
private function buildCachedFilepath ($resource_name, $cache_id, $compile_id)
private function buildCachedFilepath ($source_file_path, $cache_id, $compile_id)
{
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!','_',$cache_id) : null;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!','_',$compile_id) : null;
$_files = explode('|', $resource_name);
$_filepath = (string)abs(crc32($resource_name));
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$_filepath = (string)abs(crc32($source_file_path));
// if use_sub_dirs, break file into directories
if ($this->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS
@@ -176,8 +186,7 @@ class Smarty_Internal_CacheResource_File {
if (strpos('/\\', substr($_cache_dir, -1)) === false) {
$_cache_dir .= DS;
}
return $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_files[count($_files)-1]) . '.php';
return $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($source_file_path) . '.php';
}
}

View File

@@ -29,6 +29,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
$this->_open_tag('function', $save);
$_name = trim($_attr['name'], "'");
unset($_attr['name']);
foreach ($_attr as $_key => $_data) {
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
}
@@ -56,20 +57,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
{
$this->compiler = $compiler;
$this->compiler->has_code = false;
// turn off block code extraction
$compiler->template->extract_code = false;
// check and get attributes
$this->optional_attributes = array('name');
$_attr = $this->_get_attributes($args);
$saved_data = $this->_close_tag(array('function'));
// if name does match to opening tag
if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) {
$this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"');
}
$_name = trim($saved_data[0]['name'], "'");
$compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code);
$compiler->template->properties['function'][$_name]['compiled'] = $compiler->template->extracted_compiled_code;
$this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code;
$this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
// restore old code extraction status
$compiler->template->extracted_compiled_code = $saved_data[1];
$compiler->template->extract_code = $saved_data[2];
return true;

View File

@@ -36,49 +36,17 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
eval("\$tmp = $include_file;");
if ($this->compiler->template->template_resource != $tmp) {
$tpl = $compiler->smarty->createTemplate ($tmp, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template);
if ($tpl->usesCompiler() && $tpl->isExisting()) {
do {
$must_compile = false;
$prop = array();
$compiled_tpl = $tpl->getCompiledTemplate();
preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches);
$compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl);
// var_dump($matches, $compiled_tpl);
if (isset($matches[2])) {
$prop = unserialize($matches[2]);
foreach ($prop['file_dependency'] as $_file_to_check) {
If (is_file($_file_to_check[0])) {
$mtime = filemtime($_file_to_check[0]);
} else {
$tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler);
if ($resource_type == 'file') {
$must_compile = true; // subtemplate no longer existing
break;
}
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
}
// If ($mtime != $_file_to_check[1]) {
If ($mtime > $_file_to_check[1]) {
$must_compile = true;
break;
}
}
if ($must_compile) {
// recompile
$tpl->compileTemplateSource();
}
}
} while ($must_compile);
if (isset($prop['file_dependency'])) {
$compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']);
}
if (isset($prop['function'])) {
if (isset($compiler->template->properties['function'])) {
$compiler->template->properties['function'] = array_merge((array)$compiler->template->properties['function'], $prop['function']);
} else {
$compiler->template->properties['function'] = $prop['function'];
}
}
if ($this->compiler->template->caching) {
// needs code for cached page but no cache file
$tpl->caching = 9999;
}
if ($tpl->resource_object->usesCompiler && $tpl->isExisting()) {
// make sure that template is up to date and merge template properties
$tpl->renderTemplate();
// get compiled code
$compiled_tpl = $tpl->getCompiledTemplate();
// remove header code
$compiled_tpl = preg_replace('/(<\?php \/\*%%SmartyHeaderCode%%\*\/(.+?)\/\*\/%%SmartyHeaderCode%%\*\/\?>\n)/s', '', $compiled_tpl);
$has_compiled_template = true;
}
}
@@ -163,6 +131,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
}
$_output .= "<?php unset(\$_template);?>";
return $_output;
}
}
}
}
?>

View File

@@ -11,7 +11,7 @@
/**
* Smarty Internal Plugin Compile Block Plugin Class
*/
class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of block plugin
*
@@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase {
* @param object $compiler compiler object
* @return string compiled code
*/
public function compile($args, $compiler, $tag)
public function compile($args, $compiler, $tag, $function)
{
$this->compiler = $compiler;
if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) {
@@ -41,14 +41,14 @@ class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase {
$_params = 'array(' . implode(",", $_paramsArray) . ')';
$this->_open_tag($tag, array($_params, $this->compiler->nocache));
// not cachable?
if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) {
$this->compiler->nocache = true;
}
// maybe nocache because of nocache variables
// maybe nocache because of nocache variables or nocache plugin
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
// compile code
$output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->plugin_handler->' . $tag . '(array(' . $_params . ', null, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\');while ($_block_repeat) { ob_start();?>';
if (is_array($function)) {
$output = '<?php $_block_repeat=true; call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),(array(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl));while ($_block_repeat) { ob_start();?>';
} else {
$output = '<?php $_block_repeat=true; ' . $function . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>';
}
} else {
// must endblock be nocache?
if ($this->compiler->nocache) {
@@ -59,7 +59,12 @@ class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase {
// This tag does create output
$this->compiler->has_output = true;
// compile code
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->plugin_handler->' . substr($tag, 0, -5) . '(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\'); }?>';
if (is_array($function)) {
var_dump('error');
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl)); }?>';
} else {
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $function . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>';
}
}
return $output;
}

View File

@@ -12,7 +12,7 @@
/**
* Smarty Internal Plugin Compile Function_Call Class
*/
class Smarty_Internal_Compile_Function_Call extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Function_Call extends Smarty_Internal_CompileBase {
/**
* Compiles the calls of user defined tags defined by {function}
*

View File

@@ -11,7 +11,7 @@
/**
* Smarty Internal Plugin Compile Function Plugin Class
*/
class Smarty_Internal_Compile_Function_Plugin extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of function plugin
*
@@ -20,7 +20,7 @@ class Smarty_Internal_Compile_Function_Plugin extends Smarty_Internal_CompileBas
* @param object $compiler compiler object
* @return string compiled code
*/
public function compile($args, $compiler, $tag)
public function compile($args, $compiler, $tag, $function)
{
$this->compiler = $compiler;
// This tag does create output
@@ -30,10 +30,6 @@ class Smarty_Internal_Compile_Function_Plugin extends Smarty_Internal_CompileBas
$this->optional_attributes = array('_any');
// check and get attributes
$_attr = $this->_get_attributes($args);
// not cachable?
if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) {
$this->compiler->tag_nocache = true;
}
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
@@ -45,8 +41,11 @@ class Smarty_Internal_Compile_Function_Plugin extends Smarty_Internal_CompileBas
}
$_params = 'array(' . implode(",", $_paramsArray) . ')';
// compile code
$output = '<?php echo $_smarty_tpl->smarty->plugin_handler->' . $tag . '(array(' . $_params . ',$_smarty_tpl->smarty,$_smarty_tpl),\'function\');?>';
if (is_array($function)) {
$output = '<?php echo call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),(array(' . $_params . ',$_smarty_tpl->smarty,$_smarty_tpl));?>';
} else {
$output = '<?php echo ' . $function . '(' . $_params . ',$_smarty_tpl->smarty,$_smarty_tpl);?>';
}
return $output;
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Smarty Internal Plugin Compile Modifier
*
* Compiles code for modifier execution
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Compile Modifier Class
*/
class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBase {
/**
* Compiles code for modifier execution
*
* @param array $args array with attributes from parser
* @param object $compiler compiler object
* @return string compiled code
*/
public function compile($args, $compiler)
{
$this->compiler = $compiler;
$this->smarty = $this->compiler->smarty;
$this->required_attributes = array('modifier', 'params');
// check and get attributes
$_attr = $this->_get_attributes($args);
// check if modifier allowed
if (!$this->compiler->template->security || $this->smarty->security_handler->isTrustedModifier($_attr['modifier'], $this->compiler)) {
// check for registered or plugin modifier
if (isset($compiler->smarty->registered_plugins['modifier'][$_attr['modifier']])) {
$function = $compiler->smarty->registered_plugins['modifier'][$_attr['modifier']][0];
if (!is_array($function)) {
$output = "{$function}({$_attr['params']})";
} else if (is_object($function[0])) {
$output = 'call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'modifier\'][\'' . $_attr['modifier'] . '\'][0],array(' . $_attr['params'] . '))';
} else {
$output = 'call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_attr['params'] . '))';
}
} else if ($function = $this->compiler->getPlugin($_attr['modifier'], 'modifier')) {
if (!is_array($function)) {
$output = "{$function}({$_attr['params']})";
} else {
$output = 'call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_attr['params'] . '))';
}
// check if trusted PHP function
} else if (is_callable($_attr['modifier'])) {
$output = "{$_attr['modifier']}({$_attr['params']})";
} else {
$this->compiler->trigger_template_error ("unknown modifier \"" . $_attr['modifier'] . "\"");
}
return $output;
}
}
}
?>

View File

@@ -11,7 +11,7 @@
/**
* Smarty Internal Plugin Compile Object Block Function Class
*/
class Smarty_Internal_Compile_Object_Block_Function extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of block plugin
*

View File

@@ -11,7 +11,7 @@
/**
* Smarty Internal Plugin Compile Object Function Class
*/
class Smarty_Internal_Compile_Object_Function extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of function plugin
*

View File

@@ -11,7 +11,7 @@
/**
* Smarty Internal Plugin Compile Print Expression Class
*/
class Smarty_Internal_Compile_Print_Expression extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase {
/**
* Compiles code for gererting output from any expression
*
@@ -49,7 +49,7 @@ class Smarty_Internal_Compile_Print_Expression extends Smarty_Internal_CompileBa
// display value
$this->compiler->has_output = true;
if (isset($this->compiler->smarty->registered_filters['variable'])) {
$output = '<?php echo $this->smarty->filter_handler->execute(\'variable\', ' . $_attr['value'] . ',' . $_attr['filter'] . ');?>';
$output = '<?php echo Smarty_Internal_Filter_Handler::runFilter(\'variable\', ' . $_attr['value'] . ',$this->smarty);?>';
} else {
$output = '<?php echo ' . $_attr['value'] . ';?>';
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* Smarty Internal Plugin Compile Registered Block
*
* Compiles code for the execution of a registered block function
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Compile Registered Block Class
*/
class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of a block function
*
* @param array $args array with attributes from parser
* @param string $tag name of block function
* @param object $compiler compiler object
* @return string compiled code
*/
public function compile($args, $compiler, $tag)
{
$this->compiler = $compiler;
if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) {
// opening tag of block plugin
$this->required_attributes = array();
$this->optional_attributes = array('_any');
// check and get attributes
$_attr = $this->_get_attributes($args);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}
}
$_params = 'array(' . implode(",", $_paramsArray) . ')';
$this->_open_tag($tag, array($_params, $this->compiler->nocache));
// maybe nocache because of nocache variables or nocache plugin
$this->compiler->nocache = !$compiler->smarty->registered_plugins['block'][$tag][1] | $this->compiler->nocache | $this->compiler->tag_nocache;
$function = $compiler->smarty->registered_plugins['block'][$tag][0];
// compile code
if (!is_array($function)) {
$output = '<?php $_block_repeat=true; ' . $function . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>';
} else if (is_object($function[0])) {
$output = '<?php $_block_repeat=true; call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'block\'][\'' . $tag . '\'][0],array(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl));while ($_block_repeat) { ob_start();?>';
} else {
$output = '<?php $_block_repeat=true; call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl));while ($_block_repeat) { ob_start();?>';
}
} else {
// must endblock be nocache?
if ($this->compiler->nocache) {
$this->compiler->tag_nocache = true;
}
$base_tag = substr($tag, 0, -5);
// closing tag of block plugin, restore nocache
list($_params, $this->compiler->nocache) = $this->_close_tag($base_tag);
// This tag does create output
$this->compiler->has_output = true;
$function = $compiler->smarty->registered_plugins['block'][$base_tag][0];
// compile code
if (!is_array($function)) {
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $function . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>';
} else if (is_object($function[0])) {
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'block\'][\'' . $base_tag . '\'][0],array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl)); }?>';
} else {
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl)); }?>';
}
}
return $output;
}
}
?>

View File

@@ -0,0 +1,51 @@
<?php
/**
* Smarty Internal Plugin Compile Registered Function
*
* Compiles code for the execution of a registered function
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Compile Registered Function Class
*/
class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase {
/**
* Compiles code for the execution of a registered function
*
* @param array $args array with attributes from parser
* @param string $tag name of function
* @param object $compiler compiler object
* @return string compiled code
*/
public function compile($args, $compiler, $tag)
{
$this->compiler = $compiler;
// This tag does create output
$this->compiler->has_output = true;
$this->required_attributes = array();
$this->optional_attributes = array('_any');
// check and get attributes
$_attr = $this->_get_attributes($args);
// not cachable?
$this->compiler->tag_nocache = !$compiler->smarty->registered_plugins['function'][$tag][1];
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}
}
$_params = 'array(' . implode(",", $_paramsArray) . ')';
// compile code
$output = '<?php echo call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'function\'][\'' . $tag . '\'][0],array(' . $_params . ',$_smarty_tpl->smarty,$_smarty_tpl));?>';
return $output;
}
}
?>

View File

@@ -11,7 +11,7 @@
/**
* Smarty Internal Plugin Compile special Smarty Variable Class
*/
class Smarty_Internal_Compile_Special_Smarty_Variable extends Smarty_Internal_CompileBase {
class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase {
/**
* Compiles code for the speical $smarty variables
*
@@ -57,7 +57,7 @@ class Smarty_Internal_Compile_Special_Smarty_Variable extends Smarty_Internal_Co
return "'$_template_dir_name'";
case 'version':
$_version = Smarty::$_version;
$_version = Smarty::SMARTY_VERSION;
return "'$_version'";
case 'const':
@@ -78,7 +78,7 @@ class Smarty_Internal_Compile_Special_Smarty_Variable extends Smarty_Internal_Co
return "'$_rdelim'";
default:
$compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference');
$compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
break;
}
if (isset($_index[1])) {

View File

@@ -8,12 +8,6 @@
* @author Uwe Tews
*/
/*
interface TagCompilerInterface {
public function compile($args, $compiler);
}
*/
/**
* This class does extend all internal compile plugins
*/

View File

@@ -28,7 +28,7 @@ class Smarty_Internal_Configfilelexer
{
// set instance object
self::instance($this);
$this->data = $data;
$this->data = $data . "\n"; //now all lines are \n-terminated
$this->counter = 0;
$this->line = 1;
$this->smarty = $smarty;
@@ -69,6 +69,7 @@ class Smarty_Internal_Configfilelexer
function yylex1()
{
$tokenMap = array (
@@ -79,16 +80,12 @@ class Smarty_Internal_Configfilelexer
5 => 0,
6 => 0,
7 => 0,
8 => 1,
10 => 0,
11 => 0,
12 => 0,
13 => 0,
8 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(\\s*#)|^('[^'\\\\\\\\]*(?:\\\\\\\\.[^'\\\\\\\\]*)*')|^(\"\"\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\"\"\")|^(\"[^\"\\\\\\\\]*(?:\\\\\\\\.[^\"\\\\\\\\]*)*\")|^(\\[)|^(])|^(\\s*=\\s*)|^((\n|\r\n))|^([\s]+)|^(\\.)|^([0-9]*[a-zA-Z_]\\w*)|^(.)/";
$yy_global_pattern = "/^(#)|^(\\[)|^(\\])|^(=)|^([ \t\r]+)|^(\n)|^(\\.)|^(\\w+)/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@@ -141,63 +138,321 @@ class Smarty_Internal_Configfilelexer
function yy_r1_1($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
$this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART;
$this->yypushstate(self::COMMENT);
}
function yy_r1_2($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_SI_QSTR;
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
}
function yy_r1_3($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_ML_QSTR;
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
}
function yy_r1_4($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_DO_QSTR;
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
$this->yypushstate(self::VALUE);
}
function yy_r1_5($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_OPENB;
return false;
}
function yy_r1_6($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB;
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
}
function yy_r1_7($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_EQUAL;
$this->token = Smarty_Internal_Configfileparser::TPC_DOT;
}
function yy_r1_8($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_EOL;
$this->token = Smarty_Internal_Configfileparser::TPC_ID;
}
function yy_r1_10($yy_subpatterns)
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)) {
return false; // end of input
}
$yy_global_pattern = "/^([ \t\r]+)|^(\\d+\\.\\d+(?=[ \t\r]*[\n#]))|^(\\d+(?=[ \t\r]*[\n#]))|^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#]))|^(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#]))|^(\"\"\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"\"\"(?=[ \t\r]*[\n#]))|^([a-zA-Z]+(?=[ \t\r]*[\n#]))|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
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');
}
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);
if ($r === null) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
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]);
}
break;
} while (true);
} // end function
const VALUE = 2;
function yy_r2_1($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_SPACE;
return false;
}
function yy_r1_11($yy_subpatterns)
function yy_r2_2($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_DOT;
$this->token = Smarty_Internal_Configfileparser::TPC_FLOAT;
$this->yypopstate();
}
function yy_r1_12($yy_subpatterns)
function yy_r2_3($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_ID;
$this->token = Smarty_Internal_Configfileparser::TPC_INT;
$this->yypopstate();
}
function yy_r1_13($yy_subpatterns)
function yy_r2_4($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
$this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING;
$this->yypopstate();
}
function yy_r2_5($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
$this->yypopstate();
}
function yy_r2_6($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_DOUBLE_QUOTED_STRING;
$this->yypopstate();
}
function yy_r2_7($yy_subpatterns)
{
if (!$this->smarty->config_booleanize || !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($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate();
}
function yy_r2_9($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->value = "";
$this->yypopstate();
}
function yylex3()
{
$tokenMap = array (
1 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^([^\n]+?(?=[ \t\r]*\n))/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
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');
}
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);
if ($r === null) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
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]);
}
break;
} while (true);
} // end function
const NAKED_STRING_VALUE = 3;
function yy_r3_1($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->yypopstate();
}
function yylex4()
{
$tokenMap = array (
1 => 0,
2 => 0,
3 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^([ \t\r]+)|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
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');
}
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);
if ($r === null) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
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]);
}
break;
} while (true);
} // end function
const COMMENT = 4;
function yy_r4_1($yy_subpatterns)
{
return false;
}
function yy_r4_2($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
}
function yy_r4_3($yy_subpatterns)
{
$this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE;
$this->yypopstate();
}
}
?>

View File

@@ -100,8 +100,6 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
$this->lex = $lex;
$this->smarty = $compiler->smarty;
$this->compiler = $compiler;
$this->current_section = null;
$this->hidden_section = false;
}
public static function &instance($new_instance = null)
{
@@ -110,70 +108,145 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
$instance = $new_instance;
return $instance;
}
#line 107 "smarty_internal_configfileparser.php"
const TPC_OTHER = 1;
const TPC_OPENB = 2;
private function parse_bool($str) {
if (in_array(strtolower($str) ,array('on','yes','true'))) {
$res = true;
} else {
assert(in_array(strtolower($str), array('off','no','false')));
$res = false;
}
return $res;
}
private static $escapes_single = Array('\\' => '\\',
'\'' => '\'');
private static function parse_single_quoted_string($qstr) {
$escaped_string = substr($qstr, 1, strlen($qstr)-2); //remove outer quotes
$ss = preg_split('/(\\\\.)/', $escaped_string, -1, PREG_SPLIT_DELIM_CAPTURE);
$str = "";
foreach ($ss as $s) {
if (strlen($s) === 2 && $s[0] === '\\') {
if (isset(self::$escapes_single[$s[1]])) {
$s = self::$escapes_single[$s[1]];
}
}
$str .= $s;
}
return $str;
}
private static function parse_double_quoted_string($qstr) {
$inner_str = substr($qstr, 1, strlen($qstr)-2);
return stripcslashes($inner_str);
}
private static function parse_tripple_double_quoted_string($qstr) {
$inner_str = substr($qstr, 3, strlen($qstr)-6);
return stripcslashes($inner_str);
}
private function set_var(Array $var, Array &$target_array) {
$key = $var["key"];
$value = $var["value"];
if ($this->smarty->config_overwrite || !isset($target_array['vars'][$key])) {
$target_array['vars'][$key] = $value;
} else {
settype($target_array['vars'][$key], 'array');
$target_array['vars'][$key][] = $value;
}
}
private function add_global_vars(Array $vars) {
if (!isset($this->compiler->config_data['vars'])) {
$this->compiler->config_data['vars'] = Array();
}
foreach ($vars as $var) {
$this->set_var($var, $this->compiler->config_data);
}
}
private function add_section_vars($section_name, Array $vars) {
if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) {
$this->compiler->config_data['sections'][$section_name]['vars'] = Array();
}
foreach ($vars as $var) {
$this->set_var($var, $this->compiler->config_data['sections'][$section_name]);
}
}
#line 175 "smarty_internal_configfileparser.php"
const TPC_OPENB = 1;
const TPC_ID = 2;
const TPC_CLOSEB = 3;
const TPC_DOT = 4;
const TPC_BOOLEANTRUE = 5;
const TPC_BOOLEANFALSE = 6;
const TPC_SI_QSTR = 7;
const TPC_DO_QSTR = 8;
const TPC_EQUAL = 9;
const TPC_SPACE = 10;
const TPC_ID = 11;
const TPC_EOL = 12;
const TPC_COMMENTSTART = 13;
const TPC_ML_QSTR = 14;
const YY_NO_ACTION = 49;
const YY_ACCEPT_ACTION = 48;
const YY_ERROR_ACTION = 47;
const TPC_EQUAL = 5;
const TPC_FLOAT = 6;
const TPC_INT = 7;
const TPC_BOOL = 8;
const TPC_SINGLE_QUOTED_STRING = 9;
const TPC_DOUBLE_QUOTED_STRING = 10;
const TPC_TRIPPLE_DOUBLE_QUOTED_STRING = 11;
const TPC_NAKED_STRING = 12;
const TPC_NEWLINE = 13;
const TPC_COMMENTSTART = 14;
const YY_NO_ACTION = 58;
const YY_ACCEPT_ACTION = 57;
const YY_ERROR_ACTION = 56;
const YY_SZ_ACTTAB = 37;
const YY_SZ_ACTTAB = 53;
static public $yy_action = array(
/* 0 */ 9, 21, 20, 18, 3, 14, 27, 26, 28, 12,
/* 10 */ 15, 2, 21, 6, 16, 7, 5, 14, 48, 4,
/* 20 */ 17, 11, 24, 23, 1, 8, 23, 10, 13, 21,
/* 30 */ 27, 25, 22, 43, 43, 43, 19,
/* 0 */ 24, 34, 33, 32, 31, 35, 21, 57, 6, 14,
/* 10 */ 22, 7, 2, 9, 29, 8, 2, 9, 19, 11,
/* 20 */ 19, 11, 26, 23, 2, 9, 15, 20, 46, 2,
/* 30 */ 9, 12, 25, 46, 2, 9, 10, 17, 18, 27,
/* 40 */ 16, 5, 13, 30, 28, 46, 5, 46, 3, 4,
/* 50 */ 46, 46, 1,
);
static public $yy_lookahead = array(
/* 0 */ 2, 1, 19, 19, 21, 22, 22, 7, 8, 11,
/* 10 */ 12, 13, 1, 3, 14, 20, 21, 22, 16, 17,
/* 20 */ 18, 4, 19, 12, 9, 3, 12, 11, 11, 1,
/* 30 */ 22, 19, 19, 23, 23, 23, 18,
/* 0 */ 6, 7, 8, 9, 10, 11, 12, 16, 17, 2,
/* 10 */ 19, 5, 21, 22, 19, 3, 21, 22, 13, 14,
/* 20 */ 13, 14, 19, 13, 21, 22, 2, 19, 24, 21,
/* 30 */ 22, 1, 19, 24, 21, 22, 3, 12, 13, 18,
/* 40 */ 2, 20, 4, 23, 18, 24, 20, 24, 21, 21,
/* 50 */ 24, 24, 21,
);
const YY_SHIFT_USE_DFLT = -3;
const YY_SHIFT_MAX = 13;
const YY_SHIFT_USE_DFLT = -7;
const YY_SHIFT_MAX = 17;
static public $yy_shift_ofst = array(
/* 0 */ -2, 0, 11, 11, -2, 28, 14, 14, 14, 17,
/* 10 */ 10, 16, 15, 22,
/* 0 */ 7, 7, 7, 7, 7, 30, 30, -6, 5, 5,
/* 10 */ 5, 25, 38, 24, 6, 12, 33, 10,
);
const YY_REDUCE_USE_DFLT = -18;
const YY_REDUCE_MAX = 8;
const YY_REDUCE_USE_DFLT = -10;
const YY_REDUCE_MAX = 10;
static public $yy_reduce_ofst = array(
/* 0 */ 2, -5, -17, -16, 18, 8, 13, 12, 3,
/* 0 */ -9, 8, 13, 3, -5, 21, 26, 20, 31, 28,
/* 10 */ 27,
);
static public $yyExpectedTokens = array(
/* 0 */ array(2, 11, 12, 13, ),
/* 1 */ array(1, 7, 8, 14, ),
/* 2 */ array(1, 12, ),
/* 3 */ array(1, 12, ),
/* 4 */ array(2, 11, 12, 13, ),
/* 0 */ array(2, 13, 14, ),
/* 1 */ array(2, 13, 14, ),
/* 2 */ array(2, 13, 14, ),
/* 3 */ array(2, 13, 14, ),
/* 4 */ array(2, 13, 14, ),
/* 5 */ array(1, ),
/* 6 */ array(12, ),
/* 7 */ array(12, ),
/* 8 */ array(12, ),
/* 9 */ array(4, 11, ),
/* 10 */ array(3, ),
/* 11 */ array(11, ),
/* 12 */ array(9, ),
/* 13 */ array(3, ),
/* 14 */ array(),
/* 15 */ array(),
/* 16 */ array(),
/* 17 */ array(),
/* 6 */ array(1, ),
/* 7 */ array(6, 7, 8, 9, 10, 11, 12, ),
/* 8 */ array(13, 14, ),
/* 9 */ array(13, 14, ),
/* 10 */ array(13, 14, ),
/* 11 */ array(12, 13, ),
/* 12 */ array(2, 4, ),
/* 13 */ array(2, ),
/* 14 */ array(5, ),
/* 15 */ array(3, ),
/* 16 */ array(3, ),
/* 17 */ array(13, ),
/* 18 */ array(),
/* 19 */ array(),
/* 20 */ array(),
@@ -185,35 +258,28 @@ static public $yy_action = array(
/* 26 */ array(),
/* 27 */ array(),
/* 28 */ array(),
/* 29 */ array(),
/* 30 */ array(),
/* 31 */ array(),
/* 32 */ array(),
/* 33 */ array(),
/* 34 */ array(),
/* 35 */ array(),
);
static public $yy_default = array(
/* 0 */ 47, 47, 43, 43, 29, 38, 43, 43, 43, 47,
/* 10 */ 47, 47, 47, 47, 45, 35, 41, 30, 37, 31,
/* 20 */ 36, 46, 33, 42, 32, 34, 39, 44, 40,
/* 0 */ 44, 44, 44, 44, 44, 39, 39, 56, 56, 56,
/* 10 */ 56, 56, 56, 56, 56, 56, 56, 56, 54, 53,
/* 20 */ 41, 52, 37, 55, 46, 42, 40, 38, 36, 43,
/* 30 */ 45, 50, 49, 48, 47, 51,
);
const YYNOCODE = 24;
const YYNOCODE = 25;
const YYSTACKDEPTH = 100;
const YYNSTATE = 29;
const YYNRULE = 18;
const YYNSTATE = 36;
const YYNRULE = 20;
const YYERRORSYMBOL = 15;
const YYERRSYMDT = 'yy0';
const YYFALLBACK = 1;
const YYFALLBACK = 0;
static public $yyFallback = array(
0, /* $ => nothing */
0, /* OTHER => nothing */
1, /* OPENB => OTHER */
1, /* CLOSEB => OTHER */
1, /* DOT => OTHER */
1, /* BOOLEANTRUE => OTHER */
1, /* BOOLEANFALSE => OTHER */
1, /* SI_QSTR => OTHER */
1, /* DO_QSTR => OTHER */
1, /* EQUAL => OTHER */
1, /* SPACE => OTHER */
1, /* ID => OTHER */
0, /* EOL => nothing */
0, /* COMMENTSTART => nothing */
0, /* ML_QSTR => nothing */
);
static function Trace($TraceFILE, $zTracePrompt)
{
@@ -239,33 +305,35 @@ static public $yy_action = array(
public $yystack = array(); /* The parser's stack */
public $yyTokenName = array(
'$', 'OTHER', 'OPENB', 'CLOSEB',
'DOT', 'BOOLEANTRUE', 'BOOLEANFALSE', 'SI_QSTR',
'DO_QSTR', 'EQUAL', 'SPACE', 'ID',
'EOL', 'COMMENTSTART', 'ML_QSTR', 'error',
'start', 'config', 'config_element', 'opteol',
'value', 'text', 'textelement',
'$', 'OPENB', 'ID', 'CLOSEB',
'DOT', 'EQUAL', 'FLOAT', 'INT',
'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_DOUBLE_QUOTED_STRING',
'NAKED_STRING', 'NEWLINE', 'COMMENTSTART', 'error',
'start', 'global_vars', 'sections', 'var_list',
'section', 'newline', 'var', 'value',
);
static public $yyRuleName = array(
/* 0 */ "start ::= config",
/* 1 */ "config ::= config_element",
/* 2 */ "config ::= config config_element",
/* 3 */ "config_element ::= OPENB ID CLOSEB opteol",
/* 4 */ "config_element ::= OPENB DOT ID CLOSEB opteol",
/* 5 */ "config_element ::= ID EQUAL value opteol",
/* 6 */ "config_element ::= EOL",
/* 7 */ "config_element ::= COMMENTSTART opteol",
/* 8 */ "config_element ::= COMMENTSTART text opteol",
/* 9 */ "value ::= text",
/* 10 */ "value ::= SI_QSTR",
/* 11 */ "value ::= DO_QSTR",
/* 12 */ "value ::= ML_QSTR",
/* 13 */ "opteol ::= EOL",
/* 14 */ "opteol ::=",
/* 15 */ "text ::= text textelement",
/* 16 */ "text ::= textelement",
/* 17 */ "textelement ::= OTHER",
/* 0 */ "start ::= global_vars sections",
/* 1 */ "global_vars ::= var_list",
/* 2 */ "sections ::= section sections",
/* 3 */ "sections ::=",
/* 4 */ "section ::= OPENB ID CLOSEB newline var_list",
/* 5 */ "section ::= OPENB DOT ID CLOSEB newline var_list",
/* 6 */ "var_list ::= newline var_list",
/* 7 */ "var_list ::= var newline var_list",
/* 8 */ "var_list ::=",
/* 9 */ "var ::= ID EQUAL value",
/* 10 */ "value ::= FLOAT",
/* 11 */ "value ::= INT",
/* 12 */ "value ::= BOOL",
/* 13 */ "value ::= SINGLE_QUOTED_STRING",
/* 14 */ "value ::= DOUBLE_QUOTED_STRING",
/* 15 */ "value ::= TRIPPLE_DOUBLE_QUOTED_STRING",
/* 16 */ "value ::= NAKED_STRING",
/* 17 */ "newline ::= NEWLINE",
/* 18 */ "newline ::= COMMENTSTART NEWLINE",
/* 19 */ "newline ::= COMMENTSTART NAKED_STRING NEWLINE",
);
function tokenName($tokenType)
@@ -539,95 +607,92 @@ static public $yy_action = array(
}
static public $yyRuleInfo = array(
array( 'lhs' => 16, 'rhs' => 1 ),
array( 'lhs' => 16, 'rhs' => 2 ),
array( 'lhs' => 17, 'rhs' => 1 ),
array( 'lhs' => 17, 'rhs' => 2 ),
array( 'lhs' => 18, 'rhs' => 4 ),
array( 'lhs' => 18, 'rhs' => 5 ),
array( 'lhs' => 18, 'rhs' => 4 ),
array( 'lhs' => 18, 'rhs' => 1 ),
array( 'lhs' => 18, 'rhs' => 2 ),
array( 'lhs' => 18, 'rhs' => 3 ),
array( 'lhs' => 20, 'rhs' => 1 ),
array( 'lhs' => 20, 'rhs' => 1 ),
array( 'lhs' => 20, 'rhs' => 1 ),
array( 'lhs' => 20, 'rhs' => 1 ),
array( 'lhs' => 19, 'rhs' => 1 ),
array( 'lhs' => 18, 'rhs' => 0 ),
array( 'lhs' => 20, 'rhs' => 5 ),
array( 'lhs' => 20, 'rhs' => 6 ),
array( 'lhs' => 19, 'rhs' => 2 ),
array( 'lhs' => 19, 'rhs' => 3 ),
array( 'lhs' => 19, 'rhs' => 0 ),
array( 'lhs' => 21, 'rhs' => 2 ),
array( 'lhs' => 22, 'rhs' => 3 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 23, 'rhs' => 1 ),
array( 'lhs' => 21, 'rhs' => 1 ),
array( 'lhs' => 22, 'rhs' => 1 ),
array( 'lhs' => 21, 'rhs' => 2 ),
array( 'lhs' => 21, 'rhs' => 3 ),
);
static public $yyReduceMap = array(
0 => 0,
2 => 0,
3 => 0,
17 => 0,
18 => 0,
19 => 0,
1 => 1,
9 => 1,
16 => 1,
17 => 1,
2 => 2,
15 => 2,
3 => 3,
4 => 4,
5 => 5,
6 => 6,
7 => 6,
8 => 6,
16 => 6,
7 => 7,
8 => 8,
9 => 9,
10 => 10,
11 => 11,
12 => 11,
12 => 12,
13 => 13,
14 => 14,
15 => 15,
);
#line 67 "smarty_internal_configfileparser.y"
function yy_r0(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 577 "smarty_internal_configfileparser.php"
#line 73 "smarty_internal_configfileparser.y"
function yy_r1(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 580 "smarty_internal_configfileparser.php"
#line 75 "smarty_internal_configfileparser.y"
function yy_r2(){$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; }
#line 583 "smarty_internal_configfileparser.php"
#line 81 "smarty_internal_configfileparser.y"
function yy_r3(){ $this->hidden_section = false; $this->current_section = $this->yystack[$this->yyidx + -2]->minor; $this->_retvalue =''; }
#line 586 "smarty_internal_configfileparser.php"
#line 83 "smarty_internal_configfileparser.y"
function yy_r4(){ if ($this->smarty->config_read_hidden) {
$this->hidden_section = false; $this->current_section = $this->yystack[$this->yyidx + -2]->minor;
} else {$this->hidden_section = true; } $this->_retvalue =''; }
#line 591 "smarty_internal_configfileparser.php"
#line 87 "smarty_internal_configfileparser.y"
function yy_r5(){if (!$this->hidden_section) {
$value=$this->yystack[$this->yyidx + -1]->minor;
if ($this->smarty->config_booleanize) {
if (in_array(strtolower($value),array('on','yes','true')))
$value = true;
else if (in_array(strtolower($value),array('off','no','false')))
$value = false;
}
if ($this->current_section == null) {
if ($this->smarty->config_overwrite || !isset($this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor])) {
$this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor]=$value;
} else {
settype($this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor], 'array');
$this->compiler->config_data['vars'][$this->yystack[$this->yyidx + -3]->minor][]=$value;
}
} else {
if ($this->smarty->config_overwrite || !isset($this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor])) {
$this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor]=$value;
} else {
settype($this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor], 'array');
$this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor][]=$value;
}
}} $this->_retvalue =''; }
#line 616 "smarty_internal_configfileparser.php"
#line 111 "smarty_internal_configfileparser.y"
function yy_r6(){ $this->_retvalue =''; }
#line 619 "smarty_internal_configfileparser.php"
#line 116 "smarty_internal_configfileparser.y"
function yy_r10(){$this->_retvalue = trim($this->yystack[$this->yyidx + 0]->minor,"'"); }
#line 622 "smarty_internal_configfileparser.php"
#line 117 "smarty_internal_configfileparser.y"
function yy_r11(){$this->_retvalue = trim($this->yystack[$this->yyidx + 0]->minor,'"'); }
#line 625 "smarty_internal_configfileparser.php"
#line 127 "smarty_internal_configfileparser.y"
function yy_r0(){ $this->_retvalue = null; }
#line 651 "smarty_internal_configfileparser.php"
#line 130 "smarty_internal_configfileparser.y"
function yy_r1(){ $this->add_global_vars($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = null; }
#line 654 "smarty_internal_configfileparser.php"
#line 136 "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 657 "smarty_internal_configfileparser.php"
#line 137 "smarty_internal_configfileparser.y"
function yy_r5(){ if ($this->smarty->config_read_hidden) { $this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor); } $this->_retvalue = null; }
#line 660 "smarty_internal_configfileparser.php"
#line 141 "smarty_internal_configfileparser.y"
function yy_r6(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 663 "smarty_internal_configfileparser.php"
#line 142 "smarty_internal_configfileparser.y"
function yy_r7(){ $this->_retvalue = array_merge(Array($this->yystack[$this->yyidx + -2]->minor), $this->yystack[$this->yyidx + 0]->minor); }
#line 666 "smarty_internal_configfileparser.php"
#line 143 "smarty_internal_configfileparser.y"
function yy_r8(){ $this->_retvalue = Array(); }
#line 669 "smarty_internal_configfileparser.php"
#line 147 "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 672 "smarty_internal_configfileparser.php"
#line 149 "smarty_internal_configfileparser.y"
function yy_r10(){ $this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor; }
#line 675 "smarty_internal_configfileparser.php"
#line 150 "smarty_internal_configfileparser.y"
function yy_r11(){ $this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor; }
#line 678 "smarty_internal_configfileparser.php"
#line 151 "smarty_internal_configfileparser.y"
function yy_r12(){ $this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor); }
#line 681 "smarty_internal_configfileparser.php"
#line 152 "smarty_internal_configfileparser.y"
function yy_r13(){ $this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor); }
#line 684 "smarty_internal_configfileparser.php"
#line 153 "smarty_internal_configfileparser.y"
function yy_r14(){ $this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor); }
#line 687 "smarty_internal_configfileparser.php"
#line 154 "smarty_internal_configfileparser.y"
function yy_r15(){ $this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + 0]->minor); }
#line 690 "smarty_internal_configfileparser.php"
private $_retvalue;
@@ -684,12 +749,12 @@ static public $yy_action = array(
function yy_syntax_error($yymajor, $TOKEN)
{
#line 52 "smarty_internal_configfileparser.y"
#line 120 "smarty_internal_configfileparser.y"
$this->internalError = true;
$this->yymajor = $yymajor;
$this->compiler->trigger_config_file_error();
#line 688 "smarty_internal_configfileparser.php"
#line 753 "smarty_internal_configfileparser.php"
}
function yy_accept()
@@ -700,13 +765,13 @@ static public $yy_action = array(
while ($this->yyidx >= 0) {
$stack = $this->yy_pop_parser_stack();
}
#line 44 "smarty_internal_configfileparser.y"
#line 112 "smarty_internal_configfileparser.y"
$this->successful = !$this->internalError;
$this->internalError = false;
$this->retvalue = $this->_retvalue;
//echo $this->retvalue."\n\n";
#line 706 "smarty_internal_configfileparser.php"
#line 771 "smarty_internal_configfileparser.php"
}
function doParse($yymajor, $yytokenvalue)

View File

@@ -1,7 +1,7 @@
<?php
/**
* Smarty Internal Plugin TemplateBase
* Smarty Internal Plugin Data
*
* This file contains the basic classes and methodes for template and variable creation
*
@@ -13,7 +13,7 @@
/**
* Base class with template and variable methodes
*/
class Smarty_Internal_TemplateBase {
class Smarty_Internal_Data {
// class used for templates
public $template_class = 'Smarty_Internal_Template';
@@ -300,8 +300,8 @@ class Smarty_Internal_TemplateBase {
}
if (!is_object($template)) {
// we got a template resource
$_templateId = $this->buildTemplateId ($template, $cache_id, $compile_id);
// already in template cache?
$_templateId = crc32($template . $cache_id . $compile_id);
if (isset($this->smarty->template_objects[$_templateId]) && $this->smarty->caching) {
// return cached template object
$tpl = $this->smarty->template_objects[$_templateId];
@@ -323,21 +323,6 @@ class Smarty_Internal_TemplateBase {
return $tpl;
}
/**
* generates a template id
*
* @param string $_resource the resource handle of the template file
* @param mixed $_cache_id cache id to be used with this template
* @param mixed $_compile_id compile id to be used with this template
* @returns string a unique template id
*/
function buildTemplateId ($_resource, $_cache_id, $_compile_id)
{
$_cache_id = isset($_cache_id) ? preg_replace('![^\w\|]+!','_',$_cache_id) : null;
$_compile_id = isset($_compile_id) ? preg_replace('![^\w\|]+!','_',$_compile_id) : null;
return crc32($_resource . $_cache_id . $_compile_id);
}
/**
* return current time
*
@@ -358,7 +343,7 @@ class Smarty_Internal_TemplateBase {
*
* @param object $parent tpl_vars next higher level of Smarty variables
*/
class Smarty_Data extends Smarty_Internal_TemplateBase {
class Smarty_Data extends Smarty_Internal_Data {
// array of variable objects
public $tpl_vars = array();
// back pointer to parent object

View File

@@ -12,7 +12,7 @@
/**
* Smarty Internal Plugin Debug Class
*/
class Smarty_Internal_Debug extends Smarty_Internal_TemplateBase {
class Smarty_Internal_Debug extends Smarty_Internal_Data {
// template data
static $template_data = array();

View File

@@ -1,9 +1,9 @@
<?php
/**
* Smarty Internal Plugin Run Filter
* Smarty Internal Plugin Filter Handler
*
* Smarty run filter class
* Smarty filter handler class
*
* @package Smarty
* @subpackage PluginsInternal
@@ -13,11 +13,7 @@
/**
* Class for filter processing
*/
class Smarty_Internal_Run_Filter {
function __construct($smarty)
{
$this->smarty = $smarty;
}
class Smarty_Internal_Filter_Handler {
/**
* Run filters over content
*
@@ -30,22 +26,22 @@ class Smarty_Internal_Run_Filter {
* @param string $content the content which shall be processed by the filters
* @return string the filtered content
*/
public function execute($type, $content, $flag = null)
static function runFilter($type, $content, $smarty, $flag = null)
{
$output = $content;
if ($type != 'variable' || ($this->smarty->variable_filter && $flag !== false) || $flag === true) {
if ($type != 'variable' || ($smarty->variable_filter && $flag !== false) || $flag === true) {
// loop over autoload filters of specified type
if (!empty($this->smarty->autoload_filters[$type])) {
foreach ((array)$this->smarty->autoload_filters[$type] as $name) {
if (!empty($smarty->autoload_filters[$type])) {
foreach ((array)$smarty->autoload_filters[$type] as $name) {
$plugin_name = "Smarty_{$type}filter_{$name}";
if ($this->smarty->loadPlugin($plugin_name)) {
if ($smarty->loadPlugin($plugin_name)) {
// use class plugin if found
if (class_exists($plugin_name, false)) {
// loaded class of filter plugin
$output = call_user_func_array(array($plugin_name, 'execute'), array($output, $this->smarty));
$output = call_user_func_array(array($plugin_name, 'execute'), array($output, $smarty));
} elseif (function_exists($plugin_name)) {
// use loaded Smarty2 style plugin
$output = call_user_func_array($plugin_name, array($output, $this->smarty));
$output = call_user_func_array($plugin_name, array($output, $smarty));
}
} else {
// nothing found, throw exception
@@ -54,9 +50,9 @@ class Smarty_Internal_Run_Filter {
}
}
// loop over registerd filters of specified type
if (!empty($this->smarty->registered_filters[$type])) {
foreach ($this->smarty->registered_filters[$type] as $key => $name) {
$output = call_user_func_array($this->smarty->registered_filters[$type][$key], array($output, $this->smarty));
if (!empty($smarty->registered_filters[$type])) {
foreach ($smarty->registered_filters[$type] as $key => $name) {
$output = call_user_func_array($smarty->registered_filters[$type][$key], array($output, $smarty));
}
}
}

View File

@@ -1,104 +0,0 @@
<?php
/**
* Smarty Internal Plugin Handler
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Handler Class
*/
class Smarty_Internal_Plugin_Handler {
function __construct($smarty)
{
$this->smarty = $smarty;
}
/**
* Call a Smarty plugin
*
* @param string $name block function name
* @param array $args $args[0] = array of plugin attributes and $args[1] = plugin types to search for
*/
public function __call($name, $args)
{
if ($this->loadSmartyPlugin($name, $args[1])) {
// call plugin
return call_user_func_array($this->smarty->registered_plugins[$name][1], $args[0]);
} else {
// plugin not found
throw new Exception("Unable to load plugin {$name}");
}
}
public function executeModifier($name, $args, $check_array)
{
if ($this->loadSmartyPlugin($name, 'modifier')) {
// call plugin
if (!$check_array || !is_array($args[0])) {
return call_user_func_array($this->smarty->registered_plugins[$name][1], $args);
} else {
$args0 = $args[0];
foreach ($args0 as $key => $arg0) {
$args[0] = $arg0;
$result[$key] = call_user_func_array($this->smarty->registered_plugins[$name][1], $args);
}
return $result;
}
} elseif (is_callable($name)) {
if (!$check_array || !is_array($args[0])) {
return call_user_func_array($name, $args);
} else {
$args0 = $args[0];
foreach ($args0 as $key => $arg0) {
$args[0] = $arg0;
$result[$key] = call_user_func_array($name, $args);
}
return $result;
}
} else {
// plugin not found
throw new Exception("Unable to load plugin {$name}");
}
}
/**
* Lazy loads plugin files
* class name format: Smarty_PluginType_FuncName
* plugin filename format: plugintype.funcname.php
*
* @param string $name plugin name
* @param array $type array of plugin types to search for
*/
public function loadSmartyPlugin($name, $type)
{
// load plugin if missing
if (isset($this->smarty->registered_plugins[$name])) {
return true;
} else {
foreach ((array)$type as $plugin_type) {
$plugin = 'smarty_' . $plugin_type . '_' . $name;
if ($this->smarty->loadPlugin($plugin)) {
if (class_exists($plugin, false)) {
$plugin = array(new $plugin, 'execute');
}
if (is_callable($plugin)) {
$this->smarty->registered_plugins[$name] = array($plugin_type, $plugin, true);
return true;
} else {
throw new Exception("Plugin \"{$name}\" not callable");
}
}
}
}
if (!empty($this->smarty->default_plugin_handler_func)) {
if (!is_callable($this->smarty->default_plugin_handler_func)) {
throw new Exception("Default template handler not callable");
} else {
return call_user_func_array($this->smarty->default_plugin_handler_func, array($name, $type, &$this));
}
}
return false;
}
}
?>

View File

@@ -21,6 +21,9 @@ class Smarty_Internal_Resource_Extends {
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
public $template_parser_class = 'Smarty_Internal_Templateparser';
// properties
public $usesCompiler = true;
public $isEvaluated = false;
/**
* Return flag if template source is existing
@@ -135,27 +138,6 @@ class Smarty_Internal_Resource_Extends {
}
}
/**
* Return flag that this resource uses the compiler
*
* @return boolean true
*/
public function usesCompiler()
{
// template has tags, uses compiler
return true;
}
/**
* Return flag that this is not evaluated
*
* @return boolean false
*/
public function isEvaluated()
{
// save the compiled file to disk, do not evaluate
return false;
}
/**
* Get filepath to compiled template
*

View File

@@ -21,6 +21,9 @@ class Smarty_Internal_Resource_File {
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
public $template_parser_class = 'Smarty_Internal_Templateparser';
// properties
public $usesCompiler = true;
public $isEvaluated = false;
/**
* Return flag if template source is existing
@@ -82,27 +85,6 @@ class Smarty_Internal_Resource_File {
}
}
/**
* Return flag that this resource uses the compiler
*
* @return boolean true
*/
public function usesCompiler()
{
// template has tags, uses compiler
return true;
}
/**
* Return flag that this is not evaluated
*
* @return boolean false
*/
public function isEvaluated()
{
// save the compiled file to disk, do not evaluate
return false;
}
/**
* Get filepath to compiled template
*

View File

@@ -21,6 +21,9 @@ class Smarty_Internal_Resource_PHP {
$this->smarty = $smarty;
ini_set('short_open_tag', '1');
}
// properties
public $usesCompiler = false;
public $isEvaluated = false;
/**
* Return flag if template source is existing
@@ -80,27 +83,6 @@ class Smarty_Internal_Resource_PHP {
}
}
/**
* Return flag that this resource not use the compiler
*
* @return boolean false
*/
public function usesCompiler()
{
// does not use compiler, template is PHP
return false;
}
/**
* Return flag that this is not evaluated
*
* @return boolean false
*/
public function isEvaluated()
{
// does not use compiler, must be false
return false;
}
/**
* Get filepath to compiled template

View File

@@ -22,6 +22,9 @@ class Smarty_Internal_Resource_Registered {
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
public $template_parser_class = 'Smarty_Internal_Templateparser';
// properties
public $usesCompiler = true;
public $isEvaluated = false;
/**
* Return flag if template source is existing
@@ -93,28 +96,6 @@ class Smarty_Internal_Resource_Registered {
array($_template->resource_name, &$_template->template_source, $this->smarty));
}
/**
* Return flag that this resource uses the compiler
*
* @return boolean true
*/
public function usesCompiler()
{
// resource string is template, needs compiler
return true;
}
/**
* Return flag that this resource is evaluated
*
* @return boolean true
*/
public function isEvaluated()
{
// compiled template is evaluated instead of saved to disk
return false;
}
/**
* Get filepath to compiled template
*

View File

@@ -22,6 +22,9 @@ class Smarty_Internal_Resource_Stream {
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
public $template_parser_class = 'Smarty_Internal_Templateparser';
// properties
public $usesCompiler = true;
public $isEvaluated = true;
/**
* Return flag if template source is existing
@@ -80,28 +83,6 @@ class Smarty_Internal_Resource_Stream {
return true;
}
/**
* Return flag that this resource uses the compiler
*
* @return boolean true
*/
public function usesCompiler()
{
// resource string is template, needs compiler
return true;
}
/**
* Return flag that this resource is evaluated
*
* @return boolean true
*/
public function isEvaluated()
{
// compiled template is evaluated instead of saved to disk
return true;
}
/**
* Get filepath to compiled template
*

View File

@@ -22,6 +22,9 @@ class Smarty_Internal_Resource_String {
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
public $template_lexer_class = 'Smarty_Internal_Templatelexer';
public $template_parser_class = 'Smarty_Internal_Templateparser';
// properties
public $usesCompiler = true;
public $isEvaluated = true;
/**
* Return flag if template source is existing
@@ -71,28 +74,6 @@ class Smarty_Internal_Resource_String {
return true;
}
/**
* Return flag that this resource uses the compiler
*
* @return boolean true
*/
public function usesCompiler()
{
// resource string is template, needs compiler
return true;
}
/**
* Return flag that this resource is evaluated
*
* @return boolean true
*/
public function isEvaluated()
{
// compiled template is evaluated instead of saved to disk
return true;
}
/**
* Get filepath to compiled template
*

View File

@@ -37,12 +37,12 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
tags in the templates are replaces with PHP code,
then written to compiled files. */
// init the lexer/parser to compile the template
$this->lex = new $this->lexer_class($_content,$this->smarty);
$this->lex = new $this->lexer_class($_content, $this);
$this->parser = new $this->parser_class($this->lex, $this);
//$this->parser->PrintTrace();
// $this->parser->PrintTrace();
// get tokens from lexer and parse them
while ($this->lex->yylex() && !$this->abort_and_recompile) {
//echo "<pre>Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token ".htmlentities($this->lex->value)."</pre>";
// echo "<pre>Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token ".htmlentities($this->lex->value)."</pre>";
$this->parser->doParse($this->lex->token, $this->lex->value);
}
@@ -61,7 +61,8 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
if (!$this->compile_error) {
// return compiled code
return str_replace(array("?>\n<?php","?><?php"), array('',''), $this->parser->retvalue);
// return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);
return $this->parser->retvalue;
} else {
// compilation error
return false;

View File

@@ -13,7 +13,7 @@
/**
* Main class with template data structures and methods
*/
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
class Smarty_Internal_Template extends Smarty_Internal_Data {
// object cache
public $compiler_object = null;
public $cacher_object = null;
@@ -30,9 +30,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
public $template_resource = null;
public $resource_type = null;
public $resource_name = null;
private $resource_object = null;
private $usesCompiler = null;
private $isEvaluated = null;
public $resource_object = null;
private $isExisting = null;
// Template source
public $template_filepath = null;
@@ -65,7 +63,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
// special properties
public $properties = array();
// storage for block data
public $block_data = array();
public $block_data = array();
// required plugins
public $required_plugins = array();
/**
* Create template data object
@@ -89,7 +89,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
if ($this->caching === true) $this->caching = SMARTY_CACHING_LIFETIME_CURRENT;
$this->cache_lifetime = $_cache_lifetime === null ?$this->smarty->cache_lifetime : $_cache_lifetime;
$this->force_cache = $this->smarty->force_cache;
$this->cacher_class = $this->smarty->cacher_class;
$this->security = $this->smarty->security;
$this->parent = $_parent;
$this->properties['file_dependency'] = array();
@@ -102,7 +101,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
throw new Exception ("Unable to parse resource name \"{$template_resource}\"");
}
// load cache resource
if (!$this->isEvaluated() && ($this->caching == 1 || $this->caching == 2)) {
if (!$this->resource_object->isEvaluated && ($this->caching == 1 || $this->caching == 2)) {
$this->cache_resource_object = $this->smarty->loadCacheResource();
}
}
@@ -169,33 +168,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
}
return $this->isExisting;
}
/**
* Returns if the template resource uses the Smarty compiler
*
* The status is determined by the actual resource handler
*
* @return boolean true if the template will use the compiler
*/
public function usesCompiler ()
{
return $this->usesCompiler === null ?
$this->usesCompiler = $this->resource_object->usesCompiler() :
$this->usesCompiler;
}
/**
* Returns if the compiled template is stored or just evaluated in memory
*
* The status is determined by the actual resource handler
*
* @return boolean true if the compiled template has to be evaluated
*/
public function isEvaluated ()
{
return $this->isEvaluated === null ?
$this->isEvaluated = $this->resource_object->isEvaluated() :
$this->isEvaluated;
}
/**
* Returns if the current template must be compiled by the Smarty compiler
@@ -208,7 +180,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
{
$this->isExisting(true);
if ($this->mustCompile === null) {
$this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || $this->getCompiledTimestamp () === false ||
$this->mustCompile = ($this->resource_object->usesCompiler && ($this->force_compile || $this->resource_object->isEvaluated || $this->getCompiledTimestamp () === false ||
// ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ())));
($this->smarty->compile_check && $this->getCompiledTimestamp () < $this->getTemplateTimestamp ())));
}
@@ -223,7 +195,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
public function getCompiledFilepath ()
{
return $this->compiled_filepath === null ?
($this->compiled_filepath = !$this->isEvaluated() ? $this->resource_object->getCompiledFilepath($this) : false) :
($this->compiled_filepath = !$this->resource_object->isEvaluated ? $this->resource_object->getCompiledFilepath($this) : false) :
$this->compiled_filepath;
}
@@ -235,7 +207,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
public function getCompiledTimestamp ()
{
return $this->compiled_timestamp === null ?
($this->compiled_timestamp = (!$this->isEvaluated() && file_exists($this->getCompiledFilepath())) ? filemtime($this->getCompiledFilepath()) : false) :
($this->compiled_timestamp = (!$this->resource_object->isEvaluated && file_exists($this->getCompiledFilepath())) ? filemtime($this->getCompiledFilepath()) : false) :
$this->compiled_timestamp;
}
@@ -254,7 +226,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
$this->compileTemplateSource();
} else {
if ($this->compiled_template === null) {
$this->compiled_template = !$this->isEvaluated() && $this->usesCompiler() ? file_get_contents($this->getCompiledFilepath()) : false;
$this->compiled_template = !$this->resource_object->isEvaluated && $this->resource_object->usesCompiler ? file_get_contents($this->getCompiledFilepath()) : false;
}
}
}
@@ -268,7 +240,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
*/
public function compileTemplateSource ()
{
if (!$this->isEvaluated) {
if (!$this->resource_object->isEvaluated) {
$this->properties['file_dependency'] = array();
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
}
if ($this->smarty->debugging) {
@@ -278,17 +251,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
if (!is_object($this->compiler_object)) {
// load compiler
$this->smarty->loadPlugin($this->resource_object->compiler_class);
$this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty);
// load cacher
if ($this->caching) {
$this->smarty->loadPlugin($this->cacher_class);
$this->cacher_object = new $this->cacher_class($this->smarty);
}
$this->compiler_object = new $this->resource_object->compiler_class($this->resource_object->template_lexer_class, $this->resource_object->template_parser_class, $this->smarty);
}
// call compiler
if ($this->compiler_object->compileTemplate($this)) {
// compiling succeded
if (!$this->isEvaluated()) {
if (!$this->resource_object->isEvaluated) {
// write compiled template
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template, $this->smarty);
// make template and compiled file timestamp match
@@ -314,28 +282,28 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
/**
* Returns the filepath of the cached template output
*
* The filepath is determined by the actual resource handler of the cacher
* The filepath is determined by the actual cache resource
*
* @return string the cache filepath
*/
public function getCachedFilepath ()
{
return $this->cached_filepath === null ?
$this->cached_filepath = ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedFilepath($this) :
$this->cached_filepath = ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedFilepath($this) :
$this->cached_filepath;
}
/**
* Returns the timpestamp of the cached template output
*
* The timestamp is determined by the actual resource handler of the cacher
* The timestamp is determined by the actual cache resource
*
* @return integer the template timestamp
*/
public function getCachedTimestamp ()
{
return $this->cached_timestamp === null ?
$this->cached_timestamp = ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedTimestamp($this) :
$this->cached_timestamp = ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedTimestamp($this) :
$this->cached_timestamp;
}
@@ -347,7 +315,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
public function getCachedContent ()
{
return $this->rendered_content === null ?
$this->rendered_content = ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedContents($this) :
$this->rendered_content = ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedContents($this) :
$this->rendered_content;
}
@@ -355,10 +323,17 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
* Writes the cached template output
*/
public function writeCachedContent ()
{
{
if ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) {
// don't write cache file
return false;
}
// build file dependency string
$this->properties['cache_lifetime'] = $this->cache_lifetime;
return ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->writeCachedContent($this, $this->createPropertyHeader() . $this->rendered_content);
$this->dynamicId = uniqid();
$output = preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php /*' . $this->dynamicId . '*/ echo \'$1\'; ?>', $this->rendered_content);
$output = preg_replace_callback('/\/\*%%SmartyNocache%%\*\/(.+?)\/\*\/%%SmartyNocache%%\*\//s', array($this, 'unescapePhp'), $output);
return $this->cache_resource_object->writeCachedContent($this, $this->createPropertyHeader(true) . $output);
}
/**
@@ -372,11 +347,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
{
if ($this->isCached === null) {
$this->isCached = false;
if (($this->caching == 1 || $this->caching == 2) && !$this->isEvaluated() && !$this->force_compile && !$this->force_cache) {
if ($this->getCachedTimestamp() === false) {
if (($this->caching == 1 || $this->caching == 2) && !$this->resource_object->isEvaluated && !$this->force_compile && !$this->force_cache) {
$cachedTimestamp = $this->getCachedTimestamp();
if ($cachedTimestamp === false) {
return $this->isCached;
}
if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED || ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT && (time() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0))) {
if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED || ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT && (time() <= ($cachedTimestamp + $this->cache_lifetime) || $this->cache_lifetime < 0))) {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_cache($this);
}
@@ -405,7 +381,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
// If ($mtime > $this->getCachedTimestamp()) {
If ($mtime > $_file_to_check[1]) {
$this->rendered_content = null;
$this->properties['file_dependency'] = array();
return $this->isCached;
}
}
@@ -426,7 +401,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
*/
public function renderTemplate ()
{
if ($this->usesCompiler()) {
if ($this->resource_object->usesCompiler) {
if ($this->mustCompile() && $this->compiled_template === null) {
$this->compileTemplateSource();
}
@@ -435,7 +410,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
}
$_smarty_tpl = $this;
ob_start();
if ($this->isEvaluated()) {
if ($this->resource_object->isEvaluated) {
eval("?>" . $this->compiled_template);
} else {
include($this->getCompiledFilepath ());
@@ -453,7 +428,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
}
// If ($mtime != $_file_to_check[1]) {
If ($mtime > $_file_to_check[1]) {
$this->properties['file_dependency'] = array();
$this->mustCompile = true;
break;
}
@@ -480,18 +454,19 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
}
}
$this->rendered_content = ob_get_clean();
if (!$this->isEvaluated) {
if (!$this->resource_object->isEvaluated) {
$this->properties['file_dependency']['F' . abs(crc32($this->getTemplateFilepath()))] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp());
}
if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
// var_dump('merge ', $this->parent->getTemplateFilepath(), $this->parent->properties['file_dependency'], $this->getTemplateFilepath(), $this->properties['file_dependency']);
$this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
$this->parent->required_plugins = array_merge_recursive($this->parent->required_plugins, $this->required_plugins);
}
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_render($this);
}
// write to cache when nessecary
if (!$this->isEvaluated() && ($this->caching == SMARTY_CACHING_LIFETIME_SAVED || $this->caching == SMARTY_CACHING_LIFETIME_CURRENT)) {
if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_SAVED || $this->caching == SMARTY_CACHING_LIFETIME_CURRENT)) {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::start_cache($this);
}
@@ -519,7 +494,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
public function getRenderedTemplate ()
{
// disable caching for evaluated code
if ($this->isEvaluated()) {
if ($this->resource_object->isEvaluated) {
$this->caching = false;
}
// checks if template exists
@@ -553,7 +528,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
// do not cache string resources
// ***** if ($resource_type != 'string' && $this->smarty->caching) {
if ($resource_type != 'string') {
$this->smarty->template_objects[$this->buildTemplateId ($this->template_resource, $this->cache_id, $this->compile_id)] = $this;
$this->smarty->template_objects[crc32($this->template_resource . $this->cache_id . $this->compile_id)] = $this;
}
return true;
}
@@ -595,34 +570,17 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
}
/**
* Decode saved properties from compiled template and cache files
*/
public function decodeProperties ($properties)
{
$prop = unserialize($properties);
if (isset($prop['cache_lifetime'])) {
$this->properties['cache_lifetime'] = $prop['cache_lifetime'];
}
if (isset($prop['file_dependency'])) {
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $prop['file_dependency']);
// $this->properties['file_dependency'] = array_unique($this->properties['file_dependency']);
}
if (!empty($prop['function'])) {
foreach ($prop['function'] as $_name => $_data) {
$this->smarty->template_functions[$_name]['compiled'] = str_replace('_%n', "\n", $_data['compiled']);
$this->smarty->template_functions[$_name]['parameter'] = $_data['parameter'];
}
}
}
/**
* Update Smarty variables in parent variable object
* Update Smarty variables in other scopes
*/
public function updateParentVariables ($scope = SMARTY_LOCAL_SCOPE)
{
$has_root = false;
foreach ($this->tpl_vars as $_key => $_variable) {
// copy global vars back to parent
if (isset($this->parent) && ($scope == SMARTY_PARENT_SCOPE || $this->tpl_vars[$_key]->scope == SMARTY_PARENT_SCOPE)) {
$_variable_scope = $this->tpl_vars[$_key]->scope;
if ($scope == SMARTY_LOCAL_SCOPE && $_variable_scope == SMARTY_LOCAL_SCOPE) {
continue;
}
if (isset($this->parent) && ($scope == SMARTY_PARENT_SCOPE || $_variable_scope == SMARTY_PARENT_SCOPE)) {
if (isset($this->parent->tpl_vars[$_key])) {
// variable is already defined in parent, copy value
$this->parent->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value;
@@ -632,22 +590,28 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
$this->parent->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE;
}
}
if ($scope == SMARTY_ROOT_SCOPE || $this->tpl_vars[$_key]->scope == SMARTY_ROOT_SCOPE) {
$_ptr = $this;
// find root
while ($_ptr->parent != null) {
$_ptr = $_ptr->parent;
if ($scope == SMARTY_ROOT_SCOPE || $_variable_scope == SMARTY_ROOT_SCOPE) {
if ($this->parent == null) {
continue;
}
if (isset($_ptr->tpl_vars[$_key])) {
if (!$has_root) {
// find root
$root_ptr = $this;
while ($root_ptr->parent != null) {
$root_ptr = $root_ptr->parent;
$has_root = true;
}
}
if (isset($root_ptr->tpl_vars[$_key])) {
// variable is already defined in root, copy value
$_ptr->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value;
$root_ptr->tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value;
} else {
// create variable in root
$_ptr->tpl_vars[$_key] = clone $_variable;
$_ptr->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE;
$root_ptr->tpl_vars[$_key] = clone $_variable;
$root_ptr->tpl_vars[$_key]->scope = SMARTY_LOCAL_SCOPE;
}
}
if ($scope == SMARTY_GLOBAL_SCOPE || $this->tpl_vars[$_key]->scope == SMARTY_GLOBAL_SCOPE) {
if ($scope == SMARTY_GLOBAL_SCOPE || $_variable_scope == SMARTY_GLOBAL_SCOPE) {
if (isset($this->smarty->global_tpl_vars[$_key])) {
// variable is already defined in root, copy value
$this->smarty->global_tpl_vars[$_key]->value = $this->tpl_vars[$_key]->value;
@@ -694,58 +658,99 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
*/
private function loadTemplateResourceHandler ($resource_type)
{
// load resource handler if required
if (!isset($this->smarty->resource_objects[$resource_type])) {
// try registered resource
if (isset($this->smarty->_plugins['resource'][$resource_type])) {
return $this->smarty->resource_objects[$resource_type] = new Smarty_Internal_Resource_Registered($this->smarty);
} else {
// try sysplugins dir
// try registered resource
if (isset($this->smarty->_plugins['resource'][$resource_type])) {
return new Smarty_Internal_Resource_Registered($this->smarty);
} else {
// try sysplugins dir
if (in_array($resource_type, array('file', 'string', 'extends', 'php', 'registered', 'stream'))) {
$_resource_class = 'Smarty_Internal_Resource_' . $resource_type;
return new $_resource_class($this->smarty);
} else {
// try plugins dir
$_resource_class = 'Smarty_Resource_' . $resource_type;
if ($this->smarty->loadPlugin($_resource_class)) {
return $this->smarty->resource_objects[$resource_type] = new $_resource_class($this->smarty);
} else {
// try plugins dir
$_resource_class = 'Smarty_Resource_' . $resource_type;
if ($this->smarty->loadPlugin($_resource_class)) {
if (class_exists($_resource_class, false)) {
return $this->smarty->resource_objects[$resource_type] = new $_resource_class($this->smarty);
} else {
$this->smarty->register_resource($resource_type,
array("smarty_resource_{$resource_type}_source",
"smarty_resource_{$resource_type}_timestamp",
"smarty_resource_{$resource_type}_secure",
"smarty_resource_{$resource_type}_trusted"));
return $this->smarty->resource_objects[$resource_type] = new Smarty_Internal_Resource_Registered($this->smarty);
}
if (class_exists($_resource_class, false)) {
return new $_resource_class($this->smarty);
} else {
// try streams
$_known_stream = stream_get_wrappers();
if (in_array($resource_type, $_known_stream)) {
// is known stream
if ($this->smarty->security) {
$this->smarty->security_handler->isTrustedStream($resource_type);
}
return $this->smarty->resource_objects[$resource_type] = new Smarty_Internal_Resource_Stream($this->smarty);
} else {
throw new Exception('Unkown resource type \'' . $resource_type . '\'');
$this->smarty->register_resource($resource_type,
array("smarty_resource_{$resource_type}_source",
"smarty_resource_{$resource_type}_timestamp",
"smarty_resource_{$resource_type}_secure",
"smarty_resource_{$resource_type}_trusted"));
return new Smarty_Internal_Resource_Registered($this->smarty);
}
} else {
// try streams
$_known_stream = stream_get_wrappers();
if (in_array($resource_type, $_known_stream)) {
// is known stream
if ($this->smarty->security) {
$this->smarty->security_handler->isTrustedStream($resource_type);
}
return new Smarty_Internal_Resource_Stream($this->smarty);
} else {
throw new Exception('Unkown resource type \'' . $resource_type . '\'');
}
}
}
} else {
return $this->smarty->resource_objects[$resource_type];
}
}
/**
* Create property header
*/
public function createPropertyHeader ()
public function createPropertyHeader ($cache = false)
{
$directory_security = $this->smarty->direct_access_security ? "<?php if(!defined('SMARTY_DIR')) exit('no direct access allowed'); ?>\n" : '';
$properties_string = "<?php \$_smarty_tpl->decodeProperties('" . str_replace("'", "\\'", (serialize($this->properties))) . "'); ?>\n";
return $directory_security . $properties_string;
$directory_security = $this->smarty->direct_access_security ? "<?php /*%%SmartyHeaderCode%%*/ if(!defined('SMARTY_DIR')) exit('no direct access allowed'); /*/%%SmartyHeaderCode%%*/?>\n" : '';
// $properties_string = "<?php \$_smarty_tpl->decodeProperties(" . preg_replace('/\s*/', '',var_export($this->properties, true)) . "); ? >\n";
$properties_string = "<?php /*%%SmartyHeaderCode%%*/ \$_smarty_tpl->decodeProperties(" . var_export($this->properties, true) . "); /*/%%SmartyHeaderCode%%*/?>\n";
$plugins_string = '';
if (!$cache) {
if (!empty($this->required_plugins['compiled'])) {
$plugins_string = '<?php ';
foreach($this->required_plugins['compiled'] as $plugin_name => $data) {
$plugin = 'smarty_' . $data['type'] . '_' . $plugin_name;
$plugins_string .= "if (!is_callable('{$plugin}')) include '{$data['file']}';\n";
}
$plugins_string .= '?>';
}
if (!empty($this->required_plugins['cache'])) {
$plugins_string .= '<?php echo \'/*%%SmartyNocache%%*/<?php ';
foreach($this->required_plugins['cache'] as $plugin_name => $data) {
$plugin = 'smarty_' . $data['type'] . '_' . $plugin_name;
$plugins_string .= "if (!is_callable(\'{$plugin}\')) include \'{$data['file']}\';\n";
}
$plugins_string .= "?>/*/%%SmartyNocache%%*/';?>\n";
}
}
return $directory_security . $properties_string . $plugins_string;
}
/**
* Decode saved properties from compiled template and cache files
*/
public function decodeProperties ($properties)
{
if (isset($properties['cache_lifetime'])) {
$this->properties['cache_lifetime'] = $properties['cache_lifetime'];
}
if (isset($properties['file_dependency'])) {
$this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']);
}
if (!empty($properties['function'])) {
foreach ($properties['function'] as $_name => $_data) {
$this->smarty->template_functions[$_name]['compiled'] = $_data['compiled'];
$this->smarty->template_functions[$_name]['parameter'] = $_data['parameter'];
}
}
}
/**
* callback to unescap PHP
*/
public function unescapePhp($match)
{
return preg_replace('{<\?php /\*' . $this->dynamicId . '\*/ echo \'(.+?)\'; \?>}s', '$1', $match[1]);
}
/**

View File

@@ -17,7 +17,9 @@ class Smarty_Internal_TemplateCompilerBase {
// tag stack
public $_tag_stack = array();
// current template
public $template = null;
public $template = null;
// required plugins
public $required_plugins_call = array();
/**
* Initialize compiler
@@ -36,11 +38,7 @@ class Smarty_Internal_TemplateCompilerBase {
{
/* here is where the compiling takes place. Smarty
tags in the templates are replaces with PHP code,
then written to compiled files. */
if (!is_object($template->cacher_object)) {
$this->smarty->loadPlugin($template->cacher_class);
$template->cacher_object = new $template->cacher_class($this->smarty);
}
then written to compiled files. */
// flag for nochache sections
$this->nocache = false;
$this->tag_nocache = false;
@@ -52,7 +50,7 @@ class Smarty_Internal_TemplateCompilerBase {
// template header code
$template_header = '';
if (!$template->suppressHeader) {
$template_header .= "<?php /* Smarty version " . Smarty::$_version . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
$template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
$template_header .= " compiled from \"" . $this->template->getTemplateFilepath() . "\" */ ?>\n";
}
@@ -63,33 +61,31 @@ class Smarty_Internal_TemplateCompilerBase {
$_content = $template->getTemplateSource();
// run prefilter if required
if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
$_content = $this->smarty->filter_handler->execute('pre', $_content);
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $this->smarty);
}
// on empty template just return header
if ($_content == '') {
if ($template->suppressFileDependency) {
$template->compiled_template = '';
} else {
$template->compiled_template = $template->createPropertyHeader() . $template_header;
$template->compiled_template = $template_header . $template->createPropertyHeader();
}
return true;
}
// init cacher plugin
$template->cacher_object->initCacher($this);
// call compiler
$_compiled_code = $this->doCompile($_content);
} while ($this->abort_and_recompile);
if (!$this->compile_error) {
// close cacher and return compiled template
// return compiled code to template object
if ($template->suppressFileDependency) {
$template->compiled_template = $template->cacher_object->closeCacher($this, $_compiled_code);
$template->compiled_template = $_compiled_code;
} else {
$template->compiled_template = $template->createPropertyHeader() . $template_header . $template->cacher_object->closeCacher($this, $_compiled_code);
$template->compiled_template = $template_header . $template->createPropertyHeader() . $_compiled_code;
}
// run postfilter if required
if (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) {
$template->compiled_template = $this->smarty->filter_handler->execute('post', $template->compiled_template);
$template->compiled_template = Smarty_Internal_Filter_Handler::runFilter('post', $template->compiled_template, $this->smarty);
}
return true;
} else {
@@ -115,12 +111,11 @@ class Smarty_Internal_TemplateCompilerBase {
$this->has_code = true;
$this->has_output = false;
// compile the smarty tag (required compile classes to compile the tag are autoloaded)
if (($_output = $this->generateCode($tag, $args)) === false) {
if (($_output = $this->callTagCompiler($tag, $args)) === false) {
if (isset($this->smarty->template_functions[$tag])) {
// template defined by {template} tag
$args['name'] = $tag;
$tag = 'function_call';
$_output = $this->generateCode($tag, $args);
$_output = $this->callTagCompiler('private_function_call', $args);
}
}
if ($_output !== false) {
@@ -139,49 +134,85 @@ class Smarty_Internal_TemplateCompilerBase {
return '';
} else {
// not an internal compiler tag
// check if tag is a registered object
if (isset($this->smarty->registered_objects[$tag]) && isset($args['object_methode'])) {
$methode = $args['object_methode'];
unset ($args['object_methode']);
if (!in_array($methode, $this->smarty->registered_objects[$tag][3]) &&
(empty($this->smarty->registered_objects[$tag][1]) || in_array($methode, $this->smarty->registered_objects[$tag][1]))) {
return $this->generateCode('object_function',$args, $tag, $methode);
} elseif (in_array($methode, $this->smarty->registered_objects[$tag][3])) {
return $this->generateCode('object_block_function',$args, $tag, $methode);
} else {
return $this->trigger_template_error ('unallowed methode "' . $methode . '" in registered object "' . $tag . '"', $this->lex->taglineno);
}
}
// check if tag is registered or is Smarty plugin
$this->smarty->plugin_handler->loadSmartyPlugin($tag, $this->smarty->plugin_search_order);
if (isset($this->smarty->registered_plugins[$tag])) {
// if compiler function plugin call it now
if ($this->smarty->registered_plugins[$tag][0] == 'compiler') {
if (!$this->smarty->registered_plugins[$tag][2]) {
$this->tag_nocache = true;
if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) {
// check if tag is a registered object
if (isset($this->smarty->registered_objects[$tag]) && isset($args['object_methode'])) {
$methode = $args['object_methode'];
unset ($args['object_methode']);
if (!in_array($methode, $this->smarty->registered_objects[$tag][3]) &&
(empty($this->smarty->registered_objects[$tag][1]) || in_array($methode, $this->smarty->registered_objects[$tag][1]))) {
return $this->callTagCompiler('private_object_function', $args, $tag, $methode);
} elseif (in_array($methode, $this->smarty->registered_objects[$tag][3])) {
return $this->callTagCompiler('private_object_block_function', $args, $tag, $methode);
} else {
return $this->trigger_template_error ('unallowed methode "' . $methode . '" in registered object "' . $tag . '"', $this->lex->taglineno);
}
return call_user_func($this->smarty->registered_plugins[$tag][1], $args, $this);
}
// compile function or block plugin
$plugin_type = $this->smarty->registered_plugins[$tag][0] . '_plugin';
return $this->generateCode($plugin_type, $args, $tag);
}
// compile closing tag of block function
if (strlen($tag) > 5 && substr_compare($tag, 'close', -5, 5) == 0) {
// check if tag is registered
foreach (array('compiler', 'function', 'block') as $type) {
if (isset($this->smarty->registered_plugins[$type][$tag])) {
// if compiler function plugin call it now
if ($type == 'compiler') {
if (!$this->smarty->registered_plugins[$type][$tag][1]) {
$this->tag_nocache = true;
}
return call_user_func_array($this->smarty->registered_plugins[$type][$tag][0], array($args, $this));
}
// compile registered function or block function
if ($type == 'function' || $type == 'block') {
return $this->callTagCompiler('private_registered_' . $type, $args, $tag);
}
}
}
// check plugins from plugins folder
foreach ($this->smarty->plugin_search_order as $plugin_type) {
if ($plugin_type == 'compiler' && $this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
$plugin = 'smarty_compiler_' . $tag;
if (class_exists($plugin, false)) {
$plugin = array(new $plugin, 'compile');
}
if (is_callable($plugin)) {
return call_user_func_array($plugin, array($args, $this));
} else {
throw new Exception("Plugin \"{$tag}\" not callable");
}
} else {
if ($function = $this->getPlugin($tag, $plugin_type)) {
return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $tag, $function);
}
}
}
} else {
// compile closing tag of block function
$base_tag = substr($tag, 0, -5);
// check if closing tag is a registered object
if (isset($this->smarty->registered_objects[$base_tag]) && isset($args['object_methode'])) {
$methode = $args['object_methode'];
unset ($args['object_methode']);
if (in_array($methode, $this->smarty->registered_objects[$base_tag][3])) {
return $this->generateCode('object_block_function', $args, $tag, $methode);
return $this->callTagCompiler('private_object_block_function', $args, $tag, $methode);
} else {
return $this->trigger_template_error ('unallowed closing tag methode "' . $methode . '" in registered object "' . $base_tag . '"', $this->lex->taglineno);
}
}
// plugin ?
if (isset($this->smarty->registered_plugins[$base_tag]) && $this->smarty->registered_plugins[$base_tag][0] == 'block') {
return $this->generateCode('block_plugin',$args, $tag);
// registered block tag ?
if (isset($this->smarty->registered_plugins['block'][$base_tag])) {
return $this->callTagCompiler('private_registered_block', $args, $tag);
}
// block plugin?
if ($function = $this->getPlugin($base_tag, 'block')) {
return $this->callTagCompiler('private_block_plugin', $args, $tag, $function);
}
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
$plugin = 'smarty_compiler_' . $tag;
if (class_exists($plugin, false)) {
$plugin = array(new $plugin, 'compile');
}
if (is_callable($plugin)) {
return call_user_func_array($plugin, array($args, $this));
} else {
throw new Exception("Plugin \"{$tag}\" not callable");
}
}
}
$this->trigger_template_error ("unknown tag \"" . $tag . "\"", $this->lex->taglineno);
@@ -197,16 +228,17 @@ class Smarty_Internal_TemplateCompilerBase {
*
* @param $tag string tag name
* @param $args array with tag attributes
* @param $subtag optional tag name at plugins
* @param $method string optional method on object tags
* @param $param1 optional parameter
* @param $param2 optional parameter
* @param $param3 optional parameter
* @return string compiled code
*/
public function generateCode($tag, $args, $subtag = null, $method = null)
public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
{
// re-use object if already exists
if (isset(self::$_tag_objects[$tag])) {
// compile this tag
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $subtag, $method);
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $param1, $param2, $param3);
}
// lazy load internal compiler plugin
$class_name = 'Smarty_Internal_Compile_' . $tag;
@@ -214,12 +246,87 @@ class Smarty_Internal_TemplateCompilerBase {
// use plugin if found
self::$_tag_objects[$tag] = new $class_name;
// compile this tag
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $subtag, $method);
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $param1, $param2, $param3);
}
// no internal compile plugin for this tag
return false;
}
/**
* Check for plugins and return function name
*
* @param $pugin_name string name of plugin or function
* @param $type string type of plugin
* @return string call name of function
*/
public function getPlugin($plugin_name, $type)
{
if (isset($this->template->required_plugins_call[$plugin_name][$type])) {
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
if (isset($this->template->required_plugins['compiled'][$plugin_name])) {
$this->template->required_plugins['cache'][$plugin_name] = $this->template->required_plugins['compiled'][$plugin_name];
}
}
return $this->template->required_plugins_call[$plugin_name][$type];
}
// loop through plugin dirs and find the plugin
$plugin = 'smarty_' . $type . '_' . $plugin_name;
$found = false;
foreach((array)$this->smarty->plugins_dir as $_plugin_dir) {
$file = rtrim($_plugin_dir, '/\\') . DS . $type . '.' . $plugin_name . '.php';
if (file_exists($file)) {
require_once($file);
$found = true;
break;
}
}
if ($found) {
if (is_callable($plugin)) {
$this->template->required_plugins_call[$plugin_name][$type] = $plugin;
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
$this->template->required_plugins['cache'][$plugin_name]['file'] = $file;
$this->template->required_plugins['cache'][$plugin_name]['type'] = $type;
} else {
$this->template->required_plugins['compiled'][$plugin_name]['file'] = $file;
$this->template->required_plugins['compiled'][$plugin_name]['type'] = $type;
}
return $plugin;
} else {
throw new Exception("Plugin {$type} \"{$plugin_name}\" not callable");
}
}
return false;
}
/**
* Inject inline code for nocache template sections
*
* This method gets the content of each template element from the parser.
* If the content is compiled code and it should be not cached the code is injected
* into the rendered output.
*
* @param string $content content of template element
* @param boolean $tag_nocache true if the parser detected a nocache situation
* @param boolean $is_code true if content is compiled code
* @return string content
*/
public function processNocacheCode ($content, $is_code)
{
// If the template is not evaluated and we have a nocache section and or a nocache tag
if ($is_code) {
// generate replacement code
if ((!$this->template->resource_object->isEvaluated || $this->template->forceNocache) && $this->template->caching &&
($this->nocache || $this->tag_nocache)) {
$this->tag_nocache = false;
$_output = str_replace("'", "\'", $content);
$_output = "<?php echo '/*%%SmartyNocache%%*/" . $_output . "/*/%%SmartyNocache%%*/';?>\n";
} else {
$_output = $content;
}
} else {
$_output = $content;
}
return $_output;
}
/**
* display compiler error messages without dying
*
@@ -228,18 +335,16 @@ class Smarty_Internal_TemplateCompilerBase {
*
* If parameter $args contains a string this is used as error message
*
* @todo output exact position of parse error in source line
* @param $args string individual error message or null
*/
public function trigger_template_error($args = null, $line= null)
{
public function trigger_template_error($args = null, $line = null)
{
// get template source line which has error
if (!isset($line)) {
$line = $this->lex->line;
}
$match = preg_split("/\n/", $this->lex->data);
$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . $match[$line-1] . '" ';
if (isset($args)) {
// individual error message
$error_text .= $args;

View File

@@ -63,7 +63,11 @@ class Smarty_Internal_Templatelexer
'QMARK' => '"?"',
'ID' => 'identifier',
'OTHER' => 'text',
'PHP' => 'PHP code',
'FAKEPHPSTARTTAG' => 'Fake PHP start tag',
'PHPSTARTTAG' => 'PHP start tag',
'PHPENDTAG' => 'PHP end tag',
'LITERALSTART' => 'Literal start',
'LITERALEND' => 'Literal end',
'LDELSLASH' => 'closing tag',
'COMMENT' => 'comment',
'LITERALEND' => 'literal close',
@@ -74,14 +78,15 @@ class Smarty_Internal_Templatelexer
);
function __construct($data,$smarty)
function __construct($data,$compiler)
{
// set instance object
self::instance($this);
$this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
$this->counter = 0;
$this->line = 1;
$this->smarty = $smarty;
$this->smarty = $compiler->smarty;
$this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter,'/');
$this->rdel = preg_quote($this->smarty->right_delimiter,'/');
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
@@ -137,16 +142,13 @@ class Smarty_Internal_Templatelexer
10 => 0,
11 => 0,
12 => 0,
13 => 0,
14 => 0,
15 => 0,
16 => 2,
19 => 0,
13 => 2,
16 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^(<\\?xml)|^(<\\?php)|^(<\\?=)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?))|^([\S\s]+)/";
$yy_global_pattern = "/^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(([\S\s]*?)([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?))|^([\S\s]+)/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@@ -209,54 +211,42 @@ class Smarty_Internal_Templatelexer
function yy_r1_4($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_XML;
$this->yypushstate(self::PHP);
}
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
$this->yypushstate(self::PHP);
} else {
$this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
$this->value = substr($this->value, 0, 2);
}
}
function yy_r1_5($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_PHP;
$this->yypushstate(self::PHP);
}
function yy_r1_6($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_SHORTTAGSTART;
$this->yypushstate(self::PHP);
}
function yy_r1_7($yy_subpatterns)
{
if ($this->strip) {
return false;
} else {
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
}
}
function yy_r1_8($yy_subpatterns)
function yy_r1_6($yy_subpatterns)
{
$this->strip = true;
return false;
}
function yy_r1_9($yy_subpatterns)
function yy_r1_7($yy_subpatterns)
{
$this->strip = false;
return false;
}
function yy_r1_10($yy_subpatterns)
function yy_r1_8($yy_subpatterns)
{
$this->yypushstate(self::LITERAL);
return true;
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL);
}
function yy_r1_11($yy_subpatterns)
{
return false; // unexspected here just ignore
}
function yy_r1_12($yy_subpatterns)
function yy_r1_9($yy_subpatterns)
{
if ($this->smarty->auto_literal) {
@@ -267,7 +257,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
}
function yy_r1_13($yy_subpatterns)
function yy_r1_10($yy_subpatterns)
{
if ($this->smarty->auto_literal) {
@@ -278,21 +268,21 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
}
function yy_r1_14($yy_subpatterns)
function yy_r1_11($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yypushstate(self::SMARTY);
$this->taglineno = $this->line;
}
function yy_r1_15($yy_subpatterns)
function yy_r1_12($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yypushstate(self::SMARTY);
$this->taglineno = $this->line;
}
function yy_r1_16($yy_subpatterns)
function yy_r1_13($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
@@ -307,7 +297,7 @@ class Smarty_Internal_Templatelexer
return true; // rescan
}
}
function yy_r1_19($yy_subpatterns)
function yy_r1_16($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
@@ -318,34 +308,35 @@ class Smarty_Internal_Templatelexer
{
$tokenMap = array (
1 => 1,
3 => 1,
3 => 0,
4 => 0,
5 => 0,
6 => 0,
7 => 0,
8 => 0,
9 => 0,
10 => 0,
11 => 0,
12 => 0,
13 => 0,
14 => 1,
16 => 1,
11 => 1,
13 => 1,
15 => 0,
16 => 0,
17 => 0,
18 => 0,
19 => 0,
20 => 0,
21 => 0,
22 => 0,
23 => 1,
25 => 1,
27 => 1,
29 => 1,
31 => 1,
33 => 1,
35 => 1,
37 => 1,
39 => 1,
41 => 1,
43 => 1,
20 => 1,
22 => 1,
24 => 1,
26 => 1,
28 => 1,
30 => 1,
32 => 1,
34 => 1,
36 => 1,
38 => 1,
40 => 1,
42 => 0,
43 => 0,
44 => 0,
45 => 0,
46 => 0,
47 => 0,
@@ -353,20 +344,20 @@ class Smarty_Internal_Templatelexer
49 => 0,
50 => 0,
51 => 0,
52 => 0,
53 => 0,
54 => 0,
55 => 3,
52 => 3,
56 => 0,
57 => 0,
58 => 0,
59 => 0,
60 => 0,
61 => 0,
62 => 0,
63 => 0,
64 => 0,
65 => 0,
66 => 1,
68 => 1,
70 => 1,
63 => 1,
65 => 1,
67 => 1,
69 => 0,
70 => 0,
71 => 0,
72 => 0,
73 => 0,
74 => 0,
@@ -377,21 +368,18 @@ class Smarty_Internal_Templatelexer
79 => 0,
80 => 0,
81 => 0,
82 => 0,
83 => 0,
82 => 1,
84 => 0,
85 => 1,
85 => 0,
86 => 0,
87 => 0,
88 => 0,
89 => 0,
90 => 0,
91 => 0,
92 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^((\\\\\"|\\\\'))|^(''|'([\S\s]*?)[^\\\\]')|^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+(to)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|NEQ|ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(GE|GTE|ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(LE|LTE|le|lte)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(\\s+(MOD|mod)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\))|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^((if|elseif|while)(?![^\s]))|^(foreach(?![^\s]))|^(for(?![^\s]))|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/";
$yy_global_pattern = "/^((\\\\\"|\\\\'))|^('[^'\\\\]*(?:\\\\['\\\\][^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+(to)\\s+)|^(\\s+instanceof\\s+)|^(true|TRUE|True|false|FALSE|False)|^(null|NULL|Null)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|NEQ|ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(GE|GTE|ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(LE|LTE|le|lte)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(\\s+(MOD|mod)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\))|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^((\\+\\+|--)\\s*)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^((if|elseif|else if|while)(?![^\s]))|^(foreach(?![^\s]))|^(for(?![^\s]))|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@@ -451,18 +439,7 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
}
function yy_r2_5($yy_subpatterns)
{
$this->yypushstate(self::LITERAL);
return true;
}
function yy_r2_6($yy_subpatterns)
{
return false; // unexspected here just ignore
}
function yy_r2_7($yy_subpatterns)
function yy_r2_4($yy_subpatterns)
{
if ($this->smarty->auto_literal) {
@@ -473,7 +450,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
}
function yy_r2_8($yy_subpatterns)
function yy_r2_5($yy_subpatterns)
{
if ($this->smarty->auto_literal) {
@@ -484,7 +461,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
}
function yy_r2_9($yy_subpatterns)
function yy_r2_6($yy_subpatterns)
{
if ($this->smarty->auto_literal) {
@@ -494,324 +471,324 @@ class Smarty_Internal_Templatelexer
$this->yypopstate();
}
}
function yy_r2_10($yy_subpatterns)
function yy_r2_7($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yypushstate(self::SMARTY);
$this->taglineno = $this->line;
}
function yy_r2_11($yy_subpatterns)
function yy_r2_8($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yypushstate(self::SMARTY);
$this->taglineno = $this->line;
}
function yy_r2_12($yy_subpatterns)
function yy_r2_9($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
$this->yypopstate();
}
function yy_r2_13($yy_subpatterns)
function yy_r2_10($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISIN;
}
function yy_r2_14($yy_subpatterns)
function yy_r2_11($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_AS;
}
function yy_r2_16($yy_subpatterns)
function yy_r2_13($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_TO;
}
function yy_r2_18($yy_subpatterns)
function yy_r2_15($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
}
function yy_r2_19($yy_subpatterns)
function yy_r2_16($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_BOOLEAN;
}
function yy_r2_20($yy_subpatterns)
function yy_r2_17($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NULL;
}
function yy_r2_21($yy_subpatterns)
function yy_r2_18($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
}
function yy_r2_22($yy_subpatterns)
function yy_r2_19($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
}
function yy_r2_23($yy_subpatterns)
function yy_r2_20($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_EQUALS;
}
function yy_r2_25($yy_subpatterns)
function yy_r2_22($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
}
function yy_r2_27($yy_subpatterns)
function yy_r2_24($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
}
function yy_r2_29($yy_subpatterns)
function yy_r2_26($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
}
function yy_r2_31($yy_subpatterns)
function yy_r2_28($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
}
function yy_r2_33($yy_subpatterns)
function yy_r2_30($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
}
function yy_r2_35($yy_subpatterns)
function yy_r2_32($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_MOD;
}
function yy_r2_37($yy_subpatterns)
function yy_r2_34($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NOT;
}
function yy_r2_39($yy_subpatterns)
function yy_r2_36($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LAND;
}
function yy_r2_41($yy_subpatterns)
function yy_r2_38($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LOR;
}
function yy_r2_43($yy_subpatterns)
function yy_r2_40($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LXOR;
}
function yy_r2_45($yy_subpatterns)
function yy_r2_42($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
}
function yy_r2_46($yy_subpatterns)
function yy_r2_43($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
}
function yy_r2_47($yy_subpatterns)
function yy_r2_44($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISODD;
}
function yy_r2_48($yy_subpatterns)
function yy_r2_45($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
}
function yy_r2_49($yy_subpatterns)
function yy_r2_46($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
}
function yy_r2_50($yy_subpatterns)
function yy_r2_47($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
}
function yy_r2_51($yy_subpatterns)
function yy_r2_48($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
}
function yy_r2_52($yy_subpatterns)
function yy_r2_49($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
}
function yy_r2_53($yy_subpatterns)
function yy_r2_50($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
}
function yy_r2_54($yy_subpatterns)
function yy_r2_51($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
}
function yy_r2_55($yy_subpatterns)
function yy_r2_52($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
}
function yy_r2_59($yy_subpatterns)
function yy_r2_56($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OPENP;
}
function yy_r2_60($yy_subpatterns)
function yy_r2_57($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
}
function yy_r2_61($yy_subpatterns)
function yy_r2_58($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
}
function yy_r2_62($yy_subpatterns)
function yy_r2_59($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
}
function yy_r2_63($yy_subpatterns)
function yy_r2_60($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_PTR;
}
function yy_r2_64($yy_subpatterns)
function yy_r2_61($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_APTR;
}
function yy_r2_65($yy_subpatterns)
function yy_r2_62($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_EQUAL;
}
function yy_r2_66($yy_subpatterns)
function yy_r2_63($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_INCDEC;
}
function yy_r2_68($yy_subpatterns)
function yy_r2_65($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
}
function yy_r2_70($yy_subpatterns)
function yy_r2_67($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_MATH;
}
function yy_r2_72($yy_subpatterns)
function yy_r2_69($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
}
function yy_r2_73($yy_subpatterns)
function yy_r2_70($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
function yy_r2_74($yy_subpatterns)
function yy_r2_71($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
function yy_r2_75($yy_subpatterns)
function yy_r2_72($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}
function yy_r2_76($yy_subpatterns)
function yy_r2_73($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
function yy_r2_77($yy_subpatterns)
function yy_r2_74($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
function yy_r2_78($yy_subpatterns)
function yy_r2_75($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING);
}
function yy_r2_79($yy_subpatterns)
function yy_r2_76($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
function yy_r2_80($yy_subpatterns)
function yy_r2_77($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}
function yy_r2_81($yy_subpatterns)
function yy_r2_78($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}
function yy_r2_82($yy_subpatterns)
function yy_r2_79($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
function yy_r2_83($yy_subpatterns)
function yy_r2_80($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
}
function yy_r2_84($yy_subpatterns)
function yy_r2_81($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
function yy_r2_85($yy_subpatterns)
function yy_r2_82($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_IF;
}
function yy_r2_87($yy_subpatterns)
function yy_r2_84($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_FOREACH;
}
function yy_r2_88($yy_subpatterns)
function yy_r2_85($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_FOR;
}
function yy_r2_89($yy_subpatterns)
function yy_r2_86($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
function yy_r2_90($yy_subpatterns)
function yy_r2_87($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
function yy_r2_91($yy_subpatterns)
function yy_r2_88($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
}
function yy_r2_92($yy_subpatterns)
function yy_r2_89($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
@@ -881,9 +858,9 @@ class Smarty_Internal_Templatelexer
function yy_r3_1($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_SHORTTAGEND;
$this->yypopstate();
}
$this->token = Smarty_Internal_Templateparser::TP_PHPENDTAG;
$this->yypopstate();
}
function yy_r3_2($yy_subpatterns)
{
@@ -893,7 +870,7 @@ class Smarty_Internal_Templatelexer
function yy_r3_4($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
$this->compiler->trigger_template_error ("missing PHP end tag");
}
@@ -902,13 +879,15 @@ class Smarty_Internal_Templatelexer
$tokenMap = array (
1 => 0,
2 => 0,
3 => 1,
5 => 0,
3 => 0,
4 => 0,
5 => 1,
7 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(([\S\s]*?)".$this->ldel."\/literal".$this->rdel.")|^([\S\s]+)/";
$yy_global_pattern = "/^(".$this->ldel."literal".$this->rdel.")|^(".$this->ldel."\/literal".$this->rdel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^([\S\s]+?(".$this->ldel."\/?literal".$this->rdel."|<\\?))|^([\S\s]+)/";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@@ -961,30 +940,50 @@ class Smarty_Internal_Templatelexer
function yy_r4_1($yy_subpatterns)
{
return false;
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL);
}
function yy_r4_2($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypopstate();
return false;
}
function yy_r4_3($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
$this->value = substr($this->value,0,-strlen($this->smarty->left_delimiter)-strlen($this->smarty->right_delimiter)-8);
$this->yypopstate();
if (strlen($this->value) == 0) {
return false; // change state directly
} else {
return; // change state after processiing token
}
if (in_array($this->value, Array('<?', '<?=', '<?php'))) {
$this->token = Smarty_Internal_Templateparser::TP_PHPSTARTTAG;
} else {
$this->token = Smarty_Internal_Templateparser::TP_FAKEPHPSTARTTAG;
$this->value = substr($this->value, 0, 2);
}
}
function yy_r4_4($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
}
function yy_r4_5($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
$lenght_literal = strlen($this->smarty->left_delimiter.$this->smarty->right_delimiter)+7;
if (substr($this->value,-2,2) === '<?') {
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
$this->value = substr($this->value,0,-2);
} else if (substr($this->value,-$lenght_literal,$lenght_literal) === $this->smarty->left_delimiter.'literal'.$this->smarty->right_delimiter) {
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
$this->value = substr($this->value,0,-$lenght_literal);
} else {
assert(substr($this->value,-$lenght_literal-1,$lenght_literal+1) === $this->smarty->left_delimiter.'/literal'.$this->smarty->right_delimiter);
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
$this->value = substr($this->value,0,-$lenght_literal-1);
}
}
function yy_r4_7($yy_subpatterns)
{
$this->compiler->trigger_template_error ("missing or misspelled literal closing tag");
}

File diff suppressed because it is too large Load Diff

View File

@@ -23,13 +23,13 @@
*/
function Smarty_Method_Register_Block($smarty, $block_tag, $block_impl, $cacheable = true, $cache_attr = array())
{
if (isset($smarty->registered_plugins[$block_tag])) {
if (isset($smarty->registered_plugins['block'][$block_tag])) {
throw new Exception("Plugin tag \"{$block_tag}\" already registered");
} elseif (!is_callable($block_impl)) {
throw new Exception("Plugin \"{$block_tag}\" not callable");
} else {
$smarty->registered_plugins[$block_tag] =
array('block', $block_impl, $cacheable, $cache_attr);
$smarty->registered_plugins['block'][$block_tag] =
array($block_impl, $cacheable, $cache_attr);
}
}

View File

@@ -22,13 +22,13 @@
*/
function Smarty_Method_Register_Compiler_Function($smarty, $compiler_tag, $compiler_impl, $cacheable = true)
{
if (isset($smarty->registered_plugins[$compiler_tag])) {
if (isset($smarty->registered_plugins['compiler'][$compiler_tag])) {
throw new Exception("Plugin tag \"{$compiler_tag}\" already registered");
} elseif (!is_callable($compiler_impl)) {
throw new Exception("Plugin \"{$compiler_tag}\" not callable");
} else {
$smarty->registered_plugins[$compiler_tag] =
array('compiler', $compiler_impl, $cacheable);
$smarty->registered_plugins['compiler'][$compiler_tag] =
array($compiler_impl, $cacheable);
}
}

View File

@@ -20,13 +20,13 @@
*/
function Smarty_Method_Register_Function($smarty, $function_tag, $function_impl, $cacheable = true, $cache_attr = array())
{
if (isset($smarty->registered_plugins[$function_tag])) {
if (isset($smarty->registered_plugins['function'][$function_tag])) {
throw new Exception("Plugin tag \"{$function_tag}\" already registered");
} elseif (!is_callable($function_impl)) {
throw new Exception("Plugin \"{$function_tag}\" not callable");
} else {
$smarty->registered_plugins[$function_tag] =
array('function', $function_impl, $cacheable, $cache_attr);
$smarty->registered_plugins['function'][$function_tag] =
array($function_impl, $cacheable, $cache_attr);
}
}

View File

@@ -19,13 +19,13 @@
*/
function Smarty_Method_Register_Modifier($smarty, $modifier, $modifier_impl)
{
if (isset($smarty->registered_plugins[$modifier])) {
if (isset($smarty->registered_plugins['modifier'][$modifier])) {
throw new Exception("Plugin \"{$modifier}\" already registered");
} elseif (!is_callable($modifier_impl)) {
throw new Exception("Plugin \"{$modifier}\" not callable");
} else {
$smarty->registered_plugins[$modifier] =
array('modifier', $modifier_impl);
$smarty->registered_plugins['modifier'][$modifier] =
array($modifier_impl);
}
}
?>

View File

@@ -21,8 +21,8 @@
*/
function Smarty_Method_Unregister_Block($smarty, $block_tag)
{
if (isset($smarty->registered_plugins[$block_tag]) && $smarty->registered_plugins[$block_tag][0] == 'block') {
unset($smarty->registered_plugins[$block_tag]);
if (isset($smarty->registered_plugins['block'][$block_tag])) {
unset($smarty->registered_plugins['block'][$block_tag]);
}
}

View File

@@ -21,8 +21,8 @@
*/
function Smarty_Method_Unregister_Compiler_Function($smarty, $compiler_tag)
{
if (isset($smarty->registered_plugins[$compiler_tag]) && $smarty->registered_plugins[$compiler_tag][0] == 'compiler') {
unset($smarty->registered_plugins[$compiler_tag]);
if (isset($smarty->registered_plugins['compiler'][$compiler_tag])) {
unset($smarty->registered_plugins['compiler'][$compiler_tag]);
}
}

View File

@@ -21,8 +21,8 @@
*/
function Smarty_Method_Unregister_Function($smarty, $function_tag)
{
if (isset($smarty->registered_plugins[$function_tag]) && $smarty->registered_plugins[$function_tag][0] == 'function') {
unset($smarty->registered_plugins[$function_tag]);
if (isset($smarty->registered_plugins['function'][$function_tag])) {
unset($smarty->registered_plugins['function'][$function_tag]);
}
}

View File

@@ -21,8 +21,8 @@
*/
function Smarty_Method_Unregister_Modifier($smarty, $modifier)
{
if (isset($smarty->registered_plugins[$modifier]) && $smarty->registered_plugins[$modifier][0] == 'modifier') {
unset($smarty->registered_plugins[$modifier]);
if (isset($smarty->registered_plugins['modifier'][$modifier])) {
unset($smarty->registered_plugins['modifier'][$modifier]);
}
}