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