remove plugins dir

This commit is contained in:
mohrt
2003-02-21 20:20:26 +00:00
parent a1020815a2
commit 65fd1f26cf
38 changed files with 0 additions and 1983 deletions

View File

@@ -1,71 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: block function
* Name: textformat
* Purpose: format text a certain way with preset styles
* or custom wrap/indent settings
* Params: style: string (email)
* indent: integer (0)
* wrap: integer (80)
* wrap_char string ("\n")
* indent_char: string (" ")
* wrap_boundary: boolean (true)
* -------------------------------------------------------------
*/
function smarty_block_textformat($params, $content, &$this)
{
$style = null;
$indent = 0;
$indent_first = 0;
$indent_char = ' ';
$wrap = 80;
$wrap_char = "\n";
$wrap_cut = false;
$assign = null;
if($content == null) {
return true;
}
extract($params);
if($style == 'email') {
$wrap = 72;
}
// split into paragraphs
$paragraphs = preg_split('![\r\n][\r\n]!',$content);
foreach($paragraphs as $paragraph) {
if($paragraph == '') {
continue;
}
// convert mult. spaces & special chars to single space
$paragraph = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'),array(' ',''),$paragraph);
// indent first line
if($indent_first > 0) {
$paragraph = str_repeat($indent_char,$indent_first) . $paragraph;
}
// wordwrap sentences
$paragraph = wordwrap($paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
// indent lines
if($indent > 0) {
$paragraph = preg_replace('!^!m',str_repeat($indent_char,$indent),$paragraph);
}
$output .= $paragraph . $wrap_char . $wrap_char;
}
if($assign != null) {
$this->assign($assign,$output);
} else {
echo $output;
}
//echo $content;
}
/* vim: set expandtab: */
?>

View File

@@ -1,30 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: assign
* Purpose: assign a value to a template variable
* -------------------------------------------------------------
*/
function smarty_function_assign($params, &$smarty)
{
extract($params);
if (empty($var)) {
$smarty->trigger_error("assign: missing 'var' parameter");
return;
}
if (!in_array('value', array_keys($params))) {
$smarty->trigger_error("assign: missing 'value' parameter");
return;
}
$smarty->assign($var, $value);
}
/* vim: set expandtab: */
?>

View File

@@ -1,32 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: assign_debug_info
* Purpose: assign debug info to the template
* -------------------------------------------------------------
*/
function smarty_function_assign_debug_info($params, &$smarty)
{
$assigned_vars = $smarty->_tpl_vars;
ksort($assigned_vars);
if (@is_array($smarty->_config[0])) {
$config_vars = $smarty->_config[0];
ksort($config_vars);
$smarty->assign("_debug_config_keys", array_keys($config_vars));
$smarty->assign("_debug_config_vals", array_values($config_vars));
}
$included_templates = $smarty->_smarty_debug_info;
$smarty->assign("_debug_keys", array_keys($assigned_vars));
$smarty->assign("_debug_vals", array_values($assigned_vars));
$smarty->assign("_debug_tpls", $included_templates);
}
/* vim: set expandtab: */
?>

View File

@@ -1,72 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: counter
* Purpose: print out a counter value
* -------------------------------------------------------------
*/
function smarty_function_counter($params, &$smarty)
{
static $count = array();
static $skipval = array();
static $dir = array();
static $name = "default";
static $printval = array();
static $assign = "";
extract($params);
if (!isset($name)) {
if(isset($id)) {
$name = $id;
} else {
$name = "default";
}
}
if (isset($start))
$count[$name] = $start;
else if (!isset($count[$name]))
$count[$name]=1;
if (!isset($print))
$printval[$name]=true;
else
$printval[$name]=$print;
if (!empty($assign)) {
$printval[$name] = false;
$smarty->assign($assign, $count[$name]);
}
if ($printval[$name]) {
$retval = $count[$name];
} else {
$retval = null;
}
if (isset($skip))
$skipval[$name] = $skip;
else if (empty($skipval[$name]))
$skipval[$name] = 1;
if (isset($direction))
$dir[$name] = $direction;
else if (!isset($dir[$name]))
$dir[$name] = "up";
if ($dir[$name] == "down")
$count[$name] -= $skipval[$name];
else
$count[$name] += $skipval[$name];
return $retval;
}
/* vim: set expandtab: */
?>

View File

@@ -1,107 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: cycle
* Version: 1.3
* Date: May 3, 2002
* Author: Monte Ohrt <monte@ispi.net>
* Credits: Mark Priatel <mpriatel@rogers.com>
* Gerard <gerard@interfold.com>
* Jason Sweat <jsweat_php@yahoo.com>
* Purpose: cycle through given values
* Input: name = name of cycle (optional)
* values = comma separated list of values to cycle,
* or an array of values to cycle
* (this can be left out for subsequent calls)
*
* reset = boolean - resets given var to true
* print = boolean - print var or not. default is true
* advance = boolean - whether or not to advance the cycle
* delimiter = the value delimiter, default is ","
* assign = boolean, assigns to template var instead of
* printed.
*
* Examples: {cycle values="#eeeeee,#d0d0d0d"}
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
* -------------------------------------------------------------
*/
function smarty_function_cycle($params, &$smarty)
{
static $cycle_vars;
extract($params);
if (empty($name)) {
$name = 'default';
}
if (!isset($print)) {
$print = true;
}
if (!isset($advance)) {
$advance = true;
}
if (!isset($reset)) {
$reset = false;
}
if (!in_array('values', array_keys($params))) {
if(!isset($cycle_vars[$name]['values'])) {
$smarty->trigger_error("cycle: missing 'values' parameter");
return;
}
} else {
if(isset($cycle_vars[$name]['values'])
&& $cycle_vars[$name]['values'] != $values ) {
$cycle_vars[$name]['index'] = 0;
}
$cycle_vars[$name]['values'] = $values;
}
if (isset($delimiter)) {
$cycle_vars[$name]['delimiter'] = $delimiter;
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
$cycle_vars[$name]['delimiter'] = ',';
}
if(!is_array($cycle_vars[$name]['values'])) {
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
} else {
$cycle_array = $cycle_vars[$name]['values'];
}
if(!isset($cycle_vars[$name]['index']) || $reset ) {
$cycle_vars[$name]['index'] = 0;
}
if (isset($assign)) {
$print = false;
$smarty->assign($assign, $cycle_array[$cycle_vars[$name]['index']]);
}
if($print) {
$retval = $cycle_array[$cycle_vars[$name]['index']];
} else {
$retval = null;
}
if($advance) {
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
$cycle_vars[$name]['index'] = 0;
} else {
$cycle_vars[$name]['index']++;
}
}
return $retval;
}
/* vim: set expandtab: */
?>

View File

@@ -1,24 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: debug
* Version: 1.0
* Date: July 1, 2002
* Author: Monte Ohrt <monte@ispi.net>
* Purpose: popup debug window
* -------------------------------------------------------------
*/
function smarty_function_debug($params, &$smarty)
{
if($params['output']) {
$smarty->assign('_smarty_debug_output',$params['output']);
}
return $smarty->_generate_debug_output();
}
/* vim: set expandtab: */
?>

View File

@@ -1,39 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: eval
* Purpose: evaluate a template variable as a template
* -------------------------------------------------------------
*/
function smarty_function_eval($params, &$this)
{
extract($params);
if (!isset($var)) {
$this->trigger_error("eval: missing 'var' parameter");
return;
}
if($var == '') {
return;
}
$this->_compile_template("evaluated template", $var, $source);
ob_start();
eval('?>' . $source);
$contents = ob_get_contents();
ob_end_clean();
if (!empty($assign)) {
$this->assign($assign, $contents);
} else {
return $contents;
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,211 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: fetch
* Purpose: fetch file, web or ftp data and display results
* -------------------------------------------------------------
*/
function smarty_function_fetch($params, &$smarty)
{
$file = $params['file'];
if (empty($file)) {
$smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty");
return;
}
if ($smarty->security && !preg_match('!^(http|ftp)://!i', $file)) {
// fetching file, make sure it comes from secure directory
foreach ($smarty->secure_dir as $curr_dir) {
if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) {
$resource_is_secure = true;
break;
}
}
if (!$resource_is_secure) {
$smarty->_trigger_fatal_error("[plugin] (secure mode) fetch '$file' is not allowed");
return;
}
// fetch the file
if($fp = @fopen($file,'r')) {
while(!feof($fp)) {
$content .= fgets ($fp,4096);
}
fclose($fp);
} else {
$smarty->_trigger_fatal_error("[plugin] fetch cannot read file '$file'");
return;
}
} else {
// not a local file
if(preg_match('!^http://!i',$file)) {
// http fetch
if($uri_parts = parse_url($file)) {
// set defaults
$host = $server_name = $uri_parts['host'];
$timeout = 30;
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
$agent = "Smarty Template Engine ".$smarty->_version;
$referer = "";
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
$_is_proxy = false;
if(empty($uri_parts['port'])) {
$port = 80;
} else {
$port = $uri_parts['port'];
}
if(empty($uri_parts['user'])) {
$user = $uri_parts['user'];
}
// loop through parameters, setup headers
foreach($params as $param_key => $param_value) {
switch($param_key) {
case "file":
case "assign":
case "assign_headers":
break;
case "user":
if(!empty($param_value)) {
$user = $param_value;
}
break;
case "pass":
if(!empty($param_value)) {
$pass = $param_value;
}
break;
case "accept":
if(!empty($param_value)) {
$accept = $param_value;
}
break;
case "header":
if(!empty($param_value)) {
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
$smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
return;
} else {
$extra_headers[] = $param_value;
}
}
break;
case "proxy_host":
if(!empty($param_value)) {
$proxy_host = $param_value;
}
break;
case "proxy_port":
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
return;
}
break;
case "agent":
if(!empty($param_value)) {
$agent = $param_value;
}
break;
case "referer":
if(!empty($param_value)) {
$referer = $param_value;
}
break;
case "timeout":
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
return;
}
break;
default:
$smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'");
return;
}
}
if(!empty($proxy_host) && !empty($proxy_port)) {
$_is_proxy = true;
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
} else {
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
}
if(!$fp) {
$smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
return;
} else {
if($_is_proxy) {
fputs($fp, "GET $file HTTP/1.0\r\n");
} else {
fputs($fp, "GET $uri HTTP/1.0\r\n");
}
if(!empty($host)) {
fputs($fp, "Host: $host\r\n");
}
if(!empty($accept)) {
fputs($fp, "Accept: $accept\r\n");
}
if(!empty($agent)) {
fputs($fp, "User-Agent: $agent\r\n");
}
if(!empty($referer)) {
fputs($fp, "Referer: $referer\r\n");
}
if(is_array($extra_headers)) {
foreach($extra_headers as $curr_header) {
fputs($fp, $curr_header."\r\n");
}
}
if(!empty($user) && !empty($pass)) {
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
}
fputs($fp, "\r\n");
while(!feof($fp)) {
$content .= fgets($fp,4096);
}
fclose($fp);
$csplit = split("\r\n\r\n",$content,2);
$content = $csplit[1];
if(!empty($params['assign_headers'])) {
$smarty->assign($params['assign_headers'],split("\r\n",$csplit[0]));
}
}
} else {
$smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax");
return;
}
} else {
// ftp fetch
if($fp = @fopen($file,'r')) {
while(!feof($fp)) {
$content .= fgets ($fp,4096);
}
fclose($fp);
} else {
$smarty->_trigger_fatal_error("[plugin] fetch cannot read file '$file'");
return;
}
}
}
if (!empty($params['assign'])) {
$smarty->assign($params['assign'],$content);
} else {
return $content;
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,71 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_options
* Purpose: Prints the list of <option> tags generated from
* the passed parameters
* -------------------------------------------------------------
*/
function smarty_function_html_options($params, &$smarty)
{
extract($params);
$html_result = '';
settype($selected, 'array');
if (isset($options)) {
settype($options, 'array');
foreach ($options as $key => $value) {
$html_result .= smarty_function_html_options_optoutput($key, $value, $selected);
}
} else {
settype($output, 'array');
settype($values, 'array');
for ($i = 0, $for_max = count($output); $i < $for_max; $i++) {
if ($i < count($values)) {
$html_result .= smarty_function_html_options_optoutput($values[$i], $output[$i], $selected);
} else {
$html_result .= smarty_function_html_options_optoutput($output[$i], $output[$i], $selected);
}
}
}
return $html_result;
}
function smarty_function_html_options_optoutput($key, $value, $selected) {
if(!is_array($value)) {
$html_result = '<option label="' . smarty_function_html_options_htmlspecialchars($value) . '" value="' .
smarty_function_html_options_htmlspecialchars($key) . '"';
if (in_array($key, $selected))
$html_result .= " selected=\"selected\"";
$html_result .= '>' . smarty_function_html_options_htmlspecialchars($value) . '</option>' . "\n";
} else {
$html_result = smarty_function_html_options_optgroup($key, $value, $selected);
}
return $html_result;
}
function smarty_function_html_options_optgroup($key, $values, $selected) {
$optgroup_html = '<optgroup label="' . smarty_function_html_options_htmlspecialchars($value) . '">' . "\n";
foreach ($values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
}
$optgroup_html .= "</optgroup>\n";
return $optgroup_html;
}
function smarty_function_html_options_htmlspecialchars($text) {
// do not escape already escaped entities (&amp; &#123;)
$text = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $text);
$text = htmlspecialchars($text);
$text = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $text);
return $text;
}
/* vim: set expandtab: */
?>

View File

@@ -1,232 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_select_date
* Version: 1.3
* Purpose: Prints the dropdowns for date selection.
* Author: Andrei Zmievski
*
* ChangeLog: 1.0 initial release
* 1.1 added support for +/- N syntax for begin
* and end year values. (Monte)
* 1.2 added support for yyyy-mm-dd syntax for
* time value. (Jan Rosier)
* 1.3 added support for choosing format for
* month values (Gary Loescher)
* 1.3.1 added support for choosing format for
* day values (Marcus Bointon)
* -------------------------------------------------------------
*/
require_once $this->_get_plugin_filepath('shared','make_timestamp');
require_once $this->_get_plugin_filepath('function','html_options');
function smarty_function_html_select_date($params, &$smarty)
{
/* Default values. */
$prefix = "Date_";
$start_year = strftime("%Y");
$end_year = $start_year;
$display_days = true;
$display_months = true;
$display_years = true;
$month_format = "%B";
/* Write months as numbers by default GL */
$month_value_format = "%m";
$day_format = "%02d";
/* Write day values using this format MB */
$day_value_format = "%d";
$year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false;
/* Should the select boxes be part of an array when returned from PHP?
e.g. setting it to "birthday", would create "birthday[Day]",
"birthday[Month]" & "birthday[Year]". Can be combined with prefix */
$field_array = null;
/* <select size>'s of the different <select> tags.
If not set, uses default dropdown. */
$day_size = null;
$month_size = null;
$year_size = null;
/* Unparsed attributes common to *ALL* the <select>/<input> tags.
An example might be in the template: all_extra ='class ="foo"'. */
$all_extra = null;
/* Separate attributes for the tags. */
$day_extra = null;
$month_extra = null;
$year_extra = null;
/* Order in which to display the fields.
"D" -> day, "M" -> month, "Y" -> year. */
$field_order = 'MDY';
/* String printed between the different fields. */
$field_separator = "\n";
$time = time();
extract($params);
// If $time is not in format yyyy-mm-dd
if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $time)) {
// then $time is empty or unix timestamp or mysql timestamp
// using smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
$end_year = strftime('%Y') + $match[2];
} else {
$end_year = strftime('%Y') - $match[2];
}
}
if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
if ($match[1] == '+') {
$start_year = strftime('%Y') + $match[2];
} else {
$start_year = strftime('%Y') - $match[2];
}
}
$field_order = strtoupper($field_order);
$html_result = $month_result = $day_result = $year_result = "";
if ($display_months) {
$month_names = array();
$month_values = array();
for ($i = 1; $i <= 12; $i++) {
$month_names[] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
$month_values[] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
$month_result .= '<select name=';
if (null !== $field_array){
$month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
} else {
$month_result .= '"' . $prefix . 'Month"';
}
if (null !== $month_size){
$month_result .= ' size="' . $month_size . '"';
}
if (null !== $month_extra){
$month_result .= ' ' . $month_extra;
}
if (null !== $all_extra){
$month_result .= ' ' . $all_extra;
}
$month_result .= '>'."\n";
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
'selected' => $month_values[$time[1]-1],
'print_result' => false),
$smarty);
$month_result .= '</select>';
}
if ($display_days) {
$days = array();
for ($i = 1; $i <= 31; $i++) {
$days[] = sprintf($day_format, $i);
$day_values[] = sprintf($day_value_format, $i);
}
$day_result .= '<select name=';
if (null !== $field_array){
$day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
} else {
$day_result .= '"' . $prefix . 'Day"';
}
if (null !== $day_size){
$day_result .= ' size="' . $day_size . '"';
}
if (null !== $all_extra){
$day_result .= ' ' . $all_extra;
}
if (null !== $day_extra){
$day_result .= ' ' . $day_extra;
}
$day_result .= '>'."\n";
$day_result .= smarty_function_html_options(array('output' => $days,
'values' => $day_values,
'selected' => $time[2],
'print_result' => false),
$smarty);
$day_result .= '</select>';
}
if ($display_years) {
if (null !== $field_array){
$year_name = $field_array . '[' . $prefix . 'Year]';
} else {
$year_name = $prefix . 'Year';
}
if ($year_as_text) {
$year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
if (null !== $all_extra){
$year_result .= ' ' . $all_extra;
}
if (null !== $year_extra){
$year_result .= ' ' . $year_extra;
}
$year_result .= '>';
} else {
$years = range((int)$start_year, (int)$end_year);
if ($reverse_years) {
rsort($years, SORT_NUMERIC);
}
$year_result .= '<select name="' . $year_name . '"';
if (null !== $year_size){
$year_result .= ' size="' . $year_size . '"';
}
if (null !== $all_extra){
$year_result .= ' ' . $all_extra;
}
if (null !== $year_extra){
$year_result .= ' ' . $year_extra;
}
$year_result .= '>'."\n";
$year_result .= smarty_function_html_options(array('output' => $years,
'values' => $years,
'selected' => $time[0],
'print_result' => false),
$smarty);
$year_result .= '</select>';
}
}
// Loop thru the field_order field
for ($i = 0; $i <= 2; $i++){
$c = substr($field_order, $i, 1);
switch ($c){
case 'D':
$html_result .= $day_result;
break;
case 'M':
$html_result .= $month_result;
break;
case 'Y':
$html_result .= $year_result;
break;
}
// Add the field seperator
if($i != 2) {
$html_result .= $field_separator;
}
}
return $html_result;
}
/* vim: set expandtab: */
?>

View File

@@ -1,152 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_select_time
* Purpose: Prints the dropdowns for time selection
* -------------------------------------------------------------
*/
require_once $this->_get_plugin_filepath('shared','make_timestamp');
require_once $this->_get_plugin_filepath('function','html_options');
function smarty_function_html_select_time($params, &$smarty)
{
/* Default values. */
$prefix = "Time_";
$time = time();
$display_hours = true;
$display_minutes = true;
$display_seconds = true;
$display_meridian = true;
$use_24_hours = true;
$minute_interval = 1;
$second_interval = 1;
/* Should the select boxes be part of an array when returned from PHP?
e.g. setting it to "birthday", would create "birthday[Hour]",
"birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
Can be combined with prefix. */
$field_array = null;
$all_extra = null;
$hour_extra = null;
$minute_extra = null;
$second_extra = null;
$meridian_extra = null;
extract($params);
$time = smarty_make_timestamp($time);
$html_result = '';
if ($display_hours) {
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
$hour_fmt = $use_24_hours ? '%H' : '%I';
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
$hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
} else {
$html_result .= '"' . $prefix . 'Hour"';
}
if (null !== $hour_extra){
$html_result .= ' ' . $hour_extra;
}
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
}
$html_result .= '>'."\n";
$html_result .= smarty_function_html_options(array('output' => $hours,
'values' => $hours,
'selected' => strftime($hour_fmt, $time),
'print_result' => false),
$smarty);
$html_result .= "</select>\n";
}
if ($display_minutes) {
$all_minutes = range(0, 59);
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i+= $minute_interval)
$minutes[] = sprintf('%02d', $all_minutes[$i]);
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
} else {
$html_result .= '"' . $prefix . 'Minute"';
}
if (null !== $minute_extra){
$html_result .= ' ' . $minute_extra;
}
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
}
$html_result .= '>'."\n";
$html_result .= smarty_function_html_options(array('output' => $minutes,
'values' => $minutes,
'selected' => $selected,
'print_result' => false),
$smarty);
$html_result .= "</select>\n";
}
if ($display_seconds) {
$all_seconds = range(0, 59);
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i+= $second_interval)
$seconds[] = sprintf('%02d', $all_seconds[$i]);
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
} else {
$html_result .= '"' . $prefix . 'Second"';
}
if (null !== $second_extra){
$html_result .= ' ' . $second_extra;
}
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
}
$html_result .= '>'."\n";
$html_result .= smarty_function_html_options(array('output' => $seconds,
'values' => $seconds,
'selected' => $selected,
'print_result' => false),
$smarty);
$html_result .= "</select>\n";
}
if ($display_meridian && !$use_24_hours) {
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
} else {
$html_result .= '"' . $prefix . 'Meridian"';
}
if (null !== $meridian_extra){
$html_result .= ' ' . $meridian_extra;
}
if (null !== $all_extra){
$html_result .= ' ' . $all_extra;
}
$html_result .= '>'."\n";
$html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
'values' => array('am', 'pm'),
'selected' => strtolower(strftime('%p', $time)),
'print_result' => false),
$smarty);
$html_result .= "</select>\n";
}
return $html_result;
}
/* vim: set expandtab: */
?>

View File

@@ -1,85 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: html_table
* Version: 1.0
* Date: Feb 17, 2003
* Author: Monte Ohrt <monte@ispi.net>
* Purpose: make an html table from an array of data
* Input: loop = array to loop through
* cols = number of columns
* table_attr = table attributes
* tr_attr = table row attributes (arrays are cycled)
* td_attr = table cell attributes (arrays are cycled)
* cellpad = value to pad trailing cells with
*
* Examples: {table loop=$data}
* {$table loop=$data cols=4 tr_attr='"bgcolor=red"'}
* {$table loop=$data cols=4 tr_attr=$colors}
* -------------------------------------------------------------
*/
function smarty_function_html_table($params, &$smarty)
{
$table_attr = 'border=1';
$tr_attr = '';
$td_attr = '';
$cols = 3;
$cellpad = '&nbsp;';
extract($params);
if (!isset($loop)) {
$smarty->trigger_error("table: missing 'loop' parameter");
return;
}
$output = "<table $table_attr>\n";
$output .= "<tr " . smarty_function_html_table_cycle('tr', $tr_attr) . ">\n";
for($x = 0, $y = count($loop); $x < $y; $x++) {
$output .= "<td " . smarty_function_html_table_cycle('td', $td_attr) . ">" . $loop[$x] . "</td>\n";
if((!(($x+1) % $cols)) && $x < $y-1) {
// go to next row
$output .= "</tr>\n<tr " . smarty_function_html_table_cycle('tr', $tr_attr) . ">\n";
}
if($x == $y-1) {
// last row, pad remaining cells
$cells = $cols - $y % $cols;
if($cells != $cols) {
for($padloop = 0; $padloop < $cells; $padloop++) {
$output .= "<td " . smarty_function_html_table_cycle('td', $td_attr) . ">$cellpad</td>\n";
}
}
$output .= "</tr>\n";
}
}
$output .= "</table>\n";
return $output;
}
function smarty_function_html_table_cycle($name, $var) {
static $names = array();
if(!is_array($var)) {
return $var;
}
if(!isset($names[$name]) || $names[$name] == count($var)-1) {
$names[$name] = 0;
return $var[0];
}
$names[$name]++;
return $var[$names[$name]];
}
/* vim: set expandtab: */
?>

View File

@@ -1,124 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: mailto
* Version: 1.2
* Date: May 21, 2002
* Author: Monte Ohrt <monte@ispi.net>
* Credits: Jason Sweat (added cc, bcc and subject functionality)
* Purpose: automate mailto address link creation, and optionally
* encode them.
* Input: address = e-mail address
* text = (optional) text to display, default is address
* encode = (optional) can be one of:
* none : no encoding (default)
* javascript : encode with javascript
* hex : encode with hexidecimal (no javascript)
* cc = (optional) address(es) to carbon copy
* bcc = (optional) address(es) to blind carbon copy
* subject = (optional) e-mail subject
* newsgroups = (optional) newsgroup(s) to post to
* followupto = (optional) address(es) to follow up to
* extra = (optional) extra tags for the href link
*
* Examples: {mailto address="me@domain.com"}
* {mailto address="me@domain.com" encode="javascript"}
* {mailto address="me@domain.com" encode="hex"}
* {mailto address="me@domain.com" subject="Hello to you!"}
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
* -------------------------------------------------------------
*/
function smarty_function_mailto($params, &$smarty)
{
extract($params);
if (empty($address)) {
$smarty->trigger_error("mailto: missing 'address' parameter");
return;
}
if (empty($text)) {
$text = $address;
}
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it.
$mail_parms = array();
if (!empty($cc)) {
$mail_parms[] = 'cc='.str_replace('%40','@',rawurlencode($cc));
}
if (!empty($bcc)) {
$mail_parms[] = 'bcc='.str_replace('%40','@',rawurlencode($bcc));
}
if (!empty($subject)) {
$mail_parms[] = 'subject='.rawurlencode($subject);
}
if (!empty($newsgroups)) {
$mail_parms[] = 'newsgroups='.rawurlencode($newsgroups);
}
if (!empty($followupto)) {
$mail_parms[] = 'followupto='.str_replace('%40','@',rawurlencode($followupto));
}
for ($i=0; $i<count($mail_parms); $i++) {
$mail_parm_vals .= (0==$i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
}
$address .= $mail_parm_vals;
if (empty($encode)) {
$encode = 'none';
} elseif (!in_array($encode,array('javascript','hex','none')) ) {
$smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
return;
}
if ($encode == 'javascript' ) {
$string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
for ($x=0; $x < strlen($string); $x++) {
$js_encode .= '%' . bin2hex($string[$x]);
}
return '<SCRIPT language="javascript">eval(unescape(\''.$js_encode.'\'))</SCRIPT>';
} elseif ($encode == 'hex') {
preg_match('!^(.*)(\?.*)$!',$address,$match);
if(!empty($match[2])) {
$smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
return;
}
for ($x=0; $x < strlen($address); $x++) {
if(preg_match('!\w!',$address[$x])) {
$address_encode .= '%' . bin2hex($address[$x]);
} else {
$address_encode .= $address[$x];
}
}
for ($x=0; $x < strlen($text); $x++) {
$text_encode .= '&#x' . bin2hex($text[$x]).';';
}
return '<a href="mailto:'.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
} else {
// no encoding
return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,73 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: math
* Purpose: handle math computations in template
* -------------------------------------------------------------
*/
function smarty_function_math($params, &$smarty)
{
// be sure equation parameter is present
if (empty($params['equation'])) {
$smarty->trigger_error("math: missing equation parameter");
return;
}
$equation = $params['equation'];
// make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) {
$smarty->trigger_error("math: unbalanced parenthesis");
return;
}
// match all vars in equation, make sure all are passed
preg_match_all("![a-zA-Z][a-zA-Z0-9]*!",$equation, $match);
$allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
foreach($match[0] as $curr_var) {
if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
$smarty->trigger_error("math: parameter $curr_var not passed as argument");
return;
}
}
foreach($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val)==0) {
$smarty->trigger_error("math: parameter $key is empty");
return;
}
if (!is_numeric($val)) {
$smarty->trigger_error("math: parameter $key: is not numeric");
return;
}
$equation = preg_replace("/\b$key\b/",$val, $equation);
}
}
eval("\$smarty_math_result = ".$equation.";");
if (empty($params['format'])) {
if (empty($params['assign'])) {
return $smarty_math_result;
} else {
$smarty->assign($params['assign'],$smarty_math_result);
}
} else {
if (empty($params['assign'])){
printf($params['format'],$smarty_math_result);
} else {
$smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
}
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,77 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: popup
* Purpose: make text pop up in windows via overlib
* -------------------------------------------------------------
*/
function smarty_function_popup($params, &$smarty)
{
extract($params);
if (empty($text) && !isset($inarray) && empty($function)) {
$smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
return false;
}
if (empty($trigger)) { $trigger = "onMouseOver"; }
$retval .= $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
if ($sticky) { $retval .= ",STICKY"; }
if (!empty($caption)) { $retval .= ",CAPTION,'".str_replace("'","\'",$caption)."'"; }
if (!empty($fgcolor)) { $retval .= ",FGCOLOR,'$fgcolor'"; }
if (!empty($bgcolor)) { $retval .= ",BGCOLOR,'$bgcolor'"; }
if (!empty($textcolor)) { $retval .= ",TEXTCOLOR,'$textcolor'"; }
if (!empty($capcolor)) { $retval .= ",CAPCOLOR,'$capcolor'"; }
if (!empty($closecolor)) { $retval .= ",CLOSECOLOR,'$closecolor'"; }
if (!empty($textfont)) { $retval .= ",TEXTFONT,'$textfont'"; }
if (!empty($captionfont)) { $retval .= ",CAPTIONFONT,'$captionfont'"; }
if (!empty($closefont)) { $retval .= ",CLOSEFONT,'$closefont'"; }
if (!empty($textsize)) { $retval .= ",TEXTSIZE,$textsize"; }
if (!empty($captionsize)) { $retval .= ",CAPTIONSIZE,$captionsize"; }
if (!empty($closesize)) { $retval .= ",CLOSESIZE,$closesize"; }
if (!empty($width)) { $retval .= ",WIDTH,$width"; }
if (!empty($height)) { $retval .= ",HEIGHT,$height"; }
if (!empty($left)) { $retval .= ",LEFT"; }
if (!empty($right)) { $retval .= ",RIGHT"; }
if (!empty($center)) { $retval .= ",CENTER"; }
if (!empty($above)) { $retval .= ",ABOVE"; }
if (!empty($below)) { $retval .= ",BELOW"; }
if (isset($border)) { $retval .= ",BORDER,$border"; }
if (isset($offsetx)) { $retval .= ",OFFSETX,$offsetx"; }
if (isset($offsety)) { $retval .= ",OFFSETY,$offsety"; }
if (!empty($fgbackground)) { $retval .= ",FGBACKGROUND,'$fgbackground'"; }
if (!empty($bgbackground)) { $retval .= ",BGBACKGROUND,'$bgbackground'"; }
if (!empty($closetext)) { $retval .= ",CLOSETEXT,'".str_replace("'","\'",$closetext)."'"; }
if (!empty($noclose)) { $retval .= ",NOCLOSE"; }
if (!empty($status)) { $retval .= ",STATUS,'".str_replace("'","\'",$status)."'"; }
if (!empty($autostatus)) { $retval .= ",AUTOSTATUS"; }
if (!empty($autostatuscap)) { $retval .= ",AUTOSTATUSCAP"; }
if (isset($inarray)) { $retval .= ",INARRAY,'$inarray'"; }
if (isset($caparray)) { $retval .= ",CAPARRAY,'$caparray'"; }
if (!empty($capicon)) { $retval .= ",CAPICON,'$capicon'"; }
if (!empty($snapx)) { $retval .= ",SNAPX,$snapx"; }
if (!empty($snapy)) { $retval .= ",SNAPY,$snapy"; }
if (isset($fixx)) { $retval .= ",FIXX,$fixx"; }
if (isset($fixy)) { $retval .= ",FIXY,$fixy"; }
if (!empty($background)) { $retval .= ",BACKGROUND,'$background'"; }
if (!empty($padx)) { $retval .= ",PADX,$padx"; }
if (!empty($pady)) { $retval .= ",PADY,$pady"; }
if (!empty($fullhtml)) { $retval .= ",FULLHTML"; }
if (!empty($frame)) { $retval .= ",FRAME,'$frame'"; }
if (isset($timeout)) { $retval .= ",TIMEOUT,$timeout"; }
if (!empty($function)) { $retval .= ",FUNCTION,'$function'"; }
if (isset($delay)) { $retval .= ",DELAY,$delay"; }
if (!empty($hauto)) { $retval .= ",HAUTO"; }
if (!empty($vauto)) { $retval .= ",VAUTO"; }
$retval .= ');" onMouseOut="nd();"';
return $retval;
}
/* vim: set expandtab: */
?>

View File

@@ -1,29 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: function
* Name: popup_init
* Purpose: initialize overlib
* -------------------------------------------------------------
*/
function smarty_function_popup_init($params, &$smarty)
{
$zindex = 1000;
if (!empty($params['zindex'])) {
$zindex = $params['zindex'];
}
if (!empty($params['src'])) {
return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
. '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
} else {
$smarty->trigger_error("popup_init: missing src parameter");
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,16 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: capitalize
* Purpose: capitalize words in the string
* -------------------------------------------------------------
*/
function smarty_modifier_capitalize($string)
{
return ucwords($string);
}
?>

View File

@@ -1,21 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: count_characteres
* Purpose: count the number of characters in a text
* -------------------------------------------------------------
*/
function smarty_modifier_count_characters($string, $include_spaces = false)
{
if ($include_spaces)
return(strlen($string));
return preg_match_all("/[^\s]/",$string, $match);
}
/* vim: set expandtab: */
?>

View File

@@ -1,19 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: count_paragraphs
* Purpose: count the number of paragraphs in a text
* -------------------------------------------------------------
*/
function smarty_modifier_count_paragraphs($string)
{
// count \r or \n characters
return count(preg_split('/[\r\n]+/', $string));
}
/* vim: set expandtab: */
?>

View File

@@ -1,19 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: count_sentences
* Purpose: count the number of sentences in a text
* -------------------------------------------------------------
*/
function smarty_modifier_count_sentences($string)
{
// find periods with a word before but not after.
return preg_match_all('/[^\s]\.(?!\w)/', $string, $match);
}
/* vim: set expandtab: */
?>

View File

@@ -1,23 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: count_words
* Purpose: count the number of words in a text
* -------------------------------------------------------------
*/
function smarty_modifier_count_words($string)
{
// split text by ' ',\r,\n,\f,\t
$split_array = preg_split('/\s+/',$string);
// count matches that contain alphanumerics
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
return count($word_count);
}
/* vim: set expandtab: */
?>

View File

@@ -1,28 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: date_format
* Purpose: format datestamps via strftime
* Input: string: input date string
* format: strftime format for output
* default_date: default date if $string is empty
* -------------------------------------------------------------
*/
require_once $this->_get_plugin_filepath('shared','make_timestamp');
function smarty_modifier_date_format($string, $format="%b %e, %Y", $default_date=null)
{
if($string != '') {
return strftime($format, smarty_make_timestamp($string));
} elseif (isset($default_date) && $default_date != '') {
return strftime($format, smarty_make_timestamp($default_date));
} else {
return;
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,45 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: debug_print_var
* Purpose: formats variable contents for display in the console
* -------------------------------------------------------------
*/
function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{
if (is_array($var)) {
$results = "<b>Array (".count($var).")</b>";
foreach ($var as $curr_key => $curr_val) {
$return = smarty_modifier_debug_print_var($curr_val, $depth+1);
$results .= '<br>\r'.str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
}
return $results;
} else if (is_object($var)) {
$object_vars = get_object_vars($var);
$results = "<b>".get_class($var)." Object (".count($object_vars).")</b>";
foreach ($object_vars as $curr_key => $curr_val) {
$return = smarty_modifier_debug_print_var($curr_val, $depth+1);
$results .= '<br>\r'.str_repeat('&nbsp;', $depth*2)."<b>$curr_key</b> =&gt; $return";
}
return $results;
} else {
if (empty($var) && $var != "0") {
return '<i>empty</i>';
}
if (strlen($var) > $length ) {
$results = substr($var, 0, $length-3).'...';
} else {
$results = $var;
}
$results = preg_replace("![\r\t\n]!", " ", $results);
$results = htmlspecialchars($results);
return $results;
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,21 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: default
* Purpose: designate default value for empty variables
* -------------------------------------------------------------
*/
function smarty_modifier_default($string, $default = '')
{
if (!isset($string) || $string == '')
return $default;
else
return $string;
}
/* vim: set expandtab: */
?>

View File

@@ -1,53 +0,0 @@
<?php
/*
* Smarty plugin
* ------------------------------------------------------------
* Type: modifier
* Name: escape
* Purpose: Escape the string according to escapement type
* ------------------------------------------------------------
*/
function smarty_modifier_escape($string, $esc_type = 'html')
{
switch ($esc_type) {
case 'html':
return htmlspecialchars($string, ENT_QUOTES);
case 'htmlall':
return htmlentities($string, ENT_QUOTES);
case 'url':
return urlencode($string);
case 'quotes':
// escape unescaped single quotes
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
case 'hex':
// escape every character into hex
$return = '';
for ($x=0; $x < strlen($string); $x++) {
$return .= '%' . bin2hex($string[$x]);
}
return $return;
case 'hexentity':
$return = '';
for ($x=0; $x < strlen($string); $x++) {
$return .= '&#x' . bin2hex($string[$x]) . ';';
}
return $return;
case 'javascript':
// escape quotes and backslashes and newlines
return str_replace(array('\\','\'',"\r","\n"), array("\\\\", "\\'",'\r','\r'), $string);
default:
return $string;
}
}
/* vim: set expandtab: */
?>

View File

@@ -1,16 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: indent
* Purpose: indent lines of text
* -------------------------------------------------------------
*/
function smarty_modifier_indent($string,$chars=4,$char=" ")
{
return preg_replace('!^!m',str_repeat($char,$chars),$string);
}
?>

View File

@@ -1,16 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: lower
* Purpose: convert string to lowercase
* -------------------------------------------------------------
*/
function smarty_modifier_lower($string)
{
return strtolower($string);
}
?>

View File

@@ -1,18 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: regex_replace
* Purpose: regular epxression search/replace
* -------------------------------------------------------------
*/
function smarty_modifier_regex_replace($string, $search, $replace)
{
return preg_replace($search, $replace, $string);
}
/* vim: set expandtab: */
?>

View File

@@ -1,18 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: replace
* Purpose: simple search/replace
* -------------------------------------------------------------
*/
function smarty_modifier_replace($string, $search, $replace)
{
return str_replace($search, $replace, $string);
}
/* vim: set expandtab: */
?>

View File

@@ -1,19 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: spacify
* Purpose: add spaces between characters in a string
* -------------------------------------------------------------
*/
function smarty_modifier_spacify($string, $spacify_char = ' ')
{
return implode($spacify_char,
preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
}
/* vim: set expandtab: */
?>

View File

@@ -1,18 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: string_format
* Purpose: format strings via sprintf
* -------------------------------------------------------------
*/
function smarty_modifier_string_format($string, $format)
{
return sprintf($format, $string);
}
/* vim: set expandtab: */
?>

View File

@@ -1,23 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: strip
* Purpose: Replace all repeated spaces, newlines, tabs
* with a single space or supplied replacement string.
* Example: {$var|strip} {$var|strip:"&nbsp;"}
* Author: Monte Ohrt <monte@ispi.net>
* Version: 1.0
* Date: September 25th, 2002
* -------------------------------------------------------------
*/
function smarty_modifier_strip($text, $replace = ' ')
{
return preg_replace('!\s+!', $replace, $text);
}
/* vim: set expandtab: */
?>

View File

@@ -1,21 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: strip_tags
* Purpose: strip html tags from text
* -------------------------------------------------------------
*/
function smarty_modifier_strip_tags($string, $replace_with_space = true)
{
if ($replace_with_space)
return preg_replace('!<[^>]*?>!', ' ', $string);
else
return strip_tags($string);
}
/* vim: set expandtab: */
?>

View File

@@ -1,33 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: truncate
* Purpose: Truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and
* appending the $etc string.
* -------------------------------------------------------------
*/
function smarty_modifier_truncate($string, $length = 80, $etc = '...',
$break_words = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length) {
$length -= strlen($etc);
$fragment = substr($string, 0, $length+1);
if ($break_words)
$fragment = substr($fragment, 0, -1);
else
$fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
return $fragment.$etc;
} else
return $string;
}
/* vim: set expandtab: */
?>

View File

@@ -1,16 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: upper
* Purpose: convert string to uppercase
* -------------------------------------------------------------
*/
function smarty_modifier_upper($string)
{
return strtoupper($string);
}
?>

View File

@@ -1,16 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* Type: modifier
* Name: wordwrap
* Purpose: wrap a string of text at a given length
* -------------------------------------------------------------
*/
function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false)
{
return wordwrap($string,$length,$break,$cut);
}
?>

View File

@@ -1,60 +0,0 @@
<?php
/*
* Smarty plugin
* -------------------------------------------------------------
* File: outputfilter.trimwhitespace.php
* Type: outputfilter
* Name: trimwhitespace
* Version: 1.3
* Date: Jan 25, 2003
* Purpose: trim leading white space and blank lines from
* template source after it gets interpreted, cleaning
* up code and saving bandwidth. Does not affect
* <PRE></PRE> and <SCRIPT></SCRIPT> blocks.
* Install: Drop into the plugin directory, call
* $smarty->load_filter('output','trimwhitespace');
* from application.
* Author: Monte Ohrt <monte@ispi.net>
* Contribs: Lars Noschinski <lars@usenet.noschinski.de>
* -------------------------------------------------------------
*/
function smarty_outputfilter_trimwhitespace($source, &$smarty)
{
// Pull out the script blocks
preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
$_script_blocks = $match[0];
$source = preg_replace("!<script[^>]+>.*?</script>!is",
'@@@SMARTY:TRIM:SCRIPT@@@', $source);
// Pull out the pre blocks
preg_match_all("!<pre>.*?</pre>!is", $source, $match);
$_pre_blocks = $match[0];
$source = preg_replace("!<pre>.*?</pre>!is",
'@@@SMARTY:TRIM:PRE@@@', $source);
// Pull out the textarea blocks
preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
$_textarea_blocks = $match[0];
$source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
'@@@SMARTY:TRIM:TEXTAREA@@@', $source);
// remove all leading spaces, tabs and carriage returns NOT
// preceeded by a php close tag.
$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
// replace script blocks
foreach($_script_blocks as $curr_block) {
$source = preg_replace("!@@@SMARTY:TRIM:SCRIPT@@@!",$curr_block,$source,1);
}
// replace pre blocks
foreach($_pre_blocks as $curr_block) {
$source = preg_replace("!@@@SMARTY:TRIM:PRE@@@!",$curr_block,$source,1);
}
// replace textarea blocks
foreach($_textarea_blocks as $curr_block) {
$source = preg_replace("!@@@SMARTY:TRIM:TEXTAREA@@@!",$curr_block,$source,1);
}
return $source;
}
?>

View File

@@ -1,35 +0,0 @@
<?php
/*======================================================================*\
Function: smarty_make_timestamp
Purpose: used by other smarty functions to make a timestamp
from a string.
\*======================================================================*/
function smarty_make_timestamp($string)
{
if(empty($string)) {
$string = "now";
}
$time = strtotime($string);
if (is_numeric($time) && $time != -1)
return $time;
// is mysql timestamp format of YYYYMMDDHHMMSS?
if (is_numeric($string) && strlen($string) == 14) {
$time = mktime(substr($string,8,2),substr($string,10,2),substr($string,12,2),
substr($string,4,2),substr($string,6,2),substr($string,0,4));
return $time;
}
// couldn't recognize it, try to return a time
$time = (int) $string;
if ($time > 0)
return $time;
else
return time();
}
/* vim: set expandtab: */
?>