mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-02 17:34:26 +02:00
Rewrote all Compile and Compiler classes to PSR-4
This commit is contained in:
@@ -15,12 +15,12 @@
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
* @throws SmartyException
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
function smarty_modifiercompiler_escape($params, \Smarty\Compiler\Template $compiler)
|
||||
{
|
||||
try {
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
|
@@ -14,11 +14,11 @@
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
function smarty_modifiercompiler_unescape($params, \Smarty\Compiler\Template $compiler)
|
||||
{
|
||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||
|
||||
|
@@ -15,12 +15,12 @@
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
function smarty_modifiercompiler_wordwrap($params, \Smarty\Compiler\Template $compiler)
|
||||
{
|
||||
if (!isset($params[ 1 ])) {
|
||||
$params[ 1 ] = 80;
|
||||
|
@@ -5,83 +5,82 @@
|
||||
* @package Smarty
|
||||
* @subpackage PluginsShared
|
||||
*/
|
||||
if (!function_exists('smarty_mb_str_replace')) {
|
||||
/**
|
||||
* Multibyte string replace
|
||||
*
|
||||
* @param string|string[] $search the string to be searched
|
||||
* @param string|string[] $replace the replacement string
|
||||
* @param string $subject the source string
|
||||
* @param int &$count number of matches found
|
||||
*
|
||||
* @return string replaced string
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
|
||||
{
|
||||
if (!is_array($search) && is_array($replace)) {
|
||||
return false;
|
||||
|
||||
/**
|
||||
* Multibyte string replace
|
||||
*
|
||||
* @param string|string[] $search the string to be searched
|
||||
* @param string|string[] $replace the replacement string
|
||||
* @param string $subject the source string
|
||||
* @param int &$count number of matches found
|
||||
*
|
||||
* @return string replaced string
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
|
||||
{
|
||||
if (!is_array($search) && is_array($replace)) {
|
||||
return false;
|
||||
}
|
||||
if (is_array($subject)) {
|
||||
// call mb_replace for each single string in $subject
|
||||
foreach ($subject as &$string) {
|
||||
$string = smarty_mb_str_replace($search, $replace, $string, $c);
|
||||
$count += $c;
|
||||
}
|
||||
if (is_array($subject)) {
|
||||
// call mb_replace for each single string in $subject
|
||||
foreach ($subject as &$string) {
|
||||
$string = smarty_mb_str_replace($search, $replace, $string, $c);
|
||||
} elseif (is_array($search)) {
|
||||
if (!is_array($replace)) {
|
||||
foreach ($search as &$string) {
|
||||
$subject = smarty_mb_str_replace($string, $replace, $subject, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} elseif (is_array($search)) {
|
||||
if (!is_array($replace)) {
|
||||
foreach ($search as &$string) {
|
||||
$subject = smarty_mb_str_replace($string, $replace, $subject, $c);
|
||||
$count += $c;
|
||||
}
|
||||
} else {
|
||||
$n = max(count($search), count($replace));
|
||||
while ($n--) {
|
||||
$subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
|
||||
$count += $c;
|
||||
next($search);
|
||||
next($replace);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$mb_reg_charset = mb_regex_encoding();
|
||||
// Check if mbstring regex is using UTF-8
|
||||
$reg_is_unicode = !strcasecmp($mb_reg_charset, "UTF-8");
|
||||
if(!$reg_is_unicode) {
|
||||
// ...and set to UTF-8 if not
|
||||
mb_regex_encoding("UTF-8");
|
||||
}
|
||||
|
||||
// See if charset used by Smarty is matching one used by regex...
|
||||
$current_charset = mb_regex_encoding();
|
||||
$convert_result = (bool)strcasecmp(\Smarty\Smarty::$_CHARSET, $current_charset);
|
||||
if($convert_result) {
|
||||
// ...convert to it if not.
|
||||
$subject = mb_convert_encoding($subject, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
$search = mb_convert_encoding($search, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
$replace = mb_convert_encoding($replace, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
$parts = mb_split(preg_quote($search), $subject ?? "") ?: array();
|
||||
// If original regex encoding was not unicode...
|
||||
if(!$reg_is_unicode) {
|
||||
// ...restore original regex encoding to avoid breaking the system.
|
||||
mb_regex_encoding($mb_reg_charset);
|
||||
}
|
||||
if($parts === false) {
|
||||
// This exception is thrown if call to mb_split failed.
|
||||
// Usually it happens, when $search or $replace are not valid for given mb_regex_encoding().
|
||||
// There may be other cases for it to fail, please file an issue if you find a reproducible one.
|
||||
throw new SmartyException("Source string is not a valid $current_charset sequence (probably)");
|
||||
}
|
||||
|
||||
$count = count($parts) - 1;
|
||||
$subject = implode($replace, $parts);
|
||||
// Convert results back to charset used by Smarty, if needed.
|
||||
if($convert_result) {
|
||||
$subject = mb_convert_encoding($subject, \Smarty\Smarty::$_CHARSET, $current_charset);
|
||||
$n = max(count($search), count($replace));
|
||||
while ($n--) {
|
||||
$subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
|
||||
$count += $c;
|
||||
next($search);
|
||||
next($replace);
|
||||
}
|
||||
}
|
||||
return $subject;
|
||||
} else {
|
||||
$mb_reg_charset = mb_regex_encoding();
|
||||
// Check if mbstring regex is using UTF-8
|
||||
$reg_is_unicode = !strcasecmp($mb_reg_charset, "UTF-8");
|
||||
if(!$reg_is_unicode) {
|
||||
// ...and set to UTF-8 if not
|
||||
mb_regex_encoding("UTF-8");
|
||||
}
|
||||
|
||||
// See if charset used by Smarty is matching one used by regex...
|
||||
$current_charset = mb_regex_encoding();
|
||||
$convert_result = (bool)strcasecmp(\Smarty\Smarty::$_CHARSET, $current_charset);
|
||||
if($convert_result) {
|
||||
// ...convert to it if not.
|
||||
$subject = mb_convert_encoding($subject, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
$search = mb_convert_encoding($search, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
$replace = mb_convert_encoding($replace, $current_charset, \Smarty\Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
$parts = mb_split(preg_quote($search), $subject ?? "") ?: array();
|
||||
// If original regex encoding was not unicode...
|
||||
if(!$reg_is_unicode) {
|
||||
// ...restore original regex encoding to avoid breaking the system.
|
||||
mb_regex_encoding($mb_reg_charset);
|
||||
}
|
||||
if($parts === false) {
|
||||
// This exception is thrown if call to mb_split failed.
|
||||
// Usually it happens, when $search or $replace are not valid for given mb_regex_encoding().
|
||||
// There may be other cases for it to fail, please file an issue if you find a reproducible one.
|
||||
throw new SmartyException("Source string is not a valid $current_charset sequence (probably)");
|
||||
}
|
||||
|
||||
$count = count($parts) - 1;
|
||||
$subject = implode($replace, $parts);
|
||||
// Convert results back to charset used by Smarty, if needed.
|
||||
if($convert_result) {
|
||||
$subject = mb_convert_encoding($subject, \Smarty\Smarty::$_CHARSET, $current_charset);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $subject;
|
||||
}
|
@@ -23,13 +23,13 @@ class Append extends Assign
|
||||
* Compiles code for the {append} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in parent class
|
||||
$this->required_attributes = array('var', 'value');
|
||||
|
@@ -28,14 +28,14 @@ class Assign extends CompileBase
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = array('nocache', 'noscope');
|
||||
protected $option_flags = array('nocache', 'noscope');
|
||||
|
||||
/**
|
||||
* Valid scope names
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $valid_scopes = array(
|
||||
protected $valid_scopes = array(
|
||||
'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
|
||||
'root' => Smarty::SCOPE_ROOT, 'global' => Smarty::SCOPE_GLOBAL,
|
||||
'tpl_root' => Smarty::SCOPE_TPL_ROOT, 'smarty' => Smarty::SCOPE_SMARTY
|
||||
@@ -45,13 +45,13 @@ class Assign extends CompileBase
|
||||
* Compiles code for the {assign} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// the following must be assigned at runtime because it will be overwritten in Append
|
||||
$this->required_attributes = array('var', 'value');
|
||||
|
@@ -202,11 +202,11 @@ abstract class Base {
|
||||
* Compiles code for the tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
abstract public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null);
|
||||
abstract public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null);
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\ParseTree\Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Class
|
||||
@@ -42,7 +41,7 @@ class Block extends Inheritance {
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = ['hide', 'nocache'];
|
||||
protected $option_flags = ['hide', 'nocache'];
|
||||
|
||||
/**
|
||||
* Attribute definition: Overwrites base class.
|
||||
@@ -56,10 +55,10 @@ class Block extends Inheritance {
|
||||
* Compiles code for the {block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
if (!isset($compiler->_cache['blockNesting'])) {
|
||||
$compiler->_cache['blockNesting'] = 0;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\ParseTree\Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile BlockClose Class
|
||||
@@ -14,12 +14,12 @@ class BlockClose extends Inheritance {
|
||||
* Compiles code for the {/block} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching] = $this->closeTag($compiler, ['block']);
|
||||
// init block parameter
|
||||
|
@@ -10,9 +10,6 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\ForeachTag;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Break Class
|
||||
*
|
||||
@@ -48,12 +45,12 @@ class BreakTag extends Base {
|
||||
* Compiles code for the {break} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$levels, $foreachLevels] = $this->checkLevels($args, $compiler);
|
||||
$output = "<?php ";
|
||||
@@ -73,12 +70,12 @@ class BreakTag extends Base {
|
||||
* check attributes and return array of break and foreach levels
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return array
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function checkLevels($args, Smarty_Internal_TemplateCompilerBase $compiler) {
|
||||
public function checkLevels($args, \Smarty\Compiler\Template $compiler) {
|
||||
static $_is_loopy = ['for' => true, 'foreach' => true, 'while' => true, 'section' => true];
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
@@ -50,7 +50,7 @@ class Call extends Base
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Capture Class
|
||||
*
|
||||
@@ -31,13 +29,13 @@ class Capture extends Base {
|
||||
/**
|
||||
* Compiles code for the {$smarty.capture.xxx}
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public static function compileSpecialVariable(
|
||||
Smarty_Internal_TemplateCompilerBase $compiler,
|
||||
\Smarty\Compiler\Template $compiler,
|
||||
$parameter = null
|
||||
) {
|
||||
return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl' .
|
||||
@@ -48,12 +46,12 @@ class Capture extends Base {
|
||||
* Compiles code for the {capture} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param null $parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
||||
$buffer = $_attr['name'] ?? "'default'";
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Captureclose Class
|
||||
@@ -24,12 +24,12 @@ class CaptureClose extends Base {
|
||||
* Compiles code for the {/capture} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param null $parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, '/capture');
|
||||
// must endblock be nocache?
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Child Class
|
||||
@@ -45,13 +45,13 @@ class Child extends Base {
|
||||
* Compiles code for the {child} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$tag = isset($parameter[0]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Config Load Class
|
||||
@@ -68,12 +68,12 @@ class ConfigLoad extends Base {
|
||||
* Compiles code for the {config_load} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Debug Class
|
||||
@@ -29,7 +29,7 @@ class Debug extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes, may trigger errors
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ElseIf Class
|
||||
@@ -16,13 +16,13 @@ class ElseIfTag extends Base {
|
||||
* Compiles code for the {elseif} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
[$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, ['if', 'elseif']);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Else Class
|
||||
@@ -16,11 +16,11 @@ class ElseTag extends Base {
|
||||
* Compiles code for the {else} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
[$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, ['if', 'elseif']);
|
||||
$this->openTag($compiler, 'else', [$nesting, $compiler->tag_nocache]);
|
||||
return '<?php } else { ?>';
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Eval Class
|
||||
@@ -53,7 +53,7 @@ class EvalTag extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if (isset($_attr['assign'])) {
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile extend Class
|
||||
@@ -49,13 +49,13 @@ class ExtendsTag extends Inheritance {
|
||||
* Compiles code for the {extends} tag extends: resource
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
@@ -96,13 +96,13 @@ class ExtendsTag extends Inheritance {
|
||||
/**
|
||||
* Add code for inheritance endChild() method to end of template
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
* @param null|string $template optional inheritance parent template
|
||||
*
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler, $template = null) {
|
||||
private function compileEndChild(\Smarty\Compiler\Template $compiler, $template = null) {
|
||||
$inlineUids = '';
|
||||
if (isset($template) && $compiler->smarty->merge_compiled_includes) {
|
||||
$code = $compiler->compileTag('include', [$template, ['scope' => 'parent']]);
|
||||
@@ -122,13 +122,13 @@ class ExtendsTag extends Inheritance {
|
||||
/**
|
||||
* Add code for including subtemplate to end of template
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
* @param string $template subtemplate name
|
||||
*
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $template) {
|
||||
private function compileInclude(\Smarty\Compiler\Template $compiler, $template) {
|
||||
$compiler->parser->template_postfix[] = new \Smarty\ParseTree\Tag(
|
||||
$compiler->parser,
|
||||
$compiler->compileTag(
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forclose Class
|
||||
@@ -29,7 +29,7 @@ class ForClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
// check and get attributes
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Forelse Class
|
||||
@@ -21,7 +21,7 @@ class ForElse extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$this->getAttributes($compiler, $args);
|
||||
[$openTag, $nocache] = $this->closeTag($compiler, ['for']);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile For Class
|
||||
@@ -28,7 +28,7 @@ class ForTag extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
if ($parameter === 0) {
|
||||
$this->required_attributes = ['start', 'to'];
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_Compile_Foreach;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachclose Class
|
||||
@@ -25,12 +25,12 @@ class ForeachClose extends Base {
|
||||
* Compiles code for the {/foreach} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreachelse Class
|
||||
@@ -16,11 +16,11 @@ class ForeachElse extends Base {
|
||||
* Compiles code for the {foreachelse} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$this->getAttributes($compiler, $args);
|
||||
[$openTag, $nocache, $local, $itemVar, $restore] = $this->closeTag($compiler, ['foreach']);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile ForeachSection Class
|
||||
@@ -78,11 +78,11 @@ abstract class ForeachSection extends Base {
|
||||
* Scan sources for used tag attributes
|
||||
*
|
||||
* @param array $attributes
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
protected function scanForProperties($attributes, Smarty_Internal_TemplateCompilerBase $compiler) {
|
||||
protected function scanForProperties($attributes, \Smarty\Compiler\Template $compiler) {
|
||||
$this->propertyPreg = '~(';
|
||||
$this->startOffset = 1;
|
||||
$this->resultOffsets = [];
|
||||
@@ -151,20 +151,20 @@ abstract class ForeachSection extends Base {
|
||||
/**
|
||||
* Find matches in template source
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*/
|
||||
private function matchTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler) {
|
||||
private function matchTemplateSource(\Smarty\Compiler\Template $compiler) {
|
||||
$this->matchProperty($compiler->parser->lex->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find matches in all parent template source
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function matchParentTemplateSource(Smarty_Internal_TemplateCompilerBase $compiler) {
|
||||
private function matchParentTemplateSource(\Smarty\Compiler\Template $compiler) {
|
||||
// search parent compiler template source
|
||||
$nextCompiler = $compiler;
|
||||
while ($nextCompiler !== $nextCompiler->parent_compiler) {
|
||||
@@ -190,13 +190,13 @@ abstract class ForeachSection extends Base {
|
||||
/**
|
||||
* Compiles code for the {$smarty.foreach.xxx} or {$smarty.section.xxx}tag
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compileSpecialVariable(Smarty_Internal_TemplateCompilerBase $compiler, $parameter) {
|
||||
public function compileSpecialVariable(\Smarty\Compiler\Template $compiler, $parameter) {
|
||||
$tag = smarty_strtolower_ascii(trim($parameter[0], '"\''));
|
||||
$name = isset($parameter[1]) ? $compiler->getId($parameter[1]) : false;
|
||||
if (!$name) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Foreach Class
|
||||
@@ -75,13 +75,13 @@ class ForeachTag extends ForeachSection {
|
||||
* Compiles code for the {foreach} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
// init
|
||||
$this->isNamed = false;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Functionclose Class
|
||||
@@ -31,11 +31,11 @@ class FunctionClose extends Base {
|
||||
* Compiles code for the {/function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object|\Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param object|\Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->compiler = $compiler;
|
||||
$saved_data = $this->closeTag($compiler, ['function']);
|
||||
$_attr = $saved_data[0];
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Class
|
||||
@@ -40,12 +40,12 @@ class FunctionTag extends Base {
|
||||
* Compiles code for the {function} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return bool true
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
|
@@ -12,7 +12,7 @@ namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\Assign;
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ifclose Class
|
||||
@@ -26,11 +26,11 @@ class IfClose extends Base {
|
||||
* Compiles code for the {/if} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
$compiler->tag_nocache = true;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile If Class
|
||||
@@ -16,13 +16,13 @@ class IfTag extends Base {
|
||||
* Compiles code for the {if} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$this->openTag($compiler, 'if', [1, $compiler->nocache]);
|
||||
|
@@ -10,10 +10,10 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compiler\Template;
|
||||
use Smarty\Smarty;
|
||||
use Smarty_Internal_SmartyTemplateCompiler;
|
||||
use Smarty_Internal_Template;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
use Smarty_Resource;
|
||||
use Smarty_Template_Compiled;
|
||||
|
||||
@@ -77,14 +77,14 @@ class IncludeTag extends Base {
|
||||
* Compiles code for the {include} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param Smarty_Internal_SmartyTemplateCompiler $compiler compiler object
|
||||
* @param Template $compiler compiler object
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$uid = $t_hash = null;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -288,7 +288,7 @@ class IncludeTag extends Base {
|
||||
/**
|
||||
* Compile inline sub template
|
||||
*
|
||||
* @param \Smarty_Internal_SmartyTemplateCompiler $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param string $t_hash
|
||||
*
|
||||
@@ -297,9 +297,9 @@ class IncludeTag extends Base {
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compileInlineTemplate(
|
||||
Smarty_Internal_SmartyTemplateCompiler $compiler,
|
||||
Smarty_Internal_Template $tpl,
|
||||
$t_hash
|
||||
Template $compiler,
|
||||
Smarty_Internal_Template $tpl,
|
||||
$t_hash
|
||||
) {
|
||||
$uid = $tpl->source->type . $tpl->source->uid;
|
||||
if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
|
||||
|
@@ -22,10 +22,10 @@ abstract class Inheritance extends \Smarty\Compile\Base
|
||||
/**
|
||||
* Compile inheritance initialization code as prefix
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
* @param bool|false $initChildSequence if true force child template
|
||||
*/
|
||||
public static function postCompile(\Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
public static function postCompile(\Smarty\Compiler\Template $compiler, $initChildSequence = false)
|
||||
{
|
||||
$compiler->prefixCompiledCode .= "<?php \$_smarty_tpl->_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " .
|
||||
var_export($initChildSequence, true) . ");\n?>\n";
|
||||
@@ -34,10 +34,10 @@ abstract class Inheritance extends \Smarty\Compile\Base
|
||||
/**
|
||||
* Register post compile callback to compile inheritance initialization code
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
* @param bool|false $initChildSequence if true force child template
|
||||
*/
|
||||
public function registerInit(\Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false)
|
||||
public function registerInit(\Smarty\Compiler\Template $compiler, $initChildSequence = false)
|
||||
{
|
||||
if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) {
|
||||
$compiler->registerPostCompileCallback(
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Variable;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Insert Class
|
||||
@@ -49,13 +49,13 @@ class Insert extends Base {
|
||||
* Compiles code for the {insert} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$nocacheParam = $compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Ldelim Class
|
||||
@@ -25,12 +25,12 @@ class Ldelim extends Base {
|
||||
* This tag does output the left delimiter
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Make_Nocache Class
|
||||
@@ -47,11 +47,11 @@ class MakeNocache extends Base {
|
||||
* Compiles code for the {make_nocache} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($compiler->template->caching) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Nocache Class
|
||||
@@ -17,18 +17,18 @@ class Nocache extends Base {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $option_flags = [];
|
||||
protected $option_flags = [];
|
||||
|
||||
/**
|
||||
* Compiles code for the {nocache} tag
|
||||
* This tag does not generate compiled output. It only sets a compiler flag.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->getAttributes($compiler, $args);
|
||||
$this->openTag($compiler, 'nocache', [$compiler->nocache]);
|
||||
// enter nocache mode
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Nocacheclose Class
|
||||
@@ -25,11 +25,11 @@ class NocacheClose extends Base {
|
||||
* This tag does not generate compiled output. It only sets a compiler flag.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// leave nocache mode
|
||||
[$compiler->nocache] = $this->closeTag($compiler, ['nocache']);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Block Plugin Class
|
||||
@@ -39,7 +39,7 @@ class PrivateBlockPlugin extends Base {
|
||||
* Compiles code for the execution of block plugin
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of block plugin
|
||||
* @param string $function PHP function name
|
||||
@@ -48,7 +48,7 @@ class PrivateBlockPlugin extends Base {
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
if (!isset($tag[5]) || substr($tag, -5) !== 'close') {
|
||||
// opening tag of block plugin
|
||||
// check and get attributes
|
||||
@@ -104,14 +104,14 @@ class PrivateBlockPlugin extends Base {
|
||||
/**
|
||||
* Setup callback and parameter array
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
* @param array $_attr attributes
|
||||
* @param string $tag
|
||||
* @param string $function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) {
|
||||
protected function setup(\Smarty\Compiler\Template $compiler, $_attr, $tag, $function) {
|
||||
$_paramsArray = [];
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Function Plugin Class
|
||||
@@ -41,7 +41,7 @@ class PrivateFunctionPlugin extends Base {
|
||||
* Compiles code for the execution of function plugin
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of function plugin
|
||||
* @param string $function PHP function name
|
||||
@@ -50,7 +50,7 @@ class PrivateFunctionPlugin extends Base {
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
unset($_attr['nocache']);
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Modifier Class
|
||||
@@ -24,14 +24,14 @@ class PrivateModifier extends Base {
|
||||
* Compiles code for modifier execution
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter['value'];
|
||||
|
@@ -10,8 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\PrivateBlockPlugin;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Object Block Function Class
|
||||
@@ -24,14 +23,14 @@ class PrivateObjectBlockFunction extends PrivateBlockPlugin {
|
||||
/**
|
||||
* Setup callback and parameter array
|
||||
*
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param Template $compiler
|
||||
* @param array $_attr attributes
|
||||
* @param string $tag
|
||||
* @param string $function
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) {
|
||||
protected function setup(Template $compiler, $_attr, $tag, $function) {
|
||||
$_paramsArray = [];
|
||||
foreach ($_attr as $_key => $_value) {
|
||||
if (is_int($_key)) {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Object Function Class
|
||||
@@ -32,7 +32,7 @@ class PrivateObjectFunction extends Base {
|
||||
* Compiles code for the execution of function plugin
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of function
|
||||
* @param string $function name of method to call
|
||||
@@ -41,7 +41,7 @@ class PrivateObjectFunction extends Base {
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
unset($_attr['nocache']);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Print Expression Class
|
||||
@@ -35,19 +35,19 @@ class PrivatePrintExpression extends Base {
|
||||
* @var array
|
||||
* @see Base
|
||||
*/
|
||||
public $option_flags = ['nocache', 'nofilter'];
|
||||
protected $option_flags = ['nocache', 'nofilter'];
|
||||
|
||||
/**
|
||||
* Compiles code for generating output from any expression
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$output = $parameter['value'];
|
||||
@@ -133,14 +133,14 @@ class PrivatePrintExpression extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param string $name name of variable filter
|
||||
* @param string $output embedded output
|
||||
*
|
||||
* @return string
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
private function compile_variable_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output) {
|
||||
private function compile_variable_filter(\Smarty\Compiler\Template $compiler, $name, $output) {
|
||||
$function = $compiler->getPlugin($name, 'variablefilter');
|
||||
if ($function) {
|
||||
return "{$function}({$output},\$_smarty_tpl)";
|
||||
|
@@ -10,7 +10,8 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
use Smarty\Smarty;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Registered Function Class
|
||||
@@ -32,7 +33,7 @@ class PrivateRegisteredFunction extends Base {
|
||||
* Compiles code for the execution of a registered function
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
* @param string $tag name of function
|
||||
*
|
||||
@@ -40,15 +41,15 @@ class PrivateRegisteredFunction extends Base {
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
unset($_attr['nocache']);
|
||||
if (isset($compiler->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_FUNCTION][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_FUNCTION][$tag];
|
||||
if (isset($compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
|
||||
$tag_info = $compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
$is_registered = true;
|
||||
} else {
|
||||
$tag_info = $compiler->default_handler_plugins[\Smarty\Smarty::PLUGIN_FUNCTION][$tag];
|
||||
$tag_info = $compiler->default_handler_plugins[Smarty::PLUGIN_FUNCTION][$tag];
|
||||
$is_registered = false;
|
||||
}
|
||||
// not cacheable?
|
||||
|
@@ -14,7 +14,7 @@ use Smarty\Compile\Capture;
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty\Compile\ForeachTag;
|
||||
use Smarty\Compile\Section;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile special Smarty Variable Class
|
||||
@@ -28,13 +28,13 @@ class PrivateSpecialVariable extends Base {
|
||||
* Compiles code for the special $smarty variables
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param $parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
|
||||
$variable = smarty_strtolower_ascii($compiler->getId($_index[0]));
|
||||
if ($variable === false) {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Rdelim Class
|
||||
@@ -25,12 +25,12 @@ class Rdelim extends Ldelim {
|
||||
* This tag does output the right delimiter.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
parent::compile($args, $compiler);
|
||||
return $compiler->smarty->right_delimiter;
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Section Class
|
||||
@@ -78,13 +78,13 @@ class Section extends ForeachSection {
|
||||
* Compiles code for the {section} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
@@ -12,7 +12,7 @@ namespace Smarty\Compile;
|
||||
|
||||
use Smarty\Compile\ForeachSection;
|
||||
use Smarty\Compile\Base;
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Sectionclose Class
|
||||
@@ -26,11 +26,11 @@ class SectionClose extends Base {
|
||||
* Compiles code for the {/section} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Sectionelse Class
|
||||
@@ -16,11 +16,11 @@ class SectionElse extends Base {
|
||||
* Compiles code for the {sectionelse} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$this->getAttributes($compiler, $args);
|
||||
[$openTag, $nocache, $local, $sectionVar] = $this->closeTag($compiler, ['section']);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilter Class
|
||||
@@ -16,12 +16,12 @@ class Setfilter extends Base {
|
||||
* Compiles code for setfilter tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->variable_filter_stack[] = $compiler->variable_filters;
|
||||
$compiler->variable_filters = $parameter['modifier_list'];
|
||||
// this tag does not return compiled code
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Setfilterclose Class
|
||||
@@ -25,11 +25,11 @@ class SetfilterClose extends Base {
|
||||
* This tag does not generate compiled output. It resets variable filter.
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->getAttributes($compiler, $args);
|
||||
// reset variable filter to previous state
|
||||
if (count($compiler->variable_filter_stack)) {
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Whileclose Class
|
||||
@@ -24,11 +24,11 @@ class WhileClose extends Base {
|
||||
* Compiles code for the {/while} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
// must endblock be nocache?
|
||||
if ($compiler->nocache) {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Smarty\Compile;
|
||||
|
||||
use Smarty_Internal_TemplateCompilerBase;
|
||||
use Smarty\Compiler\Template;
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile While Class
|
||||
@@ -16,13 +16,13 @@ class WhileTag extends Base {
|
||||
* Compiles code for the {while} tag
|
||||
*
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
208
src/Compiler/ConfigFile.php
Normal file
208
src/Compiler/ConfigFile.php
Normal file
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Config File Compiler
|
||||
* This is the config file compiler class. It calls the lexer and parser to
|
||||
* perform the compiling.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
namespace Smarty\Compiler;
|
||||
use Smarty;
|
||||
use Smarty_Internal_ConfigFileLexer;
|
||||
use Smarty_Internal_ConfigFileParser;
|
||||
use Smarty_Internal_Template;
|
||||
use SmartyCompilerException;
|
||||
|
||||
/**
|
||||
* Main config file compiler class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
*/
|
||||
class ConfigFile {
|
||||
|
||||
/**
|
||||
* Lexer class name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $lexer_class;
|
||||
|
||||
/**
|
||||
* Parser class name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $parser_class;
|
||||
|
||||
/**
|
||||
* Lexer object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $lex;
|
||||
|
||||
/**
|
||||
* Parser object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $parser;
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
* @var Smarty object
|
||||
*/
|
||||
public $smarty;
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
* @var Smarty_Internal_Template object
|
||||
*/
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* Compiled config data sections and variables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $config_data = [];
|
||||
|
||||
/**
|
||||
* Initialize compiler
|
||||
*
|
||||
* @param string $lexer_class class name
|
||||
* @param string $parser_class class name
|
||||
* @param Smarty $smarty global instance
|
||||
*/
|
||||
public function __construct($lexer_class, $parser_class, Smarty $smarty) {
|
||||
$this->smarty = $smarty;
|
||||
// get required plugins
|
||||
$this->lexer_class = $lexer_class;
|
||||
$this->parser_class = $parser_class;
|
||||
$this->smarty = $smarty;
|
||||
$this->config_data['sections'] = [];
|
||||
$this->config_data['vars'] = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to compile Smarty config source.
|
||||
*
|
||||
* @param Smarty_Internal_Template $template
|
||||
*
|
||||
* @return bool true if compiling succeeded, false if it failed
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compileTemplate(Smarty_Internal_Template $template) {
|
||||
$this->template = $template;
|
||||
$this->template->compiled->file_dependency[$this->template->source->uid] =
|
||||
[
|
||||
$this->template->source->filepath,
|
||||
$this->template->source->getTimeStamp(),
|
||||
$this->template->source->type,
|
||||
];
|
||||
if ($this->smarty->debugging) {
|
||||
if (!isset($this->smarty->_debug)) {
|
||||
$this->smarty->_debug = new \Smarty\Debug();
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
// init the lexer/parser to compile the config file
|
||||
/* @var Smarty_Internal_ConfigFileLexer $this- >lex */
|
||||
$this->lex = new $this->lexer_class(
|
||||
str_replace(
|
||||
[
|
||||
"\r\n",
|
||||
"\r",
|
||||
],
|
||||
"\n",
|
||||
$template->source->getContent()
|
||||
) . "\n",
|
||||
$this
|
||||
);
|
||||
/* @var Smarty_Internal_ConfigFileParser $this- >parser */
|
||||
$this->parser = new $this->parser_class($this->lex, $this);
|
||||
if (function_exists('mb_internal_encoding')
|
||||
&& function_exists('ini_get')
|
||||
&& ((int)ini_get('mbstring.func_overload')) & 2
|
||||
) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ASCII');
|
||||
} else {
|
||||
$mbEncoding = null;
|
||||
}
|
||||
if ($this->smarty->_parserdebug) {
|
||||
$this->parser->PrintTrace();
|
||||
}
|
||||
// get tokens from lexer and parse them
|
||||
while ($this->lex->yylex()) {
|
||||
if ($this->smarty->_parserdebug) {
|
||||
echo "<br>Parsing {$this->parser->yyTokenName[$this->lex->token]} Token {$this->lex->value} Line {$this->lex->line} \n";
|
||||
}
|
||||
$this->parser->doParse($this->lex->token, $this->lex->value);
|
||||
}
|
||||
// finish parsing process
|
||||
$this->parser->doParse(0, 0);
|
||||
if ($mbEncoding) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
if ($this->smarty->debugging) {
|
||||
$this->smarty->_debug->end_compile($this->template);
|
||||
}
|
||||
// template header code
|
||||
$template_header = sprintf(
|
||||
"<?php /* Smarty version %s, created on %s\n compiled from '%s' */ ?>\n",
|
||||
\Smarty\Smarty::SMARTY_VERSION,
|
||||
date("Y-m-d H:i:s"),
|
||||
str_replace('*/', '* /', $this->template->source->filepath)
|
||||
);
|
||||
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
|
||||
var_export($this->config_data, true) . '); ?>';
|
||||
return $template_header . $this->createCodeFrame($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* display compiler error messages without dying
|
||||
* If parameter $args is empty it is a parser detected syntax error.
|
||||
* In this case the parser is called to obtain information about expected tokens.
|
||||
* If parameter $args contains a string this is used as error message
|
||||
*
|
||||
* @param string $args individual error message or null
|
||||
*
|
||||
* @throws SmartyCompilerException
|
||||
*/
|
||||
public function trigger_config_file_error($args = null) {
|
||||
// get config source line which has error
|
||||
$line = $this->lex->line;
|
||||
if (isset($args)) {
|
||||
// $line--;
|
||||
}
|
||||
$match = preg_split("/\n/", $this->lex->data);
|
||||
$error_text =
|
||||
"Syntax error in config file '{$this->template->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
|
||||
if (isset($args)) {
|
||||
// individual error message
|
||||
$error_text .= $args;
|
||||
} else {
|
||||
// expected token from parser
|
||||
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
|
||||
$exp_token = $this->parser->yyTokenName[$token];
|
||||
if (isset($this->lex->smarty_token_names[$exp_token])) {
|
||||
// token type from lexer
|
||||
$expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
|
||||
} else {
|
||||
// otherwise internal token name
|
||||
$expect[] = $this->parser->yyTokenName[$token];
|
||||
}
|
||||
}
|
||||
// output parser error message
|
||||
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
||||
}
|
||||
throw new SmartyCompilerException($error_text);
|
||||
}
|
||||
}
|
1744
src/Compiler/Template.php
Normal file
1744
src/Compiler/Template.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,211 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Config File Compiler
|
||||
* This is the config file compiler class. It calls the lexer and parser to
|
||||
* perform the compiling.
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Main config file compiler class
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Config
|
||||
*/
|
||||
class Smarty_Internal_Config_File_Compiler
|
||||
{
|
||||
/**
|
||||
* Lexer class name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $lexer_class;
|
||||
|
||||
/**
|
||||
* Parser class name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $parser_class;
|
||||
|
||||
/**
|
||||
* Lexer object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $lex;
|
||||
|
||||
/**
|
||||
* Parser object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $parser;
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
* @var Smarty object
|
||||
*/
|
||||
public $smarty;
|
||||
|
||||
/**
|
||||
* Smarty object
|
||||
*
|
||||
* @var Smarty_Internal_Template object
|
||||
*/
|
||||
public $template;
|
||||
|
||||
/**
|
||||
* Compiled config data sections and variables
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $config_data = array();
|
||||
|
||||
/**
|
||||
* compiled config data must always be written
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $write_compiled_code = true;
|
||||
|
||||
/**
|
||||
* Initialize compiler
|
||||
*
|
||||
* @param string $lexer_class class name
|
||||
* @param string $parser_class class name
|
||||
* @param Smarty $smarty global instance
|
||||
*/
|
||||
public function __construct($lexer_class, $parser_class, Smarty $smarty)
|
||||
{
|
||||
$this->smarty = $smarty;
|
||||
// get required plugins
|
||||
$this->lexer_class = $lexer_class;
|
||||
$this->parser_class = $parser_class;
|
||||
$this->smarty = $smarty;
|
||||
$this->config_data[ 'sections' ] = array();
|
||||
$this->config_data[ 'vars' ] = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to compile Smarty config source.
|
||||
*
|
||||
* @param Smarty_Internal_Template $template
|
||||
*
|
||||
* @return bool true if compiling succeeded, false if it failed
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function compileTemplate(Smarty_Internal_Template $template)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->template->compiled->file_dependency[ $this->template->source->uid ] =
|
||||
array(
|
||||
$this->template->source->filepath,
|
||||
$this->template->source->getTimeStamp(),
|
||||
$this->template->source->type
|
||||
);
|
||||
if ($this->smarty->debugging) {
|
||||
if (!isset($this->smarty->_debug)) {
|
||||
$this->smarty->_debug = new \Smarty\Debug();
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
// init the lexer/parser to compile the config file
|
||||
/* @var Smarty_Internal_ConfigFileLexer $this->lex */
|
||||
$this->lex = new $this->lexer_class(
|
||||
str_replace(
|
||||
array(
|
||||
"\r\n",
|
||||
"\r"
|
||||
),
|
||||
"\n",
|
||||
$template->source->getContent()
|
||||
) . "\n",
|
||||
$this
|
||||
);
|
||||
/* @var Smarty_Internal_ConfigFileParser $this->parser */
|
||||
$this->parser = new $this->parser_class($this->lex, $this);
|
||||
if (function_exists('mb_internal_encoding')
|
||||
&& function_exists('ini_get')
|
||||
&& ((int)ini_get('mbstring.func_overload')) & 2
|
||||
) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ASCII');
|
||||
} else {
|
||||
$mbEncoding = null;
|
||||
}
|
||||
if ($this->smarty->_parserdebug) {
|
||||
$this->parser->PrintTrace();
|
||||
}
|
||||
// get tokens from lexer and parse them
|
||||
while ($this->lex->yylex()) {
|
||||
if ($this->smarty->_parserdebug) {
|
||||
echo "<br>Parsing {$this->parser->yyTokenName[$this->lex->token]} Token {$this->lex->value} Line {$this->lex->line} \n";
|
||||
}
|
||||
$this->parser->doParse($this->lex->token, $this->lex->value);
|
||||
}
|
||||
// finish parsing process
|
||||
$this->parser->doParse(0, 0);
|
||||
if ($mbEncoding) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
if ($this->smarty->debugging) {
|
||||
$this->smarty->_debug->end_compile($this->template);
|
||||
}
|
||||
// template header code
|
||||
$template_header = sprintf(
|
||||
"<?php /* Smarty version %s, created on %s\n compiled from '%s' */ ?>\n",
|
||||
\Smarty\Smarty::SMARTY_VERSION,
|
||||
date("Y-m-d H:i:s"),
|
||||
str_replace('*/', '* /' , $this->template->source->filepath)
|
||||
);
|
||||
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
|
||||
var_export($this->config_data, true) . '); ?>';
|
||||
return $template_header . $this->createCodeFrame($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* display compiler error messages without dying
|
||||
* If parameter $args is empty it is a parser detected syntax error.
|
||||
* In this case the parser is called to obtain information about expected tokens.
|
||||
* If parameter $args contains a string this is used as error message
|
||||
*
|
||||
* @param string $args individual error message or null
|
||||
*
|
||||
* @throws SmartyCompilerException
|
||||
*/
|
||||
public function trigger_config_file_error($args = null)
|
||||
{
|
||||
// get config source line which has error
|
||||
$line = $this->lex->line;
|
||||
if (isset($args)) {
|
||||
// $line--;
|
||||
}
|
||||
$match = preg_split("/\n/", $this->lex->data);
|
||||
$error_text =
|
||||
"Syntax error in config file '{$this->template->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
|
||||
if (isset($args)) {
|
||||
// individual error message
|
||||
$error_text .= $args;
|
||||
} else {
|
||||
// expected token from parser
|
||||
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
|
||||
$exp_token = $this->parser->yyTokenName[ $token ];
|
||||
if (isset($this->lex->smarty_token_names[ $exp_token ])) {
|
||||
// token type from lexer
|
||||
$expect[] = '"' . $this->lex->smarty_token_names[ $exp_token ] . '"';
|
||||
} else {
|
||||
// otherwise internal token name
|
||||
$expect[] = $this->parser->yyTokenName[ $token ];
|
||||
}
|
||||
}
|
||||
// output parser error message
|
||||
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
|
||||
}
|
||||
throw new SmartyCompilerException($error_text);
|
||||
}
|
||||
}
|
@@ -1,184 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty Internal Plugin Smarty Template Compiler Base
|
||||
* This file contains the basic classes and methods for compiling Smarty templates with lexer/parser
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class SmartyTemplateCompiler
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Compiler
|
||||
*/
|
||||
class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCompilerBase
|
||||
{
|
||||
/**
|
||||
* Lexer class name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $lexer_class;
|
||||
|
||||
/**
|
||||
* Parser class name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $parser_class;
|
||||
|
||||
/**
|
||||
* array of vars which can be compiled in local scope
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $local_var = array();
|
||||
|
||||
/**
|
||||
* array of callbacks called when the normal compile process of template is finished
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $postCompileCallbacks = array();
|
||||
|
||||
/**
|
||||
* prefix code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $prefixCompiledCode = '';
|
||||
|
||||
/**
|
||||
* postfix code
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $postfixCompiledCode = '';
|
||||
|
||||
/**
|
||||
* Initialize compiler
|
||||
*
|
||||
* @param string $lexer_class class name
|
||||
* @param string $parser_class class name
|
||||
* @param Smarty $smarty global instance
|
||||
*/
|
||||
public function __construct($lexer_class, $parser_class, Smarty $smarty)
|
||||
{
|
||||
parent::__construct($smarty);
|
||||
// get required plugins
|
||||
$this->lexer_class = $lexer_class;
|
||||
$this->parser_class = $parser_class;
|
||||
}
|
||||
|
||||
/**
|
||||
* method to compile a Smarty template
|
||||
*
|
||||
* @param mixed $_content template source
|
||||
* @param bool $isTemplateSource
|
||||
*
|
||||
* @return bool true if compiling succeeded, false if it failed
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
protected function doCompile($_content, $isTemplateSource = false)
|
||||
{
|
||||
/* here is where the compiling takes place. Smarty
|
||||
tags in the templates are replaces with PHP code,
|
||||
then written to compiled files. */
|
||||
// init the lexer/parser to compile the template
|
||||
$this->parser =
|
||||
new $this->parser_class(
|
||||
new $this->lexer_class(
|
||||
str_replace(
|
||||
array(
|
||||
"\r\n",
|
||||
"\r"
|
||||
),
|
||||
"\n",
|
||||
$_content
|
||||
),
|
||||
$this
|
||||
),
|
||||
$this
|
||||
);
|
||||
if ($isTemplateSource && $this->template->caching) {
|
||||
$this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n");
|
||||
}
|
||||
if (function_exists('mb_internal_encoding')
|
||||
&& function_exists('ini_get')
|
||||
&& ((int)ini_get('mbstring.func_overload')) & 2
|
||||
) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ASCII');
|
||||
} else {
|
||||
$mbEncoding = null;
|
||||
}
|
||||
if ($this->smarty->_parserdebug) {
|
||||
$this->parser->PrintTrace();
|
||||
$this->parser->lex->PrintTrace();
|
||||
}
|
||||
// get tokens from lexer and parse them
|
||||
while ($this->parser->lex->yylex()) {
|
||||
if ($this->smarty->_parserdebug) {
|
||||
echo "<pre>Line {$this->parser->lex->line} Parsing {$this->parser->yyTokenName[$this->parser->lex->token]} Token " .
|
||||
htmlentities($this->parser->lex->value) . "</pre>";
|
||||
}
|
||||
$this->parser->doParse($this->parser->lex->token, $this->parser->lex->value);
|
||||
}
|
||||
// finish parsing process
|
||||
$this->parser->doParse(0, 0);
|
||||
if ($mbEncoding) {
|
||||
mb_internal_encoding($mbEncoding);
|
||||
}
|
||||
// check for unclosed tags
|
||||
if (count($this->_tag_stack) > 0) {
|
||||
// get stacked info
|
||||
list($openTag, $_data) = array_pop($this->_tag_stack);
|
||||
$this->trigger_template_error(
|
||||
"unclosed {$this->smarty->left_delimiter}" . $openTag .
|
||||
"{$this->smarty->right_delimiter} tag"
|
||||
);
|
||||
}
|
||||
// call post compile callbacks
|
||||
foreach ($this->postCompileCallbacks as $cb) {
|
||||
$parameter = $cb;
|
||||
$parameter[ 0 ] = $this;
|
||||
call_user_func_array($cb[ 0 ], $parameter);
|
||||
}
|
||||
// return compiled code
|
||||
return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a post compile callback
|
||||
* - when the callback is called after template compiling the compiler object will be inserted as first parameter
|
||||
*
|
||||
* @param callback $callback
|
||||
* @param array $parameter optional parameter array
|
||||
* @param string $key optional key for callback
|
||||
* @param bool $replace if true replace existing keyed callback
|
||||
*/
|
||||
public function registerPostCompileCallback($callback, $parameter = array(), $key = null, $replace = false)
|
||||
{
|
||||
array_unshift($parameter, $callback);
|
||||
if (isset($key)) {
|
||||
if ($replace || !isset($this->postCompileCallbacks[ $key ])) {
|
||||
$this->postCompileCallbacks[ $key ] = $parameter;
|
||||
}
|
||||
} else {
|
||||
$this->postCompileCallbacks[] = $parameter;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a post compile callback
|
||||
*
|
||||
* @param string $key callback key
|
||||
*/
|
||||
public function unregisterPostCompileCallback($key)
|
||||
{
|
||||
unset($this->postCompileCallbacks[ $key ]);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,7 @@ class Smarty_Internal_Configfilelexer
|
||||
/**
|
||||
* compiler object
|
||||
*
|
||||
* @var Smarty_Internal_Config_File_Compiler
|
||||
* @var Smarty\Compiler\ConfigFile
|
||||
*/
|
||||
private $compiler = null;
|
||||
/**
|
||||
@@ -122,9 +122,9 @@ class Smarty_Internal_Configfilelexer
|
||||
* constructor
|
||||
*
|
||||
* @param string $data template source
|
||||
* @param Smarty_Internal_Config_File_Compiler $compiler
|
||||
* @param Smarty\Compiler\ConfigFile $compiler
|
||||
*/
|
||||
public function __construct($data, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
public function __construct($data, Smarty\Compiler\ConfigFile $compiler)
|
||||
{
|
||||
$this->data = $data . "\n"; //now all lines are \n-terminated
|
||||
$this->dataLength = strlen($data);
|
||||
|
@@ -84,7 +84,7 @@ class Smarty_Internal_Templatelexer
|
||||
/**
|
||||
* compiler object
|
||||
*
|
||||
* @var Smarty_Internal_TemplateCompilerBase
|
||||
* @var \Smarty\Compiler\Template
|
||||
*/
|
||||
public $compiler = null;
|
||||
|
||||
@@ -219,9 +219,9 @@ class Smarty_Internal_Templatelexer
|
||||
* constructor
|
||||
*
|
||||
* @param string $source template source
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*/
|
||||
public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function __construct($source, \Smarty\Compiler\Template $compiler)
|
||||
{
|
||||
$this->data = $source;
|
||||
$this->dataLength = strlen($this->data);
|
||||
|
@@ -59,7 +59,7 @@ class Configfile
|
||||
/**
|
||||
* compiler object
|
||||
*
|
||||
* @var Smarty_Internal_Config_File_Compiler
|
||||
* @var Smarty\Compiler\ConfigFile
|
||||
*/
|
||||
public $compiler = null;
|
||||
/**
|
||||
@@ -92,9 +92,9 @@ class Configfile
|
||||
* constructor
|
||||
*
|
||||
* @param Lexer $lex
|
||||
* @param Smarty_Internal_Config_File_Compiler $compiler
|
||||
* @param Smarty\Compiler\ConfigFile $compiler
|
||||
*/
|
||||
public function __construct(Lexer $lex, Smarty_Internal_Config_File_Compiler $compiler)
|
||||
public function __construct(Lexer $lex, Smarty\Compiler\ConfigFile $compiler)
|
||||
{
|
||||
$this->lex = $lex;
|
||||
$this->smarty = $compiler->smarty;
|
||||
|
@@ -94,7 +94,7 @@ class Smarty_Internal_Templateparser
|
||||
/**
|
||||
* compiler object
|
||||
*
|
||||
* @var Smarty_Internal_TemplateCompilerBase
|
||||
* @var \Smarty\Compiler\Template
|
||||
*/
|
||||
public $compiler = null;
|
||||
|
||||
@@ -144,9 +144,9 @@ class Smarty_Internal_Templateparser
|
||||
* constructor
|
||||
*
|
||||
* @param Smarty_Internal_Templatelexer $lex
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*/
|
||||
public function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
public function __construct(Smarty_Internal_Templatelexer $lex, \Smarty\Compiler\Template $compiler)
|
||||
{
|
||||
$this->lex = $lex;
|
||||
$this->compiler = $compiler;
|
||||
|
@@ -24,7 +24,7 @@ class CodeFrame
|
||||
* @param string $content optional template content
|
||||
* @param string $functions compiled template function and block code
|
||||
* @param bool $cache flag for cache file
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -33,7 +33,7 @@ class CodeFrame
|
||||
$content = '',
|
||||
$functions = '',
|
||||
$cache = false,
|
||||
\Smarty_Internal_TemplateCompilerBase $compiler = null
|
||||
\Smarty\Compiler\Template $compiler = null
|
||||
) {
|
||||
// build property code
|
||||
$properties[ 'version' ] = \Smarty::SMARTY_VERSION;
|
||||
|
@@ -43,7 +43,7 @@ class Smarty_Template_Config extends Smarty_Template_Source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $compiler_class = 'Smarty_Internal_Config_File_Compiler';
|
||||
public $compiler_class = 'Smarty\Compiler\ConfigFile';
|
||||
|
||||
/**
|
||||
* Name of the Class to tokenize this resource's contents with
|
||||
|
@@ -106,7 +106,7 @@ class Smarty_Template_Source
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler';
|
||||
public $compiler_class = 'Smarty\Compiler\Template';
|
||||
|
||||
/**
|
||||
* Name of the Class to tokenize this resource's contents with
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @property Smarty_Template_Compiled $compiled
|
||||
* @property Smarty_Template_Cached $cached
|
||||
* @property Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @property \Smarty\Compiler\Template $compiler
|
||||
* @property mixed|\Smarty_Template_Cached registered_plugins
|
||||
*
|
||||
* The following methods will be dynamically loaded by the extension handler when they are called.
|
||||
@@ -624,11 +624,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
* @param string $content optional template content
|
||||
* @param string $functions compiled template function and block code
|
||||
* @param bool $cache flag for cache file
|
||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler
|
||||
* @param \Smarty\Compiler\Template $compiler
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createCodeFrame($content = '', $functions = '', $cache = false, Smarty_Internal_TemplateCompilerBase $compiler = null) {
|
||||
public function createCodeFrame($content = '', $functions = '', $cache = false, \Smarty\Compiler\Template $compiler = null) {
|
||||
return \Smarty\Template\CodeFrame::create($this, $content, $functions, $cache, $compiler);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user