[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/propel/om/ -> PreOrderNodeIterator.php (source)

   1  <?php
   2  
   3  /*
   4   *  $Id: PreOrderNodeIterator.php 64 2005-05-13 02:43:56Z root $
   5   *
   6   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   7   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   8   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   9   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  10   * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  11   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  12   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  13   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  14   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  15   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  16   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17   *
  18   * This software consists of voluntary contributions made by many individuals
  19   * and is licensed under the LGPL. For more information please see
  20   * <http://propel.phpdb.org>.
  21   */ 
  22  
  23  /**
  24   * Pre-order node iterator for Node objects.
  25   *
  26   * @author Dave Lawson <dlawson@masterytech.com>
  27   * @version $Revision: 64 $
  28   * @package propel.om
  29   */
  30  class PreOrderNodeIterator implements Iterator
  31  {
  32      private $topNode = null;
  33      
  34      private $curNode = null;
  35   
  36      private $querydb = false;
  37      
  38      private $con = null;
  39      
  40      public function __construct($node, $opts) {
  41          $this->topNode = $node;
  42          $this->curNode = $node;
  43          
  44          if (isset($opts['con']))
  45              $this->con = $opts['con'];
  46              
  47          if (isset($opts['querydb']))
  48              $this->querydb = $opts['querydb'];
  49      }
  50      
  51      public function rewind() {
  52          $this->curNode = $this->topNode;
  53      }
  54      
  55      public function valid() {
  56          return ($this->curNode !== null);
  57      }
  58      
  59      public function current() {
  60          return $this->curNode;
  61      }
  62      
  63      public function key() {
  64          return $this->curNode->getNodePath();
  65      }
  66  
  67      public function next() {
  68  
  69          if ($this->valid())
  70          {
  71              $nextNode = $this->curNode->getFirstChildNode($this->querydb, $this->con);
  72  
  73              while ($nextNode === null)
  74              {
  75                  if ($this->curNode === null || $this->curNode->equals($this->topNode))
  76                      break;
  77  
  78                  $nextNode = $this->curNode->getSiblingNode(false, $this->querydb, $this->con);
  79                  
  80                  if ($nextNode === null)
  81                      $this->curNode = $this->curNode->getParentNode($this->querydb, $this->con);
  82              }
  83              
  84              $this->curNode = $nextNode;
  85          }
  86          
  87          return $this->curNode;
  88      }
  89      
  90  }
  91  
  92  ?>


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7