[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/components/list/ -> WactListSeparatorComponent.class.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  
  10  /**
  11   * Represents list tags separator at runtime.
  12   * Created just to simplify list:separator tag code
  13   * @package wact
  14   * @version $Id$
  15   */
  16  class WactListSeparatorComponent extends WactRuntimeComponent
  17  {
  18    protected $step = 1;
  19    protected $step_counter = 0;
  20    protected $total = 0;
  21    protected $total_counter = 0;
  22    protected $list_component = null;
  23    protected $skip_next = false;
  24  
  25    function setStep($step)
  26    {
  27      if($step < 1)
  28        $step = 1;
  29  
  30      $this->step = $step;
  31    }
  32  
  33    function next()
  34    {
  35      if($this->skip_next)
  36        $this->step_counter = 0;
  37      else
  38        $this->step_counter++;
  39  
  40      $this->total_counter++;
  41    }
  42  
  43    function reset()
  44    {
  45      $this->step_counter = 0;
  46    }
  47  
  48    function prepare()
  49    {
  50      $this->step_counter = 0;
  51      $this->total_counter = 0;
  52  
  53      if(!$this->list_component)
  54      {
  55        $this->list_component = $this->findParentByClass('WactListComponent');
  56        if(!$this->list_component)
  57          throw new WactException('Parent List Component not found');
  58      }
  59  
  60      $this->total = $this->list_component->countPaginated();
  61    }
  62  
  63    function shouldDisplay()
  64    {
  65      if($this->skip_next ||
  66         ($this->step_counter != $this->step) ||
  67         ($this->total_counter >= $this->total) ||
  68         !$this->list_component->valid())
  69      {
  70        $result = false;
  71      }
  72      else
  73        $result = true;
  74  
  75      $this->skip_next = false;
  76  
  77      return $result;
  78    }
  79  
  80    function skipNext()
  81    {
  82      $this->reset();
  83      $this->skip_next = true;
  84    }
  85  }
  86  ?>


Generated: Thu Oct 16 04:42:25 2008 Cross-referenced by PHPXref 0.7