* @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.ship-simu.org * @todo This template engine does not make use of setTemplateType() * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ class XmlSelfConnectTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { /** * Data nodes */ const SELF_CONNECT_DATA_NODE_ID = 'node-id'; const SELF_CONNECT_DATA_SESSION_ID = 'session-id'; /** * Protected constructor * * @return void */ protected function __construct () { // Call parent constructor parent::__construct(__CLASS__); // Init array $this->subNodes = array( 'self-connect-data', self::SELF_CONNECT_DATA_NODE_ID, self::SELF_CONNECT_DATA_SESSION_ID ); } /** * Creates an instance of the class TemplateEngine and prepares it for usage * * @return $templateInstance An instance of TemplateEngine * @throws BasePathIsEmptyException If the provided $templateBasePath is empty * @throws InvalidBasePathStringException If $templateBasePath is no string * @throws BasePathIsNoDirectoryException If $templateBasePath is no * directory or not found * @throws BasePathReadProtectedException If $templateBasePath is * read-protected */ public static final function createXmlSelfConnectTemplateEngine () { // Get a new instance $templateInstance = new XmlSelfConnectTemplateEngine(); // Init template instance $templateInstance->initXmlTemplateEngine('node', 'self_connect'); // Return the prepared instance return $templateInstance; } /** * Load a specified self-connect template into the engine * * @param $template The self-connect template we shall load which is * located in 'self_connect' by default * @return void */ public function loadSelfConnectTemplate ($template = 'self_connect') { // Set template type $this->setTemplateType($this->getConfigInstance()->getConfigEntry('node_self_connect_template_type')); // Load the special template $this->loadTemplate($template); } /** * Currently not used * * @param $resource XML parser resource (currently ignored) * @param $characters Characters to handle * @return void * @todo Find something useful with this! */ public function characterHandler ($resource, $characters) { // Trim all spaces away $characters = trim($characters); // Is this string empty? if (empty($characters)) { // Then skip it silently return false; } // END - if /* * Assign the found characters to variable and use the last entry from * stack as the name */ parent::assignVariable($this->getStackerInstance()->getNamed('self_connect'), $characters); } /** * Read self-connect variables by calling readVariable() with 'general' as * variable stack. * * @param $key Key to read from * @return $value Value from variable */ public function readSelfConnectData ($key) { // Read the variable $value = parent::readVariable($key, 'general'); // Return value return $value; } /** * Getter for cache file (FQFN) * * @return $fqfn Full-qualified file name of the menu cache */ public function getMenuCacheFqfn () { $this->partialStub('Please implement this method.'); } /** * Starts the self_connect * * @return void */ protected function startSelfConnect () { // Push the node name on the stacker $this->getStackerInstance()->pushNamed('self_connect', 'self-connect'); } /** * Starts the self_connect data * * @return void */ protected function startSelfConnectData () { // Push the node name on the stacker $this->getStackerInstance()->pushNamed('self_connect', 'self-connect-data'); } /** * Starts the node id * * @return void */ protected function startNodeId () { // Push the node name on the stacker $this->getStackerInstance()->pushNamed('self_connect', self::SELF_CONNECT_DATA_NODE_ID); } /** * Starts the session id * * @return void */ protected function startSessionId () { // Push the node name on the stacker $this->getStackerInstance()->pushNamed('self_connect', self::SELF_CONNECT_DATA_SESSION_ID); } /** * Finishes the session id * * @return void */ protected function finishSessionId () { // Pop the last entry $this->getStackerInstance()->popNamed('self_connect'); } /** * Finishes the node id * * @return void */ protected function finishNodeId () { // Pop the last entry $this->getStackerInstance()->popNamed('self_connect'); } /** * Finishes the self_connect data * * @return void */ protected function finishSelfConnectData () { // Pop the last entry $this->getStackerInstance()->popNamed('self_connect'); } /** * Finishes the self_connect * * @return void */ protected function finishSelfConnect () { // Pop the last entry $this->getStackerInstance()->popNamed('self_connect'); } } // [EOF] ?>