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