mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
- change of filenames in sysplugins folder for internal spl_autoload function
- lexer/parser changed for increased compilation speed
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
10/31/2009
|
||||
- change of filenames in sysplugins folder for internal spl_autoload function
|
||||
- lexer/parser changed for increased compilation speed
|
||||
|
||||
10/27/2009
|
||||
- fixed missing quotes in include_php.php
|
||||
|
@@ -73,7 +73,7 @@ define('SMARTY_GLOBAL_SCOPE', 3);
|
||||
*/
|
||||
define('SMARTY_CACHING_OFF', 0);
|
||||
define('SMARTY_CACHING_LIFETIME_CURRENT', 1);
|
||||
define('SMARTY_CACHING_LIVETIME_SAVED', 2);
|
||||
define('SMARTY_CACHING_LIFETIME_SAVED', 2);
|
||||
|
||||
/**
|
||||
* This determines how Smarty handles "<?php ... ?>" tags in templates.
|
||||
@@ -86,9 +86,16 @@ define('SMARTY_PHP_ALLOW', 3); //-> escape tags as entities
|
||||
|
||||
/**
|
||||
* register the class autoloader
|
||||
**/
|
||||
spl_autoload_register('smartyAutoload');
|
||||
|
||||
*/
|
||||
if (set_include_path(SMARTY_SYSPLUGINS_DIR . PATH_SEPARATOR . get_include_path()) !== false) {
|
||||
spl_autoload_extensions('.php,.inc');
|
||||
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
|
||||
spl_autoload_register();
|
||||
}
|
||||
} else {
|
||||
spl_autoload_register('smartyAutoload');
|
||||
}
|
||||
/**
|
||||
* This is the main Smarty class
|
||||
*/
|
||||
@@ -97,8 +104,8 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
public static $_version = 'Smarty3-SVN$Rev: 3286 $';
|
||||
// auto literal on delimiters with whitspace
|
||||
public $auto_literal = true;
|
||||
// display error on not assigned variabled
|
||||
static $error_unassigned = false;
|
||||
// display error on not assigned variables
|
||||
public $error_unassigned = false;
|
||||
// template directory
|
||||
public $template_dir = null;
|
||||
// default template handler
|
||||
@@ -154,7 +161,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
|
||||
@@ -204,12 +211,17 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
// global internal smarty vars
|
||||
public $_smarty_vars = array();
|
||||
// start time for execution time calculation
|
||||
public $start_time = 0;
|
||||
public $start_time = 0;
|
||||
// default file permissions
|
||||
public $_file_perms = 0644;
|
||||
// default dir permissions
|
||||
public $_dir_perms = 0771;
|
||||
|
||||
/**
|
||||
* Class constructor, initializes basic smarty properties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
{
|
||||
// self reference needed by other classes methodes
|
||||
$this->smarty = $this;
|
||||
|
||||
@@ -226,7 +238,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
$this->plugins_dir = array(SMARTY_PLUGINS_DIR);
|
||||
$this->cache_dir = '.' . DS . 'cache' . DS;
|
||||
$this->config_dir = '.' . DS . 'configs' . DS;
|
||||
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
|
||||
$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') {
|
||||
@@ -435,24 +447,24 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
if (is_callable($plugin_name))
|
||||
return true;
|
||||
// Plugin name is expected to be: Smarty_[Type]_[Name]
|
||||
$plugin_name = strtolower($plugin_name);
|
||||
$_name_parts = explode('_', $plugin_name, 3);
|
||||
$_plugin_name = strtolower($plugin_name);
|
||||
$_name_parts = explode('_', $_plugin_name, 3);
|
||||
// class name must have three parts to be valid plugin
|
||||
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
|
||||
throw new Exception("plugin {$plugin_name} is not a valid name format");
|
||||
return false;
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}{$this->php_ext}";
|
||||
// if type is "internal", get plugin from sysplugins
|
||||
if ($_name_parts[1] == 'internal') {
|
||||
if (file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_filename)) {
|
||||
require_once(SMARTY_SYSPLUGINS_DIR . $_plugin_filename);
|
||||
if (file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_name . $this->php_ext)) {
|
||||
require_once(SMARTY_SYSPLUGINS_DIR . $_plugin_name . $this->php_ext);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}{$this->php_ext}";
|
||||
// loop through plugin dirs and find the plugin
|
||||
foreach((array)$this->plugins_dir as $_plugin_dir) {
|
||||
if (strpos('/\\', substr($_plugin_dir, -1)) === false) {
|
||||
@@ -512,7 +524,7 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
public function __call($name, $args)
|
||||
{
|
||||
if (!is_callable($name)) {
|
||||
$_plugin_filename = strtolower('method.' . $name . $this->php_ext);
|
||||
$_plugin_filename = strtolower('smarty_method_' . $name . $this->php_ext);
|
||||
if (!file_exists(SMARTY_SYSPLUGINS_DIR . $_plugin_filename)) {
|
||||
throw new Exception("Sysplugin file " . $_plugin_filename . " does not exist");
|
||||
}
|
||||
@@ -527,10 +539,9 @@ class Smarty extends Smarty_Internal_TemplateBase {
|
||||
|
||||
function smartyAutoload($class)
|
||||
{
|
||||
if (substr($class, 0, 16) === 'Smarty_Internal_') {
|
||||
$class = strtolower($class);
|
||||
$_name_parts = explode('_', $class, 3);
|
||||
include SMARTY_SYSPLUGINS_DIR . 'internal.' . $_name_parts[2] . '.php';
|
||||
$_class = strtolower($class);
|
||||
if (substr($_class, 0, 16) === 'smarty_internal_') {
|
||||
include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,38 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block
|
||||
*
|
||||
* Compiles the {block} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('name');
|
||||
$this->optional_attributes = array('assign');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
$this->_open_tag('block', $save);
|
||||
$compiler->template->extract_code = true;
|
||||
$compiler->template->extracted_compiled_code = '';
|
||||
$compiler->template->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture Close
|
||||
*
|
||||
* Compiles the {/capture} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile CaptureClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/capture} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($buffer, $assign, $append) = array_pop($this->compiler->_capture_stack);
|
||||
|
||||
$_output = "<?php ";
|
||||
if (isset($assign)) {
|
||||
$_output .= " \$_smarty_tpl->assign($assign, ob_get_contents());";
|
||||
}
|
||||
if (isset($append)) {
|
||||
$_output .= " \$_smarty_tpl->append($append, ob_get_contents());";
|
||||
}
|
||||
$_output .= " \$_smarty_tpl->smarty->_smarty_vars['capture'][$buffer]=ob_get_clean(); ?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Else
|
||||
*
|
||||
* Compiles the {else} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Else Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {else} tag
|
||||
*
|
||||
* @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;
|
||||
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif'));
|
||||
$this->_open_tag('else',array($nesting,$compiler->tag_nocache));
|
||||
|
||||
return '<?php }else{ ?>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Else If
|
||||
*
|
||||
* Compiles the {elseif} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ElseIf Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_ElseIf extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {elseif} tag
|
||||
*
|
||||
* @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->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif'));
|
||||
|
||||
if (empty($this->compiler->prefix_code)) {
|
||||
$this->_open_tag('elseif', array($nesting, $compiler->tag_nocache));
|
||||
return '<?php }elseif(' . $args['if condition'] . '){?>';
|
||||
} else {
|
||||
$tmp = '';
|
||||
foreach ($this->compiler->prefix_code as $code) $tmp .= $code;
|
||||
$this->compiler->prefix_code = array();
|
||||
$this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
return '<?php }else{?>' . $tmp . '<?php if (' . $args['if condition'] . '){?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Close
|
||||
*
|
||||
* Compiles the {/for} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ForClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_ForClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/for} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for', 'forelse'));
|
||||
if ($_open_tag == 'forelse')
|
||||
return "<?php } ?>";
|
||||
else
|
||||
return "<?php }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,41 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Close
|
||||
*
|
||||
* Compiles the {/foreach} tag
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ForeachClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_ForeachClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/foreach} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach', 'foreachelse'));
|
||||
|
||||
if ($_open_tag == 'foreachelse')
|
||||
return "<?php } ?>";
|
||||
else
|
||||
return "<?php }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Else
|
||||
*
|
||||
* Compiles the {foreachelse} tag
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachelse Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {foreachelse} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach'));
|
||||
$this->_open_tag('foreachelse',array('foreachelse', $this->compiler->nocache));
|
||||
|
||||
return "<?php }} else { ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Else
|
||||
*
|
||||
* Compiles the {forelse} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forelse Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {forelse} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for'));
|
||||
$this->_open_tag('forelse',array('forelse', $this->compiler->nocache));
|
||||
return "<?php }} else { ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function
|
||||
*
|
||||
* Compiles the {function} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('name');
|
||||
$this->optional_attributes = array('_any');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
$this->_open_tag('function', $save);
|
||||
$_name = trim($_attr['name'], "'");
|
||||
foreach ($_attr as $_key => $_data) {
|
||||
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
|
||||
}
|
||||
// make function known for recursive calls
|
||||
$this->compiler->smarty->template_functions[$_name]['compiled'] = '';
|
||||
$compiler->template->extract_code = true;
|
||||
$compiler->template->extracted_compiled_code = '';
|
||||
$compiler->template->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,39 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If
|
||||
*
|
||||
* Compiles the {if} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {if} tag
|
||||
*
|
||||
* @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->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$this->_open_tag('if',array(1,$compiler->tag_nocache));
|
||||
if (is_array($args['if condition'])) {
|
||||
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."){?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return '<?php if (' . $args['if condition'] . '){?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If Close
|
||||
*
|
||||
* Compiles the {/if} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile IfClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_IfClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/if} tag
|
||||
*
|
||||
* @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;
|
||||
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'else', 'elseif'));
|
||||
$tmp = '';
|
||||
for ($i = 0; $i < $nesting ; $i++) $tmp .= '}';
|
||||
return "<?php $tmp?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Nocache Close
|
||||
*
|
||||
* Compiles the {/nocache} tag
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile NocacheClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_NocacheClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/nocache} tag
|
||||
*
|
||||
* This tag does not generate compiled output. It only sets a compiler flag
|
||||
* @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;
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// leave nocache mode
|
||||
$this->compiler->nocache = false;
|
||||
// this tag does not return compiled code
|
||||
$this->compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section Close
|
||||
*
|
||||
* Compiles the {/section} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile SectionClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_SectionClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/section} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section', 'sectionelse'));
|
||||
|
||||
if ($_open_tag == 'sectionelse')
|
||||
return "<?php endif; ?>";
|
||||
else
|
||||
return "<?php endfor; endif; ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section Else
|
||||
*
|
||||
* Compiles the {sectionelse} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Sectionelse Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {sectionelse} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section'));
|
||||
$this->_open_tag('sectionelse',array('sectionelse', $this->compiler->nocache));
|
||||
|
||||
return "<?php endfor; else: ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Strip
|
||||
*
|
||||
* Compiles the {strip} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Strip Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Strip extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {strip} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('strip');
|
||||
|
||||
$_output = "<?php ob_start(); ?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Strip Close
|
||||
*
|
||||
* Compiles the {/strip} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile StripClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_StripClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/strip} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$saved_attr = $this->_close_tag(array('strip'));
|
||||
|
||||
$_output = "<?php echo preg_replace('![\t ]*[\r\n]+[\t ]*!', '', ob_get_clean()); ?>\n";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While Close
|
||||
*
|
||||
* Compiles the {/while} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile WhileClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_WhileClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/while} tag
|
||||
*
|
||||
* @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;
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
$this->compiler->nocache = $this->_close_tag(array('while'));
|
||||
return "<?php }?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,17 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Close
|
||||
* Smarty Internal Plugin Compile Block
|
||||
*
|
||||
* Compiles the {/block} tag
|
||||
* Compiles the {block}{/block} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('name');
|
||||
$this->optional_attributes = array('assign');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
$this->_open_tag('block', $save);
|
||||
$compiler->template->extract_code = true;
|
||||
$compiler->template->extracted_compiled_code = '';
|
||||
$compiler->template->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_BlockClose extends Smarty_Internal_CompileBase {
|
||||
class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
@@ -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, $tag, $compiler)
|
||||
public function compile($args, $compiler, $tag)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) {
|
@@ -38,4 +38,35 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Captureclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/capture} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($buffer, $assign, $append) = array_pop($this->compiler->_capture_stack);
|
||||
|
||||
$_output = "<?php ";
|
||||
if (isset($assign)) {
|
||||
$_output .= " \$_smarty_tpl->assign($assign, ob_get_contents());";
|
||||
}
|
||||
if (isset($append)) {
|
||||
$_output .= " \$_smarty_tpl->append($append, ob_get_contents());";
|
||||
}
|
||||
$_output .= " \$_smarty_tpl->smarty->_smarty_vars['capture'][$buffer]=ob_get_clean(); ?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For
|
||||
*
|
||||
* Compiles the {for} tag
|
||||
* Compiles the {for} {forelse} {/for} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
@@ -54,4 +54,56 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forelse Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {forelse} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for'));
|
||||
$this->_open_tag('forelse',array('forelse', $this->compiler->nocache));
|
||||
return "<?php }} else { ?>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/for} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('for', 'forelse'));
|
||||
if ($_open_tag == 'forelse')
|
||||
return "<?php } ?>";
|
||||
else
|
||||
return "<?php }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach
|
||||
*
|
||||
* Compiles the {foreach} tag
|
||||
* Compiles the {foreach} {foreachelse} {/foreach} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
@@ -134,4 +134,59 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachelse Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {foreachelse} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach'));
|
||||
$this->_open_tag('foreachelse',array('foreachelse', $this->compiler->nocache));
|
||||
|
||||
return "<?php }} else { ?>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/foreach} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('foreach', 'foreachelse'));
|
||||
|
||||
if ($_open_tag == 'foreachelse')
|
||||
return "<?php } ?>";
|
||||
else
|
||||
return "<?php }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -1,17 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Close
|
||||
* Smarty Internal Plugin Compile Function
|
||||
*
|
||||
* Compiles the {/function} tag
|
||||
* Compiles the {function} {/function} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile FunctionClose Class
|
||||
* Smarty Internal Plugin Compile Function Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_FunctionClose extends Smarty_Internal_CompileBase {
|
||||
class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('name');
|
||||
$this->optional_attributes = array('_any');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
$this->_open_tag('function', $save);
|
||||
$_name = trim($_attr['name'], "'");
|
||||
foreach ($_attr as $_key => $_data) {
|
||||
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
|
||||
}
|
||||
// make function known for recursive calls
|
||||
$this->compiler->smarty->template_functions[$_name]['compiled'] = '';
|
||||
$compiler->template->extract_code = true;
|
||||
$compiler->template->extracted_compiled_code = '';
|
||||
$compiler->template->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Functionclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/function} tag
|
||||
*
|
@@ -1,20 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Internal_Function_Call
|
||||
* Smarty Internal Plugin Compile Function_Call
|
||||
*
|
||||
* Compiles the {internal_function_call} tag
|
||||
* Compiles the calls of user defined tags defined by {function}
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Internal_Function_Call Class
|
||||
* Smarty Internal Plugin Compile Function_Call Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Internal_Function_Call extends Smarty_Internal_CompileBase {
|
||||
class Smarty_Internal_Compile_Function_Call extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {internal_function_call} tag
|
||||
* Compiles the calls of user defined tags defined by {function}
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
@@ -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, $tag, $compiler)
|
||||
public function compile($args, $compiler, $tag)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
// This tag does create output
|
114
libs/sysplugins/smarty_internal_compile_if.php
Normal file
114
libs/sysplugins/smarty_internal_compile_if.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If
|
||||
*
|
||||
* Compiles the {if} {else} {elseif} {/if} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {if} tag
|
||||
*
|
||||
* @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->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$this->_open_tag('if',array(1,$compiler->tag_nocache));
|
||||
if (is_array($args['if condition'])) {
|
||||
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;";
|
||||
$_output .= "if (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value']."){?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return '<?php if (' . $args['if condition'] . '){?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Else Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {else} tag
|
||||
*
|
||||
* @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;
|
||||
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif'));
|
||||
$this->_open_tag('else',array($nesting,$compiler->tag_nocache));
|
||||
|
||||
return '<?php }else{ ?>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ElseIf Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {elseif} tag
|
||||
*
|
||||
* @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->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'elseif'));
|
||||
|
||||
if (empty($this->compiler->prefix_code)) {
|
||||
$this->_open_tag('elseif', array($nesting, $compiler->tag_nocache));
|
||||
return '<?php }elseif(' . $args['if condition'] . '){?>';
|
||||
} else {
|
||||
$tmp = '';
|
||||
foreach ($this->compiler->prefix_code as $code) $tmp .= $code;
|
||||
$this->compiler->prefix_code = array();
|
||||
$this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache));
|
||||
return '<?php }else{?>' . $tmp . '<?php if (' . $args['if condition'] . '){?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ifclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/if} tag
|
||||
*
|
||||
* @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;
|
||||
list($nesting, $compiler->tag_nocache) = $this->_close_tag(array('if', 'else', 'elseif'));
|
||||
$tmp = '';
|
||||
for ($i = 0; $i < $nesting ; $i++) $tmp .= '}';
|
||||
return "<?php $tmp?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Nocache
|
||||
*
|
||||
* Compiles the {nocache} tag
|
||||
* Compiles the {nocache} {/nocache} tags
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
@@ -32,4 +32,28 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Nocacheclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/nocache} tag
|
||||
*
|
||||
* This tag does not generate compiled output. It only sets a compiler flag
|
||||
* @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;
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// leave nocache mode
|
||||
$this->compiler->nocache = false;
|
||||
// this tag does not return compiled code
|
||||
$this->compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -21,7 +21,7 @@ class Smarty_Internal_Compile_Object_Block_Function extends Smarty_Internal_Comp
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $tag, $methode, $compiler)
|
||||
public function compile($args, $compiler, $tag, $methode)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
if (strlen($tag) < 5 || substr_compare($tag, 'close', -5, 5) != 0) {
|
@@ -21,7 +21,7 @@ class Smarty_Internal_Compile_Object_Function extends Smarty_Internal_CompileBas
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $tag, $methode, $compiler)
|
||||
public function compile($args, $compiler, $tag, $methode)
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
// This tag does create output
|
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section
|
||||
*
|
||||
* Compiles the {section} tag
|
||||
* Compiles the {section} {sectionelse} {/section} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
@@ -111,4 +111,60 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Sectionelse Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {sectionelse} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section'));
|
||||
$this->_open_tag('sectionelse',array('sectionelse', $this->compiler->nocache));
|
||||
|
||||
return "<?php endfor; else: ?>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Sectionclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/section} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
|
||||
list($_open_tag, $this->compiler->nocache) = $this->_close_tag(array('section', 'sectionelse'));
|
||||
|
||||
if ($_open_tag == 'sectionelse')
|
||||
return "<?php endif; ?>";
|
||||
else
|
||||
return "<?php endfor; endif; ?>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Smarty
|
||||
* Smarty Internal Plugin Compile Special Smarty Variable
|
||||
*
|
||||
* Compiles the special $smarty variables
|
||||
*
|
||||
@@ -9,9 +9,9 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Smarty Class
|
||||
* Smarty Internal Plugin Compile special Smarty Variable Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_CompileBase {
|
||||
class Smarty_Internal_Compile_Special_Smarty_Variable extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the speical $smarty variables
|
||||
*
|
59
libs/sysplugins/smarty_internal_compile_strip.php
Normal file
59
libs/sysplugins/smarty_internal_compile_strip.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Strip
|
||||
*
|
||||
* Compiles the {strip} {/strip} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Strip Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Strip extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {strip} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('strip');
|
||||
|
||||
$_output = "<?php ob_start(); ?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Stripclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Stripclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/strip} tag
|
||||
*
|
||||
* @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;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$saved_attr = $this->_close_tag(array('strip'));
|
||||
|
||||
$_output = "<?php echo preg_replace('![\t ]*[\r\n]+[\t ]*!', '', ob_get_clean()); ?>\n";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
?>
|
@@ -41,4 +41,26 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Whileclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/while} tag
|
||||
*
|
||||
* @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;
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
$this->compiler->nocache = $this->_close_tag(array('while'));
|
||||
return "<?php }?>";
|
||||
}
|
||||
}
|
||||
?>
|
@@ -137,9 +137,9 @@ class Smarty_Internal_Config {
|
||||
$_filepath = (string)abs(crc32($this->config_resource_name . $_flag));
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($this->smarty->use_sub_dirs) {
|
||||
$_filepath = substr($_filepath, 0, 3) . DS
|
||||
. substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 0, 1) . DS
|
||||
$_filepath = substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 2, 2) . DS
|
||||
. substr($_filepath, 4, 2) . DS
|
||||
. $_filepath;
|
||||
}
|
||||
$_compile_dir = $this->smarty->compile_dir;
|
||||
@@ -226,7 +226,9 @@ class Smarty_Internal_Config {
|
||||
{
|
||||
if (isset($this->template)) {
|
||||
$this->template->properties['file_dependency']['F' . abs(crc32($this->getConfigFilepath()))] = array($this->getConfigFilepath(), $this->getTimestamp());
|
||||
}
|
||||
} else {
|
||||
$this->smarty->properties['file_dependency']['F' . abs(crc32($this->getConfigFilepath()))] = array($this->getConfigFilepath(), $this->getTimestamp());
|
||||
}
|
||||
$config_data = unserialize($this->getCompiledConfig());
|
||||
// var_dump($config_data);
|
||||
// copy global config vars
|
@@ -8,7 +8,7 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Templatelexer
|
||||
* Smarty Internal Plugin Configfilelexer
|
||||
*/
|
||||
class Smarty_Internal_Configfilelexer
|
||||
{
|
@@ -103,12 +103,12 @@ class TPC_yyStackEntry
|
||||
// code external to the class is included here
|
||||
|
||||
// declare_class is output here
|
||||
#line 12 "internal.configfileparser.y"
|
||||
class Smarty_Internal_Configfileparser#line 109 "internal.configfileparser.php"
|
||||
#line 12 "Smarty_Internal_Configfileparser.y"
|
||||
class Smarty_Internal_Configfileparser#line 109 "Smarty_Internal_Configfileparser.php"
|
||||
{
|
||||
/* First off, code is included which follows the "include_class" declaration
|
||||
** in the input file. */
|
||||
#line 14 "internal.configfileparser.y"
|
||||
#line 14 "Smarty_Internal_Configfileparser.y"
|
||||
|
||||
// states whether the parse was successful or not
|
||||
public $successful = true;
|
||||
@@ -133,7 +133,7 @@ class Smarty_Internal_Configfileparser#line 109 "internal.configfileparser.php"
|
||||
return $instance;
|
||||
}
|
||||
|
||||
#line 139 "internal.configfileparser.php"
|
||||
#line 139 "Smarty_Internal_Configfileparser.php"
|
||||
|
||||
/* Next is all token values, as class constants
|
||||
*/
|
||||
@@ -830,24 +830,24 @@ static public $yy_action = array(
|
||||
** function yy_r0($yymsp){ ... } // User supplied code
|
||||
** #line <lineno> <thisfile>
|
||||
*/
|
||||
#line 67 "internal.configfileparser.y"
|
||||
#line 67 "Smarty_Internal_Configfileparser.y"
|
||||
function yy_r0(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
|
||||
#line 840 "internal.configfileparser.php"
|
||||
#line 73 "internal.configfileparser.y"
|
||||
#line 840 "Smarty_Internal_Configfileparser.php"
|
||||
#line 73 "Smarty_Internal_Configfileparser.y"
|
||||
function yy_r1(){$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
|
||||
#line 843 "internal.configfileparser.php"
|
||||
#line 75 "internal.configfileparser.y"
|
||||
#line 843 "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 846 "internal.configfileparser.php"
|
||||
#line 81 "internal.configfileparser.y"
|
||||
#line 846 "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 849 "internal.configfileparser.php"
|
||||
#line 83 "internal.configfileparser.y"
|
||||
#line 849 "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 854 "internal.configfileparser.php"
|
||||
#line 87 "internal.configfileparser.y"
|
||||
#line 854 "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) {
|
||||
@@ -871,19 +871,19 @@ static public $yy_action = array(
|
||||
$this->compiler->config_data['sections'][$this->current_section]['vars'][$this->yystack[$this->yyidx + -3]->minor][]=$value;
|
||||
}
|
||||
}} $this->_retvalue =''; }
|
||||
#line 879 "internal.configfileparser.php"
|
||||
#line 111 "internal.configfileparser.y"
|
||||
#line 879 "Smarty_Internal_Configfileparser.php"
|
||||
#line 111 "Smarty_Internal_Configfileparser.y"
|
||||
function yy_r6(){ $this->_retvalue =''; }
|
||||
#line 882 "internal.configfileparser.php"
|
||||
#line 115 "internal.configfileparser.y"
|
||||
#line 882 "Smarty_Internal_Configfileparser.php"
|
||||
#line 115 "Smarty_Internal_Configfileparser.y"
|
||||
function yy_r9(){$this->_retvalue = trim($this->yystack[$this->yyidx + 0]->minor,"'"); }
|
||||
#line 885 "internal.configfileparser.php"
|
||||
#line 116 "internal.configfileparser.y"
|
||||
#line 885 "Smarty_Internal_Configfileparser.php"
|
||||
#line 116 "Smarty_Internal_Configfileparser.y"
|
||||
function yy_r10(){$this->_retvalue = trim($this->yystack[$this->yyidx + 0]->minor,'"'); }
|
||||
#line 888 "internal.configfileparser.php"
|
||||
#line 118 "internal.configfileparser.y"
|
||||
#line 888 "Smarty_Internal_Configfileparser.php"
|
||||
#line 118 "Smarty_Internal_Configfileparser.y"
|
||||
function yy_r12(){$this->_retvalue = (int)$this->yystack[$this->yyidx + 0]->minor; }
|
||||
#line 891 "internal.configfileparser.php"
|
||||
#line 891 "Smarty_Internal_Configfileparser.php"
|
||||
|
||||
/**
|
||||
* placeholder for the left hand side in a reduce operation.
|
||||
@@ -995,12 +995,12 @@ static public $yy_action = array(
|
||||
*/
|
||||
function yy_syntax_error($yymajor, $TOKEN)
|
||||
{
|
||||
#line 52 "internal.configfileparser.y"
|
||||
#line 52 "Smarty_Internal_Configfileparser.y"
|
||||
|
||||
$this->internalError = true;
|
||||
$this->yymajor = $yymajor;
|
||||
$this->compiler->trigger_config_file_error();
|
||||
#line 1009 "internal.configfileparser.php"
|
||||
#line 1009 "Smarty_Internal_Configfileparser.php"
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1018,13 +1018,13 @@ static public $yy_action = array(
|
||||
}
|
||||
/* Here code is inserted which will be executed whenever the
|
||||
** parser accepts */
|
||||
#line 44 "internal.configfileparser.y"
|
||||
#line 44 "Smarty_Internal_Configfileparser.y"
|
||||
|
||||
$this->successful = !$this->internalError;
|
||||
$this->internalError = false;
|
||||
$this->retvalue = $this->_retvalue;
|
||||
//echo $this->retvalue."\n\n";
|
||||
#line 1034 "internal.configfileparser.php"
|
||||
#line 1034 "Smarty_Internal_Configfileparser.php"
|
||||
}
|
||||
|
||||
/**
|
@@ -171,9 +171,9 @@ class Smarty_Internal_Resource_Extend {
|
||||
$_filepath = (string)abs(crc32($template->resource_name));
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($template->smarty->use_sub_dirs) {
|
||||
$_filepath = substr($_filepath, 0, 3) . DS
|
||||
. substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 0, 1) . DS
|
||||
$_filepath = substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 2, 2) . DS
|
||||
. substr($_filepath, 4, 2) . DS
|
||||
. $_filepath;
|
||||
}
|
||||
$_compile_dir_sep = $template->smarty->use_sub_dirs ? DS : '^';
|
@@ -115,9 +115,9 @@ class Smarty_Internal_Resource_File {
|
||||
$_filepath = (string)abs(crc32($_template->resource_name));
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($_template->smarty->use_sub_dirs) {
|
||||
$_filepath = substr($_filepath, 0, 3) . DS
|
||||
. substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 0, 1) . DS
|
||||
$_filepath = substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 2, 2) . DS
|
||||
. substr($_filepath, 4, 2) . DS
|
||||
. $_filepath;
|
||||
}
|
||||
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
|
@@ -127,9 +127,9 @@ class Smarty_Internal_Resource_Registered {
|
||||
$_filepath = (string)abs(crc32($_template->template_resource));
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($_template->smarty->use_sub_dirs) {
|
||||
$_filepath = substr($_filepath, 0, 3) . DS
|
||||
. substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 0, 1) . DS
|
||||
$_filepath = substr($_filepath, 0, 2) . DS
|
||||
. substr($_filepath, 2, 2) . DS
|
||||
. substr($_filepath, 4, 2) . DS
|
||||
. $_filepath;
|
||||
}
|
||||
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
|
@@ -209,7 +209,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
public function mustCompile ()
|
||||
{
|
||||
$this->isExisting(true);
|
||||
|
||||
if ($this->mustCompile === null) {
|
||||
$this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ())));
|
||||
}
|
||||
@@ -291,7 +290,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
// write compiled template
|
||||
Smarty_Internal_Write_File::writeFile($this->getCompiledFilepath(), $this->compiled_template);
|
||||
// make template and compiled file timestamp match
|
||||
$this->compiled_timestamp = null;
|
||||
touch($this->getCompiledFilepath(), $this->getTemplateTimestamp());
|
||||
// daylight saving time problem on windows
|
||||
if ($this->template_timestamp != $this->getCompiledTimestamp()) {
|
||||
touch($this->getCompiledFilepath(),2*$this->template_timestamp - $this->compiled_timestamp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// error compiling template
|
||||
@@ -366,11 +370,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
if ($this->getCachedTimestamp() === false) {
|
||||
return $this->isCached;
|
||||
}
|
||||
if (($this->caching == SMARTY_CACHING_LIVETIME_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() <= ($this->getCachedTimestamp() + $this->cache_lifetime) || $this->cache_lifetime < 0)))) {
|
||||
$_start_time = $this->_get_time();
|
||||
$this->rendered_content = $this->cache_resource_object->getCachedContents($this);
|
||||
$this->cache_time += $this->_get_time() - $_start_time;
|
||||
if ($this->caching == SMARTY_CACHING_LIVETIME_SAVED && $this->properties['cache_lifetime'] >0 && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']))) {
|
||||
if ($this->caching == SMARTY_CACHING_LIFETIME_SAVED && $this->properties['cache_lifetime'] >0 && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']))) {
|
||||
$this->rendered_content = null;
|
||||
return $this->isCached;
|
||||
}
|
||||
@@ -664,12 +668,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase {
|
||||
return $this->smarty->resource_objects[$resource_type] = new Smarty_Internal_Resource_Registered($this->smarty);
|
||||
} else {
|
||||
// try sysplugins dir
|
||||
$_resource_class = "Smarty_Internal_Resource_{$resource_type}";
|
||||
$_resource_class = 'Smarty_Internal_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}";
|
||||
$_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);
|
@@ -228,7 +228,7 @@ class Smarty_Internal_TemplateBase {
|
||||
// found it, return it
|
||||
return $this->smarty->global_tpl_vars[$variable];
|
||||
}
|
||||
if (Smarty::$error_unassigned && $error_enable) {
|
||||
if ($this->smarty->error_unassigned && $error_enable) {
|
||||
throw new Exception('Undefined Smarty variable "' . $variable . '"');
|
||||
} else {
|
||||
return new Undefined_Smarty_Variable;
|
||||
@@ -251,7 +251,7 @@ class Smarty_Internal_TemplateBase {
|
||||
// not found, try at parent
|
||||
$_ptr = $_ptr->parent;
|
||||
}
|
||||
if (Smarty::$error_unassigned) {
|
||||
if ($this->smarty->error_unassigned) {
|
||||
throw new Exception('Undefined config variable "' . $variable . '"');
|
||||
} else {
|
||||
return '';
|
||||
@@ -274,7 +274,7 @@ class Smarty_Internal_TemplateBase {
|
||||
return $_result;
|
||||
}
|
||||
|
||||
if (Smarty::$error_unassigned) {
|
||||
if ($this->smarty->$error_unassigned) {
|
||||
throw new Exception('Undefined stream variable "' . $variable . '"');
|
||||
} else {
|
||||
return '';
|
@@ -100,8 +100,8 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
/**
|
||||
* Compile Tag
|
||||
*
|
||||
* This is a call back from the lexer/parser
|
||||
* It executes the required compile plugin for the Smarty tag
|
||||
* This is a call back from the lexer/parser
|
||||
* It executes the required compile plugin for the Smarty tag
|
||||
*
|
||||
* @param string $tag tag name
|
||||
* @param array $args array with tag attributes
|
||||
@@ -114,12 +114,12 @@ 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->$tag($args, $this)) === false) {
|
||||
if (($_output = $this->generateCode($tag, $args)) === false) {
|
||||
if (isset($this->smarty->template_functions[$tag])) {
|
||||
// template defined by {template} tag
|
||||
$args['name'] = $tag;
|
||||
$tag = 'internal_function_call';
|
||||
$_output = $this->$tag($args, $this);
|
||||
$tag = 'function_call';
|
||||
$_output = $this->generateCode($tag, $args);
|
||||
}
|
||||
}
|
||||
if ($_output !== false) {
|
||||
@@ -144,9 +144,9 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
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->object_function($args, $tag, $methode, $this);
|
||||
return $this->generateCode('object_function',$args, $tag, $methode);
|
||||
} elseif (in_array($methode, $this->smarty->registered_objects[$tag][3])) {
|
||||
return $this->object_block_function($args, $tag, $methode, $this);
|
||||
return $this->generateCode('object_block_function',$args, $tag, $methode);
|
||||
} else {
|
||||
return $this->trigger_template_error ('unallowed methode "' . $methode . '" in registered object "' . $tag . '"');
|
||||
}
|
||||
@@ -159,11 +159,11 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
if (!$this->smarty->registered_plugins[$tag][2]) {
|
||||
$this->tag_nocache = true;
|
||||
}
|
||||
return call_user_func_array($this->smarty->registered_plugins[$tag][1], array($args, $this));
|
||||
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->$plugin_type($args, $tag, $this);
|
||||
return $this->generateCode($plugin_type, $args, $tag);
|
||||
}
|
||||
// compile closing tag of block function
|
||||
if (strlen($tag) > 5 && substr_compare($tag, 'close', -5, 5) == 0) {
|
||||
@@ -173,14 +173,14 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
$methode = $args['object_methode'];
|
||||
unset ($args['object_methode']);
|
||||
if (in_array($methode, $this->smarty->registered_objects[$base_tag][3])) {
|
||||
return $this->object_block_function($args, $tag, $methode, $this);
|
||||
return $this->generateCode('object_block_function', $args, $tag, $methode);
|
||||
} else {
|
||||
return $this->trigger_template_error ('unallowed closing tag methode "' . $methode . '" in registered object "' . $base_tag . '"');
|
||||
}
|
||||
}
|
||||
// plugin ?
|
||||
if (isset($this->smarty->registered_plugins[$base_tag]) && $this->smarty->registered_plugins[$base_tag][0] == 'block') {
|
||||
return $this->block_plugin($args, $tag, $this);
|
||||
return $this->generateCode('block_plugin',$args, $tag);
|
||||
}
|
||||
}
|
||||
$this->trigger_template_error ("unknown tag \"" . $tag . "\"");
|
||||
@@ -192,26 +192,28 @@ class Smarty_Internal_TemplateCompilerBase {
|
||||
*
|
||||
* compile objects cached for reuse.
|
||||
* class name format: Smarty_Internal_Compile_TagName
|
||||
* plugin filename format: internal.compile_tagname.php
|
||||
* plugin filename format: Smarty_Internal_Tagname.php
|
||||
*
|
||||
* @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
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
public function generateCode($tag, $args, $subtag = null, $method = null)
|
||||
{
|
||||
// re-use object if already exists
|
||||
if (isset(self::$_tag_objects[$name])) {
|
||||
if (isset(self::$_tag_objects[$tag])) {
|
||||
// compile this tag
|
||||
return call_user_func_array(array(self::$_tag_objects[$name], 'compile'), $args);
|
||||
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $subtag, $method);
|
||||
}
|
||||
// lazy load internal compiler plugin
|
||||
$class_name = "Smarty_Internal_Compile_{$name}";
|
||||
$class_name = 'Smarty_Internal_Compile_' . $tag;
|
||||
if ($this->smarty->loadPlugin($class_name)) {
|
||||
// use plugin if found
|
||||
self::$_tag_objects[$name] = new $class_name;
|
||||
self::$_tag_objects[$tag] = new $class_name;
|
||||
// compile this tag
|
||||
return call_user_func_array(array(self::$_tag_objects[$name], 'compile'), $args);
|
||||
return call_user_func(array(self::$_tag_objects[$tag], 'compile'), $args, $this, $subtag, $method);
|
||||
}
|
||||
// no internal compile plugin for this tag
|
||||
return false;
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user