ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
DataValidation.php
Go to the documentation of this file.
1 <?php
37 {
38  /* Data validation types */
39  const TYPE_NONE = 'none';
40  const TYPE_CUSTOM = 'custom';
41  const TYPE_DATE = 'date';
42  const TYPE_DECIMAL = 'decimal';
43  const TYPE_LIST = 'list';
44  const TYPE_TEXTLENGTH = 'textLength';
45  const TYPE_TIME = 'time';
46  const TYPE_WHOLE = 'whole';
47 
48  /* Data validation error styles */
49  const STYLE_STOP = 'stop';
50  const STYLE_WARNING = 'warning';
51  const STYLE_INFORMATION = 'information';
52 
53  /* Data validation operators */
54  const OPERATOR_BETWEEN = 'between';
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_NOTBETWEEN = 'notBetween';
61  const OPERATOR_NOTEQUAL = 'notEqual';
62 
68  private $_formula1;
69 
75  private $_formula2;
76 
83 
90 
96  private $_operator;
97 
103  private $_allowBlank;
104 
110  private $_showDropDown;
111 
118 
125 
131  private $_errorTitle;
132 
138  private $_error;
139 
145  private $_promptTitle;
146 
152  private $_prompt;
153 
159  private $_parent;
160 
167  public function __construct(PHPExcel_Cell $pCell = null)
168  {
169  // Initialise member variables
170  $this->_formula1 = '';
171  $this->_formula2 = '';
173  $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
174  $this->_operator = '';
175  $this->_allowBlank = false;
176  $this->_showDropDown = false;
177  $this->_showInputMessage = false;
178  $this->_showErrorMessage = false;
179  $this->_errorTitle = '';
180  $this->_error = '';
181  $this->_promptTitle = '';
182  $this->_prompt = '';
183 
184  // Set cell
185  $this->_parent = $pCell;
186  }
187 
193  public function getFormula1() {
194  return $this->_formula1;
195  }
196 
203  public function setFormula1($value = '') {
204  $this->_formula1 = $value;
205  return $this;
206  }
207 
213  public function getFormula2() {
214  return $this->_formula2;
215  }
216 
223  public function setFormula2($value = '') {
224  $this->_formula2 = $value;
225  return $this;
226  }
227 
233  public function getType() {
234  return $this->_type;
235  }
236 
244  $this->_type = $value;
245  return $this;
246  }
247 
253  public function getErrorStyle() {
254  return $this->_errorStyle;
255  }
256 
264  $this->_errorStyle = $value;
265  return $this;
266  }
267 
273  public function getOperator() {
274  return $this->_operator;
275  }
276 
283  public function setOperator($value = '') {
284  $this->_operator = $value;
285  return $this;
286  }
287 
293  public function getAllowBlank() {
294  return $this->_allowBlank;
295  }
296 
303  public function setAllowBlank($value = false) {
304  $this->_allowBlank = $value;
305  return $this;
306  }
307 
313  public function getShowDropDown() {
314  return $this->_showDropDown;
315  }
316 
323  public function setShowDropDown($value = false) {
324  $this->_showDropDown = $value;
325  return $this;
326  }
327 
333  public function getShowInputMessage() {
335  }
336 
343  public function setShowInputMessage($value = false) {
344  $this->_showInputMessage = $value;
345  return $this;
346  }
347 
353  public function getShowErrorMessage() {
355  }
356 
363  public function setShowErrorMessage($value = false) {
364  $this->_showErrorMessage = $value;
365  return $this;
366  }
367 
373  public function getErrorTitle() {
374  return $this->_errorTitle;
375  }
376 
383  public function setErrorTitle($value = '') {
384  $this->_errorTitle = $value;
385  return $this;
386  }
387 
393  public function getError() {
394  return $this->_error;
395  }
396 
403  public function setError($value = '') {
404  $this->_error = $value;
405  return $this;
406  }
407 
413  public function getPromptTitle() {
414  return $this->_promptTitle;
415  }
416 
423  public function setPromptTitle($value = '') {
424  $this->_promptTitle = $value;
425  return $this;
426  }
427 
433  public function getPrompt() {
434  return $this->_prompt;
435  }
436 
443  public function setPrompt($value = '') {
444  $this->_prompt = $value;
445  return $this;
446  }
447 
453  public function getParent() {
454  return $this->_parent;
455  }
456 
463  public function setParent($value = null) {
464  $this->_parent = $value;
465  return $this;
466  }
467 
473  public function getHashCode() {
474  return md5(
475  $this->_formula1
476  . $this->_formula2
478  . $this->_errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP
479  . $this->_operator
480  . ($this->_allowBlank ? 't' : 'f')
481  . ($this->_showDropDown ? 't' : 'f')
482  . ($this->_showInputMessage ? 't' : 'f')
483  . ($this->_showErrorMessage ? 't' : 'f')
484  . $this->_errorTitle
485  . $this->_error
486  . $this->_promptTitle
487  . $this->_prompt
488  . $this->_parent->getCoordinate()
489  . __CLASS__
490  );
491  }
492 
496  public function __clone() {
497  // unbind parent
498  $this->setParent(null);
499 
500  $vars = get_object_vars($this);
501  foreach ($vars as $key => $value) {
502  if (is_object($value) && $key != '_parent') {
503  $this->$key = clone $value;
504  } else {
505  $this->$key = $value;
506  }
507  }
508  }
509 }