fix line endings

This commit is contained in:
Uwe.Tews@googlemail.com
2014-03-17 21:57:15 +00:00
parent 45fc4cd729
commit d82d54bffd
4 changed files with 2847 additions and 2847 deletions

View File

@@ -1,393 +1,393 @@
<?php <?php
/** /**
* Smarty Internal Plugin Templateparser Parsetrees * Smarty Internal Plugin Templateparser Parsetrees
* *
* These are classes to build parsetrees in the template parser * These are classes to build parsetrees in the template parser
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @author Thue Kristensen * @author Thue Kristensen
* @author Uwe Tews * @author Uwe Tews
*/ */
/** /**
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
abstract class _smarty_parsetree abstract class _smarty_parsetree
{ {
/** /**
* Parser object * Parser object
* @var object * @var object
*/ */
public $parser; public $parser;
/** /**
* Buffer content * Buffer content
* @var mixed * @var mixed
*/ */
public $data; public $data;
/** /**
* Return buffer * Return buffer
* *
* @return string buffer content * @return string buffer content
*/ */
abstract public function to_smarty_php(); abstract public function to_smarty_php();
} }
/** /**
* A complete smarty tag. * A complete smarty tag.
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_tag extends _smarty_parsetree class _smarty_tag extends _smarty_parsetree
{ {
/** /**
* Saved block nesting level * Saved block nesting level
* @var int * @var int
*/ */
public $saved_block_nesting; public $saved_block_nesting;
/** /**
* Create parse tree buffer for Smarty tag * Create parse tree buffer for Smarty tag
* *
* @param object $parser parser object * @param object $parser parser object
* @param string $data content * @param string $data content
*/ */
public function __construct($parser, $data) public function __construct($parser, $data)
{ {
$this->parser = $parser; $this->parser = $parser;
$this->data = $data; $this->data = $data;
$this->saved_block_nesting = $parser->block_nesting_level; $this->saved_block_nesting = $parser->block_nesting_level;
} }
/** /**
* Return buffer content * Return buffer content
* *
* @return string content * @return string content
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
return $this->data; return $this->data;
} }
/** /**
* Return complied code that loads the evaluated outout of buffer content into a temporary variable * Return complied code that loads the evaluated outout of buffer content into a temporary variable
* *
* @return string template code * @return string template code
*/ */
public function assign_to_var() public function assign_to_var()
{ {
$var = sprintf('$_tmp%d', ++Smarty_Internal_Templateparser::$prefix_number); $var = sprintf('$_tmp%d', ++Smarty_Internal_Templateparser::$prefix_number);
$this->parser->compiler->prefix_code[] = sprintf('<?php ob_start();?>%s<?php %s=ob_get_clean();?>', $this->data, $var); $this->parser->compiler->prefix_code[] = sprintf('<?php ob_start();?>%s<?php %s=ob_get_clean();?>', $this->data, $var);
return $var; return $var;
} }
} }
/** /**
* Code fragment inside a tag. * Code fragment inside a tag.
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_code extends _smarty_parsetree class _smarty_code extends _smarty_parsetree
{ {
/** /**
* Create parse tree buffer for code fragment * Create parse tree buffer for code fragment
* *
* @param object $parser parser object * @param object $parser parser object
* @param string $data content * @param string $data content
*/ */
public function __construct($parser, $data) public function __construct($parser, $data)
{ {
$this->parser = $parser; $this->parser = $parser;
$this->data = $data; $this->data = $data;
} }
/** /**
* Return buffer content in parentheses * Return buffer content in parentheses
* *
* @return string content * @return string content
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
return sprintf("(%s)", $this->data); return sprintf("(%s)", $this->data);
} }
} }
/** /**
* Double quoted string inside a tag. * Double quoted string inside a tag.
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_doublequoted extends _smarty_parsetree class _smarty_doublequoted extends _smarty_parsetree
{ {
/** /**
* Create parse tree buffer for double quoted string subtrees * Create parse tree buffer for double quoted string subtrees
* *
* @param object $parser parser object * @param object $parser parser object
* @param _smarty_parsetree $subtree parsetree buffer * @param _smarty_parsetree $subtree parsetree buffer
*/ */
public function __construct($parser, _smarty_parsetree $subtree) public function __construct($parser, _smarty_parsetree $subtree)
{ {
$this->parser = $parser; $this->parser = $parser;
$this->subtrees[] = $subtree; $this->subtrees[] = $subtree;
if ($subtree instanceof _smarty_tag) { if ($subtree instanceof _smarty_tag) {
$this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack); $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
} }
} }
/** /**
* Append buffer to subtree * Append buffer to subtree
* *
* @param _smarty_parsetree $subtree parsetree buffer * @param _smarty_parsetree $subtree parsetree buffer
*/ */
public function append_subtree(_smarty_parsetree $subtree) public function append_subtree(_smarty_parsetree $subtree)
{ {
$last_subtree = count($this->subtrees) - 1; $last_subtree = count($this->subtrees) - 1;
if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof _smarty_tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) { if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof _smarty_tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) {
if ($subtree instanceof _smarty_code) { if ($subtree instanceof _smarty_code) {
$this->subtrees[$last_subtree]->data .= '<?php echo ' . $subtree->data . ';?>'; $this->subtrees[$last_subtree]->data .= '<?php echo ' . $subtree->data . ';?>';
} elseif ($subtree instanceof _smarty_dq_content) { } elseif ($subtree instanceof _smarty_dq_content) {
$this->subtrees[$last_subtree]->data .= '<?php echo "' . $subtree->data . '";?>'; $this->subtrees[$last_subtree]->data .= '<?php echo "' . $subtree->data . '";?>';
} else { } else {
$this->subtrees[$last_subtree]->data .= $subtree->data; $this->subtrees[$last_subtree]->data .= $subtree->data;
} }
} else { } else {
$this->subtrees[] = $subtree; $this->subtrees[] = $subtree;
} }
if ($subtree instanceof _smarty_tag) { if ($subtree instanceof _smarty_tag) {
$this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack); $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
} }
} }
/** /**
* Merge subtree buffer content together * Merge subtree buffer content together
* *
* @return string compiled template code * @return string compiled template code
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
$code = ''; $code = '';
foreach ($this->subtrees as $subtree) { foreach ($this->subtrees as $subtree) {
if ($code !== "") { if ($code !== "") {
$code .= "."; $code .= ".";
} }
if ($subtree instanceof _smarty_tag) { if ($subtree instanceof _smarty_tag) {
$more_php = $subtree->assign_to_var(); $more_php = $subtree->assign_to_var();
} else { } else {
$more_php = $subtree->to_smarty_php(); $more_php = $subtree->to_smarty_php();
} }
$code .= $more_php; $code .= $more_php;
if (!$subtree instanceof _smarty_dq_content) { if (!$subtree instanceof _smarty_dq_content) {
$this->parser->compiler->has_variable_string = true; $this->parser->compiler->has_variable_string = true;
} }
} }
return $code; return $code;
} }
} }
/** /**
* Raw chars as part of a double quoted string. * Raw chars as part of a double quoted string.
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_dq_content extends _smarty_parsetree class _smarty_dq_content extends _smarty_parsetree
{ {
/** /**
* Create parse tree buffer with string content * Create parse tree buffer with string content
* *
* @param object $parser parser object * @param object $parser parser object
* @param string $data string section * @param string $data string section
*/ */
public function __construct($parser, $data) public function __construct($parser, $data)
{ {
$this->parser = $parser; $this->parser = $parser;
$this->data = $data; $this->data = $data;
} }
/** /**
* Return content as double quoted string * Return content as double quoted string
* *
* @return string doubled quoted string * @return string doubled quoted string
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
return '"' . $this->data . '"'; return '"' . $this->data . '"';
} }
} }
/** /**
* Template element * Template element
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_template_buffer extends _smarty_parsetree class _smarty_template_buffer extends _smarty_parsetree
{ {
/** /**
* Array of template elements * Array of template elements
* *
* @var array * @var array
*/ */
public $subtrees = Array(); public $subtrees = Array();
/** /**
* Create root of parse tree for template elements * Create root of parse tree for template elements
* *
* @param object $parser parse object * @param object $parser parse object
*/ */
public function __construct($parser) public function __construct($parser)
{ {
$this->parser = $parser; $this->parser = $parser;
} }
/** /**
* Append buffer to subtree * Append buffer to subtree
* *
* @param _smarty_parsetree $subtree * @param _smarty_parsetree $subtree
*/ */
public function append_subtree(_smarty_parsetree $subtree) public function append_subtree(_smarty_parsetree $subtree)
{ {
$this->subtrees[] = $subtree; $this->subtrees[] = $subtree;
} }
/** /**
* Sanitize and merge subtree buffers together * Sanitize and merge subtree buffers together
* *
* @return string template code content * @return string template code content
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
$code = ''; $code = '';
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) { for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
if ($key + 2 < $cnt) { if ($key + 2 < $cnt) {
if ($this->subtrees[$key] instanceof _smarty_linebreak && $this->subtrees[$key + 1] instanceof _smarty_tag && $this->subtrees[$key + 1]->data == '' && $this->subtrees[$key + 2] instanceof _smarty_linebreak) { if ($this->subtrees[$key] instanceof _smarty_linebreak && $this->subtrees[$key + 1] instanceof _smarty_tag && $this->subtrees[$key + 1]->data == '' && $this->subtrees[$key + 2] instanceof _smarty_linebreak) {
$key = $key + 1; $key = $key + 1;
continue; continue;
} }
if (substr($this->subtrees[$key]->data, -1) == '<' && $this->subtrees[$key + 1]->data == '' && substr($this->subtrees[$key + 2]->data, -1) == '?') { if (substr($this->subtrees[$key]->data, -1) == '<' && $this->subtrees[$key + 1]->data == '' && substr($this->subtrees[$key + 2]->data, -1) == '?') {
$key = $key + 2; $key = $key + 2;
continue; continue;
} }
} }
if (substr($code, -1) == '<') { if (substr($code, -1) == '<') {
$subtree = $this->subtrees[$key]->to_smarty_php(); $subtree = $this->subtrees[$key]->to_smarty_php();
if (substr($subtree, 0, 1) == '?') { if (substr($subtree, 0, 1) == '?') {
$code = substr($code, 0, strlen($code) - 1) . '<<?php ?>?' . substr($subtree, 1); $code = substr($code, 0, strlen($code) - 1) . '<<?php ?>?' . substr($subtree, 1);
} elseif ($this->parser->asp_tags && substr($subtree, 0, 1) == '%') { } elseif ($this->parser->asp_tags && substr($subtree, 0, 1) == '%') {
$code = substr($code, 0, strlen($code) - 1) . '<<?php ?>%' . substr($subtree, 1); $code = substr($code, 0, strlen($code) - 1) . '<<?php ?>%' . substr($subtree, 1);
} else { } else {
$code .= $subtree; $code .= $subtree;
} }
continue; continue;
} }
if ($this->parser->asp_tags && substr($code, -1) == '%') { if ($this->parser->asp_tags && substr($code, -1) == '%') {
$subtree = $this->subtrees[$key]->to_smarty_php(); $subtree = $this->subtrees[$key]->to_smarty_php();
if (substr($subtree, 0, 1) == '>') { if (substr($subtree, 0, 1) == '>') {
$code = substr($code, 0, strlen($code) - 1) . '%<?php ?>>' . substr($subtree, 1); $code = substr($code, 0, strlen($code) - 1) . '%<?php ?>>' . substr($subtree, 1);
} else { } else {
$code .= $subtree; $code .= $subtree;
} }
continue; continue;
} }
if (substr($code, -1) == '?') { if (substr($code, -1) == '?') {
$subtree = $this->subtrees[$key]->to_smarty_php(); $subtree = $this->subtrees[$key]->to_smarty_php();
if (substr($subtree, 0, 1) == '>') { if (substr($subtree, 0, 1) == '>') {
$code = substr($code, 0, strlen($code) - 1) . '?<?php ?>>' . substr($subtree, 1); $code = substr($code, 0, strlen($code) - 1) . '?<?php ?>>' . substr($subtree, 1);
} else { } else {
$code .= $subtree; $code .= $subtree;
} }
continue; continue;
} }
$code .= $this->subtrees[$key]->to_smarty_php(); $code .= $this->subtrees[$key]->to_smarty_php();
} }
return $code; return $code;
} }
} }
/** /**
* template text * template text
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_text extends _smarty_parsetree class _smarty_text extends _smarty_parsetree
{ {
/** /**
* Create template text buffer * Create template text buffer
* *
* @param object $parser parser object * @param object $parser parser object
* @param string $data text * @param string $data text
*/ */
public function __construct($parser, $data) public function __construct($parser, $data)
{ {
$this->parser = $parser; $this->parser = $parser;
$this->data = $data; $this->data = $data;
} }
/** /**
* Return buffer content * Return buffer content
* *
* @return strint text * @return strint text
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
return $this->data; return $this->data;
} }
} }
/** /**
* template linebreaks * template linebreaks
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @ignore * @ignore
*/ */
class _smarty_linebreak extends _smarty_parsetree class _smarty_linebreak extends _smarty_parsetree
{ {
/** /**
* Create buffer with linebreak content * Create buffer with linebreak content
* *
* @param object $parser parser object * @param object $parser parser object
* @param string $data linebreak string * @param string $data linebreak string
*/ */
public function __construct($parser, $data) public function __construct($parser, $data)
{ {
$this->parser = $parser; $this->parser = $parser;
$this->data = $data; $this->data = $data;
} }
/** /**
* Return linebrak * Return linebrak
* *
* @return string linebreak * @return string linebreak
*/ */
public function to_smarty_php() public function to_smarty_php()
{ {
return $this->data; return $this->data;
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff