3 * An AnnouncementAnswer template engine class for XML templates
5 * @author Roland Haeder <webmaster@shipsimu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.shipsimu.org
10 * @todo This template engine does not make use of setTemplateType()
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class XmlAnnouncementAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
27 * Some XML nodes must be available for later data extraction
29 const ANNOUNCEMENT_DATA_SESSION_ID = 'my-session-id';
30 const ANNOUNCEMENT_DATA_NODE_STATUS = 'my-status';
31 const ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS = 'my-external-address';
32 const ANNOUNCEMENT_DATA_INTERNAL_ADDRESS = 'my-internal-address';
35 * Protected constructor
39 protected function __construct () {
40 // Call parent constructor
41 parent::__construct(__CLASS__);
43 // Init sub-nodes array
44 $this->setSubNodes(array(
45 // These nodes don't contain any data
48 // Data from *this* node
49 self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
50 self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
51 self::ANNOUNCEMENT_DATA_NODE_STATUS,
52 self::ANNOUNCEMENT_DATA_SESSION_ID,
53 // Data from other node
54 'your-external-address',
55 'your-internal-address',
57 // Answer status (generic field)
63 * Creates an instance of the class TemplateEngine and prepares it for usage
65 * @return $templateInstance An instance of TemplateEngine
66 * @throws BasePathIsEmptyException If the provided $templateBasePath is empty
67 * @throws InvalidBasePathStringException If $templateBasePath is no string
68 * @throws BasePathIsNoDirectoryException If $templateBasePath is no
69 * directory or not found
70 * @throws BasePathReadProtectedException If $templateBasePath is
73 public static final function createXmlAnnouncementAnswerTemplateEngine () {
75 $templateInstance = new XmlAnnouncementAnswerTemplateEngine();
78 $templateInstance->initXmlTemplateEngine('node', 'announcement_answer');
80 // Return the prepared instance
81 return $templateInstance;
87 * @param $resource XML parser resource (currently ignored)
88 * @param $characters Characters to handle
90 * @todo Find something useful with this!
92 public function characterHandler ($resource, $characters) {
93 // Trim all spaces away
94 $characters = trim($characters);
96 // Is this string empty?
97 if (empty($characters)) {
98 // Then skip it silently
103 * Assign the found characters to variable and use the last entry from
106 parent::assignVariable($this->getStackInstance()->getNamed('node_announcement_answer'), $characters);
110 * Getter for cache file (FQFN)
112 * @return $fqfn Full-qualified file name of the menu cache
114 public function getAnnouncementAnswerCacheFqfn () {
115 $this->partialStub('Please implement this method.');
119 * Starts the announcement-answer
123 protected function startAnnouncementAnswer () {
124 // Push the node name on the stacker
125 $this->getStackInstance()->pushNamed('node_announcement_answer', 'announcement-answer');
133 protected function startMyData () {
134 // Push the node name on the stacker
135 $this->getStackInstance()->pushNamed('node_announcement_answer', 'my-data');
139 * Starts the my-external-address
143 protected function startMyExternalAddress () {
144 // Push the node name on the stacker
145 $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS);
149 * Starts the my-internal-address
153 protected function startMyInternalAddress () {
154 // Push the node name on the stacker
155 $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS);
159 * Starts the my-session-id
163 protected function startMySessionId () {
164 // Push the node name on the stacker
165 $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
169 * Starts the my-status
173 protected function startMyStatus () {
174 // Push the node name on the stacker
175 $this->getStackInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
179 * Finishes the my-status
183 protected function finishMyStatus () {
184 // Pop the last entry
185 $this->getStackInstance()->popNamed('node_announcement_answer');
189 * Finishes the my-session-id
193 protected function finishMySessionId () {
194 // Pop the last entry
195 $this->getStackInstance()->popNamed('node_announcement_answer');
199 * Finishes the my-internal-address
203 protected function finishMyInternalAddress () {
204 // Pop the last entry
205 $this->getStackInstance()->popNamed('node_announcement_answer');
209 * Finishes the my-external-address
213 protected function finishMyExternalAddress () {
214 // Pop the last entry
215 $this->getStackInstance()->popNamed('node_announcement_answer');
219 * Finishes the my-data
223 protected function finishMyData () {
224 // Pop the last entry
225 $this->getStackInstance()->popNamed('node_announcement_answer');
229 * Starts the your-data
233 protected function startYourData () {
234 // Push the node name on the stacker
235 $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-data');
239 * Starts the your-external-address
243 protected function startYourExternalAddress () {
244 // Push the node name on the stacker
245 $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-external-address');
249 * Starts the your-internal-address
253 protected function startYourInternalAddress () {
254 // Push the node name on the stacker
255 $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-internal-address');
259 * Starts the your-session-id
263 protected function startYourSessionId () {
264 // Push the node name on the stacker
265 $this->getStackInstance()->pushNamed('node_announcement_answer', 'your-session-id');
269 * Finishes the your-session-id
273 protected function finishYourSessionId () {
274 // Pop the last entry
275 $this->getStackInstance()->popNamed('node_announcement_answer');
279 * Finishes the your-internal-address
283 protected function finishYourInternalAddress () {
284 // Pop the last entry
285 $this->getStackInstance()->popNamed('node_announcement_answer');
289 * Finishes the your-external-address
293 protected function finishYourExternalAddress () {
294 // Pop the last entry
295 $this->getStackInstance()->popNamed('node_announcement_answer');
299 * Finishes the your-data
303 protected function finishYourData () {
304 // Pop the last entry
305 $this->getStackInstance()->popNamed('node_announcement_answer');
309 * Finishes the announcement-answer
313 protected function finishAnnouncementAnswer () {
314 // Pop the last entry
315 $this->getStackInstance()->popNamed('node_announcement_answer');