mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-02 13:21:36 +01:00
change linefeed style to native on all files
This commit is contained in:
@@ -1,91 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block
|
||||
*
|
||||
* 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 {
|
||||
/**
|
||||
* Compiles code for the {/block} 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->smarty = $compiler->smarty;
|
||||
$this->compiler->has_code = true;
|
||||
// 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('block'));
|
||||
// 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'], "\"'");
|
||||
if (isset($this->smarty->block_data[$_name])) {
|
||||
if (strpos($this->smarty->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) {
|
||||
$_output = str_replace('%%%%SMARTY_PARENT%%%%', $compiler->template->extracted_compiled_code, $this->smarty->block_data[$_name]['compiled']);
|
||||
} elseif ($this->smarty->block_data[$_name]['mode'] == 'prepend') {
|
||||
$_output = $this->smarty->block_data[$_name]['compiled'] . $compiler->template->extracted_compiled_code;
|
||||
} elseif ($this->smarty->block_data[$_name]['mode'] == 'append') {
|
||||
$_output = $compiler->template->extracted_compiled_code . $this->smarty->block_data[$_name]['compiled'];
|
||||
} elseif (!empty($this->smarty->block_data[$_name])) {
|
||||
$_output = $this->smarty->block_data[$_name]['compiled'];
|
||||
}
|
||||
} else {
|
||||
$_output = $compiler->template->extracted_compiled_code;
|
||||
}
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
// check for includes in block tags
|
||||
preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $_output, $matches);
|
||||
$_output = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $_output);
|
||||
if (isset($matches[2])) {
|
||||
$prop = unserialize($matches[2]);
|
||||
$compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']);
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block
|
||||
*
|
||||
* 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 {
|
||||
/**
|
||||
* Compiles code for the {/block} 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->smarty = $compiler->smarty;
|
||||
$this->compiler->has_code = true;
|
||||
// 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('block'));
|
||||
// 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'], "\"'");
|
||||
if (isset($this->smarty->block_data[$_name])) {
|
||||
if (strpos($this->smarty->block_data[$_name]['compiled'], '%%%%SMARTY_PARENT%%%%') !== false) {
|
||||
$_output = str_replace('%%%%SMARTY_PARENT%%%%', $compiler->template->extracted_compiled_code, $this->smarty->block_data[$_name]['compiled']);
|
||||
} elseif ($this->smarty->block_data[$_name]['mode'] == 'prepend') {
|
||||
$_output = $this->smarty->block_data[$_name]['compiled'] . $compiler->template->extracted_compiled_code;
|
||||
} elseif ($this->smarty->block_data[$_name]['mode'] == 'append') {
|
||||
$_output = $compiler->template->extracted_compiled_code . $this->smarty->block_data[$_name]['compiled'];
|
||||
} elseif (!empty($this->smarty->block_data[$_name])) {
|
||||
$_output = $this->smarty->block_data[$_name]['compiled'];
|
||||
}
|
||||
} else {
|
||||
$_output = $compiler->template->extracted_compiled_code;
|
||||
}
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
// check for includes in block tags
|
||||
preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $_output, $matches);
|
||||
$_output = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $_output);
|
||||
if (isset($matches[2])) {
|
||||
$prop = unserialize($matches[2]);
|
||||
$compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']);
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,64 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Plugin
|
||||
*
|
||||
* Compiles code for the execution of block plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Plugin Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the execution of block plugin
|
||||
*
|
||||
* @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) {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
$_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
|
||||
$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();?>';
|
||||
} else {
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
// closing tag of block plugin, restore nocache
|
||||
list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5));
|
||||
// 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\'); }?>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Plugin
|
||||
*
|
||||
* Compiles code for the execution of block plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Plugin Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Block_Plugin extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the execution of block plugin
|
||||
*
|
||||
* @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) {
|
||||
$_paramsArray[] = "'$_key'=>$_value";
|
||||
}
|
||||
$_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
|
||||
$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();?>';
|
||||
} else {
|
||||
// must endblock be nocache?
|
||||
if ($this->compiler->nocache) {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
// closing tag of block plugin, restore nocache
|
||||
list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5));
|
||||
// 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\'); }?>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture
|
||||
*
|
||||
* Compiles the {capture} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Capture 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;
|
||||
$this->optional_attributes = array('name', 'assign', 'append');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$buffer = isset($_attr['name']) ? $_attr['name'] : "'default'";
|
||||
$assign = isset($_attr['assign']) ? $_attr['assign'] : null;
|
||||
$append = isset($_attr['append']) ? $_attr['append'] : null;
|
||||
|
||||
$this->compiler->_capture_stack[] = array($buffer, $assign, $append);
|
||||
|
||||
$_output = "<?php ob_start(); ?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture
|
||||
*
|
||||
* Compiles the {capture} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Capture 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;
|
||||
$this->optional_attributes = array('name', 'assign', 'append');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$buffer = isset($_attr['name']) ? $_attr['name'] : "'default'";
|
||||
$assign = isset($_attr['assign']) ? $_attr['assign'] : null;
|
||||
$append = isset($_attr['append']) ? $_attr['append'] : null;
|
||||
|
||||
$this->compiler->_capture_stack[] = array($buffer, $assign, $append);
|
||||
|
||||
$_output = "<?php ob_start(); ?>";
|
||||
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,34 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug
|
||||
*
|
||||
* Compiles the {debug} tag
|
||||
* It opens a window the the Smarty Debugging Console
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {debug} 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);
|
||||
|
||||
// display debug template
|
||||
$_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl->smarty); ?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug
|
||||
*
|
||||
* Compiles the {debug} tag
|
||||
* It opens a window the the Smarty Debugging Console
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {debug} 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);
|
||||
|
||||
// display debug template
|
||||
$_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl->smarty); ?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,109 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For
|
||||
*
|
||||
* Compiles the {for} {forelse} {/for} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {for} tag
|
||||
*
|
||||
* Smarty 3 does implement two different sytaxes:
|
||||
*
|
||||
* - {for $var in $array}
|
||||
* For looping over arrays or iterators
|
||||
*
|
||||
* - {for $x=0; $x<$y; $x++}
|
||||
* For general loops
|
||||
*
|
||||
* The parser is gereration different sets of attribute by which this compiler can
|
||||
* determin which syntax is used.
|
||||
*
|
||||
* @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;
|
||||
// {for $x=0; $x<$y; $x++} syntax
|
||||
$this->required_attributes = array('ifexp', 'start', 'loop', 'varloop');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('for', array('for',$this->compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||
|
||||
$output = "<?php ";
|
||||
foreach ($_attr['start'] as $_statement) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]] = new Smarty_Variable;";
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n";
|
||||
}
|
||||
$output .= " if ($_attr[ifexp]){ for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$_attr[varloop]]->value$_attr[loop]){\n";
|
||||
$output .= "?>";
|
||||
// return compiled code
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For
|
||||
*
|
||||
* Compiles the {for} {forelse} {/for} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {for} tag
|
||||
*
|
||||
* Smarty 3 does implement two different sytaxes:
|
||||
*
|
||||
* - {for $var in $array}
|
||||
* For looping over arrays or iterators
|
||||
*
|
||||
* - {for $x=0; $x<$y; $x++}
|
||||
* For general loops
|
||||
*
|
||||
* The parser is gereration different sets of attribute by which this compiler can
|
||||
* determin which syntax is used.
|
||||
*
|
||||
* @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;
|
||||
// {for $x=0; $x<$y; $x++} syntax
|
||||
$this->required_attributes = array('ifexp', 'start', 'loop', 'varloop');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('for', array('for',$this->compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||
|
||||
$output = "<?php ";
|
||||
foreach ($_attr['start'] as $_statement) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]] = new Smarty_Variable;";
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n";
|
||||
}
|
||||
$output .= " if ($_attr[ifexp]){ for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$_attr[varloop]]->value$_attr[loop]){\n";
|
||||
$output .= "?>";
|
||||
// return compiled code
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,192 +1,192 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach
|
||||
*
|
||||
* Compiles the {foreach} {foreachelse} {/foreach} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreach 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;
|
||||
$this->required_attributes = array('from', 'item');
|
||||
$this->optional_attributes = array('name', 'key');
|
||||
$tpl = $compiler->template;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('foreach', array('foreach',$this->compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||
|
||||
$from = $_attr['from'];
|
||||
$item = $_attr['item'];
|
||||
|
||||
if (isset($_attr['key'])) {
|
||||
$key = $_attr['key'];
|
||||
} else {
|
||||
$key = null;
|
||||
}
|
||||
|
||||
if (isset($_attr['name'])) {
|
||||
$name = $_attr['name'];
|
||||
$has_name = true;
|
||||
$SmartyVarName = '$smarty.foreach.' . trim($name,'\'"') . '.';
|
||||
} else {
|
||||
$name = null;
|
||||
$has_name = false;
|
||||
}
|
||||
$ItemVarName = '$' . trim($item,'\'"') . '@';
|
||||
// evaluates which Smarty variables and properties have to be computed
|
||||
if ($has_name) {
|
||||
$usesSmartyFirst = strpos($tpl->template_source, $SmartyVarName . 'first') !== false;
|
||||
$usesSmartyLast = strpos($tpl->template_source, $SmartyVarName . 'last') !== false;
|
||||
$usesSmartyIndex = strpos($tpl->template_source, $SmartyVarName . 'index') !== false;
|
||||
$usesSmartyIteration = strpos($tpl->template_source, $SmartyVarName . 'iteration') !== false;
|
||||
$usesSmartyShow = strpos($tpl->template_source, $SmartyVarName . 'show') !== false;
|
||||
$usesSmartyTotal = $usesSmartyLast || strpos($tpl->template_source, $SmartyVarName . 'total') !== false;
|
||||
} else {
|
||||
$usesSmartyFirst = false;
|
||||
$usesSmartyLast = false;
|
||||
$usesSmartyTotal = false;
|
||||
}
|
||||
|
||||
$usesPropFirst = $usesSmartyFirst || strpos($tpl->template_source, $ItemVarName . 'first') !== false;
|
||||
$usesPropLast = $usesSmartyLast || strpos($tpl->template_source, $ItemVarName . 'last') !== false;
|
||||
$usesPropIndex = $usesPropFirst || strpos($tpl->template_source, $ItemVarName . 'index') !== false;
|
||||
$usesPropIteration = $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'iteration') !== false;
|
||||
$usesPropShow = strpos($tpl->template_source, $ItemVarName . 'show') !== false;
|
||||
$usesPropTotal = $usesSmartyTotal || $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'total') !== false;
|
||||
// generate output code
|
||||
$output = "<?php ";
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable;\n";
|
||||
if ($key != null) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n";
|
||||
}
|
||||
$output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n";
|
||||
if ($usesPropTotal) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->total=count(\$_from);\n";
|
||||
}
|
||||
if ($usesPropIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n";
|
||||
}
|
||||
if ($usesPropIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n";
|
||||
}
|
||||
if ($has_name) {
|
||||
if ($usesSmartyTotal) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = \$_smarty_tpl->tpl_vars[$item]->total;\n";
|
||||
}
|
||||
if ($usesSmartyIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n";
|
||||
}
|
||||
if ($usesSmartyIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']=-1;\n";
|
||||
}
|
||||
}
|
||||
$output .= "if (count(\$_from) > 0){\n";
|
||||
$output .= " foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n";
|
||||
if ($key != null) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n";
|
||||
}
|
||||
if ($usesPropIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->iteration++;\n";
|
||||
}
|
||||
if ($usesPropIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->index++;\n";
|
||||
}
|
||||
if ($usesPropFirst) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index === 0;\n";
|
||||
}
|
||||
if ($usesPropLast) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration === \$_smarty_tpl->tpl_vars[$item]->total;\n";
|
||||
}
|
||||
if ($has_name) {
|
||||
if ($usesSmartyFirst) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['first'] = \$_smarty_tpl->tpl_vars[$item]->first;\n";
|
||||
}
|
||||
if ($usesSmartyIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']++;\n";
|
||||
}
|
||||
if ($usesSmartyIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']++;\n";
|
||||
}
|
||||
if ($usesSmartyLast) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['last'] = \$_smarty_tpl->tpl_vars[$item]->last;\n";
|
||||
}
|
||||
}
|
||||
$output .= "?>";
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 }} ?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach
|
||||
*
|
||||
* Compiles the {foreach} {foreachelse} {/foreach} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Foreach 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;
|
||||
$this->required_attributes = array('from', 'item');
|
||||
$this->optional_attributes = array('name', 'key');
|
||||
$tpl = $compiler->template;
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('foreach', array('foreach',$this->compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||
|
||||
$from = $_attr['from'];
|
||||
$item = $_attr['item'];
|
||||
|
||||
if (isset($_attr['key'])) {
|
||||
$key = $_attr['key'];
|
||||
} else {
|
||||
$key = null;
|
||||
}
|
||||
|
||||
if (isset($_attr['name'])) {
|
||||
$name = $_attr['name'];
|
||||
$has_name = true;
|
||||
$SmartyVarName = '$smarty.foreach.' . trim($name,'\'"') . '.';
|
||||
} else {
|
||||
$name = null;
|
||||
$has_name = false;
|
||||
}
|
||||
$ItemVarName = '$' . trim($item,'\'"') . '@';
|
||||
// evaluates which Smarty variables and properties have to be computed
|
||||
if ($has_name) {
|
||||
$usesSmartyFirst = strpos($tpl->template_source, $SmartyVarName . 'first') !== false;
|
||||
$usesSmartyLast = strpos($tpl->template_source, $SmartyVarName . 'last') !== false;
|
||||
$usesSmartyIndex = strpos($tpl->template_source, $SmartyVarName . 'index') !== false;
|
||||
$usesSmartyIteration = strpos($tpl->template_source, $SmartyVarName . 'iteration') !== false;
|
||||
$usesSmartyShow = strpos($tpl->template_source, $SmartyVarName . 'show') !== false;
|
||||
$usesSmartyTotal = $usesSmartyLast || strpos($tpl->template_source, $SmartyVarName . 'total') !== false;
|
||||
} else {
|
||||
$usesSmartyFirst = false;
|
||||
$usesSmartyLast = false;
|
||||
$usesSmartyTotal = false;
|
||||
}
|
||||
|
||||
$usesPropFirst = $usesSmartyFirst || strpos($tpl->template_source, $ItemVarName . 'first') !== false;
|
||||
$usesPropLast = $usesSmartyLast || strpos($tpl->template_source, $ItemVarName . 'last') !== false;
|
||||
$usesPropIndex = $usesPropFirst || strpos($tpl->template_source, $ItemVarName . 'index') !== false;
|
||||
$usesPropIteration = $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'iteration') !== false;
|
||||
$usesPropShow = strpos($tpl->template_source, $ItemVarName . 'show') !== false;
|
||||
$usesPropTotal = $usesSmartyTotal || $usesPropLast || strpos($tpl->template_source, $ItemVarName . 'total') !== false;
|
||||
// generate output code
|
||||
$output = "<?php ";
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable;\n";
|
||||
if ($key != null) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n";
|
||||
}
|
||||
$output .= " \$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array');}\n";
|
||||
if ($usesPropTotal) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->total=count(\$_from);\n";
|
||||
}
|
||||
if ($usesPropIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->iteration=0;\n";
|
||||
}
|
||||
if ($usesPropIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->index=-1;\n";
|
||||
}
|
||||
if ($has_name) {
|
||||
if ($usesSmartyTotal) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['total'] = \$_smarty_tpl->tpl_vars[$item]->total;\n";
|
||||
}
|
||||
if ($usesSmartyIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']=0;\n";
|
||||
}
|
||||
if ($usesSmartyIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']=-1;\n";
|
||||
}
|
||||
}
|
||||
$output .= "if (count(\$_from) > 0){\n";
|
||||
$output .= " foreach (\$_from as \$_smarty_tpl->tpl_vars[$item]->key => \$_smarty_tpl->tpl_vars[$item]->value){\n";
|
||||
if ($key != null) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n";
|
||||
}
|
||||
if ($usesPropIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->iteration++;\n";
|
||||
}
|
||||
if ($usesPropIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->index++;\n";
|
||||
}
|
||||
if ($usesPropFirst) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index === 0;\n";
|
||||
}
|
||||
if ($usesPropLast) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration === \$_smarty_tpl->tpl_vars[$item]->total;\n";
|
||||
}
|
||||
if ($has_name) {
|
||||
if ($usesSmartyFirst) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['first'] = \$_smarty_tpl->tpl_vars[$item]->first;\n";
|
||||
}
|
||||
if ($usesSmartyIteration) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['iteration']++;\n";
|
||||
}
|
||||
if ($usesSmartyIndex) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['index']++;\n";
|
||||
}
|
||||
if ($usesSmartyLast) {
|
||||
$output .= " \$_smarty_tpl->tpl_vars['smarty']->value['foreach'][$name]['last'] = \$_smarty_tpl->tpl_vars[$item]->last;\n";
|
||||
}
|
||||
}
|
||||
$output .= "?>";
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,79 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function
|
||||
*
|
||||
* Compiles the {function} {/function} tags
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Functionclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$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);
|
||||
$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'];
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function
|
||||
*
|
||||
* Compiles the {function} {/function} tags
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Functionclose Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {/function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return boolean true
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$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);
|
||||
$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'];
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,114 +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?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?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?>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,159 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include
|
||||
*
|
||||
* Compiles the {include} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {include} 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('file');
|
||||
$this->optional_attributes = array('_any');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// save posible attributes
|
||||
$include_file = $_attr['file'];
|
||||
$has_compiled_template = false;
|
||||
if ($compiler->smarty->merge_compiled_includes) {
|
||||
// check if compiled code can be merged (contains no variable part)
|
||||
if (!$compiler->has_variable_string && (substr_count($include_file, '"') == 2 or substr_count($include_file, "'") == 2) and substr_count($include_file, '(') == 0) {
|
||||
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);
|
||||
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
|
||||
}
|
||||
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']);
|
||||
}
|
||||
$has_compiled_template = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_attr['assign'])) {
|
||||
// output will be stored in a smarty variable instead of beind displayed
|
||||
$_assign = $_attr['assign'];
|
||||
}
|
||||
|
||||
$_parent_scope = SMARTY_LOCAL_SCOPE;
|
||||
if (isset($_attr['scope'])) {
|
||||
if ($_attr['scope'] == '\'parent\'') {
|
||||
$_parent_scope = SMARTY_PARENT_SCOPE;
|
||||
} elseif ($_attr['scope'] == '\'root\'') {
|
||||
$_parent_scope = SMARTY_ROOT_SCOPE;
|
||||
} elseif ($_attr['scope'] == '\'global\'') {
|
||||
$_parent_scope = SMARTY_GLOBAL_SCOPE;
|
||||
}
|
||||
}
|
||||
// default for included templates
|
||||
if ($compiler->template->caching) {
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
} else {
|
||||
$_caching = SMARTY_CACHING_OFF;
|
||||
}
|
||||
/*
|
||||
* if the {include} tag provides individual parameter for caching
|
||||
* it will not be included into the common cache file and treated like
|
||||
* a nocache section
|
||||
*/
|
||||
if (isset($_attr['cache_lifetime'])) {
|
||||
$_cache_lifetime = $_attr['cache_lifetime'];
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
if (isset($_attr['nocache'])) {
|
||||
if ($_attr['nocache'] == 'true') {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
}
|
||||
if (isset($_attr['caching'])) {
|
||||
if ($_attr['caching'] == 'true') {
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
} else {
|
||||
$_caching = SMARTY_CACHING_OFF;
|
||||
}
|
||||
}
|
||||
// create template object
|
||||
$_output = "<?php \$_template = new Smarty_Template ($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);";
|
||||
// delete {include} standard attributes
|
||||
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']);
|
||||
// remaining attributes must be assigned as smarty variable
|
||||
if (!empty($_attr)) {
|
||||
if ($_parent_scope == SMARTY_LOCAL_SCOPE) {
|
||||
// create variables
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
$_output .= "\$_template->assign('$_key',$_value);";
|
||||
}
|
||||
} else {
|
||||
$this->compiler->trigger_template_error('variable passing not allowed in parent/global scope');
|
||||
}
|
||||
}
|
||||
// add caching parameter if required
|
||||
if (isset($_cache_lifetime)) {
|
||||
$_output .= "\$_template->cache_lifetime = $_cache_lifetime;";
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
$_output .= "\$_template->caching = $_caching;";
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch()); ?>";
|
||||
} else {
|
||||
if ($has_compiled_template) {
|
||||
$_output .= " \$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n";
|
||||
$_output .= $compiled_tpl . "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>";
|
||||
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
|
||||
} else {
|
||||
$_output .= " echo \$_template->fetch(); ?>";
|
||||
}
|
||||
}
|
||||
if ($_parent_scope != SMARTY_LOCAL_SCOPE) {
|
||||
$_output .= "<?php \$_template->updateParentVariables($_parent_scope); ?>";
|
||||
}
|
||||
$_output .= "<?php unset(\$_template); ?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include
|
||||
*
|
||||
* Compiles the {include} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the {include} 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('file');
|
||||
$this->optional_attributes = array('_any');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// save posible attributes
|
||||
$include_file = $_attr['file'];
|
||||
$has_compiled_template = false;
|
||||
if ($compiler->smarty->merge_compiled_includes) {
|
||||
// check if compiled code can be merged (contains no variable part)
|
||||
if (!$compiler->has_variable_string && (substr_count($include_file, '"') == 2 or substr_count($include_file, "'") == 2) and substr_count($include_file, '(') == 0) {
|
||||
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);
|
||||
$mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name);
|
||||
}
|
||||
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']);
|
||||
}
|
||||
$has_compiled_template = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_attr['assign'])) {
|
||||
// output will be stored in a smarty variable instead of beind displayed
|
||||
$_assign = $_attr['assign'];
|
||||
}
|
||||
|
||||
$_parent_scope = SMARTY_LOCAL_SCOPE;
|
||||
if (isset($_attr['scope'])) {
|
||||
if ($_attr['scope'] == '\'parent\'') {
|
||||
$_parent_scope = SMARTY_PARENT_SCOPE;
|
||||
} elseif ($_attr['scope'] == '\'root\'') {
|
||||
$_parent_scope = SMARTY_ROOT_SCOPE;
|
||||
} elseif ($_attr['scope'] == '\'global\'') {
|
||||
$_parent_scope = SMARTY_GLOBAL_SCOPE;
|
||||
}
|
||||
}
|
||||
// default for included templates
|
||||
if ($compiler->template->caching) {
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
} else {
|
||||
$_caching = SMARTY_CACHING_OFF;
|
||||
}
|
||||
/*
|
||||
* if the {include} tag provides individual parameter for caching
|
||||
* it will not be included into the common cache file and treated like
|
||||
* a nocache section
|
||||
*/
|
||||
if (isset($_attr['cache_lifetime'])) {
|
||||
$_cache_lifetime = $_attr['cache_lifetime'];
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
if (isset($_attr['nocache'])) {
|
||||
if ($_attr['nocache'] == 'true') {
|
||||
$this->compiler->tag_nocache = true;
|
||||
}
|
||||
}
|
||||
if (isset($_attr['caching'])) {
|
||||
if ($_attr['caching'] == 'true') {
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
} else {
|
||||
$_caching = SMARTY_CACHING_OFF;
|
||||
}
|
||||
}
|
||||
// create template object
|
||||
$_output = "<?php \$_template = new Smarty_Template ($include_file, \$_smarty_tpl->smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);";
|
||||
// delete {include} standard attributes
|
||||
unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']);
|
||||
// remaining attributes must be assigned as smarty variable
|
||||
if (!empty($_attr)) {
|
||||
if ($_parent_scope == SMARTY_LOCAL_SCOPE) {
|
||||
// create variables
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
$_output .= "\$_template->assign('$_key',$_value);";
|
||||
}
|
||||
} else {
|
||||
$this->compiler->trigger_template_error('variable passing not allowed in parent/global scope');
|
||||
}
|
||||
}
|
||||
// add caching parameter if required
|
||||
if (isset($_cache_lifetime)) {
|
||||
$_output .= "\$_template->cache_lifetime = $_cache_lifetime;";
|
||||
$_caching = SMARTY_CACHING_LIFETIME_CURRENT;
|
||||
}
|
||||
$_output .= "\$_template->caching = $_caching;";
|
||||
// was there an assign attribute
|
||||
if (isset($_assign)) {
|
||||
$_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch()); ?>";
|
||||
} else {
|
||||
if ($has_compiled_template) {
|
||||
$_output .= " \$_tpl_stack[] = \$_smarty_tpl; \$_smarty_tpl = \$_template;?>\n";
|
||||
$_output .= $compiled_tpl . "<?php /* End of included template \"" . $tpl->getTemplateFilepath() . "\" */ ?>";
|
||||
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
|
||||
} else {
|
||||
$_output .= " echo \$_template->fetch(); ?>";
|
||||
}
|
||||
}
|
||||
if ($_parent_scope != SMARTY_LOCAL_SCOPE) {
|
||||
$_output .= "<?php \$_template->updateParentVariables($_parent_scope); ?>";
|
||||
}
|
||||
$_output .= "<?php unset(\$_template); ?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,170 +1,170 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section
|
||||
*
|
||||
* Compiles the {section} {sectionelse} {/section} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Section 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;
|
||||
$this->required_attributes = array('name', 'loop');
|
||||
$this->optional_attributes = array('start', 'step', 'max', 'show');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('section', array('section',$this->compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||
|
||||
$output = "<?php ";
|
||||
|
||||
$section_name = $_attr['name'];
|
||||
|
||||
$output .= "unset(\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]);\n";
|
||||
$section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]";
|
||||
|
||||
foreach ($_attr as $attr_name => $attr_value) {
|
||||
switch ($attr_name) {
|
||||
case 'loop':
|
||||
$output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
|
||||
break;
|
||||
|
||||
case 'show':
|
||||
if (is_bool($attr_value))
|
||||
$show_attr_value = $attr_value ? 'true' : 'false';
|
||||
else
|
||||
$show_attr_value = "(bool)$attr_value";
|
||||
$output .= "{$section_props}['show'] = $show_attr_value;\n";
|
||||
break;
|
||||
|
||||
case 'name':
|
||||
$output .= "{$section_props}['$attr_name'] = $attr_value;\n";
|
||||
break;
|
||||
|
||||
case 'max':
|
||||
case 'start':
|
||||
$output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n";
|
||||
break;
|
||||
|
||||
case 'step':
|
||||
$output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_attr['show']))
|
||||
$output .= "{$section_props}['show'] = true;\n";
|
||||
|
||||
if (!isset($_attr['loop']))
|
||||
$output .= "{$section_props}['loop'] = 1;\n";
|
||||
|
||||
if (!isset($_attr['max']))
|
||||
$output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
|
||||
else
|
||||
$output .= "if ({$section_props}['max'] < 0)\n" . " {$section_props}['max'] = {$section_props}['loop'];\n";
|
||||
|
||||
if (!isset($_attr['step']))
|
||||
$output .= "{$section_props}['step'] = 1;\n";
|
||||
|
||||
if (!isset($_attr['start']))
|
||||
$output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
|
||||
else {
|
||||
$output .= "if ({$section_props}['start'] < 0)\n" . " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . "else\n" . " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
|
||||
}
|
||||
|
||||
$output .= "if ({$section_props}['show']) {\n";
|
||||
if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) {
|
||||
$output .= " {$section_props}['total'] = {$section_props}['loop'];\n";
|
||||
} else {
|
||||
$output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
|
||||
}
|
||||
$output .= " if ({$section_props}['total'] == 0)\n" . " {$section_props}['show'] = false;\n" . "} else\n" . " {$section_props}['total'] = 0;\n";
|
||||
|
||||
$output .= "if ({$section_props}['show']):\n";
|
||||
$output .= "
|
||||
for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1;
|
||||
{$section_props}['iteration'] <= {$section_props}['total'];
|
||||
{$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n";
|
||||
$output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n";
|
||||
$output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n";
|
||||
$output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n";
|
||||
$output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n";
|
||||
$output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
|
||||
|
||||
$output .= "?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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; ?>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section
|
||||
*
|
||||
* Compiles the {section} {sectionelse} {/section} tags
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Section 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;
|
||||
$this->required_attributes = array('name', 'loop');
|
||||
$this->optional_attributes = array('start', 'step', 'max', 'show');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
$this->_open_tag('section', array('section',$this->compiler->nocache));
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||
|
||||
$output = "<?php ";
|
||||
|
||||
$section_name = $_attr['name'];
|
||||
|
||||
$output .= "unset(\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]);\n";
|
||||
$section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]";
|
||||
|
||||
foreach ($_attr as $attr_name => $attr_value) {
|
||||
switch ($attr_name) {
|
||||
case 'loop':
|
||||
$output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
|
||||
break;
|
||||
|
||||
case 'show':
|
||||
if (is_bool($attr_value))
|
||||
$show_attr_value = $attr_value ? 'true' : 'false';
|
||||
else
|
||||
$show_attr_value = "(bool)$attr_value";
|
||||
$output .= "{$section_props}['show'] = $show_attr_value;\n";
|
||||
break;
|
||||
|
||||
case 'name':
|
||||
$output .= "{$section_props}['$attr_name'] = $attr_value;\n";
|
||||
break;
|
||||
|
||||
case 'max':
|
||||
case 'start':
|
||||
$output .= "{$section_props}['$attr_name'] = (int)$attr_value;\n";
|
||||
break;
|
||||
|
||||
case 'step':
|
||||
$output .= "{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_attr['show']))
|
||||
$output .= "{$section_props}['show'] = true;\n";
|
||||
|
||||
if (!isset($_attr['loop']))
|
||||
$output .= "{$section_props}['loop'] = 1;\n";
|
||||
|
||||
if (!isset($_attr['max']))
|
||||
$output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
|
||||
else
|
||||
$output .= "if ({$section_props}['max'] < 0)\n" . " {$section_props}['max'] = {$section_props}['loop'];\n";
|
||||
|
||||
if (!isset($_attr['step']))
|
||||
$output .= "{$section_props}['step'] = 1;\n";
|
||||
|
||||
if (!isset($_attr['start']))
|
||||
$output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
|
||||
else {
|
||||
$output .= "if ({$section_props}['start'] < 0)\n" . " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . "else\n" . " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
|
||||
}
|
||||
|
||||
$output .= "if ({$section_props}['show']) {\n";
|
||||
if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) {
|
||||
$output .= " {$section_props}['total'] = {$section_props}['loop'];\n";
|
||||
} else {
|
||||
$output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
|
||||
}
|
||||
$output .= " if ({$section_props}['total'] == 0)\n" . " {$section_props}['show'] = false;\n" . "} else\n" . " {$section_props}['total'] = 0;\n";
|
||||
|
||||
$output .= "if ({$section_props}['show']):\n";
|
||||
$output .= "
|
||||
for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1;
|
||||
{$section_props}['iteration'] <= {$section_props}['total'];
|
||||
{$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n";
|
||||
$output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n";
|
||||
$output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n";
|
||||
$output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n";
|
||||
$output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n";
|
||||
$output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
|
||||
|
||||
$output .= "?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,106 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Special Smarty Variable
|
||||
*
|
||||
* Compiles the special $smarty variables
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile special Smarty Variable Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Special_Smarty_Variable extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the speical $smarty variables
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$_index = explode(',', str_replace(array(']['), array(','), substr($args,1,strlen($args)-2)));
|
||||
$compiled_ref = ' ';
|
||||
switch (trim($_index[0], "'")) {
|
||||
case 'foreach':
|
||||
return "\$_smarty_tpl->getVariable('smarty')->value$args";
|
||||
case 'section':
|
||||
return "\$_smarty_tpl->getVariable('smarty')->value$args";
|
||||
case 'capture':
|
||||
return "\$_smarty_tpl->smarty->_smarty_vars$args";
|
||||
case 'now':
|
||||
return 'time()';
|
||||
|
||||
case 'get':
|
||||
$compiled_ref = "\$_GET";
|
||||
break;
|
||||
|
||||
case 'post':
|
||||
$compiled_ref = "\$_POST";
|
||||
break;
|
||||
|
||||
case 'cookies':
|
||||
$compiled_ref = "\$_COOKIE";
|
||||
break;
|
||||
|
||||
case 'env':
|
||||
$compiled_ref = "\$_ENV";
|
||||
break;
|
||||
|
||||
case 'server':
|
||||
$compiled_ref = "\$_SERVER";
|
||||
break;
|
||||
|
||||
case 'session':
|
||||
$compiled_ref = "\$_SESSION";
|
||||
break;
|
||||
|
||||
case 'request':
|
||||
$compiled_ref = "\$_REQUEST";
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
$_template_name = basename($compiler->template->getTemplateFilepath());
|
||||
return "'$_template_name'";
|
||||
|
||||
case 'current_dir':
|
||||
$_template_dir_name = dirname($compiler->template->getTemplateFilepath());
|
||||
return "'$_template_dir_name'";
|
||||
|
||||
case 'version':
|
||||
$_version = Smarty::$_version;
|
||||
return "'$_version'";
|
||||
|
||||
case 'const':
|
||||
if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) {
|
||||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||
break;
|
||||
}
|
||||
return '@' . trim($_index[1], "'");
|
||||
|
||||
case 'config':
|
||||
return "\$_smarty_tpl->getConfigVariable($_index[1])";
|
||||
case 'ldelim':
|
||||
$_ldelim = $compiler->smarty->left_delimiter;
|
||||
return "'$_ldelim'";
|
||||
|
||||
case 'rdelim':
|
||||
$_rdelim = $compiler->smarty->right_delimiter;
|
||||
return "'$_rdelim'";
|
||||
|
||||
default:
|
||||
$compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference');
|
||||
break;
|
||||
}
|
||||
if (isset($_index[1])) {
|
||||
array_shift($_index);
|
||||
foreach ($_index as $_ind) {
|
||||
$compiled_ref = $compiled_ref . "[$_ind]";
|
||||
}
|
||||
}
|
||||
return $compiled_ref;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Special Smarty Variable
|
||||
*
|
||||
* Compiles the special $smarty variables
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile special Smarty Variable Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_Special_Smarty_Variable extends Smarty_Internal_CompileBase {
|
||||
/**
|
||||
* Compiles code for the speical $smarty variables
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object $compiler compiler object
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, $compiler)
|
||||
{
|
||||
$_index = explode(',', str_replace(array(']['), array(','), substr($args,1,strlen($args)-2)));
|
||||
$compiled_ref = ' ';
|
||||
switch (trim($_index[0], "'")) {
|
||||
case 'foreach':
|
||||
return "\$_smarty_tpl->getVariable('smarty')->value$args";
|
||||
case 'section':
|
||||
return "\$_smarty_tpl->getVariable('smarty')->value$args";
|
||||
case 'capture':
|
||||
return "\$_smarty_tpl->smarty->_smarty_vars$args";
|
||||
case 'now':
|
||||
return 'time()';
|
||||
|
||||
case 'get':
|
||||
$compiled_ref = "\$_GET";
|
||||
break;
|
||||
|
||||
case 'post':
|
||||
$compiled_ref = "\$_POST";
|
||||
break;
|
||||
|
||||
case 'cookies':
|
||||
$compiled_ref = "\$_COOKIE";
|
||||
break;
|
||||
|
||||
case 'env':
|
||||
$compiled_ref = "\$_ENV";
|
||||
break;
|
||||
|
||||
case 'server':
|
||||
$compiled_ref = "\$_SERVER";
|
||||
break;
|
||||
|
||||
case 'session':
|
||||
$compiled_ref = "\$_SESSION";
|
||||
break;
|
||||
|
||||
case 'request':
|
||||
$compiled_ref = "\$_REQUEST";
|
||||
break;
|
||||
|
||||
case 'template':
|
||||
$_template_name = basename($compiler->template->getTemplateFilepath());
|
||||
return "'$_template_name'";
|
||||
|
||||
case 'current_dir':
|
||||
$_template_dir_name = dirname($compiler->template->getTemplateFilepath());
|
||||
return "'$_template_dir_name'";
|
||||
|
||||
case 'version':
|
||||
$_version = Smarty::$_version;
|
||||
return "'$_version'";
|
||||
|
||||
case 'const':
|
||||
if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) {
|
||||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||
break;
|
||||
}
|
||||
return '@' . trim($_index[1], "'");
|
||||
|
||||
case 'config':
|
||||
return "\$_smarty_tpl->getConfigVariable($_index[1])";
|
||||
case 'ldelim':
|
||||
$_ldelim = $compiler->smarty->left_delimiter;
|
||||
return "'$_ldelim'";
|
||||
|
||||
case 'rdelim':
|
||||
$_rdelim = $compiler->smarty->right_delimiter;
|
||||
return "'$_rdelim'";
|
||||
|
||||
default:
|
||||
$compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is an unknown reference');
|
||||
break;
|
||||
}
|
||||
if (isset($_index[1])) {
|
||||
array_shift($_index);
|
||||
foreach ($_index as $_ind) {
|
||||
$compiled_ref = $compiled_ref . "[$_ind]";
|
||||
}
|
||||
}
|
||||
return $compiled_ref;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,59 +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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While
|
||||
*
|
||||
* Compiles the {while} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_While 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;
|
||||
$this->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$this->_open_tag('while', $this->compiler->nocache);
|
||||
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->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;\n";
|
||||
$_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return '<?php while (' . $args['if condition'] . ') { ?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 }?>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While
|
||||
*
|
||||
* Compiles the {while} tag
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While Class
|
||||
*/
|
||||
class Smarty_Internal_Compile_While 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;
|
||||
$this->required_attributes = array('if condition');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$this->_open_tag('while', $this->compiler->nocache);
|
||||
|
||||
// maybe nocache because of nocache variables
|
||||
$this->compiler->nocache = $this->compiler->nocache | $this->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;\n";
|
||||
$_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>";
|
||||
return $_output;
|
||||
} else {
|
||||
return '<?php while (' . $args['if condition'] . ') { ?>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,84 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Security
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does contain the security settings
|
||||
*/
|
||||
class Smarty_Security {
|
||||
/**
|
||||
* This determines how Smarty handles "<?php ... ?>" tags in templates.
|
||||
* possible values:
|
||||
* <ul>
|
||||
* <li>SMARTY_PHP_PASSTHRU -> echo PHP tags as they are</li>
|
||||
* <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
|
||||
* <li>SMARTY_PHP_REMOVE -> remove php tags</li>
|
||||
* <li>SMARTY_PHP_ALLOW -> execute php tags</li>
|
||||
* </ul>
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $php_handling = SMARTY_PHP_PASSTHRU;
|
||||
|
||||
/**
|
||||
* This is the list of template directories that are considered secure.
|
||||
* One directory per array element.
|
||||
* $template_dir is in this list implicitly.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $secure_dir = array();
|
||||
|
||||
|
||||
/**
|
||||
* This is an array of directories where trusted php scripts reside.
|
||||
* {@link $security} is disabled during their inclusion/execution.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $trusted_dir = array();
|
||||
|
||||
|
||||
/**
|
||||
* This is an array of trusted PHP functions.
|
||||
*
|
||||
* If empty all functions are allowed.
|
||||
* If set to 'none' none is allowed.
|
||||
* @var array
|
||||
*/
|
||||
public $php_functions = array('isset', 'empty',
|
||||
'count', 'sizeof','in_array', 'is_array','time','nl2br');
|
||||
|
||||
/**
|
||||
* This is an array of trusted modifers.
|
||||
*
|
||||
* If empty all modifiers are allowed.
|
||||
* If set to 'none' none is allowed.
|
||||
* @var array
|
||||
*/
|
||||
public $modifiers = array('escape','count');
|
||||
|
||||
/**
|
||||
* This is an array of trusted streams.
|
||||
*
|
||||
* If empty all streams are allowed.
|
||||
* If set to 'none' none is allowed.
|
||||
* @var array
|
||||
*/
|
||||
public $streams = array('file');
|
||||
/**
|
||||
+ flag if constants can be accessed from template
|
||||
*/
|
||||
public $allow_constants = true;
|
||||
/**
|
||||
+ flag if {php} tag can be executed
|
||||
*/
|
||||
public $allow_php_tag = false;
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Security
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does contain the security settings
|
||||
*/
|
||||
class Smarty_Security {
|
||||
/**
|
||||
* This determines how Smarty handles "<?php ... ?>" tags in templates.
|
||||
* possible values:
|
||||
* <ul>
|
||||
* <li>SMARTY_PHP_PASSTHRU -> echo PHP tags as they are</li>
|
||||
* <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
|
||||
* <li>SMARTY_PHP_REMOVE -> remove php tags</li>
|
||||
* <li>SMARTY_PHP_ALLOW -> execute php tags</li>
|
||||
* </ul>
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $php_handling = SMARTY_PHP_PASSTHRU;
|
||||
|
||||
/**
|
||||
* This is the list of template directories that are considered secure.
|
||||
* One directory per array element.
|
||||
* $template_dir is in this list implicitly.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $secure_dir = array();
|
||||
|
||||
|
||||
/**
|
||||
* This is an array of directories where trusted php scripts reside.
|
||||
* {@link $security} is disabled during their inclusion/execution.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $trusted_dir = array();
|
||||
|
||||
|
||||
/**
|
||||
* This is an array of trusted PHP functions.
|
||||
*
|
||||
* If empty all functions are allowed.
|
||||
* If set to 'none' none is allowed.
|
||||
* @var array
|
||||
*/
|
||||
public $php_functions = array('isset', 'empty',
|
||||
'count', 'sizeof','in_array', 'is_array','time','nl2br');
|
||||
|
||||
/**
|
||||
* This is an array of trusted modifers.
|
||||
*
|
||||
* If empty all modifiers are allowed.
|
||||
* If set to 'none' none is allowed.
|
||||
* @var array
|
||||
*/
|
||||
public $modifiers = array('escape','count');
|
||||
|
||||
/**
|
||||
* This is an array of trusted streams.
|
||||
*
|
||||
* If empty all streams are allowed.
|
||||
* If set to 'none' none is allowed.
|
||||
* @var array
|
||||
*/
|
||||
public $streams = array('file');
|
||||
/**
|
||||
+ flag if constants can be accessed from template
|
||||
*/
|
||||
public $allow_constants = true;
|
||||
/**
|
||||
+ flag if {php} tag can be executed
|
||||
*/
|
||||
public $allow_php_tag = false;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user