1
0
This repository has been archived on 2025-06-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
LuckyCoinkydink/bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
Ian b19d6137fb Smarty bugfix releases, since last upgrade, to 3.1.25
Will now compile vastly better!

Please read change_log.txt and NEW_FEATURES.txt

We may want to use some of these new features in 2.1, which briefly are about:
Namespace support within templates, Security, Compiled Templates, Debugging
2015-06-16 12:28:49 +02:00

87 lines
2.9 KiB
PHP

<?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->parser = $parser;
$this->subtrees[] = $subtree;
if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
$this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
}
}
/**
* Append buffer to subtree
*
* @param Smarty_Internal_ParseTree $subtree parse tree buffer
*/
public function append_subtree(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 < $this->parser->block_nesting_level) {
if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
$this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
} elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
$this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
} else {
$this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
}
} else {
$this->subtrees[] = $subtree;
}
if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
$this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
}
}
/**
* Merge subtree buffer content together
*
* @return string compiled template code
*/
public function to_smarty_php()
{
$code = '';
foreach ($this->subtrees as $subtree) {
if ($code !== "") {
$code .= ".";
}
if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
$more_php = $subtree->assign_to_var();
} else {
$more_php = $subtree->to_smarty_php();
}
$code .= $more_php;
if (!$subtree instanceof Smarty_Internal_ParseTree_DqContent) {
$this->parser->compiler->has_variable_string = true;
}
}
return $code;
}
}