PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / libraries / vendor / PhpSpreadsheet / Cell / DataValidation.php

DataValidation.php in TablePress – Tables in WordPress made easy 3.4, at libraries/vendor/PhpSpreadsheet/Cell/DataValidation.php

400 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace TablePress\PhpOffice\PhpSpreadsheet\Cell;
4
5 class DataValidation
6 {
7 // Data validation types
8 const TYPE_NONE = 'none';
9 const TYPE_CUSTOM = 'custom';
10 const TYPE_DATE = 'date';
11 const TYPE_DECIMAL = 'decimal';
12 const TYPE_LIST = 'list';
13 const TYPE_TEXTLENGTH = 'textLength';
14 const TYPE_TIME = 'time';
15 const TYPE_WHOLE = 'whole';
16
17 // Data validation error styles
18 const STYLE_STOP = 'stop';
19 const STYLE_WARNING = 'warning';
20 const STYLE_INFORMATION = 'information';
21
22 // Data validation operators
23 const OPERATOR_BETWEEN = 'between';
24 const OPERATOR_EQUAL = 'equal';
25 const OPERATOR_GREATERTHAN = 'greaterThan';
26 const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
27 const OPERATOR_LESSTHAN = 'lessThan';
28 const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
29 const OPERATOR_NOTBETWEEN = 'notBetween';
30 const OPERATOR_NOTEQUAL = 'notEqual';
31 private const DEFAULT_OPERATOR = self::OPERATOR_BETWEEN;
32
33 /**
34 * Formula 1.
35 */
36 private string $formula1 = '';
37
38 /**
39 * Formula 2.
40 */
41 private string $formula2 = '';
42
43 /**
44 * Type.
45 */
46 private string $type = self::TYPE_NONE;
47
48 /**
49 * Error style.
50 */
51 private string $errorStyle = self::STYLE_STOP;
52
53 /**
54 * Operator.
55 */
56 private string $operator = self::DEFAULT_OPERATOR;
57
58 /**
59 * Allow Blank.
60 */
61 private bool $allowBlank = false;
62
63 /**
64 * Show DropDown.
65 */
66 private bool $showDropDown = false;
67
68 /**
69 * Show InputMessage.
70 */
71 private bool $showInputMessage = false;
72
73 /**
74 * Show ErrorMessage.
75 */
76 private bool $showErrorMessage = false;
77
78 /**
79 * Error title.
80 */
81 private string $errorTitle = '';
82
83 /**
84 * Error.
85 */
86 private string $error = '';
87
88 /**
89 * Prompt title.
90 */
91 private string $promptTitle = '';
92
93 /**
94 * Prompt.
95 */
96 private string $prompt = '';
97
98 /**
99 * Get Formula 1.
100 */
101 public function getFormula1(): string
102 {
103 return $this->formula1;
104 }
105
106 /**
107 * Set Formula 1.
108 *
109 * @return $this
110 */
111 public function setFormula1(string $formula)
112 {
113 $this->formula1 = $formula;
114
115 return $this;
116 }
117
118 /**
119 * Get Formula 2.
120 */
121 public function getFormula2(): string
122 {
123 return $this->formula2;
124 }
125
126 /**
127 * Set Formula 2.
128 *
129 * @return $this
130 */
131 public function setFormula2(string $formula)
132 {
133 $this->formula2 = $formula;
134
135 return $this;
136 }
137
138 /**
139 * Get Type.
140 */
141 public function getType(): string
142 {
143 return $this->type;
144 }
145
146 /**
147 * Set Type.
148 *
149 * @return $this
150 */
151 public function setType(string $type)
152 {
153 $this->type = $type;
154
155 return $this;
156 }
157
158 /**
159 * Get Error style.
160 */
161 public function getErrorStyle(): string
162 {
163 return $this->errorStyle;
164 }
165
166 /**
167 * Set Error style.
168 *
169 * @param string $errorStyle see self::STYLE_*
170 *
171 * @return $this
172 */
173 public function setErrorStyle(string $errorStyle)
174 {
175 $this->errorStyle = $errorStyle;
176
177 return $this;
178 }
179
180 /**
181 * Get Operator.
182 */
183 public function getOperator(): string
184 {
185 return $this->operator;
186 }
187
188 /**
189 * Set Operator.
190 *
191 * @return $this
192 */
193 public function setOperator(string $operator)
194 {
195 $this->operator = ($operator === '') ? self::DEFAULT_OPERATOR : $operator;
196
197 return $this;
198 }
199
200 /**
201 * Get Allow Blank.
202 */
203 public function getAllowBlank(): bool
204 {
205 return $this->allowBlank;
206 }
207
208 /**
209 * Set Allow Blank.
210 *
211 * @return $this
212 */
213 public function setAllowBlank(bool $allowBlank)
214 {
215 $this->allowBlank = $allowBlank;
216
217 return $this;
218 }
219
220 /**
221 * Get Show DropDown.
222 */
223 public function getShowDropDown(): bool
224 {
225 return $this->showDropDown;
226 }
227
228 /**
229 * Set Show DropDown.
230 *
231 * @return $this
232 */
233 public function setShowDropDown(bool $showDropDown)
234 {
235 $this->showDropDown = $showDropDown;
236
237 return $this;
238 }
239
240 /**
241 * Get Show InputMessage.
242 */
243 public function getShowInputMessage(): bool
244 {
245 return $this->showInputMessage;
246 }
247
248 /**
249 * Set Show InputMessage.
250 *
251 * @return $this
252 */
253 public function setShowInputMessage(bool $showInputMessage)
254 {
255 $this->showInputMessage = $showInputMessage;
256
257 return $this;
258 }
259
260 /**
261 * Get Show ErrorMessage.
262 */
263 public function getShowErrorMessage(): bool
264 {
265 return $this->showErrorMessage;
266 }
267
268 /**
269 * Set Show ErrorMessage.
270 *
271 * @return $this
272 */
273 public function setShowErrorMessage(bool $showErrorMessage)
274 {
275 $this->showErrorMessage = $showErrorMessage;
276
277 return $this;
278 }
279
280 /**
281 * Get Error title.
282 */
283 public function getErrorTitle(): string
284 {
285 return $this->errorTitle;
286 }
287
288 /**
289 * Set Error title.
290 *
291 * @return $this
292 */
293 public function setErrorTitle(string $errorTitle)
294 {
295 $this->errorTitle = $errorTitle;
296
297 return $this;
298 }
299
300 /**
301 * Get Error.
302 */
303 public function getError(): string
304 {
305 return $this->error;
306 }
307
308 /**
309 * Set Error.
310 *
311 * @return $this
312 */
313 public function setError(string $error)
314 {
315 $this->error = $error;
316
317 return $this;
318 }
319
320 /**
321 * Get Prompt title.
322 */
323 public function getPromptTitle(): string
324 {
325 return $this->promptTitle;
326 }
327
328 /**
329 * Set Prompt title.
330 *
331 * @return $this
332 */
333 public function setPromptTitle(string $promptTitle)
334 {
335 $this->promptTitle = $promptTitle;
336
337 return $this;
338 }
339
340 /**
341 * Get Prompt.
342 */
343 public function getPrompt(): string
344 {
345 return $this->prompt;
346 }
347
348 /**
349 * Set Prompt.
350 *
351 * @return $this
352 */
353 public function setPrompt(string $prompt)
354 {
355 $this->prompt = $prompt;
356
357 return $this;
358 }
359
360 /**
361 * Get hash code.
362 *
363 * @return string Hash code
364 */
365 public function getHashCode(): string
366 {
367 return md5(
368 $this->formula1
369 . $this->formula2
370 . $this->type
371 . $this->errorStyle
372 . $this->operator
373 . ($this->allowBlank ? 't' : 'f')
374 . ($this->showDropDown ? 't' : 'f')
375 . ($this->showInputMessage ? 't' : 'f')
376 . ($this->showErrorMessage ? 't' : 'f')
377 . $this->errorTitle
378 . $this->error
379 . $this->promptTitle
380 . $this->prompt
381 . $this->sqref
382 . __CLASS__
383 );
384 }
385
386 private ?string $sqref = null;
387
388 public function getSqref(): ?string
389 {
390 return $this->sqref;
391 }
392
393 public function setSqref(?string $str): self
394 {
395 $this->sqref = $str;
396
397 return $this;
398 }
399 }
400