Implemented plugin architecture.

This commit is contained in:
andrey
2002-01-31 20:49:40 +00:00
parent 70b076bf0b
commit e6fc0e5291
69 changed files with 3561 additions and 1706 deletions

View File

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