summaryrefslogtreecommitdiffstats
path: root/lib/SimpleSAML
diff options
context:
space:
mode:
authorHanne Moa <hanne.moa@uninett.no>2016-02-29 13:51:52 +0100
committerHanne Moa <hanne.moa@uninett.no>2016-02-29 13:51:52 +0100
commit9273cd320cc02f90d2375888d0dd9a9ce1f33c04 (patch)
tree89eae22a017ed89f9af442aa74ccd751f84fbcbc /lib/SimpleSAML
parent708fd42442fc55205cb0229cd8808a74206e6895 (diff)
downloadsimplesamlphp-9273cd320cc02f90d2375888d0dd9a9ce1f33c04.zip
simplesamlphp-9273cd320cc02f90d2375888d0dd9a9ce1f33c04.tar.gz
simplesamlphp-9273cd320cc02f90d2375888d0dd9a9ce1f33c04.tar.bz2
Handle paths in template names
Now works for: new SimpleSAML_XHTML_Template($globalConfig, 'saml:sp/wrong_authncontextclassref.tpl.php');
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r--lib/SimpleSAML/XHTML/Template.php24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 6956e1f..747c9b5 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);