]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
Renamed again a bunch of methods to generic 'readXmlData' name
[hub.git] / application / hub / main / template / answer / announcement / class_XmlAnnouncementAnswerTemplateEngine.php
1 <?php
2 /**
3  * An ??? template engine class for XML templates
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  * @todo                This template engine does not make use of setTemplateType()
11  *
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.
16  *
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.
21  *
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/>.
24  */
25 class XmlAnnouncementAnswerTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
26         /**
27          * Some XML nodes must be available for later data extraction
28          */
29         const ANNOUNCEMENT_DATA_SESSION_ID    = 'my-session-id';
30         const ANNOUNCEMENT_DATA_NODE_STATUS   = 'my-status';
31         const ANNOUNCEMENT_DATA_EXTERNAL_IP   = 'my-external-ip';
32         const ANNOUNCEMENT_DATA_INTERNAL_IP   = 'my-internal-ip';
33         const ANNOUNCEMENT_DATA_TCP_PORT      = 'my-tcp-port';
34         const ANNOUNCEMENT_DATA_UDP_PORT      = 'my-udp-port';
35         const ANNOUNCEMENT_DATA_ANSWER_STATUS = 'answer-status';
36
37         /**
38          * Protected constructor
39          *
40          * @return      void
41          */
42         protected function __construct () {
43                 // Call parent constructor
44                 parent::__construct(__CLASS__);
45
46                 // Init sub-nodes array
47                 $this->subNodes = array(
48                         // These nodes don't contain any data
49                         'my-data',
50                         'your-data',
51                         // Data from *this* node
52                         self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
53                         self::ANNOUNCEMENT_DATA_INTERNAL_IP,
54                         self::ANNOUNCEMENT_DATA_TCP_PORT,
55                         self::ANNOUNCEMENT_DATA_UDP_PORT,
56                         self::ANNOUNCEMENT_DATA_NODE_STATUS,
57                         self::ANNOUNCEMENT_DATA_SESSION_ID,
58                         // Data from other node
59                         'your-external-ip',
60                         'your-internal-ip',
61                         'your-session-id',
62                         // Answer status (code)
63                         self::ANNOUNCEMENT_DATA_ANSWER_STATUS
64                 );
65         }
66
67         /**
68          * Creates an instance of the class TemplateEngine and prepares it for usage
69          *
70          * @return      $templateInstance               An instance of TemplateEngine
71          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
72          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
73          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
74          *                                                                                      directory or not found
75          * @throws      BasePathReadProtectedException  If $templateBasePath is
76          *                                                                                      read-protected
77          */
78         public static final function createXmlAnnouncementAnswerTemplateEngine () {
79                 // Get a new instance
80                 $templateInstance = new XmlAnnouncementAnswerTemplateEngine();
81
82                 // Init instance
83                 $templateInstance->initXmlTemplateEngine('node', 'announcement_answer');
84
85                 // Return the prepared instance
86                 return $templateInstance;
87         }
88
89         /**
90          * Load a specified announcement-answer template into the engine
91          *
92          * @param       $template       The announcement-answer template we shall load which is
93          *                                              located in 'announcement_answer' by default
94          * @return      void
95          */
96         public function loadAnnouncementAnswerTemplate ($template = 'announcement_answer') {
97                 // Set template type
98                 $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_announcement_answer_template_type'));
99
100                 // Load the special template
101                 $this->loadTemplate($template);
102         }
103
104         /**
105          * Currently not used
106          *
107          * @param       $resource               XML parser resource (currently ignored)
108          * @param       $characters             Characters to handle
109          * @return      void
110          * @todo        Find something useful with this!
111          */
112         public function characterHandler ($resource, $characters) {
113                 // Trim all spaces away
114                 $characters = trim($characters);
115
116                 // Is this string empty?
117                 if (empty($characters)) {
118                         // Then skip it silently
119                         return false;
120                 } // END - if
121
122                 /*
123                  * Assign the found characters to variable and use the last entry from
124                  * stack as the name.
125                  */
126                 parent::assignVariable($this->getStackerInstance()->getNamed('announcement_answer'), $characters);
127         }
128
129         /**
130          * Getter for cache file (FQFN)
131          *
132          * @return      $fqfn   Full-qualified file name of the menu cache
133          */
134         public function getAnnouncementAnswerCacheFqfn () {
135                 $this->partialStub('Please implement this method.');
136         }
137
138         /**
139          * Starts the announcement-answer
140          *
141          * @return      void
142          */
143         protected function startAnnouncementAnswer () {
144                 // Push the node name on the stacker
145                 $this->getStackerInstance()->pushNamed('announcement_answer', 'announcement-answer');
146         }
147
148         /**
149          * Starts the my-data
150          *
151          * @return      void
152          */
153         protected function startMyData () {
154                 // Push the node name on the stacker
155                 $this->getStackerInstance()->pushNamed('announcement_answer', 'my-data');
156         }
157
158         /**
159          * Starts the my-external-ip
160          *
161          * @return      void
162          */
163         protected function startMyExternalIp () {
164                 // Push the node name on the stacker
165                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
166         }
167
168         /**
169          * Starts the my-internal-ip
170          *
171          * @return      void
172          */
173         protected function startMyInternalIp () {
174                 // Push the node name on the stacker
175                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
176         }
177
178         /**
179          * Starts the my-tcp-port
180          *
181          * @return      void
182          */
183         protected function startMyTcpPort () {
184                 // Push the node name on the stacker
185                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_TCP_PORT);
186         }
187
188         /**
189          * Starts the my-udp-port
190          *
191          * @return      void
192          */
193         protected function startMyUdpPort () {
194                 // Push the node name on the stacker
195                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_UDP_PORT);
196         }
197
198         /**
199          * Starts the my-session-id
200          *
201          * @return      void
202          */
203         protected function startMySessionId () {
204                 // Push the node name on the stacker
205                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
206         }
207
208         /**
209          * Starts the my-status
210          *
211          * @return      void
212          */
213         protected function startMyStatus () {
214                 // Push the node name on the stacker
215                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
216         }
217
218         /**
219          * Finishes the my-status
220          *
221          * @return      void
222          */
223         protected function finishMyStatus () {
224                 // Pop the last entry
225                 $this->getStackerInstance()->popNamed('announcement_answer');
226         }
227
228         /**
229          * Finishes the my-session-id
230          *
231          * @return      void
232          */
233         protected function finishMySessionId () {
234                 // Pop the last entry
235                 $this->getStackerInstance()->popNamed('announcement_answer');
236         }
237
238         /**
239          * Finishes the my-udp-port
240          *
241          * @return      void
242          */
243         protected function finishMyUdpPort () {
244                 // Pop the last entry
245                 $this->getStackerInstance()->popNamed('announcement_answer');
246         }
247
248         /**
249          * Finishes the my-tcp-port
250          *
251          * @return      void
252          */
253         protected function finishMyTcpPort () {
254                 // Pop the last entry
255                 $this->getStackerInstance()->popNamed('announcement_answer');
256         }
257
258         /**
259          * Finishes the my-internal-ip
260          *
261          * @return      void
262          */
263         protected function finishMyInternalIp () {
264                 // Pop the last entry
265                 $this->getStackerInstance()->popNamed('announcement_answer');
266         }
267
268         /**
269          * Finishes the my-external-ip
270          *
271          * @return      void
272          */
273         protected function finishMyExternalIp () {
274                 // Pop the last entry
275                 $this->getStackerInstance()->popNamed('announcement_answer');
276         }
277
278         /**
279          * Finishes the my-data
280          *
281          * @return      void
282          */
283         protected function finishMyData () {
284                 // Pop the last entry
285                 $this->getStackerInstance()->popNamed('announcement_answer');
286         }
287
288         /**
289          * Starts the your-data
290          *
291          * @return      void
292          */
293         protected function startYourData () {
294                 // Push the node name on the stacker
295                 $this->getStackerInstance()->pushNamed('announcement_answer', 'your-data');
296         }
297
298         /**
299          * Starts the your-external-ip
300          *
301          * @return      void
302          */
303         protected function startYourExternalIp () {
304                 // Push the node name on the stacker
305                 $this->getStackerInstance()->pushNamed('announcement_answer', 'your-external-ip');
306         }
307
308         /**
309          * Starts the your-internal-ip
310          *
311          * @return      void
312          */
313         protected function startYourInternalIp () {
314                 // Push the node name on the stacker
315                 $this->getStackerInstance()->pushNamed('announcement_answer', 'your-internal-ip');
316         }
317
318         /**
319          * Starts the your-session-id
320          *
321          * @return      void
322          */
323         protected function startYourSessionId () {
324                 // Push the node name on the stacker
325                 $this->getStackerInstance()->pushNamed('announcement_answer', 'your-session-id');
326         }
327
328         /**
329          * Finishes the your-session-id
330          *
331          * @return      void
332          */
333         protected function finishYourSessionId () {
334                 // Pop the last entry
335                 $this->getStackerInstance()->popNamed('announcement_answer');
336         }
337
338         /**
339          * Finishes the your-internal-ip
340          *
341          * @return      void
342          */
343         protected function finishYourInternalIp () {
344                 // Pop the last entry
345                 $this->getStackerInstance()->popNamed('announcement_answer');
346         }
347
348         /**
349          * Finishes the your-external-ip
350          *
351          * @return      void
352          */
353         protected function finishYourExternalIp () {
354                 // Pop the last entry
355                 $this->getStackerInstance()->popNamed('announcement_answer');
356         }
357
358         /**
359          * Finishes the your-data
360          *
361          * @return      void
362          */
363         protected function finishYourData () {
364                 // Pop the last entry
365                 $this->getStackerInstance()->popNamed('announcement_answer');
366         }
367
368         /**
369          * Starts the answer-status
370          *
371          * @return      void
372          */
373         protected function startAnswerStatus () {
374                 // Push the node name on the stacker
375                 $this->getStackerInstance()->pushNamed('announcement_answer', self::ANNOUNCEMENT_DATA_ANSWER_STATUS);
376         }
377
378         /**
379          * Finishes the answer-status
380          *
381          * @return      void
382          */
383         protected function finishAnswerStatus () {
384                 // Pop the last entry
385                 $this->getStackerInstance()->popNamed('announcement_answer');
386         }
387
388         /**
389          * Finishes the announcement-answer
390          *
391          * @return      void
392          */
393         protected function finishAnnouncementAnswer () {
394                 // Pop the last entry
395                 $this->getStackerInstance()->popNamed('announcement_answer');
396         }
397 }
398
399 // [EOF]
400 ?>