1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the {@see Mailcode_Traits_Commands_Validation_NoHTML} trait. |
4
|
|
|
* |
5
|
|
|
* @package Mailcode |
6
|
|
|
* @subpackage Validation |
7
|
|
|
* @see Mailcode_Traits_Commands_Validation_NoHTML |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
declare(strict_types=1); |
11
|
|
|
|
12
|
|
|
namespace Mailcode; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Command validation drop-in: checks for the presence |
16
|
|
|
* of a "urlencode:" keyword, to automatically set the |
17
|
|
|
* command's URL encoding flag. |
18
|
|
|
* |
19
|
|
|
* @package Mailcode |
20
|
|
|
* @subpackage Validation |
21
|
|
|
* @author Sebastian Mordziol <[email protected]> |
22
|
|
|
* |
23
|
|
|
* @property Mailcode_Parser_Statement_Validator $validator |
24
|
|
|
* @property Mailcode_Parser_Statement $params |
25
|
|
|
* |
26
|
|
|
* @see Mailcode_Interfaces_Commands_Validation_NoHTML |
27
|
|
|
*/ |
28
|
|
|
trait Mailcode_Traits_Commands_Validation_NoHTML |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @var Mailcode_Parser_Statement_Tokenizer_Token_Keyword|NULL |
32
|
|
|
*/ |
33
|
|
|
protected $noHTMLToken = null; |
34
|
|
|
|
35
|
|
|
protected function validateSyntax_nohtml() : void |
36
|
|
|
{ |
37
|
|
|
$this->noHTMLToken = null; |
38
|
|
|
|
39
|
|
|
$keywords = $this->params->getInfo()->getKeywords(); |
40
|
|
|
|
41
|
|
|
foreach($keywords as $keyword) |
42
|
|
|
{ |
43
|
|
|
if($keyword->isNoHTML()) |
44
|
|
|
{ |
45
|
|
|
$this->noHTMLToken = $keyword; |
46
|
|
|
break; |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Sets the HTML generation mode for the command. |
53
|
|
|
* |
54
|
|
|
* @param bool $enabled |
55
|
|
|
* @return $this |
56
|
|
|
* @throws Mailcode_Exception |
57
|
|
|
*/ |
58
|
|
|
public function setHTMLEnabled(bool $enabled=true) |
59
|
|
|
{ |
60
|
|
|
$this->params->getInfo()->setKeywordEnabled(Mailcode_Commands_Keywords::TYPE_NOHTML, !$enabled); |
61
|
|
|
|
62
|
|
|
$this->validateSyntax_nohtml(); |
63
|
|
|
|
64
|
|
|
return $this; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Whether generating HTML code is enabled for the command. |
69
|
|
|
* @return bool |
70
|
|
|
*/ |
71
|
|
|
public function isHTMLEnabled() : bool |
72
|
|
|
{ |
73
|
|
|
return !isset($this->noHTMLToken); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getNoHTMLToken() : ?Mailcode_Parser_Statement_Tokenizer_Token_Keyword |
77
|
|
|
{ |
78
|
|
|
return $this->noHTMLToken; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|