[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/Cell/ -> DataValidation.php (source)

   1  <?php
   2  
   3  /**
   4   * PHPExcel_Cell_DataValidation
   5   *
   6   * Copyright (c) 2006 - 2015 PHPExcel
   7   *
   8   * This library is free software; you can redistribute it and/or
   9   * modify it under the terms of the GNU Lesser General Public
  10   * License as published by the Free Software Foundation; either
  11   * version 2.1 of the License, or (at your option) any later version.
  12   *
  13   * This library is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16   * Lesser General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU Lesser General Public
  19   * License along with this library; if not, write to the Free Software
  20   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  21   *
  22   * @category   PHPExcel
  23   * @package    PHPExcel_Cell
  24   * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  25   * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  26   * @version    ##VERSION##, ##DATE##
  27   */
  28  class PHPExcel_Cell_DataValidation
  29  {
  30      /* Data validation types */
  31      const TYPE_NONE        = 'none';
  32      const TYPE_CUSTOM      = 'custom';
  33      const TYPE_DATE        = 'date';
  34      const TYPE_DECIMAL     = 'decimal';
  35      const TYPE_LIST        = 'list';
  36      const TYPE_TEXTLENGTH  = 'textLength';
  37      const TYPE_TIME        = 'time';
  38      const TYPE_WHOLE       = 'whole';
  39  
  40      /* Data validation error styles */
  41      const STYLE_STOP         = 'stop';
  42      const STYLE_WARNING      = 'warning';
  43      const STYLE_INFORMATION  = 'information';
  44  
  45      /* Data validation operators */
  46      const OPERATOR_BETWEEN             = 'between';
  47      const OPERATOR_EQUAL               = 'equal';
  48      const OPERATOR_GREATERTHAN         = 'greaterThan';
  49      const OPERATOR_GREATERTHANOREQUAL  = 'greaterThanOrEqual';
  50      const OPERATOR_LESSTHAN            = 'lessThan';
  51      const OPERATOR_LESSTHANOREQUAL     = 'lessThanOrEqual';
  52      const OPERATOR_NOTBETWEEN          = 'notBetween';
  53      const OPERATOR_NOTEQUAL            = 'notEqual';
  54  
  55      /**
  56       * Formula 1
  57       *
  58       * @var string
  59       */
  60      private $formula1;
  61  
  62      /**
  63       * Formula 2
  64       *
  65       * @var string
  66       */
  67      private $formula2;
  68  
  69      /**
  70       * Type
  71       *
  72       * @var string
  73       */
  74      private $type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  75  
  76      /**
  77       * Error style
  78       *
  79       * @var string
  80       */
  81      private $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  82  
  83      /**
  84       * Operator
  85       *
  86       * @var string
  87       */
  88      private $operator;
  89  
  90      /**
  91       * Allow Blank
  92       *
  93       * @var boolean
  94       */
  95      private $allowBlank;
  96  
  97      /**
  98       * Show DropDown
  99       *
 100       * @var boolean
 101       */
 102      private $showDropDown;
 103  
 104      /**
 105       * Show InputMessage
 106       *
 107       * @var boolean
 108       */
 109      private $showInputMessage;
 110  
 111      /**
 112       * Show ErrorMessage
 113       *
 114       * @var boolean
 115       */
 116      private $showErrorMessage;
 117  
 118      /**
 119       * Error title
 120       *
 121       * @var string
 122       */
 123      private $errorTitle;
 124  
 125      /**
 126       * Error
 127       *
 128       * @var string
 129       */
 130      private $error;
 131  
 132      /**
 133       * Prompt title
 134       *
 135       * @var string
 136       */
 137      private $promptTitle;
 138  
 139      /**
 140       * Prompt
 141       *
 142       * @var string
 143       */
 144      private $prompt;
 145  
 146      /**
 147       * Create a new PHPExcel_Cell_DataValidation
 148       */
 149      public function __construct()
 150      {
 151          // Initialise member variables
 152          $this->formula1          = '';
 153          $this->formula2          = '';
 154          $this->type              = PHPExcel_Cell_DataValidation::TYPE_NONE;
 155          $this->errorStyle        = PHPExcel_Cell_DataValidation::STYLE_STOP;
 156          $this->operator          = '';
 157          $this->allowBlank        = false;
 158          $this->showDropDown      = false;
 159          $this->showInputMessage  = false;
 160          $this->showErrorMessage  = false;
 161          $this->errorTitle        = '';
 162          $this->error             = '';
 163          $this->promptTitle       = '';
 164          $this->prompt            = '';
 165      }
 166  
 167      /**
 168       * Get Formula 1
 169       *
 170       * @return string
 171       */
 172      public function getFormula1()
 173      {
 174          return $this->formula1;
 175      }
 176  
 177      /**
 178       * Set Formula 1
 179       *
 180       * @param  string    $value
 181       * @return PHPExcel_Cell_DataValidation
 182       */
 183      public function setFormula1($value = '')
 184      {
 185          $this->formula1 = $value;
 186          return $this;
 187      }
 188  
 189      /**
 190       * Get Formula 2
 191       *
 192       * @return string
 193       */
 194      public function getFormula2()
 195      {
 196          return $this->formula2;
 197      }
 198  
 199      /**
 200       * Set Formula 2
 201       *
 202       * @param  string    $value
 203       * @return PHPExcel_Cell_DataValidation
 204       */
 205      public function setFormula2($value = '')
 206      {
 207          $this->formula2 = $value;
 208          return $this;
 209      }
 210  
 211      /**
 212       * Get Type
 213       *
 214       * @return string
 215       */
 216      public function getType()
 217      {
 218          return $this->type;
 219      }
 220  
 221      /**
 222       * Set Type
 223       *
 224       * @param  string    $value
 225       * @return PHPExcel_Cell_DataValidation
 226       */
 227      public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE)
 228      {
 229          $this->type = $value;
 230          return $this;
 231      }
 232  
 233      /**
 234       * Get Error style
 235       *
 236       * @return string
 237       */
 238      public function getErrorStyle()
 239      {
 240          return $this->errorStyle;
 241      }
 242  
 243      /**
 244       * Set Error style
 245       *
 246       * @param  string    $value
 247       * @return PHPExcel_Cell_DataValidation
 248       */
 249      public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP)
 250      {
 251          $this->errorStyle = $value;
 252          return $this;
 253      }
 254  
 255      /**
 256       * Get Operator
 257       *
 258       * @return string
 259       */
 260      public function getOperator()
 261      {
 262          return $this->operator;
 263      }
 264  
 265      /**
 266       * Set Operator
 267       *
 268       * @param  string    $value
 269       * @return PHPExcel_Cell_DataValidation
 270       */
 271      public function setOperator($value = '')
 272      {
 273          $this->operator = $value;
 274          return $this;
 275      }
 276  
 277      /**
 278       * Get Allow Blank
 279       *
 280       * @return boolean
 281       */
 282      public function getAllowBlank()
 283      {
 284          return $this->allowBlank;
 285      }
 286  
 287      /**
 288       * Set Allow Blank
 289       *
 290       * @param  boolean    $value
 291       * @return PHPExcel_Cell_DataValidation
 292       */
 293      public function setAllowBlank($value = false)
 294      {
 295          $this->allowBlank = $value;
 296          return $this;
 297      }
 298  
 299      /**
 300       * Get Show DropDown
 301       *
 302       * @return boolean
 303       */
 304      public function getShowDropDown()
 305      {
 306          return $this->showDropDown;
 307      }
 308  
 309      /**
 310       * Set Show DropDown
 311       *
 312       * @param  boolean    $value
 313       * @return PHPExcel_Cell_DataValidation
 314       */
 315      public function setShowDropDown($value = false)
 316      {
 317          $this->showDropDown = $value;
 318          return $this;
 319      }
 320  
 321      /**
 322       * Get Show InputMessage
 323       *
 324       * @return boolean
 325       */
 326      public function getShowInputMessage()
 327      {
 328          return $this->showInputMessage;
 329      }
 330  
 331      /**
 332       * Set Show InputMessage
 333       *
 334       * @param  boolean    $value
 335       * @return PHPExcel_Cell_DataValidation
 336       */
 337      public function setShowInputMessage($value = false)
 338      {
 339          $this->showInputMessage = $value;
 340          return $this;
 341      }
 342  
 343      /**
 344       * Get Show ErrorMessage
 345       *
 346       * @return boolean
 347       */
 348      public function getShowErrorMessage()
 349      {
 350          return $this->showErrorMessage;
 351      }
 352  
 353      /**
 354       * Set Show ErrorMessage
 355       *
 356       * @param  boolean    $value
 357       * @return PHPExcel_Cell_DataValidation
 358       */
 359      public function setShowErrorMessage($value = false)
 360      {
 361          $this->showErrorMessage = $value;
 362          return $this;
 363      }
 364  
 365      /**
 366       * Get Error title
 367       *
 368       * @return string
 369       */
 370      public function getErrorTitle()
 371      {
 372          return $this->errorTitle;
 373      }
 374  
 375      /**
 376       * Set Error title
 377       *
 378       * @param  string    $value
 379       * @return PHPExcel_Cell_DataValidation
 380       */
 381      public function setErrorTitle($value = '')
 382      {
 383          $this->errorTitle = $value;
 384          return $this;
 385      }
 386  
 387      /**
 388       * Get Error
 389       *
 390       * @return string
 391       */
 392      public function getError()
 393      {
 394          return $this->error;
 395      }
 396  
 397      /**
 398       * Set Error
 399       *
 400       * @param  string    $value
 401       * @return PHPExcel_Cell_DataValidation
 402       */
 403      public function setError($value = '')
 404      {
 405          $this->error = $value;
 406          return $this;
 407      }
 408  
 409      /**
 410       * Get Prompt title
 411       *
 412       * @return string
 413       */
 414      public function getPromptTitle()
 415      {
 416          return $this->promptTitle;
 417      }
 418  
 419      /**
 420       * Set Prompt title
 421       *
 422       * @param  string    $value
 423       * @return PHPExcel_Cell_DataValidation
 424       */
 425      public function setPromptTitle($value = '')
 426      {
 427          $this->promptTitle = $value;
 428          return $this;
 429      }
 430  
 431      /**
 432       * Get Prompt
 433       *
 434       * @return string
 435       */
 436      public function getPrompt()
 437      {
 438          return $this->prompt;
 439      }
 440  
 441      /**
 442       * Set Prompt
 443       *
 444       * @param  string    $value
 445       * @return PHPExcel_Cell_DataValidation
 446       */
 447      public function setPrompt($value = '')
 448      {
 449          $this->prompt = $value;
 450          return $this;
 451      }
 452  
 453      /**
 454       * Get hash code
 455       *
 456       * @return string    Hash code
 457       */
 458      public function getHashCode()
 459      {
 460          return md5(
 461              $this->formula1 .
 462              $this->formula2 .
 463              $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE .
 464              $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP .
 465              $this->operator .
 466              ($this->allowBlank ? 't' : 'f') .
 467              ($this->showDropDown ? 't' : 'f') .
 468              ($this->showInputMessage ? 't' : 'f') .
 469              ($this->showErrorMessage ? 't' : 'f') .
 470              $this->errorTitle .
 471              $this->error .
 472              $this->promptTitle .
 473              $this->prompt .
 474              __CLASS__
 475          );
 476      }
 477  
 478      /**
 479       * Implement PHP __clone to create a deep clone, not just a shallow copy.
 480       */
 481      public function __clone()
 482      {
 483          $vars = get_object_vars($this);
 484          foreach ($vars as $key => $value) {
 485              if (is_object($value)) {
 486                  $this->$key = clone $value;
 487              } else {
 488                  $this->$key = $value;
 489              }
 490          }
 491      }
 492  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1