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