TTextBox::addAttributesToRender()   F
last analyzed

Complexity

Conditions 37
Paths 8320

Size

Total Lines 105
Code Lines 87

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 1406

Importance

Changes 0
Metric Value
cc 37
eloc 87
c 0
b 0
f 0
nc 8320
nop 1
dl 0
loc 105
ccs 0
cts 102
cp 0
crap 1406
rs 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * TTextBox class file.
5
 *
6
 * @author Qiang Xue <[email protected]>
7
 * @link https://github.com/pradosoft/prado
8
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
9
 */
10
11
namespace Prado\Web\UI\WebControls;
12
13
use Prado\Prado;
14
use Prado\TPropertyValue;
15
use Prado\Web\THttpUtility;
16
use Prado\Exceptions\TInvalidDataValueException;
17
use Prado\Exceptions\TConfigurationException;
18
19
/**
20
 * TTextBox class
21
 *
22
 * TTextBox displays a text box on the Web page for user input.
23
 * The text displayed in the TTextBox control is determined by the
24
 * {@see setText Text} property. You can create a <b>SingleLine</b>,
25
 * a <b>MultiLine</b>, or a <b>Password</b> text box by setting
26
 * the {@see setTextMode TextMode} property. If the TTextBox control
27
 * is a multiline text box, the number of rows it displays is determined
28
 * by the {@see setRows Rows} property, and the {@see setWrap Wrap} property
29
 * can be used to determine whether to wrap the text in the component.
30
 * Additional {@see setTextMode TextMode} types enable the use of new input types
31
 * added with html5, eg. <b>Color</b>, <b>Date</b>, <b>Email</b>.
32
 *
33
 * To specify the display width of the text box, in characters, set
34
 * the {@see setColumns Columns} property. To prevent the text displayed
35
 * in the component from being modified, set the {@see setReadOnly ReadOnly}
36
 * property to true. If you want to limit the user input to a specified number
37
 * of characters, set the {@see setMaxLength MaxLength} property.
38
 * To use AutoComplete feature, set the {@see setAutoCompleteType AutoCompleteType} property.
39
 *
40
 * If {@see setAutoPostBack AutoPostBack} is set true, updating the text box
41
 * and then changing the focus out of it will cause postback action.
42
 * And if {@see setCausesValidation CausesValidation} is true, validation will
43
 * also be processed, which can be further restricted within
44
 * a {@see setValidationGroup ValidationGroup}.
45
 *
46
 * WARNING: Be careful if you want to display the text collected via TTextBox.
47
 * Malicious cross-site script may be injected in. You may use {@see getSafeText SafeText}
48
 * to prevent this problem.
49
 *
50
 * NOTE: If you set {@see setWrap Wrap} to false or use {@see setAutoCompleteType AutoCompleteType},
51
 * the generated HTML output for the textbox will not be XHTML-compatible.
52
 * Currently, no alternatives are available.
53
 *
54
 * @author Qiang Xue <[email protected]>
55
 * @since 3.0
56
 */
57
class TTextBox extends \Prado\Web\UI\WebControls\TWebControl implements \Prado\Web\UI\IPostBackDataHandler, \Prado\Web\UI\IValidatable, \Prado\IDataRenderer
58
{
59
	/**
60
	 * Default number of rows (for MultiLine text box)
61
	 */
62
	public const DEFAULT_ROWS = 4;
63
	/**
64
	 * Default number of columns (for MultiLine text box)
65
	 */
66
	public const DEFAULT_COLUMNS = 20;
67
	/**
68
	 * @var mixed safe text parser
69
	 */
70
	private static $_safeTextParser;
71
	/**
72
	 * @var string safe textbox content with javascript stripped off
73
	 */
74
	private $_safeText;
75
	private $_dataChanged = false;
76
	private $_isValid = true;
77
78
	/**
79
	 * @return string tag name of the textbox
80
	 */
81
	protected function getTagName()
82
	{
83
		return ($this->getTextMode() === TTextBoxMode::MultiLine) ? 'textarea' : 'input';
0 ignored issues
show
introduced by
The condition $this->getTextMode() ===...TTextBoxMode::MultiLine is always false.
Loading history...
84
	}
85
86
	/**
87
	 * @return bool whether to render javascript.
88
	 */
89
	public function getEnableClientScript()
90
	{
91
		return $this->getViewState('EnableClientScript', true);
92
	}
93
94
	/**
95
	 * @param bool $value whether to render javascript.
96
	 */
97
	public function setEnableClientScript($value)
98
	{
99
		$this->setViewState('EnableClientScript', TPropertyValue::ensureBoolean($value), true);
100
	}
101
102
	/**
103
	 * Adds attribute name-value pairs to renderer.
104
	 * This method overrides the parent implementation with additional textbox specific attributes.
105
	 * @param \Prado\Web\UI\THtmlWriter $writer the writer used for the rendering purpose
106
	 */
107
	protected function addAttributesToRender($writer)
108
	{
109
		$page = $this->getPage();
110
		$page->ensureRenderInForm($this);
111
		if (($uid = $this->getUniqueID()) !== '') {
112
			$writer->addAttribute('name', $uid);
113
		}
114
		if (($textMode = $this->getTextMode()) === TTextBoxMode::MultiLine) {
0 ignored issues
show
introduced by
The condition $textMode = $this->getTe...TTextBoxMode::MultiLine is always false.
Loading history...
115
			if (($rows = $this->getRows()) <= 0) {
116
				$rows = self::DEFAULT_ROWS;
117
			}
118
			if (($cols = $this->getColumns()) <= 0) {
119
				$cols = self::DEFAULT_COLUMNS;
120
			}
121
			$writer->addAttribute('rows', "$rows");
122
			$writer->addAttribute('cols', "$cols");
123
			if (!$this->getWrap()) {
124
				$writer->addAttribute('wrap', 'off');
125
			}
126
		} else {
127
			switch ($textMode) {
128
				case TTextBoxMode::Password:
129
					$writer->addAttribute('type', 'password');
130
					break;
131
				case TTextBoxMode::Color:
132
					$writer->addAttribute('type', 'color');
133
					break;
134
				case TTextBoxMode::Date:
135
					$writer->addAttribute('type', 'date');
136
					break;
137
				case TTextBoxMode::Datetime:
138
					$writer->addAttribute('type', 'datetime');
139
					break;
140
				case TTextBoxMode::DatetimeLocal:
141
					$writer->addAttribute('type', 'datetime-local');
142
					break;
143
				case TTextBoxMode::Email:
144
					$writer->addAttribute('type', 'email');
145
					break;
146
				case TTextBoxMode::Month:
147
					$writer->addAttribute('type', 'month');
148
					break;
149
				case TTextBoxMode::Number:
150
					$writer->addAttribute('type', 'number');
151
					break;
152
				case TTextBoxMode::Range:
153
					$writer->addAttribute('type', 'range');
154
					break;
155
				case TTextBoxMode::Search:
156
					$writer->addAttribute('type', 'search');
157
					break;
158
				case TTextBoxMode::Tel:
159
					$writer->addAttribute('type', 'tel');
160
					break;
161
				case TTextBoxMode::Time:
162
					$writer->addAttribute('type', 'time');
163
					break;
164
				case TTextBoxMode::Url:
165
					$writer->addAttribute('type', 'url');
166
					break;
167
				case TTextBoxMode::Week:
168
					$writer->addAttribute('type', 'week');
169
					break;
170
				case TTextBoxMode::SingleLine:
171
				default:
172
					$writer->addAttribute('type', 'text');
173
					break;
174
			}
175
176
			if (($text = $this->getText()) !== '' && ($textMode !== TTextBoxMode::Password || $this->getPersistPassword())) {
177
				$writer->addAttribute('value', $text);
178
			}
179
180
			switch ($this->getAutoCompleteType()) {
181
				case TTextBoxAutoCompleteType::Enabled:
182
					$writer->addAttribute('autocomplete', 'on');
183
					break;
184
				case TTextBoxAutoCompleteType::Disabled:
185
					$writer->addAttribute('autocomplete', 'off');
186
					break;
187
				case TTextBoxAutoCompleteType::None:
188
					break;
189
			}
190
191
			if (($cols = $this->getColumns()) > 0) {
192
				$writer->addAttribute('size', "$cols");
193
			}
194
			if (($maxLength = $this->getMaxLength()) > 0) {
195
				$writer->addAttribute('maxlength', "$maxLength");
196
			}
197
		}
198
		if ($this->getReadOnly()) {
199
			$writer->addAttribute('readonly', 'readonly');
200
		}
201
		$isEnabled = $this->getEnabled(true);
202
		if (!$isEnabled && $this->getEnabled()) {  // in this case parent will not render 'disabled'
203
			$writer->addAttribute('disabled', 'disabled');
204
		}
205
		if ($isEnabled
206
			&& $this->getEnableClientScript()
207
			&& ($this->getAutoPostBack() || $textMode === TTextBoxMode::SingleLine)
208
			&& $page->getClientSupportsJavaScript()) {
209
			$this->renderClientControlScript($writer);
210
		}
211
		parent::addAttributesToRender($writer);
212
	}
213
214
	/**
215
	 * Renders the javascript for textbox.
216
	 * @param mixed $writer
217
	 */
218
	protected function renderClientControlScript($writer)
219
	{
220
		$writer->addAttribute('id', $this->getClientID());
221
		$cs = $this->getPage()->getClientScript();
222
		$cs->registerPostBackControl($this->getClientClassName(), $this->getPostBackOptions());
223
	}
224
225
	/**
226
	 * Gets the name of the javascript class responsible for performing postback for this control.
227
	 * This method overrides the parent implementation.
228
	 * @return string the javascript class name
229
	 */
230
	protected function getClientClassName()
231
	{
232
		return 'Prado.WebUI.TTextBox';
233
	}
234
235
	/**
236
	 * Gets the post back options for this textbox.
237
	 * @return array
238
	 */
239
	protected function getPostBackOptions()
240
	{
241
		$options['ID'] = $this->getClientID();
0 ignored issues
show
Comprehensibility Best Practice introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.
Loading history...
242
		$options['EventTarget'] = $this->getUniqueID();
243
		$options['AutoPostBack'] = $this->getAutoPostBack();
244
		$options['CausesValidation'] = $this->getCausesValidation();
245
		$options['ValidationGroup'] = $this->getValidationGroup();
246
		$options['TextMode'] = $this->getTextMode();
247
		return $options;
248
	}
249
250
	/**
251
	 * Loads user input data.
252
	 * This method is primarly used by framework developers.
253
	 * @param string $key the key that can be used to retrieve data from the input data collection
254
	 * @param array $values the input data collection
255
	 * @return bool whether the data of the component has been changed
256
	 */
257
	public function loadPostData($key, $values)
258
	{
259
		$value = $values[$key];
260
		if ($this->getAutoTrim()) {
261
			$value = trim($value);
262
		}
263
		if (!$this->getReadOnly() && $this->getText() !== $value) {
264
			$this->setText($value);
265
			return $this->_dataChanged = true;
266
		} else {
267
			return false;
268
		}
269
	}
270
271
	/**
272
	 * Returns a value indicating whether postback has caused the control data change.
273
	 * This method is required by the \Prado\Web\UI\IPostBackDataHandler interface.
274
	 * @return bool whether postback has caused the control data change. False if the page is not in postback mode.
275
	 */
276
	public function getDataChanged()
277
	{
278
		return $this->_dataChanged;
279
	}
280
281
	/**
282
	 * Returns the value to be validated.
283
	 * This methid is required by \Prado\Web\UI\IValidatable interface.
284
	 * @return mixed the value of the property to be validated.
285
	 */
286
	public function getValidationPropertyValue()
287
	{
288
		return $this->getText();
289
	}
290
291
	/**
292
	 * Returns true if this control validated successfully.
293
	 * Defaults to true.
294
	 * @return bool wether this control validated successfully.
295
	 */
296
	public function getIsValid()
297
	{
298
		return $this->_isValid;
299
	}
300
	/**
301
	 * @param bool $value wether this control is valid.
302
	 */
303
	public function setIsValid($value)
304
	{
305
		$this->_isValid = TPropertyValue::ensureBoolean($value);
306
	}
307
308
	/**
309
	 * Raises <b>OnTextChanged</b> event.
310
	 * This method is invoked when the value of the {@see getText Text}
311
	 * property changes on postback.
312
	 * If you override this method, be sure to call the parent implementation to ensure
313
	 * the invocation of the attached event handlers.
314
	 * @param \Prado\TEventParameter $param event parameter to be passed to the event handlers
315
	 */
316
	public function onTextChanged($param)
317
	{
318
		$this->raiseEvent('OnTextChanged', $this, $param);
319
	}
320
321
	/**
322
	 * Raises postdata changed event.
323
	 * This method is required by {@see \Prado\Web\UI\IPostBackDataHandler} interface.
324
	 * It is invoked by the framework when {@see getText Text} property
325
	 * is changed on postback.
326
	 * This method is primarly used by framework developers.
327
	 */
328
	public function raisePostDataChangedEvent()
329
	{
330
		if ($this->getAutoPostBack() && $this->getCausesValidation()) {
331
			$this->getPage()->validate($this->getValidationGroup());
332
		}
333
		$this->onTextChanged(null);
334
	}
335
336
	/**
337
	 * Renders the body content of the textbox when it is in MultiLine text mode.
338
	 * @param \Prado\Web\UI\THtmlWriter $writer the writer for rendering
339
	 */
340
	public function renderContents($writer)
341
	{
342
		if ($this->getTextMode() === TTextBoxMode::MultiLine) {
0 ignored issues
show
introduced by
The condition $this->getTextMode() ===...TTextBoxMode::MultiLine is always false.
Loading history...
343
			$writer->write(THttpUtility::htmlEncode($this->getText()));
344
		}
345
	}
346
347
	/**
348
	 * Renders an additional line-break after the opening tag when it
349
	 * is in MultiLine text mode.
350
	 * @param \Prado\Web\UI\THtmlWriter $writer the writer used for the rendering purpose^M
351
	 */
352
	public function renderBeginTag($writer)
353
	{
354
		parent::renderBeginTag($writer);
355
		if ($this->getTextMode() === TTextBoxMode::MultiLine) {
0 ignored issues
show
introduced by
The condition $this->getTextMode() ===...TTextBoxMode::MultiLine is always false.
Loading history...
356
			$writer->write("\n");
357
		}
358
	}
359
360
	/**
361
	 * @return TTextBoxAutoCompleteType the AutoComplete type of the textbox
362
	 */
363
	public function getAutoCompleteType()
364
	{
365
		return $this->getViewState('AutoCompleteType', TTextBoxAutoCompleteType::None);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getViewSta...AutoCompleteType::None) also could return the type string which is incompatible with the documented return type Prado\Web\UI\WebControls\TTextBoxAutoCompleteType.
Loading history...
366
	}
367
368
	/**
369
	 * @param TTextBoxAutoCompleteType $value the AutoComplete type of the textbox, default value is TTextBoxAutoCompleteType::None.
370
	 * @throws TInvalidDataValueException if the input parameter is not a valid AutoComplete type
371
	 */
372
	public function setAutoCompleteType($value)
373
	{
374
		$this->setViewState('AutoCompleteType', TPropertyValue::ensureEnum($value, TTextBoxAutoCompleteType::class), TTextBoxAutoCompleteType::None);
375
	}
376
377
	/**
378
	 * @return bool a value indicating whether an automatic postback to the server
379
	 * will occur whenever the user modifies the text in the TTextBox control and
380
	 * then tabs out of the component. Defaults to false.
381
	 */
382
	public function getAutoPostBack()
383
	{
384
		return $this->getViewState('AutoPostBack', false);
385
	}
386
387
	/**
388
	 * Sets the value indicating if postback automatically.
389
	 * An automatic postback to the server will occur whenever the user
390
	 * modifies the text in the TTextBox control and then tabs out of the component.
391
	 * @param bool $value the value indicating if postback automatically
392
	 */
393
	public function setAutoPostBack($value)
394
	{
395
		$this->setViewState('AutoPostBack', TPropertyValue::ensureBoolean($value), false);
396
	}
397
398
	/**
399
	 * @return bool a value indicating whether the input text should be trimmed spaces. Defaults to false.
400
	 */
401
	public function getAutoTrim()
402
	{
403
		return $this->getViewState('AutoTrim', false);
404
	}
405
406
	/**
407
	 * Sets the value indicating if the input text should be trimmed spaces
408
	 * @param bool $value the value indicating if the input text should be trimmed spaces
409
	 */
410
	public function setAutoTrim($value)
411
	{
412
		$this->setViewState('AutoTrim', TPropertyValue::ensureBoolean($value), false);
413
	}
414
415
	/**
416
	 * @return bool whether postback event trigger by this text box will cause input validation, default is true.
417
	 */
418
	public function getCausesValidation()
419
	{
420
		return $this->getViewState('CausesValidation', true);
421
	}
422
423
	/**
424
	 * @param bool $value whether postback event trigger by this text box will cause input validation.
425
	 */
426
	public function setCausesValidation($value)
427
	{
428
		$this->setViewState('CausesValidation', TPropertyValue::ensureBoolean($value), true);
429
	}
430
431
	/**
432
	 * @return int the display width of the text box in characters, default is 0 meaning not set.
433
	 */
434
	public function getColumns()
435
	{
436
		return $this->getViewState('Columns', 0);
437
	}
438
439
	/**
440
	 * Sets the display width of the text box in characters.
441
	 * @param int $value the display width, set it 0 to clear the setting
442
	 */
443
	public function setColumns($value)
444
	{
445
		$this->setViewState('Columns', TPropertyValue::ensureInteger($value), 0);
446
	}
447
448
	/**
449
	 * @return int the maximum number of characters allowed in the text box, default is 0 meaning not set.
450
	 */
451
	public function getMaxLength()
452
	{
453
		return $this->getViewState('MaxLength', 0);
454
	}
455
456
	/**
457
	 * Sets the maximum number of characters allowed in the text box.
458
	 * @param int $value the maximum length,  set it 0 to clear the setting
459
	 */
460
	public function setMaxLength($value)
461
	{
462
		$this->setViewState('MaxLength', TPropertyValue::ensureInteger($value), 0);
463
	}
464
465
	/**
466
	 * @return bool whether the textbox is read only, default is false.
467
	 */
468
	public function getReadOnly()
469
	{
470
		return $this->getViewState('ReadOnly', false);
471
	}
472
473
	/**
474
	 * @param bool $value whether the textbox is read only
475
	 */
476
	public function setReadOnly($value)
477
	{
478
		$this->setViewState('ReadOnly', TPropertyValue::ensureBoolean($value), false);
479
	}
480
481
	/**
482
	 * @return int the number of rows displayed in a multiline text box, default is 4
483
	 */
484
	public function getRows()
485
	{
486
		return $this->getViewState('Rows', self::DEFAULT_ROWS);
487
	}
488
489
	/**
490
	 * Sets the number of rows displayed in a multiline text box.
491
	 * @param int $value the number of rows
492
	 */
493
	public function setRows($value)
494
	{
495
		$this->setViewState('Rows', TPropertyValue::ensureInteger($value), self::DEFAULT_ROWS);
496
	}
497
498
	/**
499
	 * @return bool whether password should be displayed in the textbox during postback. Defaults to false. This property only applies when TextMode='Password'.
500
	 */
501
	public function getPersistPassword()
502
	{
503
		return $this->getViewState('PersistPassword', false);
504
	}
505
506
	/**
507
	 * @param bool $value whether password should be displayed in the textbox during postback. This property only applies when TextMode='Password'.
508
	 */
509
	public function setPersistPassword($value)
510
	{
511
		$this->setViewState('PersistPassword', TPropertyValue::ensureBoolean($value), false);
512
	}
513
514
	/**
515
	 * @return string the text content of the TTextBox control.
516
	 */
517
	public function getText()
518
	{
519
		return $this->getViewState('Text', '');
520
	}
521
522
	/**
523
	 * Sets the text content of the TTextBox control.
524
	 * @param string $value the text content
525
	 */
526
	public function setText($value)
527
	{
528
		$this->setViewState('Text', TPropertyValue::ensureString($value), '');
529
		$this->_safeText = null;
530
	}
531
532
	/**
533
	 * Returns the text content of the TTextBox control.
534
	 * This method is required by {@see \Prado\IDataRenderer}.
535
	 * It is the same as {@see getText()}.
536
	 * @return string the text content of the TTextBox control.
537
	 * @see getText
538
	 * @since 3.1.0
539
	 */
540
	public function getData()
541
	{
542
		return $this->getText();
543
	}
544
545
	/**
546
	 * Sets the text content of the TTextBox control.
547
	 * This method is required by {@see \Prado\IDataRenderer}.
548
	 * It is the same as {@see setText()}.
549
	 * @param string $value the text content of the TTextBox control.
550
	 * @see setText
551
	 * @since 3.1.0
552
	 */
553
	public function setData($value)
554
	{
555
		$this->setText($value);
556
	}
557
558
	/**
559
	 * @return string safe text content with javascript stripped off
560
	 */
561
	public function getSafeText()
562
	{
563
		if ($this->_safeText === null) {
564
			$this->_safeText = $this->getSafeTextParser()->purify($this->getText());
565
		}
566
		return $this->_safeText;
567
	}
568
569
	/**
570
	 * @return \HTMLPurifier safe text parser
571
	 */
572
	protected function getSafeTextParser()
573
	{
574
		if (!self::$_safeTextParser) {
575
			self::$_safeTextParser = new \HTMLPurifier($this->getConfig());
576
		}
577
		return self::$_safeTextParser;
578
	}
579
580
	/**
581
	 * @return TTextBoxMode the behavior mode of the TTextBox component. Defaults to TTextBoxMode::SingleLine.
582
	 */
583
	public function getTextMode()
584
	{
585
		return $this->getViewState('TextMode', TTextBoxMode::SingleLine);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getViewSta...extBoxMode::SingleLine) also could return the type string which is incompatible with the documented return type Prado\Web\UI\WebControls\TTextBoxMode.
Loading history...
586
	}
587
588
	/**
589
	 * Sets the behavior mode of the TTextBox component.
590
	 * @param TTextBoxMode $value the text mode
591
	 * @throws TInvalidDataValueException if the input value is not a valid text mode.
592
	 */
593
	public function setTextMode($value)
594
	{
595
		$this->setViewState('TextMode', TPropertyValue::ensureEnum($value, TTextBoxMode::class), TTextBoxMode::SingleLine);
596
	}
597
598
	/**
599
	 * @return string the group of validators which the text box causes validation upon postback
600
	 */
601
	public function getValidationGroup()
602
	{
603
		return $this->getViewState('ValidationGroup', '');
604
	}
605
606
	/**
607
	 * @param string $value the group of validators which the text box causes validation upon postback
608
	 */
609
	public function setValidationGroup($value)
610
	{
611
		$this->setViewState('ValidationGroup', $value, '');
612
	}
613
614
	/**
615
	 * @return bool whether the text content wraps within a multiline text box. Defaults to true.
616
	 */
617
	public function getWrap()
618
	{
619
		return $this->getViewState('Wrap', true);
620
	}
621
622
	/**
623
	 * Sets the value indicating whether the text content wraps within a multiline text box.
624
	 * @param bool $value whether the text content wraps within a multiline text box.
625
	 */
626
	public function setWrap($value)
627
	{
628
		$this->setViewState('Wrap', TPropertyValue::ensureBoolean($value), true);
629
	}
630
631
	/**
632
	 * Sets a custom configuration for HTMLPurifier.
633
	 * @param \HTMLPurifier_Config $value custom configuration
634
	 */
635
	public function setConfig(\HTMLPurifier_Config $value)
636
	{
637
		$this->setViewState('Config', $value, null);
638
	}
639
640
	/**
641
	 * @return \HTMLPurifier_Config Configuration for HTMLPurifier.
642
	 */
643
	public function getConfig()
644
	{
645
		$config = $this->getViewState('Config', null);
646
		if ($config === null) {
647
			$path = Prado::getApplication()->getRuntimePath() . DIRECTORY_SEPARATOR . 'htmlpurifier';
648
			if (!is_dir($path)) {
649
				if (@mkdir($path) === false) {
650
					throw new TConfigurationException(
651
						'htmlpurifier_source_path_failed',
652
						$path
653
					);
654
				}
655
				chmod($path, Prado::getDefaultDirPermissions());
656
			}
657
			$config = \HTMLPurifier_Config::createDefault();
658
			$config->set(
659
				'Cache.SerializerPath',
660
				$path
661
			);
662
		}
663
		return $config;
664
	}
665
}
666