]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/requests/class_XmlRequestNodeListTemplateEngine.php
Refactured a lot methods to become more generic (eventually BaseXmlTemplateEngine...
[hub.git] / application / hub / main / template / requests / class_XmlRequestNodeListTemplateEngine.php
1 <?php
2 /**
3  * An ??? 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 XmlRequestNodeListTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
26         // Constants for array elements
27         const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types';
28         const REQUEST_DATA_SESSION_ID            = 'session-id';
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
40                 $this->subNodes = array(
41                         self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
42                         self::REQUEST_DATA_SESSION_ID,
43                 );
44         }
45
46         /**
47          * Creates an instance of the class TemplateEngine and prepares it for usage
48          *
49          * @return      $templateInstance               An instance of TemplateEngine
50          * @throws      BasePathIsEmptyException                If the provided $templateBasePath is empty
51          * @throws      InvalidBasePathStringException  If $templateBasePath is no string
52          * @throws      BasePathIsNoDirectoryException  If $templateBasePath is no
53          *                                                                                      directory or not found
54          * @throws      BasePathReadProtectedException  If $templateBasePath is
55          *                                                                                      read-protected
56          */
57         public static final function createXmlRequestNodeListTemplateEngine () {
58                 // Get a new instance
59                 $templateInstance = new XmlRequestNodeListTemplateEngine();
60
61                 // Init template instance
62                 $templateInstance->initXmlTemplateEngine('node', 'request_node_list');
63
64                 // Return the prepared instance
65                 return $templateInstance;
66         }
67
68         /**
69          * Load a specified request_node_list template into the engine
70          *
71          * @param       $template       The request_node_list template we shall load which is
72          *                                              located in 'node_request_node_list' by default
73          * @return      void
74          */
75         public function loadRequestNodeListTemplate ($template = 'node_request_node_list') {
76                 // Set template type
77                 $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_request_node_list_template_type'));
78
79                 // Load the special template
80                 $this->loadTemplate($template);
81         }
82
83         /**
84          * Currently not used
85          *
86          * @param       $resource               XML parser resource (currently ignored)
87          * @param       $characters             Characters to handle
88          * @return      void
89          * @todo        Find something useful with this!
90          */
91         public function characterHandler ($resource, $characters) {
92                 // Trim all spaces away
93                 $characters = trim($characters);
94
95                 // Is this string empty?
96                 if (empty($characters)) {
97                         // Then skip it silently
98                         return false;
99                 } // END - if
100
101                 // Assign data with matching variable here
102                 parent::assignVariable($this->getStackerInstance()->getNamed('node_request_node_list'), $characters);
103         }
104
105         /**
106          * Getter for cache file (FQFN)
107          *
108          * @return      $fqfn   Full-qualified file name of the menu cache
109          */
110         public function getNodeRequestNodeListCacheFqfn () {
111                 $this->partialStub('Please implement this method.');
112         }
113
114         /**
115          * Starts the node-request-node-list
116          *
117          * @return      void
118          */
119         private function startNodeRequestNodeList () {
120                 // Push the node name on the stacker
121                 $this->getStackerInstance()->pushNamed('node_request_node_list', 'node-request-node-list');
122         }
123
124         /**
125          * Starts the accepted-object-types
126          *
127          * @return      void
128          */
129         private function startAcceptedObjectTypes () {
130                 // Push the node name on the stacker
131                 $this->getStackerInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES);
132         }
133
134         /**
135          * Starts the session-id
136          *
137          * @return      void
138          */
139         private function startSessionId () {
140                 // Push the node name on the stacker
141                 $this->getStackerInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_SESSION_ID);
142         }
143
144         /**
145          * Finishes the session-id
146          *
147          * @return      void
148          */
149         private function finishSessionId () {
150                 // Pop the last entry
151                 $this->getStackerInstance()->popNamed('node_request_node_list');
152         }
153
154         /**
155          * Finishes the accepted-object-types
156          *
157          * @return      void
158          */
159         private function finishAcceptedObjectTypes () {
160                 // Pop the last entry
161                 $this->getStackerInstance()->popNamed('node_request_node_list');
162         }
163
164         /**
165          * Finishes the node-request-node-list
166          *
167          * @return      void
168          */
169         private function finishNodeRequestNodeList () {
170                 // Pop the last entry
171                 $this->getStackerInstance()->popNamed('node_request_node_list');
172         }
173 }
174
175 // [EOF]
176 ?>