From 407a51e6c45f411533b13176a614ed28e7cd460d Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 25 Mar 2016 18:19:31 -0400 Subject: Allow to use the original template in overridden templates (PR #1941) --- app/Core/Template.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'app/Core/Template.php') 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')); } } -- cgit v1.2.3 From 9ba44a01dbb187f4c931e1ba838e2bad258d34f4 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 27 Mar 2016 13:45:37 -0400 Subject: Minor improvements --- app/Core/Helper.php | 1 + app/Core/Template.php | 15 +++++++++++++++ tests/units/Base.php | 1 + 3 files changed, 17 insertions(+) (limited to 'app/Core/Template.php') diff --git a/app/Core/Helper.php b/app/Core/Helper.php index e6152127..3a66fbd0 100644 --- a/app/Core/Helper.php +++ b/app/Core/Helper.php @@ -15,6 +15,7 @@ use Pimple\Container; * @property \Kanboard\Helper\DateHelper $dt * @property \Kanboard\Helper\FileHelper $file * @property \Kanboard\Helper\FormHelper $form + * @property \Kanboard\Helper\HookHelper $hook * @property \Kanboard\Helper\ModelHelper $model * @property \Kanboard\Helper\SubtaskHelper $subtask * @property \Kanboard\Helper\TaskHelper $task diff --git a/app/Core/Template.php b/app/Core/Template.php index cf5512d9..1874d44a 100644 --- a/app/Core/Template.php +++ b/app/Core/Template.php @@ -7,6 +7,21 @@ namespace Kanboard\Core; * * @package core * @author Frederic Guillot + * + * @property \Kanboard\Helper\AppHelper $app + * @property \Kanboard\Helper\AssetHelper $asset + * @property \Kanboard\Helper\DateHelper $dt + * @property \Kanboard\Helper\FileHelper $file + * @property \Kanboard\Helper\FormHelper $form + * @property \Kanboard\Helper\HookHelper $hook + * @property \Kanboard\Helper\ModelHelper $model + * @property \Kanboard\Helper\SubtaskHelper $subtask + * @property \Kanboard\Helper\TaskHelper $task + * @property \Kanboard\Helper\TextHelper $text + * @property \Kanboard\Helper\UrlHelper $url + * @property \Kanboard\Helper\UserHelper $user + * @property \Kanboard\Helper\LayoutHelper $layout + * @property \Kanboard\Helper\ProjectHeaderHelper $projectHeader */ class Template { diff --git a/tests/units/Base.php b/tests/units/Base.php index 6af14ba5..563035f6 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -39,6 +39,7 @@ abstract class Base extends PHPUnit_Framework_TestCase $this->container->register(new Kanboard\ServiceProvider\ClassProvider); $this->container->register(new Kanboard\ServiceProvider\NotificationProvider); $this->container->register(new Kanboard\ServiceProvider\RouteProvider); + $this->container->register(new Kanboard\ServiceProvider\AvatarProvider); $this->container['dispatcher'] = new TraceableEventDispatcher( new EventDispatcher, -- cgit v1.2.3