summaryrefslogtreecommitdiff
path: root/lib/smarty/sysplugins/smarty_internal_parsetree_dq.php
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-10-18 02:39:34 +0200
committeremkael <emkael@tlen.pl>2018-10-18 02:39:42 +0200
commitab5d8d4e07bb3c8230d0285ef8902ef1979fce51 (patch)
tree0b955e585cb2fdbc7207392a5f2c97d610b6a5bc /lib/smarty/sysplugins/smarty_internal_parsetree_dq.php
parentc055ce2ab60c6582bad3e5babcb1d00384fde78a (diff)
Updating Smarty
Diffstat (limited to 'lib/smarty/sysplugins/smarty_internal_parsetree_dq.php')
-rw-r--r--lib/smarty/sysplugins/smarty_internal_parsetree_dq.php95
1 files changed, 95 insertions, 0 deletions
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 @@
+<?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;
+ }
+}