X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fmain%2Ftemplate%2Fclass_BaseXmlTemplateEngine.php;h=ba1b9b8b8355e1cabf42693345350eed476a2770;hb=3d5a6baf289a0b114668619f1184d6d6a1593755;hp=0027674180fb47eb4aee169b44b501944b6d9487;hpb=a5775b5f35451a4232004b55fedbef8c7eefa983;p=hub.git diff --git a/application/hub/main/template/class_BaseXmlTemplateEngine.php b/application/hub/main/template/class_BaseXmlTemplateEngine.php index 002767418..ba1b9b8b8 100644 --- a/application/hub/main/template/class_BaseXmlTemplateEngine.php +++ b/application/hub/main/template/class_BaseXmlTemplateEngine.php @@ -22,7 +22,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseXMLTemplateEngine extends BaseTemplateEngine { +class BaseXmlTemplateEngine extends BaseTemplateEngine { /** * Main nodes in the XML tree */ @@ -78,6 +78,9 @@ class BaseXMLTemplateEngine extends BaseTemplateEngine { * read-protected */ protected function initXmlTemplateEngine ($typePrefix, $xmlTemplateType) { + // Get template instance + $applicationInstance = Registry::getRegistry()->getInstance('app'); + // Determine base path $templateBasePath = $this->getConfigInstance()->getConfigEntry('application_base_path') . $applicationInstance->getRequestInstance()->getRequestElement('app') . '/'; @@ -101,7 +104,7 @@ class BaseXMLTemplateEngine extends BaseTemplateEngine { // 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')); @@ -109,6 +112,9 @@ class BaseXMLTemplateEngine extends BaseTemplateEngine { // Init a variable stacker $stackerInstance = ObjectFactory::createObjectByConfiguredName($typePrefix . '_' . $xmlTemplateType . '_stacker_class'); + // Init stacker + $stackerInstance->initStacker($typePrefix . '_' . $xmlTemplateType); + // Set it $this->setStackerInstance($stackerInstance); @@ -117,21 +123,27 @@ class BaseXMLTemplateEngine extends BaseTemplateEngine { $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); } /** @@ -171,6 +183,21 @@ class BaseXMLTemplateEngine extends BaseTemplateEngine { 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 * @@ -184,11 +211,8 @@ class BaseXMLTemplateEngine extends BaseTemplateEngine { // 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();