* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class BaseXMLTemplateEngine extends BaseTemplateEngine {
+class BaseXmlTemplateEngine extends BaseTemplateEngine {
/**
* Main nodes in the XML tree
*/
// Set template extensions
$this->setRawTemplateExtension($this->getConfigInstance()->getConfigEntry('raw_template_extension'));
- $this->setCodeTemplateExtension($this->getConfigInstance()->getConfigEntry($typePrefix . '__message_template_extension'));
+ $this->setCodeTemplateExtension($this->getConfigInstance()->getConfigEntry($typePrefix . '_message_template_extension'));
// Absolute output path for compiled templates
$this->setCompileOutputPath($this->getConfigInstance()->getConfigEntry('base_path') . $this->getConfigInstance()->getConfigEntry('compile_output_path'));
// Init a variable stacker
$stackerInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class');
+ // Init stacker
+ $stackerInstance->initStacker($typePrefix . '_' . $xmlTemplateType);
+
// Set it
$this->setStackerInstance($stackerInstance);
$this->typePrefix = $typePrefix;
// Set it in main nodes
- array_push($this->mainNodes, $xmlTemplateType);
+ array_push($this->mainNodes, str_replace('_', '-', $xmlTemplateType));
}
/**
* Load a specified XML template into the engine
*
- * @param $template The XML template we shall load
+ * @param $templateName Optional name of template
* @return void
*/
- public function loadXmlTemplate ($template) {
+ public function loadXmlTemplate ($templateName = '') {
+ // Is the template name empty?
+ if (empty($templateName)) {
+ // Set generic template name
+ $templateName = $this->typePrefix . '_' . $this->xmlTemplateType . '_template_type';
+ } // END - if
+
// Set template type
- $this->setTemplateType($this->getConfigInstance()->getConfigEntry($this->xmlTemplateType . '_template_type'));
+ $this->setTemplateType($this->getConfigInstance()->getConfigEntry($templateName));
// Load the special template
- $this->loadTemplate($template);
+ $this->loadTemplate($this->xmlTemplateType);
}
/**
return $this->subNodes;
}
+ /**
+ * Read XML variables by calling readVariable() with 'general' as
+ * variable stack.
+ *
+ * @param $key Key to read from
+ * @return $value Value from variable
+ */
+ public function readXmlData ($key) {
+ // Read the variable
+ $value = parent::readVariable($key, 'general');
+
+ // Return value
+ return $value;
+ }
+
/**
* Handles the template dependency for given node
*
// Get a temporay template instance
$templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance($this->typePrefix . '__' . $this->xmlTemplateType . '_template_class');
- // Create method name
- $methodName = 'load' . $this->convertToClassName($this->xmlTemplateType) . 'Template';
-
// Then load it
- call_user_func(array($templateInstance, $methodName), $templateDependency);
+ $templateInstance->loadXmlTemplate($templateDependency);
// Parse the XML content
$templateInstance->renderXmlContent();