/**
* A generic XML template engine class
*
- * @author Roland Haeder <webmaster@ship-simu.org>
+ * @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
+ * @link http://www.shipsimu.org
* @todo This template engine does not make use of setTemplateType()
*
* This program is free software: you can redistribute it and/or modify
/**
* Main nodes in the XML tree
*/
- protected $mainNodes = array();
+ private $mainNodes = array();
/**
* Sub nodes in the XML tree
*/
- protected $subNodes = array();
+ private $subNodes = array();
/**
* Current main node
*/
- protected $curr = array();
+ private $curr = array();
/**
* XML template type
*/
private $typePrefix = 'xml';
+ /**
+ * Name of stacker
+ */
+ private $stackerName = '';
+
/**
* Content from dependency
*/
$this->setCompileOutputPath($this->getConfigInstance()->getConfigEntry('base_path') . $this->getConfigInstance()->getConfigEntry('compile_output_path'));
// Init a variable stacker
- $stackerInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class');
+ $stackInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class');
+
+ // Set name
+ $this->stackerName = $typePrefix . '_' . $xmlTemplateType;
// Init stacker
- $stackerInstance->initStacker($xmlTemplateType);
+ $stackInstance->initStack($this->stackerName);
// Set it
- $this->setStackerInstance($stackerInstance);
+ $this->setStackInstance($stackInstance);
// Set XML template type and prefix
$this->xmlTemplateType = $xmlTemplateType;
return $this->mainNodes;
}
+ /**
+ * Getter for stacker name
+ *
+ * @return $stackerName Name of stacker of this class
+ */
+ protected final function getStackerName () {
+ return $this->stackerName;
+ }
+
+ /**
+ * Setter for sub node array
+ *
+ * @param $subNodes Array with valid sub node names
+ * @return void
+ */
+ public final function setSubNodes (array $subNodes) {
+ $this->subNodes = $subNodes;
+ }
+
/**
* Getter for sub node array
*
// Read the variable
$value = parent::readVariable($key, 'general');
+ // Is this null?
+ if (is_null($value)) {
+ // Bah, needs fixing.
+ $this->debugInstance('key=' . $key . ' returns NULL');
+ } // END - if
+
// Return value
return $value;
}
/**
- * Handles the template dependency for given node
+ * Handles the template dependency for given XML node
*
- * @param $node The node we should load a dependency template
+ * @param $node The XML node we should load a dependency template
* @param $templateDependency A template to load to satisfy dependencies
* @return void
*/
protected function handleTemplateDependency ($node, $templateDependency) {
+ // Check that the XML node is not empty
+ assert(!empty($node));
+
// Is the template dependency set?
if ((!empty($templateDependency)) && (!isset($this->dependencyContent[$node]))) {
// Get a temporay template instance
- $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '__' . $this->xmlTemplateType . '_template_class');
+ $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '_' . $this->convertDashesToUnderscores($node) . '_' . $this->xmlTemplateType . '_template_class');
// Then load it
$templateInstance->loadXmlTemplate($templateDependency);
* @return void
* @throws XmlNodeMismatchException If current main node mismatches the closing one
*/
- public final function endElement ($resource, $nodeName) {
+ public final function finishElement ($resource, $nodeName) {
// Make all lower-case
$nodeName = strtolower($nodeName);