3 * A RequestNodeListAnswer template engine class for XML templates
5 * @author Roland Haeder <webmaster@ship-simu.org>
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()
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.
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.
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/>.
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';
32 * Protected constructor
36 protected function __construct () {
37 // Call parent constructor
38 parent::__construct(__CLASS__);
40 // Init sub-nodes array
41 $this->subNodes = array(
42 self::REQUEST_DATA_SESSION_ID,
43 self::REQUEST_DATA_NODE_LIST,
48 * Creates an instance of the class TemplateEngine and prepares it for usage
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
58 public static final function createXmlRequestNodeListAnswerTemplateEngine () {
60 $templateInstance = new XmlRequestNodeListAnswerTemplateEngine();
63 $templateInstance->initXmlTemplateEngine('node', 'request_node_list_answer');
65 // Get a template instance for list entries (as they are dynamic)
66 $entriesInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_entries_template_class');
69 $templateInstance->setTemplateInstance($entriesInstance);
71 // Return the prepared instance
72 return $templateInstance;
78 * @param $resource XML parser resource (currently ignored)
79 * @param $characters Characters to handle
81 * @todo Find something useful with this!
83 public function characterHandler ($resource, $characters) {
84 // Trim all spaces away
85 $characters = trim($characters);
87 // Is this string empty?
88 if (empty($characters)) {
89 // Then skip it silently
94 * Assign the found characters to variable and use the last entry from
97 parent::assignVariable($this->getStackerInstance()->getNamed('node_request_node_list_answer'), $characters);
101 * Getter for cache file (FQFN)
103 * @return $fqfn Full-qualified file name of the menu cache
105 public function getRequestNodeListAnswerCacheFqfn () {
106 $this->partialStub('Please implement this method.');
110 * Starts the 'request-node-list-answer'
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');
120 * Starts the session-id
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);
130 * Starts the node-list
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);
140 * Finishes the node-list
144 protected function finishNodeList () {
145 // Pop the last entry
146 $this->getStackerInstance()->popNamed('node_request_node_list_answer');
150 * Finishes the session-id
154 protected function finishSessionId () {
155 // Pop the last entry
156 $this->getStackerInstance()->popNamed('node_request_node_list_answer');
160 * Finishes the 'request-node-list-answer'
164 protected function finishRequestNodeListAnswer () {
165 // Pop the last entry
166 $this->getStackerInstance()->popNamed('node_request_node_list_answer');