aboutsummaryrefslogtreecommitdiffstats
path: root/include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2015-12-30 16:21:32 +0100
committerplegall <plg@piwigo.org>2015-12-30 16:21:32 +0100
commit3ec3cbe6cec5968d29cb11af139123191f4cb4ee (patch)
tree34aecd51071d63f8df1862a1a11898d8c43fe68a /include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
parent6ba0148e646b2a193dc4111bb0a443d8c193e646 (diff)
parent1681b02ee98c2deb740d394280a2a685170bc72e (diff)
Merge branch 'bug/385-php7'
Diffstat (limited to 'include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php')
-rw-r--r--include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php b/include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
new file mode 100644
index 000000000..607389cb5
--- /dev/null
+++ b/include/smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
@@ -0,0 +1,88 @@
+<?php
+
+/**
+ * Double quoted string inside a tag.
+ *
+ * @package Smarty
+ * @subpackage Compiler
+ * @ignore
+ */
+
+/**
+ * Double quoted string inside a tag.
+ *
+ * @package Smarty
+ * @subpackage Compiler
+ * @ignore
+ */
+class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
+{
+ /**
+ * Create parse tree buffer for double quoted string subtrees
+ *
+ * @param object $parser parser object
+ * @param Smarty_Internal_ParseTree $subtree parse tree buffer
+ */
+ public function __construct($parser, Smarty_Internal_ParseTree $subtree)
+ {
+ $this->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, '<?php echo ' . $subtree->data . ';?>');
+ } elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
+ $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->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;
+ }
+}