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