diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-25 18:19:31 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-25 18:19:31 -0400 |
commit | 407a51e6c45f411533b13176a614ed28e7cd460d (patch) | |
tree | 4210a93ed27ed4797921c76ee52125c5f314aca6 /app | |
parent | 354e37971d43d3b62d8f4e2a23eff09e88525627 (diff) |
Allow to use the original template in overridden templates (PR #1941)
Diffstat (limited to 'app')
-rw-r--r-- | app/Core/Template.php | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/app/Core/Template.php b/app/Core/Template.php index f85c7f28..cf5512d9 100644 --- a/app/Core/Template.php +++ b/app/Core/Template.php @@ -84,25 +84,26 @@ class Template /** * Find template filename * - * Core template name: 'task/show' - * Plugin template name: 'myplugin:task/show' + * Core template: 'task/show' or 'kanboard:task/show' + * Plugin template: 'myplugin:task/show' * * @access public - * @param string $template_name + * @param string $template * @return string */ - public function getTemplateFile($template_name) + public function getTemplateFile($template) { - $template_name = isset($this->overrides[$template_name]) ? $this->overrides[$template_name] : $template_name; + $plugin = ''; + $template = isset($this->overrides[$template]) ? $this->overrides[$template] : $template; - if (strpos($template_name, ':') !== false) { - list($plugin, $template) = explode(':', $template_name); - $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'plugins'; - $path .= DIRECTORY_SEPARATOR.ucfirst($plugin).DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.$template.'.php'; - } else { - $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.$template_name.'.php'; + if (strpos($template, ':') !== false) { + list($plugin, $template) = explode(':', $template); } - return $path; + if ($plugin !== 'kanboard' && $plugin !== '') { + return implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', '..', 'plugins', ucfirst($plugin), 'Template', $template.'.php')); + } + + return implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'Template', $template.'.php')); } } |