update function headers

This commit is contained in:
mohrt
2001-03-02 21:48:33 +00:00
parent 3e473cce99
commit 115d36269d
5 changed files with 32 additions and 68 deletions

View File

@@ -118,28 +118,46 @@ function smarty_mod_truncate($string, $length = 80, $etc = '...', $break_words =
}
/*======================================================================*\
Function: smarty_mod_spacify
Purpose: add spaces between characters in a string
\*======================================================================*/
function smarty_mod_spacify($string, $spacify_char = ' ')
{
return implode($spacify_char, preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
}
/*======================================================================*\
Function: smarty_mod_date_format
Purpose: format datestamps via strftime
\*======================================================================*/
function smarty_mod_date_format($string, $format="%b %e, %Y")
{
return strftime($format, $string);
}
/*======================================================================*\
Function: smarty_mod_string_format
Purpose: format strings via sprintf
\*======================================================================*/
function smarty_mod_string_format($string, $format)
{
return sprintf($format, $string);
}
/*======================================================================*\
Function: smarty_mod_replace
Purpose: simple search/replace
\*======================================================================*/
function smarty_mod_replace($string, $search, $replace)
{
return str_replace($search, $replace, $string);
}
/*======================================================================*\
Function: smarty_mod_strip_tags
Purpose: strip html tags from text
\*======================================================================*/
function smarty_mod_strip_tags($string, $replace_with_space = true)
{
if ($replace_with_space)
@@ -148,6 +166,10 @@ function smarty_mod_strip_tags($string, $replace_with_space = true)
return strip_tags($string);
}
/*======================================================================*\
Function: smarty_mod_default
Purpose: designate default text for empty variables
\*======================================================================*/
function smarty_mod_default($string, $default="")
{
if(empty($string))
@@ -273,6 +295,10 @@ function smarty_func_html_select_date()
print $html_result;
}
/*======================================================================*\
Function: smarty_func_math
Purpose: allow math computations in template
\*======================================================================*/
function smarty_func_math() {
$args=func_get_arg(0);
@@ -320,6 +346,10 @@ function smarty_func_math() {
eval("echo ".$equation.";");
}
/*======================================================================*\
Function: smarty_func_fetch
Purpose: fetch file, web or ftp data and display results
\*======================================================================*/
function smarty_func_fetch() {
extract(func_get_arg(0));

View File

@@ -124,7 +124,6 @@ class Smarty
Function: assign()
Purpose: assigns values to template variables
\*======================================================================*/
function assign($tpl_var, $value = NULL)
{
if (is_array($tpl_var)){
@@ -167,7 +166,6 @@ class Smarty
Function: clear_assign()
Purpose: clear the given assigned template variable.
\*======================================================================*/
function clear_assign($tpl_var)
{
if(is_array($tpl_var))
@@ -220,7 +218,6 @@ class Smarty
Function: clear_cache()
Purpose: clear cached content for the given template and cache id
\*======================================================================*/
function clear_cache($tpl_file, $cache_id = null)
{
$cache_tpl_md5 = md5(realpath($this->template_dir.'/'.$tpl_file));
@@ -243,7 +240,6 @@ class Smarty
Function: clear_all_cache()
Purpose: clear the entire contents of cache (all templates)
\*======================================================================*/
function clear_all_cache()
{
if (!is_dir($this->cache_dir))
@@ -267,7 +263,6 @@ class Smarty
Function: is_cached()
Purpose: test to see if valid cache exists for this template
\*======================================================================*/
function is_cached($tpl_file, $cache_id = null)
{
if (!$this->caching)
@@ -293,7 +288,6 @@ class Smarty
Function: clear_all_assign()
Purpose: clear all the assigned template variables.
\*======================================================================*/
function clear_all_assign()
{
$this->_tpl_vars = array();
@@ -314,7 +308,6 @@ class Smarty
Function: display()
Purpose: executes & displays the template results
\*======================================================================*/
function display($tpl_file, $cache_id = null)
{
$this->fetch($tpl_file, $cache_id, true);
@@ -324,7 +317,6 @@ class Smarty
Function: fetch()
Purpose: executes & returns or displays the template results
\*======================================================================*/
function fetch($tpl_file, $cache_id = null, $display = false)
{
global $HTTP_SERVER_VARS;
@@ -384,7 +376,6 @@ class Smarty
Function: compile()
Purpose: called to compile the templates
\*======================================================================*/
function _compile($tpl_dir)
{
if($this->compile_check || $this->force_compile)
@@ -433,7 +424,6 @@ class Smarty
Function: _read_file()
Purpose: read in a file
\*======================================================================*/
function _read_file($filename)
{
@@ -451,7 +441,6 @@ class Smarty
Function: _write_file()
Purpose: write out a file
\*======================================================================*/
function _write_file($filename, $contents, $create_dirs = false)
{
if($create_dirs)
@@ -522,7 +511,6 @@ class Smarty
Function: _set_error_msg()
Purpose: set the error message
\*======================================================================*/
function _set_error_msg($error_msg)
{
$this->_error_msg="smarty error: $error_msg";

View File

@@ -13,7 +13,6 @@ class Smarty_Compiler extends Smarty {
Function: _traverse_files()
Purpose: traverse the template files & process each one
\*======================================================================*/
function _traverse_files($tpl_dir, $depth)
{
$retval = true;
@@ -58,7 +57,6 @@ function _traverse_files($tpl_dir, $depth)
and execute the compilation for each
one requiring it.
\*======================================================================*/
function _process_file($filepath)
{
if(preg_match("/^(.+)\/([^\/]+)$/", $filepath, $match)) {
@@ -92,7 +90,6 @@ function _process_file($filepath)
Function: _create_dir_structure
Purpose: create full directory structure
\*======================================================================*/
function _create_dir_structure($dir)
{
if (!file_exists($dir)) {
@@ -113,7 +110,6 @@ function _create_dir_structure($dir)
Function: _modified_file()
Input: return comparison of modification times of files
\*======================================================================*/
function _modified_file($filepath, $compilepath)
{
if (filemtime($filepath) >= filemtime($compilepath))
@@ -125,7 +121,6 @@ function _modified_file($filepath, $compilepath)
Function: _compile_file()
Input: compile a template file
\*======================================================================*/
function _compile_file($filepath, $compilepath)
{
if (!($template_contents = $this->_read_file($filepath)))
@@ -215,7 +210,6 @@ function _compile_file($filepath, $compilepath)
Function: _process_cached_inserts
Purpose: Replace cached inserts with the actual results
\*======================================================================*/
function _process_cached_inserts($results)
{
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
@@ -241,7 +235,6 @@ function _process_cached_inserts($results)
Function: _compile_tag
Purpose: Compile a template tag
\*======================================================================*/
function _compile_tag($template_tag)
{
/* Matched comment. */
@@ -333,7 +326,6 @@ function _compile_tag($template_tag)
Function: _compile_custom_tag
Purpose: compile custom tag
\*======================================================================*/
function _compile_custom_tag($tag_command, $tag_args)
{
$function = $this->custom_funcs[$tag_command];
@@ -357,7 +349,6 @@ function _compile_custom_tag($tag_command, $tag_args)
Function: _compile_insert_tag
Purpose: Compile {insert ...} tag
\*======================================================================*/
function _compile_insert_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -381,7 +372,6 @@ function _compile_insert_tag($tag_args)
Function: _compile_config_load_tag
Purpose: Compile {config_load ...} tag
\*======================================================================*/
function _compile_config_load_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -410,7 +400,6 @@ function _compile_config_load_tag($tag_args)
Function: _compile_include_tag
Purpose: Compile {include ...} tag
\*======================================================================*/
function _compile_include_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -450,7 +439,6 @@ function _compile_include_tag($tag_args)
Function: _compile_section_start
Purpose: Compile {section ...} tag
\*======================================================================*/
function _compile_section_start($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -514,7 +502,6 @@ function _compile_section_start($tag_args)
Function: _compile_if_tag
Purpose: Compile {if ...} tag
\*======================================================================*/
function _compile_if_tag($tag_args, $elseif = false)
{
/* Tokenize args for 'if' tag. */
@@ -619,7 +606,6 @@ function _compile_if_tag($tag_args, $elseif = false)
Function: _parse_is_expr
Purpose: Parse is expression
\*======================================================================*/
function _parse_is_expr($is_arg, $tokens)
{
$expr_end = 0;
@@ -679,7 +665,6 @@ function _parse_is_expr($is_arg, $tokens)
Function: _parse_attrs
Purpose: Parse attribute string
\*======================================================================*/
function _parse_attrs($tag_args, $quote = true)
{
/* Tokenize tag attributes. */
@@ -753,7 +738,6 @@ function _parse_attrs($tag_args, $quote = true)
Function: _preg_grep
Purpose: Emulate PHP's preg_grep()
\*======================================================================*/
function _preg_grep($pattern, $array)
{
$result = array();
@@ -770,7 +754,6 @@ function _preg_grep($pattern, $array)
Function: _parse_vars_props
Purpose:
\*======================================================================*/
function _parse_vars_props(&$tokens)
{
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
@@ -811,7 +794,6 @@ function _parse_vars_props(&$tokens)
Function: _parse_var
Purpose:
\*======================================================================*/
function _parse_var($var_expr)
{
list($var_ref, $modifiers) = explode('|', substr($var_expr, 1), 2);
@@ -841,7 +823,6 @@ function _parse_var($var_expr)
Function: _parse_conf_var
Purpose:
\*======================================================================*/
function _parse_conf_var($conf_var_expr)
{
list($var_ref, $modifiers) = explode('|', $conf_var_expr, 2);
@@ -859,7 +840,6 @@ function _parse_conf_var($conf_var_expr)
Function: _parse_section_prop
Purpose:
\*======================================================================*/
function _parse_section_prop($section_prop_expr)
{
list($var_ref, $modifiers) = explode('|', $section_prop_expr, 2);
@@ -879,7 +859,6 @@ function _parse_section_prop($section_prop_expr)
Function: _parse_modifiers
Purpose:
\*======================================================================*/
function _parse_modifiers(&$output, $modifier_string)
{
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';

View File

@@ -124,7 +124,6 @@ class Smarty
Function: assign()
Purpose: assigns values to template variables
\*======================================================================*/
function assign($tpl_var, $value = NULL)
{
if (is_array($tpl_var)){
@@ -167,7 +166,6 @@ class Smarty
Function: clear_assign()
Purpose: clear the given assigned template variable.
\*======================================================================*/
function clear_assign($tpl_var)
{
if(is_array($tpl_var))
@@ -220,7 +218,6 @@ class Smarty
Function: clear_cache()
Purpose: clear cached content for the given template and cache id
\*======================================================================*/
function clear_cache($tpl_file, $cache_id = null)
{
$cache_tpl_md5 = md5(realpath($this->template_dir.'/'.$tpl_file));
@@ -243,7 +240,6 @@ class Smarty
Function: clear_all_cache()
Purpose: clear the entire contents of cache (all templates)
\*======================================================================*/
function clear_all_cache()
{
if (!is_dir($this->cache_dir))
@@ -267,7 +263,6 @@ class Smarty
Function: is_cached()
Purpose: test to see if valid cache exists for this template
\*======================================================================*/
function is_cached($tpl_file, $cache_id = null)
{
if (!$this->caching)
@@ -293,7 +288,6 @@ class Smarty
Function: clear_all_assign()
Purpose: clear all the assigned template variables.
\*======================================================================*/
function clear_all_assign()
{
$this->_tpl_vars = array();
@@ -314,7 +308,6 @@ class Smarty
Function: display()
Purpose: executes & displays the template results
\*======================================================================*/
function display($tpl_file, $cache_id = null)
{
$this->fetch($tpl_file, $cache_id, true);
@@ -324,7 +317,6 @@ class Smarty
Function: fetch()
Purpose: executes & returns or displays the template results
\*======================================================================*/
function fetch($tpl_file, $cache_id = null, $display = false)
{
global $HTTP_SERVER_VARS;
@@ -384,7 +376,6 @@ class Smarty
Function: compile()
Purpose: called to compile the templates
\*======================================================================*/
function _compile($tpl_dir)
{
if($this->compile_check || $this->force_compile)
@@ -433,7 +424,6 @@ class Smarty
Function: _read_file()
Purpose: read in a file
\*======================================================================*/
function _read_file($filename)
{
@@ -451,7 +441,6 @@ class Smarty
Function: _write_file()
Purpose: write out a file
\*======================================================================*/
function _write_file($filename, $contents, $create_dirs = false)
{
if($create_dirs)
@@ -522,7 +511,6 @@ class Smarty
Function: _set_error_msg()
Purpose: set the error message
\*======================================================================*/
function _set_error_msg($error_msg)
{
$this->_error_msg="smarty error: $error_msg";

View File

@@ -13,7 +13,6 @@ class Smarty_Compiler extends Smarty {
Function: _traverse_files()
Purpose: traverse the template files & process each one
\*======================================================================*/
function _traverse_files($tpl_dir, $depth)
{
$retval = true;
@@ -58,7 +57,6 @@ function _traverse_files($tpl_dir, $depth)
and execute the compilation for each
one requiring it.
\*======================================================================*/
function _process_file($filepath)
{
if(preg_match("/^(.+)\/([^\/]+)$/", $filepath, $match)) {
@@ -92,7 +90,6 @@ function _process_file($filepath)
Function: _create_dir_structure
Purpose: create full directory structure
\*======================================================================*/
function _create_dir_structure($dir)
{
if (!file_exists($dir)) {
@@ -113,7 +110,6 @@ function _create_dir_structure($dir)
Function: _modified_file()
Input: return comparison of modification times of files
\*======================================================================*/
function _modified_file($filepath, $compilepath)
{
if (filemtime($filepath) >= filemtime($compilepath))
@@ -125,7 +121,6 @@ function _modified_file($filepath, $compilepath)
Function: _compile_file()
Input: compile a template file
\*======================================================================*/
function _compile_file($filepath, $compilepath)
{
if (!($template_contents = $this->_read_file($filepath)))
@@ -215,7 +210,6 @@ function _compile_file($filepath, $compilepath)
Function: _process_cached_inserts
Purpose: Replace cached inserts with the actual results
\*======================================================================*/
function _process_cached_inserts($results)
{
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
@@ -241,7 +235,6 @@ function _process_cached_inserts($results)
Function: _compile_tag
Purpose: Compile a template tag
\*======================================================================*/
function _compile_tag($template_tag)
{
/* Matched comment. */
@@ -333,7 +326,6 @@ function _compile_tag($template_tag)
Function: _compile_custom_tag
Purpose: compile custom tag
\*======================================================================*/
function _compile_custom_tag($tag_command, $tag_args)
{
$function = $this->custom_funcs[$tag_command];
@@ -357,7 +349,6 @@ function _compile_custom_tag($tag_command, $tag_args)
Function: _compile_insert_tag
Purpose: Compile {insert ...} tag
\*======================================================================*/
function _compile_insert_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -381,7 +372,6 @@ function _compile_insert_tag($tag_args)
Function: _compile_config_load_tag
Purpose: Compile {config_load ...} tag
\*======================================================================*/
function _compile_config_load_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -410,7 +400,6 @@ function _compile_config_load_tag($tag_args)
Function: _compile_include_tag
Purpose: Compile {include ...} tag
\*======================================================================*/
function _compile_include_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -450,7 +439,6 @@ function _compile_include_tag($tag_args)
Function: _compile_section_start
Purpose: Compile {section ...} tag
\*======================================================================*/
function _compile_section_start($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
@@ -514,7 +502,6 @@ function _compile_section_start($tag_args)
Function: _compile_if_tag
Purpose: Compile {if ...} tag
\*======================================================================*/
function _compile_if_tag($tag_args, $elseif = false)
{
/* Tokenize args for 'if' tag. */
@@ -619,7 +606,6 @@ function _compile_if_tag($tag_args, $elseif = false)
Function: _parse_is_expr
Purpose: Parse is expression
\*======================================================================*/
function _parse_is_expr($is_arg, $tokens)
{
$expr_end = 0;
@@ -679,7 +665,6 @@ function _parse_is_expr($is_arg, $tokens)
Function: _parse_attrs
Purpose: Parse attribute string
\*======================================================================*/
function _parse_attrs($tag_args, $quote = true)
{
/* Tokenize tag attributes. */
@@ -753,7 +738,6 @@ function _parse_attrs($tag_args, $quote = true)
Function: _preg_grep
Purpose: Emulate PHP's preg_grep()
\*======================================================================*/
function _preg_grep($pattern, $array)
{
$result = array();
@@ -770,7 +754,6 @@ function _preg_grep($pattern, $array)
Function: _parse_vars_props
Purpose:
\*======================================================================*/
function _parse_vars_props(&$tokens)
{
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
@@ -811,7 +794,6 @@ function _parse_vars_props(&$tokens)
Function: _parse_var
Purpose:
\*======================================================================*/
function _parse_var($var_expr)
{
list($var_ref, $modifiers) = explode('|', substr($var_expr, 1), 2);
@@ -841,7 +823,6 @@ function _parse_var($var_expr)
Function: _parse_conf_var
Purpose:
\*======================================================================*/
function _parse_conf_var($conf_var_expr)
{
list($var_ref, $modifiers) = explode('|', $conf_var_expr, 2);
@@ -859,7 +840,6 @@ function _parse_conf_var($conf_var_expr)
Function: _parse_section_prop
Purpose:
\*======================================================================*/
function _parse_section_prop($section_prop_expr)
{
list($var_ref, $modifiers) = explode('|', $section_prop_expr, 2);
@@ -879,7 +859,6 @@ function _parse_section_prop($section_prop_expr)
Function: _parse_modifiers
Purpose:
\*======================================================================*/
function _parse_modifiers(&$output, $modifier_string)
{
$qstr_regexp = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';