HTML_Table_Matrix
[ class tree: HTML_Table_Matrix ] [ index: HTML_Table_Matrix ] [ all elements ]

Source for file InCC.php

Documentation is available at InCC.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. require_once 'HTML/Table/Matrix/Filler.php';
  4.  
  5. /**
  6.  * Fill inwards, clockwise.
  7.  *
  8.  * @author Arpad Ray <arpad@rajeczy.com>
  9.  * @package HTML_Table_Matrix
  10.  */
  11.  
  12.     /**
  13.      * Number of columns to move towards the right for the next cell
  14.      *
  15.      * @type int
  16.      */
  17.     var $_right = 0;
  18.  
  19.     /**
  20.      * Number of rows to move downwards for the next cell
  21.      *
  22.      * @type int
  23.      */
  24.     var $_down = 1;
  25.  
  26.     /**
  27.      * Number of cells inwards for the current revolution
  28.      *
  29.      * @type int
  30.      */
  31.     var $_in = 0;
  32.     
  33.     /**
  34.      * Constructor
  35.      *
  36.      * @param Object $matrix Reference to the HTML_Table_Matrix instance we are
  37.      *                        filling data for.
  38.      * @param array $options Options for this Filler
  39.      * @return void 
  40.      */
  41.     function HTML_Table_Matrix_Filler_InCC(&$matrix$options = false{
  42.         $this->setOptions($options);
  43.         $this->matrix = $matrix;
  44.     }
  45.  
  46.     /**
  47.      * Get the next cell.
  48.      *
  49.      * @param int $index Where we're at in the data-set
  50.      * @return array 1-dimensional array in the form of (row, col) containing the
  51.      *                coordinates to put the data for this loop iteration
  52.      */
  53.     function next($index{
  54.         if ($index == 0{
  55.             $this->row = $this->matrix->_fillStartRow;
  56.             $this->col = $this->matrix->_fillStartCol;
  57.         else {
  58.             $this->row += $this->_down;
  59.             $this->col += $this->_right;
  60.             if ($this->row == $this->matrix->_rows - $this->_in - 1{
  61.                 // last row
  62.                 if ($this->col == $this->matrix->_cols - $this->_in - 1{
  63.                     // last column
  64.                     $this->_right = 0;
  65.                     $this->_down = -1;
  66.                 else if ($this->col == $this->matrix->_fillStartCol + $this->_in{
  67.                     // first column
  68.                     $this->_right = 1;
  69.                     $this->_down = 0;
  70.                 }
  71.             else if ($this->row == $this->matrix->_fillStartRow + $this->_in
  72.                  && $this->col == $this->matrix->_cols - $this->_in - 1
  73.                  && $this->col != $this->matrix->_fillStartCol + $this->_in{
  74.                 // first row, last column, revolution width != 1
  75.                 $this->_right = -1;
  76.                 $this->_down = 0;
  77.             else if ($this->col + $this->_right == $this->matrix->_fillStartCol + $this->_in
  78.                  && $this->row + $this->_down == $this->matrix->_fillStartRow + $this->_in{
  79.                 // next cell would be the starting
  80.                 $this->_in++;
  81.                 $this->_right = 0;
  82.                 $this->_down = 1;
  83.             }
  84.         }
  85.         return array($this->row$this->col);
  86.     }
  87. }
  88. ?>

Documentation generated on Mon, 11 Mar 2019 15:32:39 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.