X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Ftemplate%2Fclass_BaseTemplateEngine.php;h=8a58b46d1d6d4d2c4f1950861087b4a9d19a24fe;hb=1eec48acf4ae8da969b99668ba76fd3856f1c1d2;hp=190e2e8054085ea72373fc576327dac03cdaf081;hpb=835ba59b19e673e5fa9990871788f85d95e26a8b;p=core.git diff --git a/inc/classes/main/template/class_BaseTemplateEngine.php b/inc/classes/main/template/class_BaseTemplateEngine.php index 190e2e80..8a58b46d 100644 --- a/inc/classes/main/template/class_BaseTemplateEngine.php +++ b/inc/classes/main/template/class_BaseTemplateEngine.php @@ -145,10 +145,6 @@ class BaseTemplateEngine extends BaseFrameworkSystem { protected function __construct ($className) { // Call parent constructor parent::__construct($className); - - // Clean up a little - $this->removeNumberFormaters(); - $this->removeSystemArray(); } /** @@ -525,19 +521,23 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * Private loader for all template types * * @param $template The template we shall load + * @param $extOther An other extension to use * @return void * @throws FileNotFoundException If the template was not found */ - protected function loadTemplate ($template, $ext = '') { + protected function loadTemplate ($template, $extOther = '') { // Get extension for the template if empty - if (empty($ext)) { + if (empty($extOther)) { // None provided, so get the raw one $ext = $this->getRawTemplateExtension(); - } // END - if + } else { + // Then use it! + $ext = (string) $extOther; + } // Construct the FQFN for the template by honoring the current language $fqfn = sprintf("%s%s%s%s/%s/%s%s", - $this->getConfigInstance()->readConfig('base_path'), + $this->getConfigInstance()->getConfigEntry('base_path'), $this->getTemplateBasePath(), $this->getGenericBasePath(), $this->getLanguageInstance()->getLanguageCode(), @@ -552,7 +552,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { $this->loadRawTemplateData($fqfn); } catch (FileNotFoundException $e) { // If we shall load a code-template we need to switch the file extension - if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('web_template_type')) { + if (($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('web_template_type')) && (empty($extOther))) { // Switch over to the code-template extension and try it again $ext = $this->getCodeTemplateExtension(); @@ -926,7 +926,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public function loadWebTemplate ($template) { // Set template type - $this->setTemplateType($this->getConfigInstance()->readConfig('web_template_type')); + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('web_template_type')); // Load the special template $this->loadTemplate($template); @@ -941,7 +941,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { public function assignConfigVariable ($var) { // Sweet and simple... //* DEBUG: */ echo __METHOD__.':var={$var}
\n'; - $this->varStack['config'][$var] = $this->getConfigInstance()->readConfig($var); + $this->varStack['config'][$var] = $this->getConfigInstance()->getConfigEntry($var); } /** @@ -950,10 +950,12 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @param $template The email template we shall load which is located in * 'emails' by default * @return void + * @deprecated + * @see See loadCodeTemplate() */ public function loadEmailTemplate ($template) { // Set template type - $this->setTemplateType($this->getConfigInstance()->readConfig('email_template_type')); + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('email_template_type')); // Load the special template $this->loadTemplate($template); @@ -968,7 +970,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public function loadCodeTemplate ($template) { // Set template type - $this->setTemplateType($this->getConfigInstance()->readConfig('code_template_type')); + $this->setTemplateType($this->getConfigInstance()->getConfigEntry('code_template_type')); // Load the special template $this->loadTemplate($template); @@ -982,7 +984,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public final function compileVariables () { // Initialize the $content array - $validVar = $this->getConfigInstance()->readConfig('tpl_valid_var'); + $validVar = $this->getConfigInstance()->getConfigEntry('tpl_valid_var'); $dummy = array(); // Iterate through all general variables @@ -1046,7 +1048,7 @@ class BaseTemplateEngine extends BaseFrameworkSystem { ); // Run the constructed command. This will "compile" all variables in - @eval($eval); + eval($eval); // Goes something wrong? if ((!isset($result)) || (empty($result))) { @@ -1080,9 +1082,9 @@ class BaseTemplateEngine extends BaseFrameworkSystem { */ public function compileTemplate () { // We will only work with template type "code" from configuration - if ($this->getTemplateType() != $this->getConfigInstance()->readConfig('code_template_type')) { + if ($this->getTemplateType() != $this->getConfigInstance()->getConfigEntry('code_template_type')) { // Abort here - throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->readConfig('code_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED); + throw new UnexpectedTemplateTypeException(array($this, $this->getTemplateType(), $this->getConfigInstance()->getConfigEntry('code_template_type')), self::EXCEPTION_TEMPLATE_TYPE_IS_UNEXPECTED); } // END - if // Get the raw data. @@ -1289,42 +1291,18 @@ class BaseTemplateEngine extends BaseFrameworkSystem { * @return void * @throws XmlParserException If an XML error was found */ - public final function renderXmlContent ($content = null) { + public function renderXmlContent ($content = null) { // Is the content set? if (is_null($content)) { // Get current content $content = $this->getRawTemplateData(); } // END - if - // Convert all to UTF8 - if (function_exists('recode')) { - $content = recode("html..utf8", $content); - } else { - // @TODO We need to find a fallback solution here - } // END - if - - // Get an XML parser - $xmlParser = xml_parser_create(); - - // Force case-folding to on - xml_parser_set_option($xmlParser, XML_OPTION_CASE_FOLDING, true); - - // Set object - xml_set_object($xmlParser, $this); - - // Set handler call-backs - xml_set_element_handler($xmlParser, 'startElement', 'endElement'); - xml_set_character_data_handler($xmlParser, 'characterHandler'); - - // Now parse the XML tree - if (!xml_parse($xmlParser, $content)) { - // Error found in XML! - //die('
'.htmlentities($content).'
'); - throw new XmlParserException(array($this, $xmlParser), BaseHelper::EXCEPTION_XML_PARSER_ERROR); - } // END - if + // Get a XmlParser instance + $parserInstance = ObjectFactory::createObjectByConfiguredName('xml_parser_class', array($this)); - // Free the parser - xml_parser_free($xmlParser); + // Parse the XML document + $parserInstance->parseXmlContent($content); } }