]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/answer/requests/class_XmlRequestNodeListAnswerTemplateEngine.php
Added basic XML elements (not all fully supported)
[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 = 'my-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->subNodes = array(
41                         self::REQUEST_DATA_SESSION_ID,
42                         self::REQUEST_DATA_NODE_LIST,
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 createXmlRequestNodeListAnswerTemplateEngine () {
58                 // Get a new instance
59                 $templateInstance = new XmlRequestNodeListAnswerTemplateEngine();
60
61                 // Init instance
62                 $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer');
63
64                 // Get a template instance for list entries (as they are dynamic)
65                 $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class');
66
67                 // Set it here
68                 $templateInstance->setTemplateInstance($entriesInstance);
69
70                 // Return the prepared instance
71                 return $templateInstance;
72         }
73
74         /**
75          * Currently not used
76          *
77          * @param       $resource               XML parser resource (currently ignored)
78          * @param       $characters             Characters to handle
79          * @return      void
80          * @todo        Find something useful with this!
81          */
82         public function characterHandler ($resource, $characters) {
83                 // Trim all spaces away
84                 $characters = trim($characters);
85
86                 // Is this string empty?
87                 if (empty($characters)) {
88                         // Then skip it silently
89                         return false;
90                 } // END - if
91
92                 /*
93                  * Assign the found characters to variable and use the last entry from
94                  * stack as the name.
95                  */
96                 parent::assignVariable($this->getStackerInstance()->getNamed('node_request_node_list_answer'), $characters);
97         }
98
99         /**
100          * Getter for cache file (FQFN)
101          *
102          * @return      $fqfn   Full-qualified file name of the menu cache
103          */
104         public function getRequestNodeListAnswerCacheFqfn () {
105                 $this->partialStub('Please implement this method.');
106         }
107
108         /**
109          * Starts the 'request-node-list-answer'
110          *
111          * @return      void
112          */
113         protected function startRequestNodeListAnswer () {
114                 // Push the node name on the stacker
115                 $this->getStackerInstance()->pushNamed('node_request_node_list_answer', 'request-node-list-answer');
116         }
117
118         /**
119          * Finishes the 'request-node-list-answer'
120          *
121          * @return      void
122          */
123         protected function finishRequestNodeListAnswer () {
124                 // Pop the last entry
125                 $this->getStackerInstance()->popNamed('node_request_node_list_answer');
126         }
127 }
128
129 // [EOF]
130 ?>