[ Index ]

krapohl.info

title

Body

[close]

/pnincludes/Smarty/plugins/ -> function.counter.php (source)

   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  ?>


Generated: Wed Feb 16 22:40:07 2005 Cross-referenced by PHPXref 0.6