]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/answer/announcement/class_XmlAnnouncementAnswerTemplateEngine.php
Rewrites, some more methods:
[hub.git] / application / hub / main / template / answer / announcement / class_XmlAnnouncementAnswerTemplateEngine.php
1 <?php
2 /**
3  * An AnnouncementAnswer 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 BaseXmlAnswerTemplateEngine 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_LISTEN_PORT      = 'my-listen-port';
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 sub-nodes array
45                 $this->subNodes = array(
46                         // These nodes don't contain any data
47                         'my-data',
48                         'your-data',
49                         // Data from *this* node
50                         self::ANNOUNCEMENT_DATA_EXTERNAL_IP,
51                         self::ANNOUNCEMENT_DATA_INTERNAL_IP,
52                         self::ANNOUNCEMENT_DATA_LISTEN_PORT,
53                         self::ANNOUNCEMENT_DATA_NODE_STATUS,
54                         self::ANNOUNCEMENT_DATA_SESSION_ID,
55                         // Data from other node
56                         'your-external-ip',
57                         'your-internal-ip',
58                         'your-session-id',
59                         // Answer status (generic field)
60                         self::ANSWER_STATUS,
61                 );
62         }
63
64         /**
65          * Creates an instance of the class TemplateEngine and prepares it for usage
66          *
67          * @return      $templateInstance               An instance of TemplateEngine
68          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
69          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
70          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
71          *                                                                                      directory or not found
72          * @throws      BasePathReadProtectedException  If $templateBasePath is
73          *                                                                                      read-protected
74          */
75         public static final function createXmlAnnouncementAnswerTemplateEngine () {
76                 // Get a new instance
77                 $templateInstance = new XmlAnnouncementAnswerTemplateEngine();
78
79                 // Init instance
80                 $templateInstance->initXmlTemplateEngine('node', 'announcement_answer');
81
82                 // Return the prepared instance
83                 return $templateInstance;
84         }
85
86         /**
87          * Currently not used
88          *
89          * @param       $resource               XML parser resource (currently ignored)
90          * @param       $characters             Characters to handle
91          * @return      void
92          * @todo        Find something useful with this!
93          */
94         public function characterHandler ($resource, $characters) {
95                 // Trim all spaces away
96                 $characters = trim($characters);
97
98                 // Is this string empty?
99                 if (empty($characters)) {
100                         // Then skip it silently
101                         return false;
102                 } // END - if
103
104                 /*
105                  * Assign the found characters to variable and use the last entry from
106                  * stack as the name.
107                  */
108                 parent::assignVariable($this->getStackerInstance()->getNamed('node_announcement_answer'), $characters);
109         }
110
111         /**
112          * Getter for cache file (FQFN)
113          *
114          * @return      $fqfn   Full-qualified file name of the menu cache
115          */
116         public function getAnnouncementAnswerCacheFqfn () {
117                 $this->partialStub('Please implement this method.');
118         }
119
120         /**
121          * Starts the announcement-answer
122          *
123          * @return      void
124          */
125         protected function startAnnouncementAnswer () {
126                 // Push the node name on the stacker
127                 $this->getStackerInstance()->pushNamed('node_announcement_answer', 'announcement-answer');
128         }
129
130         /**
131          * Starts the my-data
132          *
133          * @return      void
134          */
135         protected function startMyData () {
136                 // Push the node name on the stacker
137                 $this->getStackerInstance()->pushNamed('node_announcement_answer', 'my-data');
138         }
139
140         /**
141          * Starts the my-external-ip
142          *
143          * @return      void
144          */
145         protected function startMyExternalIp () {
146                 // Push the node name on the stacker
147                 $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_EXTERNAL_IP);
148         }
149
150         /**
151          * Starts the my-internal-ip
152          *
153          * @return      void
154          */
155         protected function startMyInternalIp () {
156                 // Push the node name on the stacker
157                 $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_INTERNAL_IP);
158         }
159
160         /**
161          * Starts the my-tcp-port
162          *
163          * @return      void
164          */
165         protected function startMyListenPort () {
166                 // Push the node name on the stacker
167                 $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_LISTEN_PORT);
168         }
169
170         /**
171          * Starts the my-session-id
172          *
173          * @return      void
174          */
175         protected function startMySessionId () {
176                 // Push the node name on the stacker
177                 $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_SESSION_ID);
178         }
179
180         /**
181          * Starts the my-status
182          *
183          * @return      void
184          */
185         protected function startMyStatus () {
186                 // Push the node name on the stacker
187                 $this->getStackerInstance()->pushNamed('node_announcement_answer', self::ANNOUNCEMENT_DATA_NODE_STATUS);
188         }
189
190         /**
191          * Finishes the my-status
192          *
193          * @return      void
194          */
195         protected function finishMyStatus () {
196                 // Pop the last entry
197                 $this->getStackerInstance()->popNamed('node_announcement_answer');
198         }
199
200         /**
201          * Finishes the my-session-id
202          *
203          * @return      void
204          */
205         protected function finishMySessionId () {
206                 // Pop the last entry
207                 $this->getStackerInstance()->popNamed('node_announcement_answer');
208         }
209
210         /**
211          * Finishes the my-tcp-port
212          *
213          * @return      void
214          */
215         protected function finishMyListenPort () {
216                 // Pop the last entry
217                 $this->getStackerInstance()->popNamed('node_announcement_answer');
218         }
219
220         /**
221          * Finishes the my-internal-ip
222          *
223          * @return      void
224          */
225         protected function finishMyInternalIp () {
226                 // Pop the last entry
227                 $this->getStackerInstance()->popNamed('node_announcement_answer');
228         }
229
230         /**
231          * Finishes the my-external-ip
232          *
233          * @return      void
234          */
235         protected function finishMyExternalIp () {
236                 // Pop the last entry
237                 $this->getStackerInstance()->popNamed('node_announcement_answer');
238         }
239
240         /**
241          * Finishes the my-data
242          *
243          * @return      void
244          */
245         protected function finishMyData () {
246                 // Pop the last entry
247                 $this->getStackerInstance()->popNamed('node_announcement_answer');
248         }
249
250         /**
251          * Starts the your-data
252          *
253          * @return      void
254          */
255         protected function startYourData () {
256                 // Push the node name on the stacker
257                 $this->getStackerInstance()->pushNamed('node_announcement_answer', 'your-data');
258         }
259
260         /**
261          * Starts the your-external-ip
262          *
263          * @return      void
264          */
265         protected function startYourExternalIp () {
266                 // Push the node name on the stacker
267                 $this->getStackerInstance()->pushNamed('node_announcement_answer', 'your-external-ip');
268         }
269
270         /**
271          * Starts the your-internal-ip
272          *
273          * @return      void
274          */
275         protected function startYourInternalIp () {
276                 // Push the node name on the stacker
277                 $this->getStackerInstance()->pushNamed('node_announcement_answer', 'your-internal-ip');
278         }
279
280         /**
281          * Starts the your-session-id
282          *
283          * @return      void
284          */
285         protected function startYourSessionId () {
286                 // Push the node name on the stacker
287                 $this->getStackerInstance()->pushNamed('node_announcement_answer', 'your-session-id');
288         }
289
290         /**
291          * Finishes the your-session-id
292          *
293          * @return      void
294          */
295         protected function finishYourSessionId () {
296                 // Pop the last entry
297                 $this->getStackerInstance()->popNamed('node_announcement_answer');
298         }
299
300         /**
301          * Finishes the your-internal-ip
302          *
303          * @return      void
304          */
305         protected function finishYourInternalIp () {
306                 // Pop the last entry
307                 $this->getStackerInstance()->popNamed('node_announcement_answer');
308         }
309
310         /**
311          * Finishes the your-external-ip
312          *
313          * @return      void
314          */
315         protected function finishYourExternalIp () {
316                 // Pop the last entry
317                 $this->getStackerInstance()->popNamed('node_announcement_answer');
318         }
319
320         /**
321          * Finishes the your-data
322          *
323          * @return      void
324          */
325         protected function finishYourData () {
326                 // Pop the last entry
327                 $this->getStackerInstance()->popNamed('node_announcement_answer');
328         }
329
330         /**
331          * Finishes the announcement-answer
332          *
333          * @return      void
334          */
335         protected function finishAnnouncementAnswer () {
336                 // Pop the last entry
337                 $this->getStackerInstance()->popNamed('node_announcement_answer');
338         }
339 }
340
341 // [EOF]
342 ?>