diff --git a/config-templates/config.php b/config-templates/config.php index a0ddc3ab1d0f835e4f645a00a434d0533df4f038..7feb83a434c55bb206ecb9bd0313630ceb0f3596 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -116,10 +116,11 @@ $config = array ( 'language.default' => 'en', /* - * Which template directory should be used? The base is fallback (leave it to default). + * Which theme directory should be used? The base is fallback (leave it to default). */ - 'template.use' => 'default', - 'template.base' => 'default', + 'theme.use' => 'default', + 'theme.base' => 'default', + /* * Default IdPs. If you do not enter an idpentityid in the SSO initialization endpoints, diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index a475f0b1279110ef4394506cc31238b318ddbcb3..fe70ff62aff6c536f978c73d829dfe0beeffde23 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -17,6 +17,7 @@ class SimpleSAML_XHTML_Template { private $language = null; private $langtext = null; + private $usebasetheme = false; public $data = null; @@ -71,25 +72,34 @@ class SimpleSAML_XHTML_Template { } return $lang; } - private function includeAtTemplateBase($file) { $data = $this->data; - $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('template.use') . '/' . $file; + $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.use') . '/' . $file; + + if ($this->usebasetheme) { + SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Using base for inclusion'); + + $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.base') . '/' . $file; + if (!file_exists($filename)) { + SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $file . + '] at [' . $filename . ']'); + throw new Exception('Could not load template file [' . $file . ']'); + } + + } elseif (!file_exists($filename)) { - if (!file_exists($filename)) { SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $file . '] at [' . $filename . '] - Now trying at base'); - $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('template.base') . '/' . $file; - + $filename = $this->configuration->getPathValue('templatedir') . $this->configuration->getValue('theme.base') . '/' . $file; if (!file_exists($filename)) { SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $file . '] at [' . $filename . ']'); throw new Exception('Could not load template file [' . $file . ']'); } - - } + + } include($filename); } @@ -210,14 +220,16 @@ class SimpleSAML_XHTML_Template { $filename = $this->configuration->getPathValue('templatedir') . - $this->configuration->getValue('template.use') . '/' . $this->template; - + $this->configuration->getValue('theme.use') . '/' . $this->template; + if (!file_exists($filename)) { SimpleSAML_Logger::warning($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . '] - now trying the base template'); + $this->usebasetheme = true; + $filename = $this->configuration->getPathValue('templatedir') . - $this->configuration->getValue('template.base') . '/' . $this->template; + $this->configuration->getValue('theme.base') . '/' . $this->template; if (!file_exists($filename)) {