]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php
Changed all true/false to TRUE/FALSE respectively as PHP constants are better than...
[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_LISTEN_PORT = 'listen-port';
35
36         /**
37          * Protected constructor
38          *
39          * @return      void
40          */
41         protected function __construct () {
42                 // Call parent constructor
43                 parent::__construct(__CLASS__);
44
45                 // Init array
46                 $this->subNodes = array(
47                         'announcement-data',
48                         'listener',
49                         self::ANNOUNCEMENT_DATA_NODE_STATUS,
50                         self::ANNOUNCEMENT_DATA_NODE_MODE,
51                         self::ANNOUNCEMENT_DATA_LISTEN_PORT,
52                         self::ANNOUNCEMENT_DATA_SESSION_ID,
53                         self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
54                         self::ANNOUNCEMENT_DATA_INTERNAL_IP,
55                         'object-type-list',
56                 );
57         }
58
59         /**
60          * Creates an instance of the class TemplateEngine and prepares it for usage
61          *
62          * @return      $templateInstance               An instance of TemplateEngine
63          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
64          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
65          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
66          *                                                                                      directory or not found
67          * @throws      BasePathReadProtectedException  If $templateBasePath is
68          *                                                                                      read-protected
69          */
70         public static final function createXmlAnnouncementTemplateEngine () {
71                 // Get a new instance
72                 $templateInstance = new XmlAnnouncementTemplateEngine();
73
74                 // Init template instance
75                 $templateInstance->initXmlTemplateEngine('node', 'announcement');
76
77                 // Return the prepared instance
78                 return $templateInstance;
79         }
80
81         /**
82          * Currently not used
83          *
84          * @param       $resource               XML parser resource (currently ignored)
85          * @param       $characters             Characters to handle
86          * @return      void
87          */
88         public function characterHandler ($resource, $characters) {
89                 // Trim all spaces away
90                 $characters = trim($characters);
91
92                 // Is this string empty?
93                 if (empty($characters)) {
94                         // Then skip it silently
95                         return;
96                 } // END - if
97
98                 /*
99                  * Assign the found characters to variable and use the last entry from
100                  * stack as the name.
101                  */
102                 parent::assignVariable($this->getStackerInstance()->getNamed('node_announcement'), $characters);
103         }
104
105         /**
106          * Getter for cache file (FQFN)
107          *
108          * @return      $fqfn   Full-qualified file name of the menu cache
109          */
110         public function getMenuCacheFqfn () {
111                 $this->partialStub('Please implement this method.');
112         }
113
114         /**
115          * Starts the announcement
116          *
117          * @return      void
118          */
119         protected function startAnnouncement () {
120                 // Push the node name on the stacker
121                 $this->getStackerInstance()->pushNamed('node_announcement', 'node_announcement');
122         }
123
124         /**
125          * Starts the announcement data
126          *
127          * @return      void
128          */
129         protected function startAnnouncementData () {
130                 // Push the node name on the stacker
131                 $this->getStackerInstance()->pushNamed('node_announcement', 'announcement-data');
132         }
133
134         /**
135          * Starts the node status
136          *
137          * @return      void
138          */
139         protected function startNodeStatus () {
140                 // Push the node name on the stacker
141                 $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_STATUS);
142         }
143
144         /**
145          * Starts the node-mode
146          *
147          * @return      void
148          */
149         protected function startNodeMode () {
150                 // Push the node name on the stacker
151                 $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_NODE_MODE);
152         }
153
154         /**
155          * Starts the listener
156          *
157          * @return      void
158          */
159         protected function startListener () {
160                 // Push the node name on the stacker
161                 $this->getStackerInstance()->pushNamed('node_announcement', 'listener');
162         }
163
164         /**
165          * Starts the TCP/UDP listen port
166          *
167          * @return      void
168          */
169         protected function startListenPort () {
170                 // Push the node name on the stacker
171                 $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_LISTEN_PORT);
172         }
173
174         /**
175          * Starts the session id
176          *
177          * @return      void
178          */
179         protected function startSessionId () {
180                 // Push the node name on the stacker
181                 $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_SESSION_ID);
182         }
183
184         /**
185          * Starts the public ip
186          *
187          * @return      void
188          */
189         protected function startExternalIp () {
190                 // Push the node name on the stacker
191                 $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
192         }
193
194         /**
195          * Starts the private ip
196          *
197          * @return      void
198          */
199         protected function startInternalIp () {
200                 // Push the node name on the stacker
201                 $this->getStackerInstance()->pushNamed('node_announcement', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
202         }
203
204         /**
205          * Starts the object type list
206          *
207          * @return      void
208          */
209         protected function startObjectTypeList () {
210                 // Push the node name on the stacker
211                 $this->getStackerInstance()->pushNamed('node_announcement', 'object-type-list');
212         }
213
214         /**
215          * Starts the object type
216          *
217          * @return      void
218          */
219         protected function startObjectType () {
220                 // Push the node name on the stacker
221                 $this->getStackerInstance()->pushNamed('node_announcement', 'object-type');
222         }
223
224         /**
225          * Finishes the object type
226          *
227          * @return      void
228          */
229         protected function finishObjectType () {
230                 // Pop the last entry
231                 $this->getStackerInstance()->popNamed('node_announcement');
232         }
233
234         /**
235          * Finishes the object type list
236          *
237          * @return      void
238          */
239         protected function finishObjectTypeList () {
240                 // Pop the last entry
241                 $this->getStackerInstance()->popNamed('node_announcement');
242         }
243
244         /**
245          * Finishes the session id
246          *
247          * @return      void
248          */
249         protected function finishSessionId () {
250                 // Pop the last entry
251                 $this->getStackerInstance()->popNamed('node_announcement');
252         }
253
254         /**
255          * Finishes the private ip
256          *
257          * @return      void
258          */
259         protected function finishInternalIp () {
260                 // Pop the last entry
261                 $this->getStackerInstance()->popNamed('node_announcement');
262         }
263
264         /**
265          * Finishes the public ip
266          *
267          * @return      void
268          */
269         protected function finishExternalIp () {
270                 // Pop the last entry
271                 $this->getStackerInstance()->popNamed('node_announcement');
272         }
273
274         /**
275          * Finishes the TCP/UDP listen port
276          *
277          * @return      void
278          */
279         protected function finishListenPort () {
280                 // Pop the last entry
281                 $this->getStackerInstance()->popNamed('node_announcement');
282         }
283
284         /**
285          * Finishes the listener
286          *
287          * @return      void
288          */
289         protected function finishListener () {
290                 // Pop the last entry
291                 $this->getStackerInstance()->popNamed('node_announcement');
292         }
293
294         /**
295          * Finishes the node mode
296          *
297          * @return      void
298          */
299         protected function finishNodeMode () {
300                 // Pop the last entry
301                 $this->getStackerInstance()->popNamed('node_announcement');
302         }
303
304         /**
305          * Finishes the node status
306          *
307          * @return      void
308          */
309         protected function finishNodeStatus () {
310                 // Pop the last entry
311                 $this->getStackerInstance()->popNamed('node_announcement');
312         }
313
314         /**
315          * Finishes the announcement data
316          *
317          * @return      void
318          */
319         protected function finishAnnouncementData () {
320                 // Pop the last entry
321                 $this->getStackerInstance()->popNamed('node_announcement');
322         }
323
324         /**
325          * Finishes the announcement
326          *
327          * @return      void
328          */
329         protected function finishAnnouncement () {
330                 // Pop the last entry
331                 $this->getStackerInstance()->popNamed('node_announcement');
332         }
333 }
334
335 // [EOF]
336 ?>