00001 <?php 00022 function smarty_function_counter($params, &$smarty) 00023 { 00024 static $counters = array(); 00025 00026 $name = (isset($params['name'])) ? $params['name'] : 'default'; 00027 if (!isset($counters[$name])) { 00028 $counters[$name] = array( 00029 'start'=>1, 00030 'skip'=>1, 00031 'direction'=>'up', 00032 'count'=>1 00033 ); 00034 } 00035 $counter =& $counters[$name]; 00036 00037 if (isset($params['start'])) { 00038 $counter['start'] = $counter['count'] = (int)$params['start']; 00039 } 00040 00041 if (!empty($params['assign'])) { 00042 $counter['assign'] = $params['assign']; 00043 } 00044 00045 if (isset($counter['assign'])) { 00046 $smarty->assign($counter['assign'], $counter['count']); 00047 } 00048 00049 if (isset($params['print'])) { 00050 $print = (bool)$params['print']; 00051 } else { 00052 $print = empty($counter['assign']); 00053 } 00054 00055 if ($print) { 00056 $retval = $counter['count']; 00057 } else { 00058 $retval = null; 00059 } 00060 00061 if (isset($params['skip'])) { 00062 $counter['skip'] = $params['skip']; 00063 } 00064 00065 if (isset($params['direction'])) { 00066 $counter['direction'] = $params['direction']; 00067 } 00068 00069 if ($counter['direction'] == "down") 00070 $counter['count'] -= $counter['skip']; 00071 else 00072 $counter['count'] += $counter['skip']; 00073 00074 return $retval; 00075 00076 } 00077 00078 /* vim: set expandtab: */ 00079 00080 ?>
| Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|
