3 * An SelfConnect 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 XmlSelfConnectTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
29 const SELF_CONNECT_DATA_NODE_ID = 'node-id';
30 const SELF_CONNECT_DATA_SESSION_ID = 'session-id';
33 * Protected constructor
37 protected function __construct () {
38 // Call parent constructor
39 parent::__construct(__CLASS__);
42 $this->subNodes = array(
44 self::SELF_CONNECT_DATA_NODE_ID,
45 self::SELF_CONNECT_DATA_SESSION_ID
50 * Creates an instance of the class TemplateEngine and prepares it for usage
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
60 public static final function createXmlSelfConnectTemplateEngine () {
62 $templateInstance = new XmlSelfConnectTemplateEngine();
64 // Init template instance
65 $templateInstance->initXmlTemplateEngine('node', 'self_connect');
67 // Return the prepared instance
68 return $templateInstance;
72 * Load a specified self-connect template into the engine
74 * @param $template The self-connect template we shall load which is
75 * located in 'self_connect' by default
78 public function loadSelfConnectTemplate ($template = 'self_connect') {
80 $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_self_connect_template_type'));
82 // Load the special template
83 $this->loadTemplate($template);
89 * @param $resource XML parser resource (currently ignored)
90 * @param $characters Characters to handle
92 * @todo Find something useful with this!
94 public function characterHandler ($resource, $characters) {
95 // Trim all spaces away
96 $characters = trim($characters);
98 // Is this string empty?
99 if (empty($characters)) {
100 // Then skip it silently
105 * Assign the found characters to variable and use the last entry from
108 parent::assignVariable($this->getStackerInstance()->getNamed('self_connect'), $characters);
112 * Read self-connect variables by calling readVariable() with 'general' as
115 * @param $key Key to read from
116 * @return $value Value from variable
118 public function readSelfConnectData ($key) {
120 $value = parent::readVariable($key, 'general');
127 * Getter for cache file (FQFN)
129 * @return $fqfn Full-qualified file name of the menu cache
131 public function getMenuCacheFqfn () {
132 $this->partialStub('Please implement this method.');
136 * Starts the self_connect
140 private function startSelfConnect () {
141 // Push the node name on the stacker
142 $this->getStackerInstance()->pushNamed('self_connect', 'self-connect');
146 * Starts the self_connect data
150 private function startSelfConnectData () {
151 // Push the node name on the stacker
152 $this->getStackerInstance()->pushNamed('self_connect', 'self-connect-data');
160 private function startNodeId () {
161 // Push the node name on the stacker
162 $this->getStackerInstance()->pushNamed('self_connect', self::SELF_CONNECT_DATA_NODE_ID);
166 * Starts the session id
170 private function startSessionId () {
171 // Push the node name on the stacker
172 $this->getStackerInstance()->pushNamed('self_connect', self::SELF_CONNECT_DATA_SESSION_ID);
176 * Finishes the session id
180 private function finishSessionId () {
181 // Pop the last entry
182 $this->getStackerInstance()->popNamed('self_connect');
186 * Finishes the node id
190 private function finishNodeId () {
191 // Pop the last entry
192 $this->getStackerInstance()->popNamed('self_connect');
196 * Finishes the self_connect data
200 private function finishSelfConnectData () {
201 // Pop the last entry
202 $this->getStackerInstance()->popNamed('self_connect');
206 * Finishes the self_connect
210 private function finishSelfConnect () {
211 // Pop the last entry
212 $this->getStackerInstance()->popNamed('self_connect');