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