/[cvs]/nfo/php/libs/net.php.smarty/plugins/function.counter.php
ViewVC logotype

Contents of /nfo/php/libs/net.php.smarty/plugins/function.counter.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Wed Oct 9 00:53:36 2002 UTC (21 years, 9 months ago) by cvsjoko
Branch: MAIN
no message

1 <?php
2
3 /*
4 * Smarty plugin
5 * -------------------------------------------------------------
6 * Type: function
7 * Name: counter
8 * Purpose: print out a counter value
9 * -------------------------------------------------------------
10 */
11 function smarty_function_counter($params, &$smarty)
12 {
13 static $count = array();
14 static $skipval = array();
15 static $dir = array();
16 static $name = "default";
17 static $printval = array();
18 static $assign = "";
19
20 extract($params);
21
22 if (!isset($name)) {
23 if(isset($id)) {
24 $name = $id;
25 } else {
26 $name = "default";
27 }
28 }
29
30 if (isset($start))
31 $count[$name] = $start;
32 else if (!isset($count[$name]))
33 $count[$name]=1;
34
35 if (!isset($print))
36 $printval[$name]=true;
37 else
38 $printval[$name]=$print;
39
40 if (!empty($assign)) {
41 $printval[$name] = false;
42 $smarty->assign($assign, $count[$name]);
43 }
44
45 if ($printval[$name])
46 echo $count[$name];
47
48 if (isset($skip))
49 $skipval[$name] = $skip;
50 else if (empty($skipval[$name]))
51 $skipval[$name] = 1;
52
53 if (isset($direction))
54 $dir[$name] = $direction;
55 else if (!isset($dir[$name]))
56 $dir[$name] = "up";
57
58 if ($dir[$name] == "down")
59 $count[$name] -= $skipval[$name];
60 else
61 $count[$name] += $skipval[$name];
62 }
63
64 /* vim: set expandtab: */
65
66 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed