]> git.mxchange.org Git - hub.git/blob - application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php
Renamed again a bunch of methods to generic 'readXmlData' name
[hub.git] / application / hub / main / template / connect / class_XmlSelfConnectTemplateEngine.php
1 <?php
2 /**
3  * An SelfConnect 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 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->subNodes = 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          * Load a specified self-connect template into the engine
73          *
74          * @param       $template       The self-connect template we shall load which is
75          *                                              located in 'self_connect' by default
76          * @return      void
77          */
78         public function loadSelfConnectTemplate ($template = 'self_connect') {
79                 // Set template type
80                 $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_self_connect_template_type'));
81
82                 // Load the special template
83                 $this->loadTemplate($template);
84         }
85
86         /**
87          * Currently not used
88          *
89          * @param       $resource               XML parser resource (currently ignored)
90          * @param       $characters             Characters to handle
91          * @return      void
92          * @todo        Find something useful with this!
93          */
94         public function characterHandler ($resource, $characters) {
95                 // Trim all spaces away
96                 $characters = trim($characters);
97
98                 // Is this string empty?
99                 if (empty($characters)) {
100                         // Then skip it silently
101                         return false;
102                 } // END - if
103
104                 /*
105                  * Assign the found characters to variable and use the last entry from
106                  * stack as the name
107                  */
108                 parent::assignVariable($this->getStackerInstance()->getNamed('self_connect'), $characters);
109         }
110
111         /**
112          * Getter for cache file (FQFN)
113          *
114          * @return      $fqfn   Full-qualified file name of the menu cache
115          */
116         public function getMenuCacheFqfn () {
117                 $this->partialStub('Please implement this method.');
118         }
119
120         /**
121          * Starts the self_connect
122          *
123          * @return      void
124          */
125         protected function startSelfConnect () {
126                 // Push the node name on the stacker
127                 $this->getStackerInstance()->pushNamed('self_connect', 'self-connect');
128         }
129
130         /**
131          * Starts the self_connect data
132          *
133          * @return      void
134          */
135         protected function startSelfConnectData () {
136                 // Push the node name on the stacker
137                 $this->getStackerInstance()->pushNamed('self_connect', 'self-connect-data');
138         }
139
140         /**
141          * Starts the node id
142          *
143          * @return      void
144          */
145         protected function startNodeId () {
146                 // Push the node name on the stacker
147                 $this->getStackerInstance()->pushNamed('self_connect', self::SELF_CONNECT_DATA_NODE_ID);
148         }
149
150         /**
151          * Starts the session id
152          *
153          * @return      void
154          */
155         protected function startSessionId () {
156                 // Push the node name on the stacker
157                 $this->getStackerInstance()->pushNamed('self_connect', self::SELF_CONNECT_DATA_SESSION_ID);
158         }
159
160         /**
161          * Finishes the session id
162          *
163          * @return      void
164          */
165         protected function finishSessionId () {
166                 // Pop the last entry
167                 $this->getStackerInstance()->popNamed('self_connect');
168         }
169
170         /**
171          * Finishes the node id
172          *
173          * @return      void
174          */
175         protected function finishNodeId () {
176                 // Pop the last entry
177                 $this->getStackerInstance()->popNamed('self_connect');
178         }
179
180         /**
181          * Finishes the self_connect data
182          *
183          * @return      void
184          */
185         protected function finishSelfConnectData () {
186                 // Pop the last entry
187                 $this->getStackerInstance()->popNamed('self_connect');
188         }
189
190         /**
191          * Finishes the self_connect
192          *
193          * @return      void
194          */
195         protected function finishSelfConnect () {
196                 // Pop the last entry
197                 $this->getStackerInstance()->popNamed('self_connect');
198         }
199 }
200
201 // [EOF]
202 ?>