/
ValidationListenerTag.php
119 lines (109 loc) · 3.16 KB
/
ValidationListenerTag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
namespace APF\tools\form\taglib;
/**
* <!--
* This file is part of the adventure php framework (APF) published under
* http://adventure-php-framework.org.
*
* The APF is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The APF is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the APF. If not, see http://www.gnu.org/licenses/lgpl-3.0.txt.
* -->
*/
/**
* @package APF\tools\form\taglib
* @class ValidationListenerTag
*
* Implements a taglib, that outputs it's content, in case you notify
* the taglib to do so. This mechanism can be used within validator
* implementations to inject special style or class information into the
* form's markup on validation errors. For this reason, you can use
* <pre>
* $this->control->notifyValidatorListeners();
* </pre>
* within the <code>notify()</code> method of the
* <code>AbstractFormValidator</code> implementation. The definition of
* the tag is as follows:
* <pre>
* <form:listener control="...">
* The content to display, in case the form is sent, but the control is invalid!
* [<listener:getstring namespace="" config="" key="" />]
* [<listener:placeholder name="" />]
* [<listener:addtaglib namespace="" class="" prefix="" name="" />]
* </form:listener>
* </pre>
*
* @author Christian Achatz
* @version
* Version 0.1, 30.08.2009<br />
*/
class ValidationListenerTag extends AbstractFormControl {
/**
* Indicates, whether the listener is notified or not.
*
* @var boolean Notification flag.
*/
protected $isNotified = false;
/**
* @public
*
* Notifies the listener to output the content of the taglib on transform time.
*
* @author Christian Achatz
* @version
* Version 0.1, 30.08.2009<br />
*/
public function notify() {
$this->isNotified = true;
}
/**
* @public
*
* Overwrites the parent's method, because there is nothing to do here.
*
* @author Christian Achatz
* @version
* Version 0.1, 30.08.2009<br />
*/
public function onParseTime() {
$this->extractTagLibTags();
}
/**
* @public
*
* Overwrites the parent's method, because there is nothing to do here.
*
* @author Christian Achatz
* @version
* Version 0.1, 30.08.2009<br />
*/
public function onAfterAppend() {
}
/**
* @public
*
* Outputs the content of the tag, if notified.
*
* @return string The content of the tag.
*
* @author Christian Achatz
* @version
* Version 0.1, 30.08.2009<br />
*/
public function transform() {
if ($this->isNotified === true) {
$this->transformChildren();
return $this->content;
}
return '';
}
}