]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php
Renamed again a bunch of methods to generic 'readXmlData' name
[hub.git] / application / hub / main / template / announcement / class_XmlAnnouncementTemplateEngine.php
1 <?php
2 /**
3  * An Announcement 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 XmlAnnouncementTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable {
26         /**
27          * Some XML nodes must be available for later data extraction
28          */
29         const ANNOUNCEMENT_DATA_SESSION_ID  = 'session-id';
30         const ANNOUNCEMENT_DATA_NODE_STATUS = 'node-status';
31         const ANNOUNCEMENT_DATA_NODE_MODE   = 'node-mode';
32         const ANNOUNCEMENT_DATA_EXTERNAL_IP = 'external-ip';
33         const ANNOUNCEMENT_DATA_INTERNAL_IP = 'internal-ip';
34         const ANNOUNCEMENT_DATA_TCP_PORT    = 'tcp-port';
35         const ANNOUNCEMENT_DATA_UDP_PORT    = 'udp-port';
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 array
47                 $this->subNodes = array(
48                         'announcement-data',
49                         'listener',
50                         self::ANNOUNCEMENT_DATA_NODE_STATUS,
51                         self::ANNOUNCEMENT_DATA_NODE_MODE,
52                         self::ANNOUNCEMENT_DATA_TCP_PORT,
53                         self::ANNOUNCEMENT_DATA_UDP_PORT,
54                         self::ANNOUNCEMENT_DATA_SESSION_ID,
55                         self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
56                         self::ANNOUNCEMENT_DATA_INTERNAL_IP,
57                         'object-type-list',
58                 );
59         }
60
61         /**
62          * Creates an instance of the class TemplateEngine and prepares it for usage
63          *
64          * @return      $templateInstance               An instance of TemplateEngine
65          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
66          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
67          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
68          *                                                                                      directory or not found
69          * @throws      BasePathReadProtectedException  If $templateBasePath is
70          *                                                                                      read-protected
71          */
72         public static final function createXmlAnnouncementTemplateEngine () {
73                 // Get a new instance
74                 $templateInstance = new XmlAnnouncementTemplateEngine();
75
76                 // Init template instance
77                 $templateInstance->initXmlTemplateEngine('node', 'announcement');
78
79                 // Return the prepared instance
80                 return $templateInstance;
81         }
82
83         /**
84          * Load a specified announcement template into the engine
85          *
86          * @param       $template       The announcement template we shall load which is
87          *                                              located in 'announcement' by default
88          * @return      void
89          */
90         public function loadAnnouncementTemplate ($template = 'self_announcement') {
91                 // Set template type
92                 $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_announcement_template_type'));
93
94                 // Load the special template
95                 $this->loadTemplate($template);
96         }
97
98         /**
99          * Currently not used
100          *
101          * @param       $resource               XML parser resource (currently ignored)
102          * @param       $characters             Characters to handle
103          * @return      void
104          */
105         public function characterHandler ($resource, $characters) {
106                 // Trim all spaces away
107                 $characters = trim($characters);
108
109                 // Is this string empty?
110                 if (empty($characters)) {
111                         // Then skip it silently
112                         return false;
113                 } // END - if
114
115                 /*
116                  * Assign the found characters to variable and use the last entry from
117                  * stack as the name.
118                  */
119                 parent::assignVariable($this->getStackerInstance()->getNamed('announcement'), $characters);
120         }
121
122         /**
123          * Getter for cache file (FQFN)
124          *
125          * @return      $fqfn   Full-qualified file name of the menu cache
126          */
127         public function getMenuCacheFqfn () {
128                 $this->partialStub('Please implement this method.');
129         }
130
131         /**
132          * Starts the announcement
133          *
134          * @return      void
135          */
136         protected function startAnnouncement () {
137                 // Push the node name on the stacker
138                 $this->getStackerInstance()->pushNamed('announcement', 'announcement');
139         }
140
141         /**
142          * Starts the announcement data
143          *
144          * @return      void
145          */
146         protected function startAnnouncementData () {
147                 // Push the node name on the stacker
148                 $this->getStackerInstance()->pushNamed('announcement', 'announcement-data');
149         }
150
151         /**
152          * Starts the node status
153          *
154          * @return      void
155          */
156         protected function startNodeStatus () {
157                 // Push the node name on the stacker
158                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS);
159         }
160
161         /**
162          * Starts the node-mode
163          *
164          * @return      void
165          */
166         protected function startNodeMode () {
167                 // Push the node name on the stacker
168                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_NODE_MODE);
169         }
170
171         /**
172          * Starts the listener
173          *
174          * @return      void
175          */
176         protected function startListener () {
177                 // Push the node name on the stacker
178                 $this->getStackerInstance()->pushNamed('announcement', 'listener');
179         }
180
181         /**
182          * Starts the TCP port
183          *
184          * @return      void
185          */
186         protected function startTcpPort () {
187                 // Push the node name on the stacker
188                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_TCP_PORT);
189         }
190
191         /**
192          * Starts the UDP port
193          *
194          * @return      void
195          */
196         protected function startUdpPort () {
197                 // Push the node name on the stacker
198                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_UDP_PORT);
199         }
200
201         /**
202          * Starts the session id
203          *
204          * @return      void
205          */
206         protected function startSessionId () {
207                 // Push the node name on the stacker
208                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_SESSION_ID);
209         }
210
211         /**
212          * Starts the public ip
213          *
214          * @return      void
215          */
216         protected function startExternalIp () {
217                 // Push the node name on the stacker
218                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
219         }
220
221         /**
222          * Starts the private ip
223          *
224          * @return      void
225          */
226         protected function startInternalIp () {
227                 // Push the node name on the stacker
228                 $this->getStackerInstance()->pushNamed('announcement', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
229         }
230
231         /**
232          * Starts the object type list
233          *
234          * @return      void
235          */
236         protected function startObjectTypeList () {
237                 // Push the node name on the stacker
238                 $this->getStackerInstance()->pushNamed('announcement', 'object-type-list');
239         }
240
241         /**
242          * Starts the object type
243          *
244          * @return      void
245          */
246         protected function startObjectType () {
247                 // Push the node name on the stacker
248                 $this->getStackerInstance()->pushNamed('announcement', 'object-type');
249         }
250
251         /**
252          * Finishes the object type
253          *
254          * @return      void
255          */
256         protected function finishObjectType () {
257                 // Pop the last entry
258                 $this->getStackerInstance()->popNamed('announcement');
259         }
260
261         /**
262          * Finishes the object type list
263          *
264          * @return      void
265          */
266         protected function finishObjectTypeList () {
267                 // Pop the last entry
268                 $this->getStackerInstance()->popNamed('announcement');
269         }
270
271         /**
272          * Finishes the session id
273          *
274          * @return      void
275          */
276         protected function finishSessionId () {
277                 // Pop the last entry
278                 $this->getStackerInstance()->popNamed('announcement');
279         }
280
281         /**
282          * Finishes the private ip
283          *
284          * @return      void
285          */
286         protected function finishInternalIp () {
287                 // Pop the last entry
288                 $this->getStackerInstance()->popNamed('announcement');
289         }
290
291         /**
292          * Finishes the public ip
293          *
294          * @return      void
295          */
296         protected function finishExternalIp () {
297                 // Pop the last entry
298                 $this->getStackerInstance()->popNamed('announcement');
299         }
300
301         /**
302          * Finishes the UDP port
303          *
304          * @return      void
305          */
306         protected function finishUdpPort () {
307                 // Pop the last entry
308                 $this->getStackerInstance()->popNamed('announcement');
309         }
310
311         /**
312          * Finishes the TCP port
313          *
314          * @return      void
315          */
316         protected function finishTcpPort () {
317                 // Pop the last entry
318                 $this->getStackerInstance()->popNamed('announcement');
319         }
320
321         /**
322          * Finishes the listener
323          *
324          * @return      void
325          */
326         protected function finishListener () {
327                 // Pop the last entry
328                 $this->getStackerInstance()->popNamed('announcement');
329         }
330
331         /**
332          * Finishes the node mode
333          *
334          * @return      void
335          */
336         protected function finishNodeMode () {
337                 // Pop the last entry
338                 $this->getStackerInstance()->popNamed('announcement');
339         }
340
341         /**
342          * Finishes the node status
343          *
344          * @return      void
345          */
346         protected function finishNodeStatus () {
347                 // Pop the last entry
348                 $this->getStackerInstance()->popNamed('announcement');
349         }
350
351         /**
352          * Finishes the announcement data
353          *
354          * @return      void
355          */
356         protected function finishAnnouncementData () {
357                 // Pop the last entry
358                 $this->getStackerInstance()->popNamed('announcement');
359         }
360
361         /**
362          * Finishes the announcement
363          *
364          * @return      void
365          */
366         protected function finishAnnouncement () {
367                 // Pop the last entry
368                 $this->getStackerInstance()->popNamed('announcement');
369         }
370 }
371
372 // [EOF]
373 ?>