Updated 'core' + renamed 'main' -> 'classes'.
[hub.git] / application / hub / classes / template / answer / requests / class_XmlRequestNodeListAnswerTemplateEngine.php
1 <?php
2 /**
3  * A RequestNodeListAnswer 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 XmlRequestNodeListAnswerTemplateEngine extends BaseXmlAnswerTemplateEngine implements CompileableTemplate, Registerable {
26         // Constants for array elements
27         const REQUEST_DATA_SESSION_ID    = 'session-id';
28         const REQUEST_DATA_NODE_LIST     = 'node-list';
29
30         /**
31          * Protected constructor
32          *
33          * @return      void
34          */
35         protected function __construct () {
36                 // Call parent constructor
37                 parent::__construct(__CLASS__);
38
39                 // Init sub-nodes array
40                 $this->setSubNodes(array(
41                         self::REQUEST_DATA_SESSION_ID,
42                         self::REQUEST_DATA_NODE_LIST,
43                         // Answer status (generic field)
44                         self::ANSWER_STATUS,
45                 ));
46         }
47
48         /**
49          * Creates an instance of the class TemplateEngine and prepares it for usage
50          *
51          * @return      $templateInstance               An instance of TemplateEngine
52          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
53          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
54          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
55          *                                                                                      directory or not found
56          * @throws      BasePathReadProtectedException  If $templateBasePath is
57          *                                                                                      read-protected
58          */
59         public static final function createXmlRequestNodeListAnswerTemplateEngine () {
60                 // Get a new instance
61                 $templateInstance = new XmlRequestNodeListAnswerTemplateEngine();
62
63                 // Init instance
64                 $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer');
65
66                 // Get a template instance for list entries (as they are dynamic)
67                 $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class');
68
69                 // Set it here
70                 $templateInstance->setTemplateInstance($entriesInstance);
71
72                 // Return the prepared instance
73                 return $templateInstance;
74         }
75
76         /**
77          * Currently not used
78          *
79          * @param       $resource               XML parser resource (currently ignored)
80          * @param       $characters             Characters to handle
81          * @return      void
82          * @todo        Find something useful with this!
83          */
84         public function characterHandler ($resource, $characters) {
85                 // Trim all spaces away
86                 $characters = trim($characters);
87
88                 // Is this string empty?
89                 if (empty($characters)) {
90                         // Then skip it silently
91                         return;
92                 } // END - if
93
94                 /*
95                  * Assign the found characters to variable and use the last entry from
96                  * stack as the name.
97                  */
98                 parent::assignVariable($this->getStackInstance()->getNamed('node_request_node_list_answer'), $characters);
99         }
100
101         /**
102          * Getter for cache file (FQFN)
103          *
104          * @return      $fqfn   Full-qualified file name of the menu cache
105          */
106         public function getRequestNodeListAnswerCacheFqfn () {
107                 $this->partialStub('Please implement this method.');
108         }
109
110         /**
111          * Starts the 'request-node-list-answer'
112          *
113          * @return      void
114          */
115         protected function startRequestNodeListAnswer () {
116                 // Push the node name on the stacker
117                 $this->getStackInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer');
118         }
119
120         /**
121          * Starts the session-id
122          *
123          * @return      void
124          */
125         protected function startSessionId () {
126                 // Push the node name on the stacker
127                 $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_SESSION_ID);
128         }
129
130         /**
131          * Starts the node-list
132          *
133          * @return      void
134          */
135         protected function startNodeList () {
136                 // Push the node name on the stacker
137                 $this->getStackInstance()->pushNamed('node_request_node_list_answer', self::REQUEST_DATA_NODE_LIST);
138         }
139
140         /**
141          * Finishes the node-list
142          *
143          * @return      void
144          */
145         protected function finishNodeList () {
146                 // Pop the last entry
147                 $this->getStackInstance()->popNamed('node_request_node_list_answer');
148         }
149
150         /**
151          * Finishes the session-id
152          *
153          * @return      void
154          */
155         protected function finishSessionId () {
156                 // Pop the last entry
157                 $this->getStackInstance()->popNamed('node_request_node_list_answer');
158         }
159
160         /**
161          * Finishes the 'request-node-list-answer'
162          *
163          * @return      void
164          */
165         protected function finishRequestNodeListAnswer () {
166                 // Pop the last entry
167                 $this->getStackInstance()->popNamed('node_request_node_list_answer');
168         }
169 }
170
171 // [EOF]
172 ?>