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 - 2010 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 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.2, 2010-01-11
  26.  */
  27.  
  28.  
  29. /** PHPExcel root directory */
  30. if (!defined('PHPEXCEL_ROOT')) {
  31.     /**
  32.      * @ignore
  33.      */
  34.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../');
  35. }
  36.  
  37. /** PHPExcel_Style */
  38. require_once PHPEXCEL_ROOT 'PHPExcel/Style.php';
  39.  
  40. /** PHPExcel_IComparable */
  41. require_once PHPEXCEL_ROOT 'PHPExcel/IComparable.php';
  42.  
  43.  
  44. /**
  45.  * PHPExcel_Style_Conditional
  46.  *
  47.  * @category   PHPExcel
  48.  * @package    PHPExcel_Style
  49.  * @copyright  Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  50.  */
  51. class PHPExcel_Style_Conditional implements PHPExcel_IComparable
  52. {
  53.     /* Condition types */
  54.     const CONDITION_NONE                    'none';
  55.     const CONDITION_CELLIS                    'cellIs';
  56.     const CONDITION_CONTAINSTEXT            'containsText';
  57.     const CONDITION_EXPRESSION                 'expression';
  58.     
  59.     /* Operator types */
  60.     const OPERATOR_NONE                        '';
  61.     const OPERATOR_BEGINSWITH                'beginsWith';
  62.     const OPERATOR_ENDSWITH                    'endsWith';
  63.     const OPERATOR_EQUAL                    'equal';
  64.     const OPERATOR_GREATERTHAN                'greaterThan';
  65.     const OPERATOR_GREATERTHANOREQUAL        'greaterThanOrEqual';
  66.     const OPERATOR_LESSTHAN                    'lessThan';
  67.     const OPERATOR_LESSTHANOREQUAL            'lessThanOrEqual';
  68.     const OPERATOR_NOTEQUAL                    'notEqual';
  69.     const OPERATOR_CONTAINSTEXT                'containsText';
  70.     const OPERATOR_NOTCONTAINS                'notContains';
  71.     const OPERATOR_BETWEEN                    'between';
  72.     
  73.     /**
  74.      * Condition type
  75.      *
  76.      * @var int 
  77.      */
  78.     private $_conditionType;
  79.     
  80.     /**
  81.      * Operator type
  82.      *
  83.      * @var int 
  84.      */
  85.     private $_operatorType;
  86.     
  87.     /**
  88.      * Text
  89.      *
  90.      * @var string 
  91.      */
  92.     private $_text;
  93.     
  94.     /**
  95.      * Condition
  96.      *
  97.      * @var string[] 
  98.      */
  99.     private $_condition = array();
  100.     
  101.     /**
  102.      * Style
  103.      * 
  104.      * @var PHPExcel_Style 
  105.      */
  106.     private $_style;
  107.         
  108.     /**
  109.      * Create a new PHPExcel_Style_Conditional
  110.      */
  111.     public function __construct()
  112.     {
  113.         // Initialise values
  114.         $this->_conditionType        = PHPExcel_Style_Conditional::CONDITION_NONE;
  115.         $this->_operatorType        = PHPExcel_Style_Conditional::OPERATOR_NONE;
  116.         $this->_text                = null;
  117.         $this->_condition            = array();
  118.         $this->_style                = new PHPExcel_Style();
  119.     }
  120.     
  121.     /**
  122.      * Get Condition type
  123.      *
  124.      * @return string 
  125.      */
  126.     public function getConditionType({
  127.         return $this->_conditionType;
  128.     }
  129.     
  130.     /**
  131.      * Set Condition type
  132.      *
  133.      * @param string $pValue    PHPExcel_Style_Conditional condition type
  134.      * @return PHPExcel_Style_Conditional 
  135.      */
  136.     public function setConditionType($pValue PHPExcel_Style_Conditional::CONDITION_NONE{
  137.         $this->_conditionType = $pValue;
  138.         return $this;
  139.     }
  140.     
  141.     /**
  142.      * Get Operator type
  143.      *
  144.      * @return string 
  145.      */
  146.     public function getOperatorType({
  147.         return $this->_operatorType;
  148.     }
  149.     
  150.     /**
  151.      * Set Operator type
  152.      *
  153.      * @param string $pValue    PHPExcel_Style_Conditional operator type
  154.      * @return PHPExcel_Style_Conditional 
  155.      */
  156.     public function setOperatorType($pValue PHPExcel_Style_Conditional::OPERATOR_NONE{
  157.         $this->_operatorType = $pValue;
  158.         return $this;
  159.     }
  160.     
  161.     /**
  162.      * Get text
  163.      *
  164.      * @return string 
  165.      */
  166.     public function getText({
  167.         return $this->_text;
  168.     }
  169.     
  170.     /**
  171.      * Set text
  172.      *
  173.      * @param string $value 
  174.      * @return PHPExcel_Style_Conditional 
  175.      */
  176.     public function setText($value null{
  177.            $this->_text = $value;
  178.            return $this;
  179.     }
  180.     
  181.     /**
  182.      * Get Condition
  183.      *
  184.      * @deprecated Deprecated, use getConditions instead
  185.      * @return string 
  186.      */
  187.     public function getCondition({
  188.         if (isset($this->_condition[0])) {
  189.             return $this->_condition[0];
  190.         }
  191.         
  192.         return '';
  193.     }
  194.     
  195.     /**
  196.      * Set Condition
  197.      *
  198.      * @deprecated Deprecated, use setConditions instead
  199.      * @param string $pValue    Condition
  200.      * @return PHPExcel_Style_Conditional 
  201.      */
  202.     public function setCondition($pValue ''{
  203.         if (!is_array($pValue))
  204.             $pValue array($pValue);
  205.             
  206.         return $this->setConditions($pValue);
  207.     }
  208.     
  209.     /**
  210.      * Get Conditions
  211.      *
  212.      * @return string[] 
  213.      */
  214.     public function getConditions({
  215.         return $this->_condition;
  216.     }
  217.     
  218.     /**
  219.      * Set Conditions
  220.      *
  221.      * @param string[] $pValue    Condition
  222.      * @return PHPExcel_Style_Conditional 
  223.      */
  224.     public function setConditions($pValue{
  225.         if (!is_array($pValue))
  226.             $pValue array($pValue);
  227.             
  228.         $this->_condition = $pValue;
  229.         return $this;
  230.     }
  231.     
  232.     /**
  233.      * Add Condition
  234.      *
  235.      * @param string $pValue    Condition
  236.      * @return PHPExcel_Style_Conditional 
  237.      */
  238.     public function addCondition($pValue ''{
  239.         $this->_condition[$pValue;
  240.         return $this;
  241.     }
  242.     
  243.     /**
  244.      * Get Style
  245.      *
  246.      * @return PHPExcel_Style 
  247.      */
  248.     public function getStyle({
  249.         return $this->_style;
  250.     }
  251.     
  252.     /**
  253.      * Set Style
  254.      *
  255.      * @param     PHPExcel_Style $pValue 
  256.      * @throws     Exception
  257.      * @return PHPExcel_Style_Conditional 
  258.      */
  259.     public function setStyle(PHPExcel_Style $pValue null{
  260.            $this->_style = $pValue;
  261.            return $this;
  262.     }
  263.  
  264.     /**
  265.      * Get hash code
  266.      *
  267.      * @return string    Hash code
  268.      */    
  269.     public function getHashCode({
  270.         return md5(
  271.               $this->_conditionType
  272.             . $this->_operatorType
  273.             . implode(';'$this->_condition)
  274.             . $this->_style->getHashCode()
  275.             . __CLASS__
  276.         );
  277.     }
  278.     
  279.     /**
  280.      * Implement PHP __clone to create a deep clone, not just a shallow copy.
  281.      */
  282.     public function __clone({
  283.         $vars get_object_vars($this);
  284.         foreach ($vars as $key => $value{
  285.             if (is_object($value)) {
  286.                 $this->$key clone $value;
  287.             else {
  288.                 $this->$key $value;
  289.             }
  290.         }
  291.     }
  292. }

Documentation generated on Mon, 11 Jan 2010 08:07:25 +0100 by phpDocumentor 1.4.1