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

Source for file Conditional.php

Documentation is available at Conditional.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Style
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.5, 2009-01-05
  26.  */
  27.  
  28.  
  29. /** PHPExcel_Style */
  30. require_once 'PHPExcel/Style.php';
  31.  
  32. /** PHPExcel_IComparable */
  33. require_once 'PHPExcel/IComparable.php';
  34.  
  35.  
  36. /**
  37.  * PHPExcel_Style_Conditional
  38.  *
  39.  * @category   PHPExcel
  40.  * @package    PHPExcel_Style
  41.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  42.  */
  43. class PHPExcel_Style_Conditional implements PHPExcel_IComparable
  44. {
  45.     /* Condition types */
  46.     const CONDITION_NONE                    'none';
  47.     const CONDITION_CELLIS                    'cellIs';
  48.     const CONDITION_CONTAINSTEXT            'containsText';
  49.     const CONDITION_EXPRESSION                 'expression';
  50.     
  51.     /* Operator types */
  52.     const OPERATOR_NONE                        '';
  53.     const OPERATOR_BEGINSWITH                'beginsWith';
  54.     const OPERATOR_ENDSWITH                    'endsWith';
  55.     const OPERATOR_EQUAL                    'equal';
  56.     const OPERATOR_GREATERTHAN                'greaterThan';
  57.     const OPERATOR_GREATERTHANOREQUAL        'greaterThanOrEqual';
  58.     const OPERATOR_LESSTHAN                    'lessThan';
  59.     const OPERATOR_LESSTHANOREQUAL            'lessThanOrEqual';
  60.     const OPERATOR_NOTEQUAL                    'notEqual';
  61.     const OPERATOR_CONTAINSTEXT                'containsText';
  62.     const OPERATOR_NOTCONTAINS                'notContains';
  63.     const OPERATOR_BETWEEN                    'between';
  64.     
  65.     /**
  66.      * Condition type
  67.      *
  68.      * @var int 
  69.      */
  70.     private $_conditionType;
  71.     
  72.     /**
  73.      * Operator type
  74.      *
  75.      * @var int 
  76.      */
  77.     private $_operatorType;
  78.     
  79.     /**
  80.      * Text
  81.      *
  82.      * @var string 
  83.      */
  84.     private $_text;
  85.     
  86.     /**
  87.      * Condition
  88.      *
  89.      * @var string[] 
  90.      */
  91.     private $_condition = array();
  92.     
  93.     /**
  94.      * Style
  95.      * 
  96.      * @var PHPExcel_Style 
  97.      */
  98.     private $_style;
  99.         
  100.     /**
  101.      * Create a new PHPExcel_Style_Conditional
  102.      */
  103.     public function __construct()
  104.     {
  105.         // Initialise values
  106.         $this->_conditionType        = PHPExcel_Style_Conditional::CONDITION_NONE;
  107.         $this->_operatorType        = PHPExcel_Style_Conditional::OPERATOR_NONE;
  108.         $this->_text                = null;
  109.         $this->_condition            = array();
  110.         $this->_style                = new PHPExcel_Style();
  111.     }
  112.     
  113.     /**
  114.      * Get Condition type
  115.      *
  116.      * @return string 
  117.      */
  118.     public function getConditionType({
  119.         return $this->_conditionType;
  120.     }
  121.     
  122.     /**
  123.      * Set Condition type
  124.      *
  125.      * @param string $pValue    PHPExcel_Style_Conditional condition type
  126.      */
  127.     public function setConditionType($pValue PHPExcel_Style_Conditional::CONDITION_NONE{
  128.         $this->_conditionType = $pValue;
  129.     }
  130.     
  131.     /**
  132.      * Get Operator type
  133.      *
  134.      * @return string 
  135.      */
  136.     public function getOperatorType({
  137.         return $this->_operatorType;
  138.     }
  139.     
  140.     /**
  141.      * Set Operator type
  142.      *
  143.      * @param string $pValue    PHPExcel_Style_Conditional operator type
  144.      */
  145.     public function setOperatorType($pValue PHPExcel_Style_Conditional::OPERATOR_NONE{
  146.         $this->_operatorType = $pValue;
  147.     }
  148.     
  149.     /**
  150.      * Get text
  151.      *
  152.      * @return string 
  153.      */
  154.     public function getText({
  155.         return $this->_text;
  156.     }
  157.     
  158.     /**
  159.      * Set text
  160.      *
  161.      * @param string $value 
  162.      */
  163.     public function setText($value null{
  164.            $this->_text = $value;
  165.     }
  166.     
  167.     /**
  168.      * Get Condition
  169.      *
  170.      * @deprecated Deprecated, use getConditions instead
  171.      * @return string 
  172.      */
  173.     public function getCondition({
  174.         if (isset($this->_condition[0])) {
  175.             return $this->_condition[0];
  176.         }
  177.         
  178.         return '';
  179.     }
  180.     
  181.     /**
  182.      * Set Condition
  183.      *
  184.      * @deprecated Deprecated, use setConditions instead
  185.      * @param string $pValue    Condition
  186.      */
  187.     public function setCondition($pValue ''{
  188.         if (!is_array($pValue))
  189.             $pValue array($pValue);
  190.             
  191.         $this->setConditions($pValue);
  192.     }
  193.     
  194.     /**
  195.      * Get Conditions
  196.      *
  197.      * @return string[] 
  198.      */
  199.     public function getConditions({
  200.         return $this->_condition;
  201.     }
  202.     
  203.     /**
  204.      * Set Conditions
  205.      *
  206.      * @param string[] $pValue    Condition
  207.      */
  208.     public function setConditions($pValue{
  209.         if (!is_array($pValue))
  210.             $pValue array($pValue);
  211.             
  212.         $this->_condition = $pValue;
  213.     }
  214.     
  215.     /**
  216.      * Add Condition
  217.      *
  218.      * @param string $pValue    Condition
  219.      */
  220.     public function addCondition($pValue ''{
  221.         $this->_condition[$pValue;
  222.     }
  223.     
  224.     /**
  225.      * Get Style
  226.      *
  227.      * @return PHPExcel_Style 
  228.      */
  229.     public function getStyle({
  230.         return $this->_style;
  231.     }
  232.     
  233.     /**
  234.      * Set Style
  235.      *
  236.      * @param     PHPExcel_Style $pValue 
  237.      * @throws     Exception
  238.      */
  239.     public function setStyle(PHPExcel_Style $pValue null{
  240.            $this->_style = $pValue;
  241.     }
  242.  
  243.     /**
  244.      * Get hash code
  245.      *
  246.      * @return string    Hash code
  247.      */    
  248.     public function getHashCode({
  249.         return md5(
  250.               $this->_conditionType
  251.             . $this->_operatorType
  252.             . implode(';'$this->_condition)
  253.             . $this->_style->getHashCode()
  254.             . __CLASS__
  255.         );
  256.     }
  257.     
  258.     /**
  259.      * Hash index
  260.      *
  261.      * @var string 
  262.      */
  263.     private $_hashIndex;
  264.     
  265.     /**
  266.      * Get hash index
  267.      * 
  268.      * Note that this index may vary during script execution! Only reliable moment is
  269.      * while doing a write of a workbook and when changes are not allowed.
  270.      *
  271.      * @return string    Hash index
  272.      */
  273.     public function getHashIndex({
  274.         return $this->_hashIndex;
  275.     }
  276.     
  277.     /**
  278.      * Set hash index
  279.      * 
  280.      * Note that this index may vary during script execution! Only reliable moment is
  281.      * while doing a write of a workbook and when changes are not allowed.
  282.      *
  283.      * @param string    $value    Hash index
  284.      */
  285.     public function setHashIndex($value{
  286.         $this->_hashIndex = $value;
  287.     }
  288.         
  289.     /**
  290.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  291.      */
  292.     public function __clone({
  293.         $vars get_object_vars($this);
  294.         foreach ($vars as $key => $value{
  295.             if (is_object($value)) {
  296.                 $this->$key clone $value;
  297.             else {
  298.                 $this->$key $value;
  299.             }
  300.         }
  301.     }
  302. }

Documentation generated on Mon, 05 Jan 2009 20:36:43 +0100 by phpDocumentor 1.4.1