From ab5d8d4e07bb3c8230d0285ef8902ef1979fce51 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 18 Oct 2018 02:39:34 +0200 Subject: Updating Smarty --- .../sysplugins/smarty_internal_parsetree_dq.php | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 lib/smarty/sysplugins/smarty_internal_parsetree_dq.php (limited to 'lib/smarty/sysplugins/smarty_internal_parsetree_dq.php') diff --git a/lib/smarty/sysplugins/smarty_internal_parsetree_dq.php b/lib/smarty/sysplugins/smarty_internal_parsetree_dq.php new file mode 100644 index 0000000..8655f58 --- /dev/null +++ b/lib/smarty/sysplugins/smarty_internal_parsetree_dq.php @@ -0,0 +1,95 @@ +subtrees[] = $subtree; + if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { + $parser->block_nesting_level = count($parser->compiler->_tag_stack); + } + } + + /** + * Append buffer to subtree + * + * @param \Smarty_Internal_Templateparser $parser + * @param Smarty_Internal_ParseTree $subtree parse tree buffer + */ + public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree) + { + $last_subtree = count($this->subtrees) - 1; + if ($last_subtree >= 0 && $this->subtrees[ $last_subtree ] instanceof Smarty_Internal_ParseTree_Tag + && $this->subtrees[ $last_subtree ]->saved_block_nesting < $parser->block_nesting_level + ) { + if ($subtree instanceof Smarty_Internal_ParseTree_Code) { + $this->subtrees[ $last_subtree ]->data = + $parser->compiler->appendCode( + $this->subtrees[ $last_subtree ]->data, + 'data . ';?>' + ); + } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) { + $this->subtrees[ $last_subtree ]->data = + $parser->compiler->appendCode( + $this->subtrees[ $last_subtree ]->data, + 'data . '";?>' + ); + } else { + $this->subtrees[ $last_subtree ]->data = + $parser->compiler->appendCode($this->subtrees[ $last_subtree ]->data, $subtree->data); + } + } else { + $this->subtrees[] = $subtree; + } + if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { + $parser->block_nesting_level = count($parser->compiler->_tag_stack); + } + } + + /** + * Merge subtree buffer content together + * + * @param \Smarty_Internal_Templateparser $parser + * + * @return string compiled template code + */ + public function to_smarty_php(Smarty_Internal_Templateparser $parser) + { + $code = ''; + foreach ($this->subtrees as $subtree) { + if ($code !== '') { + $code .= '.'; + } + if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { + $more_php = $subtree->assign_to_var($parser); + } else { + $more_php = $subtree->to_smarty_php($parser); + } + $code .= $more_php; + if (!$subtree instanceof Smarty_Internal_ParseTree_DqContent) { + $parser->compiler->has_variable_string = true; + } + } + return $code; + } +} -- cgit v1.2.3