From 9273cd320cc02f90d2375888d0dd9a9ce1f33c04 Mon Sep 17 00:00:00 2001 From: Hanne Moa <hanne.moa@uninett.no> Date: Mon, 29 Feb 2016 13:51:52 +0100 Subject: [PATCH] Handle paths in template names Now works for: new SimpleSAML_XHTML_Template($globalConfig, 'saml:sp/wrong_authncontextclassref.tpl.php'); --- lib/SimpleSAML/XHTML/Template.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 6956e1fd8..747c9b537 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -54,13 +54,27 @@ class SimpleSAML_XHTML_Template $this->useTwig = $this->setupTwig(); } - private function setupTwigTemplatepaths() + /* + * Normalize template-name + * *param $templateName Template + */ + private function normalizeTemplateName($templateName) { - $filename = $this->template; - // normalize template name - if (strripos($filename, '.php', 0)) { - $filename = basename(basename($filename, '.tpl.php'), '.php').'.twig.html'; + if (strripos($templateName, '.twig.html')) { return $templateName; } + $phppos = strripos($templateName, '.php'); + if ($phppos) { + $templateName = substr($templateName, 0, $phppos); + } + $tplpos = strripos($templateName, '.tpl'); + if ($tplpos) { + $templateName = substr($templateName, 0, $tplpos); } + return $templateName.'.twig.html'; + } + + private function setupTwigTemplatepaths() + { + $filename = $this->normalizeTemplateName($this->template); // get namespace if any $namespace = ''; $split = explode(':', $filename, 2); -- GitLab