*** empty log message ***

This commit is contained in:
andrey
2000-11-21 20:29:55 +00:00
parent fbe382991d
commit 4407e49e08
5 changed files with 87 additions and 28 deletions

View File

@@ -54,4 +54,41 @@ function smarty_mod_spacify($string, $spacify_char = ' ')
return implode($spacify_char, preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
}
/*============================================*\
Custom functions
\*============================================*/
/*======================================================================*\
Function: smarty_func_options
Purpose: Returns the list of <option> tags generated from
the passed parameters
\*======================================================================*/
function smarty_func_options()
{
extract(func_get_arg(0));
settype($output, 'array');
settype($values, 'array');
settype($selected, 'array');
$html_result = "";
for ($i = 0; $i < count($output); $i++) {
/* By default, check value against $selected */
$sel_check = $values[$i];
$html_result .= "<option";
if ($i < count($values))
$html_result .= " value=\"".$values[$i]."\"";
else
$sel_check = $output[$i]; /* if more outputs than values, then
check output against $selected */
if (in_array($sel_check, $selected))
$html_result .= " selected";
$html_result .= ">".$output[$i]."</option>\n";
}
print $html_result;
}
?>

View File

@@ -41,6 +41,8 @@ class Smarty
var $config_dir = "configs"; // directory where config files are located
var $_custom_funcs = array( 'options' => 'smarty_func_options'
);
var $_modifiers = array( 'lower' => 'strtolower',
'upper' => 'strtoupper',
@@ -309,18 +311,6 @@ class Smarty
if(!($template_contents = $this->_read_file($filepath)))
return false;
if(!$this->allow_php)
{
/* Escape php tags. */
$search = array( "/\<\?/i",
"/\?\>/i"
);
$replace = array( "&lt;?",
"?&gt;"
);
$template_contents = preg_replace($search, $replacea ,$template_contents);
}
$ldq = preg_quote($this->left_delimiter, "/");
$rdq = preg_quote($this->right_delimiter, "/");
@@ -329,6 +319,10 @@ class Smarty
$template_tags = $match[1];
/* Split content by template tags to obtain non-template content. */
$text_blocks = preg_split("/$ldq.*?$rdq/s", $template_contents);
if(!$this->allow_php) {
/* Escape php tags. */
$text_blocks = preg_replace('!<\?([^?]*?)\?>!', '&lt;?$1?&gt;', $text_blocks);
}
$compiled_tags = array();
foreach ($template_tags as $template_tag)
@@ -414,11 +408,26 @@ class Smarty
return $this->left_delimiter.$tag_command.$this->right_delimiter;
default:
/* TODO capture custom functions here */
break;
if (isset($this->_custom_funcs[$tag_command])) {
return $this->_compile_custom_func($tag_command, $tag_args);
} else
/* TODO syntax error: unknown tag */
return "";
}
}
function _compile_custom_func($func_name, $tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
$function = $this->_custom_funcs[$func_name];
foreach ($attrs as $arg_name => $arg_value)
$arg_list[] = "'$arg_name' => $arg_value";
return "<?php $function(array(".implode(',', $arg_list).")); ?>";
}
function _compile_config_load_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);

View File

@@ -17,3 +17,5 @@ My interests are:
none
{/section}
{/strip}
{options output=$FirstName values=$LastName selected="Case"}

View File

@@ -41,6 +41,8 @@ class Smarty
var $config_dir = "configs"; // directory where config files are located
var $_custom_funcs = array( 'options' => 'smarty_func_options'
);
var $_modifiers = array( 'lower' => 'strtolower',
'upper' => 'strtoupper',
@@ -309,18 +311,6 @@ class Smarty
if(!($template_contents = $this->_read_file($filepath)))
return false;
if(!$this->allow_php)
{
/* Escape php tags. */
$search = array( "/\<\?/i",
"/\?\>/i"
);
$replace = array( "&lt;?",
"?&gt;"
);
$template_contents = preg_replace($search, $replacea ,$template_contents);
}
$ldq = preg_quote($this->left_delimiter, "/");
$rdq = preg_quote($this->right_delimiter, "/");
@@ -329,6 +319,10 @@ class Smarty
$template_tags = $match[1];
/* Split content by template tags to obtain non-template content. */
$text_blocks = preg_split("/$ldq.*?$rdq/s", $template_contents);
if(!$this->allow_php) {
/* Escape php tags. */
$text_blocks = preg_replace('!<\?([^?]*?)\?>!', '&lt;?$1?&gt;', $text_blocks);
}
$compiled_tags = array();
foreach ($template_tags as $template_tag)
@@ -414,11 +408,26 @@ class Smarty
return $this->left_delimiter.$tag_command.$this->right_delimiter;
default:
/* TODO capture custom functions here */
break;
if (isset($this->_custom_funcs[$tag_command])) {
return $this->_compile_custom_func($tag_command, $tag_args);
} else
/* TODO syntax error: unknown tag */
return "";
}
}
function _compile_custom_func($func_name, $tag_args)
{
$attrs = $this->_parse_attrs($tag_args);
$function = $this->_custom_funcs[$func_name];
foreach ($attrs as $arg_name => $arg_value)
$arg_list[] = "'$arg_name' => $arg_value";
return "<?php $function(array(".implode(',', $arg_list).")); ?>";
}
function _compile_config_load_tag($tag_args)
{
$attrs = $this->_parse_attrs($tag_args);

View File

@@ -17,3 +17,5 @@ My interests are:
none
{/section}
{/strip}
{options output=$FirstName values=$LastName selected="Case"}