From fa10e0945ecd45bfe78a2c8fb015a43092b4944b Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 10 Dec 2015 14:02:22 +0100 Subject: bug #385 update to smarty-3.1.28-dev (from Github) --- .../sysplugins/smarty_internal_compilebase.php | 62 +++++++++++----------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'include/smarty/libs/sysplugins/smarty_internal_compilebase.php') diff --git a/include/smarty/libs/sysplugins/smarty_internal_compilebase.php b/include/smarty/libs/sysplugins/smarty_internal_compilebase.php index 5fb56f371..0803f27a6 100644 --- a/include/smarty/libs/sysplugins/smarty_internal_compilebase.php +++ b/include/smarty/libs/sysplugins/smarty_internal_compilebase.php @@ -2,25 +2,26 @@ /** * Smarty Internal Plugin CompileBase * - * @package Smarty + * @package Smarty * @subpackage Compiler - * @author Uwe Tews + * @author Uwe Tews */ /** * This class does extend all internal compile plugins * - * @package Smarty + * @package Smarty * @subpackage Compiler */ -abstract class Smarty_Internal_CompileBase { - +abstract class Smarty_Internal_CompileBase +{ /** * Array of names of required attribute required by tag * * @var array */ public $required_attributes = array(); + /** * Array of names of optional attribute required by tag * use array('_any') if there is no restriction of attributes names @@ -28,12 +29,14 @@ abstract class Smarty_Internal_CompileBase { * @var array */ public $optional_attributes = array(); + /** * Shorttag attribute order defined by its names * * @var array */ public $shorttag_order = array(); + /** * Array of names of valid option flags * @@ -43,15 +46,15 @@ abstract class Smarty_Internal_CompileBase { /** * This function checks if the attributes passed are valid - * * The attributes passed for the tag to compile are checked against the list of required and * optional attributes. Required attributes must be present. Optional attributes are check against * the corresponding list. The keyword '_any' specifies that any attribute will be accepted * as valid * - * @param object $compiler compiler object - * @param array $attributes attributes applied to the tag - * @return array of mapped attributes for further processing + * @param object $compiler compiler object + * @param array $attributes attributes applied to the tag + * + * @return array of mapped attributes for further processing */ public function getAttributes($compiler, $attributes) { @@ -64,11 +67,11 @@ abstract class Smarty_Internal_CompileBase { if (in_array(trim($mixed, '\'"'), $this->option_flags)) { $_indexed_attr[trim($mixed, '\'"')] = true; // shorthand attribute ? - } else if (isset($this->shorttag_order[$key])) { + } elseif (isset($this->shorttag_order[$key])) { $_indexed_attr[$this->shorttag_order[$key]] = $mixed; } else { // too many shorthands - $compiler->trigger_template_error('too many shorthand attributes', $compiler->lex->taglineno); + $compiler->trigger_template_error('too many shorthand attributes', null, true); } // named attribute } else { @@ -77,20 +80,20 @@ abstract class Smarty_Internal_CompileBase { if (in_array($kv['key'], $this->option_flags)) { if (is_bool($kv['value'])) { $_indexed_attr[$kv['key']] = $kv['value']; - } else if (is_string($kv['value']) && in_array(trim($kv['value'], '\'"'), array('true', 'false'))) { + } elseif (is_string($kv['value']) && in_array(trim($kv['value'], '\'"'), array('true', 'false'))) { if (trim($kv['value']) == 'true') { $_indexed_attr[$kv['key']] = true; } else { $_indexed_attr[$kv['key']] = false; } - } else if (is_numeric($kv['value']) && in_array($kv['value'], array(0, 1))) { + } elseif (is_numeric($kv['value']) && in_array($kv['value'], array(0, 1))) { if ($kv['value'] == 1) { $_indexed_attr[$kv['key']] = true; } else { $_indexed_attr[$kv['key']] = false; } } else { - $compiler->trigger_template_error("illegal value of option flag \"{$kv['key']}\"", $compiler->lex->taglineno); + $compiler->trigger_template_error("illegal value of option flag \"{$kv['key']}\"", null, true); } // must be named attribute } else { @@ -102,15 +105,15 @@ abstract class Smarty_Internal_CompileBase { // check if all required attributes present foreach ($this->required_attributes as $attr) { if (!array_key_exists($attr, $_indexed_attr)) { - $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", $compiler->lex->taglineno); + $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true); } } - // check for unallowed attributes + // check for not allowed attributes if ($this->optional_attributes != array('_any')) { $tmp_array = array_merge($this->required_attributes, $this->optional_attributes, $this->option_flags); foreach ($_indexed_attr as $key => $dummy) { if (!in_array($key, $tmp_array) && $key !== 0) { - $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", $compiler->lex->taglineno); + $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true); } } } @@ -126,12 +129,11 @@ abstract class Smarty_Internal_CompileBase { /** * Push opening tag name on stack - * * Optionally additional data can be saved on stack * - * @param object $compiler compiler object - * @param string $openTag the opening tag's name - * @param mixed $data optional data saved + * @param object $compiler compiler object + * @param string $openTag the opening tag's name + * @param mixed $data optional data saved */ public function openTag($compiler, $openTag, $data = null) { @@ -140,12 +142,12 @@ abstract class Smarty_Internal_CompileBase { /** * Pop closing tag - * * Raise an error if this stack-top doesn't match with expected opening tags * - * @param object $compiler compiler object - * @param array|string $expectedTag the expected opening tag names - * @return mixed any type the opening tag's name or saved data + * @param object $compiler compiler object + * @param array|string $expectedTag the expected opening tag names + * + * @return mixed any type the opening tag's name or saved data */ public function closeTag($compiler, $expectedTag) { @@ -163,14 +165,14 @@ abstract class Smarty_Internal_CompileBase { } } // wrong nesting of tags - $compiler->trigger_template_error("unclosed {" . $_openTag . "} tag"); + $compiler->trigger_template_error("unclosed {$compiler->smarty->left_delimiter}" . $_openTag . + "{$compiler->smarty->right_delimiter} tag"); + return; } // wrong nesting of tags - $compiler->trigger_template_error("unexpected closing tag", $compiler->lex->taglineno); + $compiler->trigger_template_error("unexpected closing tag", null, true); + return; } - } - -?> \ No newline at end of file -- cgit v1.2.3