[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/tags/pager/ -> list.tag.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   * @tag pager:LIST
  12   * @restrict_self_nesting
  13   * @parent_tag_class WactPagerNavigatorTag
  14   * @package wact
  15   * @version $Id: list.tag.php 5945 2007-06-06 08:31:43Z pachanga $
  16   */
  17  class WactPagerListTag extends WactCompilerTag
  18  {
  19    protected $navigator;
  20    protected $navigator_component;
  21    protected $sections_mode = true;
  22    protected $show_separator_var = '';
  23    protected $elipses_count_var = '';
  24  
  25    function generateBeforeContent($code)
  26    {
  27      $this->navigator = $this->findParentByClass('WactPagerNavigatorTag');
  28      $this->navigator_component = $this->navigator->getComponentRefCode();
  29  
  30      if($this->findChildByClass('WactPagerElipsesTag'))
  31        $this->sections_mode = false;
  32  
  33      $this->show_separator_var = $code->getTempVarRef();
  34      $code->writePhp($this->show_separator_var . ' = false;' . "\n");
  35  
  36      $this->elipses_count_var = $code->getTempVarRef();
  37      $code->writePhp($this->elipses_count_var . ' = 0;' . "\n");
  38  
  39      $parent = $this->findParentByClass('WactPagerNavigatorTag');
  40      $code->writePhp('while (' . $parent->getComponentRefCode() . '->isValid()) {');
  41    }
  42  
  43    function generateTagContent($code)
  44    {
  45      if($this->sections_mode)
  46        $this->_generateForSectionsMode($code);
  47      else
  48        $this->_generateForElipsesMode($code);
  49    }
  50  
  51    function generateAfterContent($code)
  52    {
  53      $code->writePhp('}');
  54    }
  55  
  56    protected function _generateForSectionsMode($code)
  57    {
  58      $code->writePhp('if (' . $this->navigator_component . '->isDisplayedSection())');
  59      $code->writePhp('{');
  60        $this->_generateNumber($code);
  61        $code->writePhp($this->navigator_component . '->nextPage();' . "\n");
  62        $this->_generateSeparator($code);
  63      $code->writePhp('}');
  64      $code->writePhp('else');
  65      $code->writePhp('{');
  66        $this->_generateSection($code);
  67        $code->writePhp($this->navigator_component . '->nextSection();' . "\n");
  68      $code->writePhp('}');
  69    }
  70  
  71    protected function _generateForElipsesMode($code)
  72    {
  73      $sep_child = $this->findChildByClass('WactPagerSeparatorTag');
  74      $elipses_child = $this->findChildByClass('WactPagerElipsesTag');
  75  
  76      if ($sep_child)
  77      {
  78        $code->writePhp('if (');
  79        $code->writePhp($this->show_separator_var);
  80        $code->writePhp('&& ');
  81        $code->writePhp($this->navigator_component . '->shouldDisplayPage()');
  82        $code->writePhp(')');
  83        $code->writePhp('{');
  84          $sep_child->generateNow($code);
  85        $code->writePhp('}');
  86        $code->writePhp($this->show_separator_var . ' = TRUE;' . "\n");
  87      }
  88  
  89      $code->writePhp('if (' . $this->navigator_component . '->shouldDisplayPage())');
  90      $code->writePhp('{');
  91        $this->_generateNumber($code);
  92        $code->writePhp($this->elipses_count_var . ' = 0;' . "\n");
  93      $code->writePhp('}' . "\n");
  94      $code->writePhp('else');
  95      $code->writePhp('{');
  96        $code->writePhp('if (' . $this->elipses_count_var . ' == 0) {');
  97          $elipses_child->generateNow($code);
  98        $code->writePhp('}' . "\n");
  99        $code->writePhp($this->elipses_count_var . ' += 1;' . "\n");
 100        $code->writePhp($this->show_separator_var . ' = FALSE;' . "\n");
 101      $code->writePhp('}' . "\n");
 102  
 103      $code->writePhp($this->navigator_component . '->nextPage();' . "\n");
 104    }
 105  
 106    protected function _generateNumber($code)
 107    {
 108      $number_child = $this->findChildByClass('WactPagerNumberTag');
 109      $current_child = $this->findChildByClass('WactPagerDisplayedTag');
 110  
 111      $code->writePhp('if (!(' . $this->navigator_component . '->isFirst() && ' .
 112                                 $this->navigator_component . '->isLast())) {');
 113  
 114      if ($number_child)
 115        $number_child->generate($code);
 116  
 117      if($current_child)
 118        $current_child->generate($code);
 119  
 120      $code->writePhp('}' . "\n");
 121    }
 122  
 123    protected function _generateSeparator($code)
 124    {
 125      $sep_child = $this->findChildByClass('WactPagerSeparatorTag');
 126  
 127      if ($sep_child)
 128      {
 129        $code->writePhp('if (' . $this->navigator_component . '->isValid())' . "\n");
 130        $code->writePhp('{' . "\n");
 131        $sep_child->generateNow($code);
 132        $code->writePhp('}' . "\n");
 133      }
 134    }
 135  
 136    protected function _generateSection($code)
 137    {
 138      $section_child = $this->findChildByClass('WactPagerSectionTag');
 139      if($section_child)
 140        $section_child->generate($code);
 141    }
 142  }
 143  
 144  ?>


Generated: Sat Sep 6 04:46:52 2008 Cross-referenced by PHPXref 0.7