*** empty log message ***

This commit is contained in:
andrey
2000-11-22 16:23:19 +00:00
parent de9d9169ea
commit 08d75708ce
4 changed files with 46 additions and 14 deletions

View File

@@ -41,22 +41,36 @@ class Smarty
var $config_dir = "configs"; // directory where config files are located var $config_dir = "configs"; // directory where config files are located
var $_custom_tags = array( 'html_options' => 'smarty_func_html_options' var $custom_tags = array( 'html_options' => 'smarty_func_html_options'
); );
var $_modifiers = array( 'lower' => 'strtolower', var $modifiers = array( 'lower' => 'strtolower',
'upper' => 'strtoupper', 'upper' => 'strtoupper',
'capitalize' => 'ucwords', 'capitalize' => 'ucwords',
'escape' => 'smarty_mod_escape', 'escape' => 'smarty_mod_escape',
'truncate' => 'smarty_mod_truncate', 'truncate' => 'smarty_mod_truncate',
'spacify' => 'smarty_mod_spacify' 'spacify' => 'smarty_mod_spacify'
); );
var $global_assign = array( 'SCRIPT_NAME'
);
// internal vars // internal vars
var $_error_msg = false; // error messages var $_error_msg = false; // error messages
var $_tpl_vars = array(); var $_tpl_vars = array();
var $_sectionelse_stack = array(); // keeps track of whether section had 'else' part var $_sectionelse_stack = array(); // keeps track of whether section had 'else' part
/*======================================================================*\
Function: Smarty
Purpose: Constructor
\*======================================================================*/
function Smarty()
{
foreach ($this->global_assign as $var_name)
$this->assign($var_name, $GLOBALS[$var_name]);
}
/*======================================================================*\ /*======================================================================*\
Function: assign() Function: assign()
Purpose: assigns values to template variables Purpose: assigns values to template variables
@@ -143,10 +157,10 @@ class Smarty
// compile files // compile files
$this->_compile($match[1]); $this->_compile($match[1]);
//assemble compile directory path to file //assemble compile directory path to file
$compile_file = preg_replace("/([\.\/]*[^\/]+)(.*)/","\\1".preg_quote($this->compile_dir_ext,"/")."\\2",$tpl_file); $_compile_file = preg_replace("/([\.\/]*[^\/]+)(.*)/","\\1".preg_quote($this->compile_dir_ext,"/")."\\2",$tpl_file);
extract($this->_tpl_vars); extract($this->_tpl_vars);
include($compile_file); include($_compile_file);
} }
} }
@@ -408,7 +422,7 @@ class Smarty
return $this->left_delimiter.$tag_command.$this->right_delimiter; return $this->left_delimiter.$tag_command.$this->right_delimiter;
default: default:
if (isset($this->_custom_tags[$tag_command])) { if (isset($this->custom_tags[$tag_command])) {
return $this->_compile_custom_tag($tag_command, $tag_args); return $this->_compile_custom_tag($tag_command, $tag_args);
} else } else
/* TODO syntax error: unknown tag */ /* TODO syntax error: unknown tag */
@@ -420,7 +434,7 @@ class Smarty
function _compile_custom_tag($tag_command, $tag_args) function _compile_custom_tag($tag_command, $tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$function = $this->_custom_tags[$tag_command]; $function = $this->custom_tags[$tag_command];
foreach ($attrs as $arg_name => $arg_value) foreach ($attrs as $arg_name => $arg_value)
$arg_list[] = "'$arg_name' => $arg_value"; $arg_list[] = "'$arg_name' => $arg_value";
@@ -801,7 +815,7 @@ class Smarty
* First we lookup the modifier function name in the registered * First we lookup the modifier function name in the registered
* modifiers table. * modifiers table.
*/ */
$mod_func_name = $this->_modifiers[$modifier_name]; $mod_func_name = $this->modifiers[$modifier_name];
/* /*
* If we don't find that modifier there, we assume it's just a PHP * If we don't find that modifier there, we assume it's just a PHP

View File

@@ -2,6 +2,8 @@
Title: {#title#|capitalize} Title: {#title#|capitalize}
{$SCRIPT_NAME}
{strip} {strip}
{* A simple variable test *} {* A simple variable test *}
hello, my name is {$Name} hello, my name is {$Name}

View File

@@ -41,22 +41,36 @@ class Smarty
var $config_dir = "configs"; // directory where config files are located var $config_dir = "configs"; // directory where config files are located
var $_custom_tags = array( 'html_options' => 'smarty_func_html_options' var $custom_tags = array( 'html_options' => 'smarty_func_html_options'
); );
var $_modifiers = array( 'lower' => 'strtolower', var $modifiers = array( 'lower' => 'strtolower',
'upper' => 'strtoupper', 'upper' => 'strtoupper',
'capitalize' => 'ucwords', 'capitalize' => 'ucwords',
'escape' => 'smarty_mod_escape', 'escape' => 'smarty_mod_escape',
'truncate' => 'smarty_mod_truncate', 'truncate' => 'smarty_mod_truncate',
'spacify' => 'smarty_mod_spacify' 'spacify' => 'smarty_mod_spacify'
); );
var $global_assign = array( 'SCRIPT_NAME'
);
// internal vars // internal vars
var $_error_msg = false; // error messages var $_error_msg = false; // error messages
var $_tpl_vars = array(); var $_tpl_vars = array();
var $_sectionelse_stack = array(); // keeps track of whether section had 'else' part var $_sectionelse_stack = array(); // keeps track of whether section had 'else' part
/*======================================================================*\
Function: Smarty
Purpose: Constructor
\*======================================================================*/
function Smarty()
{
foreach ($this->global_assign as $var_name)
$this->assign($var_name, $GLOBALS[$var_name]);
}
/*======================================================================*\ /*======================================================================*\
Function: assign() Function: assign()
Purpose: assigns values to template variables Purpose: assigns values to template variables
@@ -143,10 +157,10 @@ class Smarty
// compile files // compile files
$this->_compile($match[1]); $this->_compile($match[1]);
//assemble compile directory path to file //assemble compile directory path to file
$compile_file = preg_replace("/([\.\/]*[^\/]+)(.*)/","\\1".preg_quote($this->compile_dir_ext,"/")."\\2",$tpl_file); $_compile_file = preg_replace("/([\.\/]*[^\/]+)(.*)/","\\1".preg_quote($this->compile_dir_ext,"/")."\\2",$tpl_file);
extract($this->_tpl_vars); extract($this->_tpl_vars);
include($compile_file); include($_compile_file);
} }
} }
@@ -408,7 +422,7 @@ class Smarty
return $this->left_delimiter.$tag_command.$this->right_delimiter; return $this->left_delimiter.$tag_command.$this->right_delimiter;
default: default:
if (isset($this->_custom_tags[$tag_command])) { if (isset($this->custom_tags[$tag_command])) {
return $this->_compile_custom_tag($tag_command, $tag_args); return $this->_compile_custom_tag($tag_command, $tag_args);
} else } else
/* TODO syntax error: unknown tag */ /* TODO syntax error: unknown tag */
@@ -420,7 +434,7 @@ class Smarty
function _compile_custom_tag($tag_command, $tag_args) function _compile_custom_tag($tag_command, $tag_args)
{ {
$attrs = $this->_parse_attrs($tag_args); $attrs = $this->_parse_attrs($tag_args);
$function = $this->_custom_tags[$tag_command]; $function = $this->custom_tags[$tag_command];
foreach ($attrs as $arg_name => $arg_value) foreach ($attrs as $arg_name => $arg_value)
$arg_list[] = "'$arg_name' => $arg_value"; $arg_list[] = "'$arg_name' => $arg_value";
@@ -801,7 +815,7 @@ class Smarty
* First we lookup the modifier function name in the registered * First we lookup the modifier function name in the registered
* modifiers table. * modifiers table.
*/ */
$mod_func_name = $this->_modifiers[$modifier_name]; $mod_func_name = $this->modifiers[$modifier_name];
/* /*
* If we don't find that modifier there, we assume it's just a PHP * If we don't find that modifier there, we assume it's just a PHP

View File

@@ -2,6 +2,8 @@
Title: {#title#|capitalize} Title: {#title#|capitalize}
{$SCRIPT_NAME}
{strip} {strip}
{* A simple variable test *} {* A simple variable test *}
hello, my name is {$Name} hello, my name is {$Name}