X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FRender%2FFriendicaSmartyEngine.php;h=c6e95ee068498ca0505577597057e761f5ac273e;hb=c2f6b166c7302d39e6e754119679036a4fca7473;hp=6fd51cf5d1a9e307920e980dc3b9cc11c1b11d19;hpb=6500c32362a3342fca59c2b54cba13961987c5ff;p=friendica.git diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php index 6fd51cf5d1..c6e95ee068 100644 --- a/src/Render/FriendicaSmartyEngine.php +++ b/src/Render/FriendicaSmartyEngine.php @@ -6,8 +6,11 @@ namespace Friendica\Render; use Friendica\Core\Addon; -define('SMARTY3_TEMPLATE_FOLDER', 'templates'); - +/** + * Smarty implementation of the Friendica template engine interface + * + * @author Hypolite Petovan + */ class FriendicaSmartyEngine implements ITemplateEngine { static $name = "smarty3"; @@ -52,8 +55,26 @@ class FriendicaSmartyEngine implements ITemplateEngine public function getTemplateFile($file, $root = '') { $a = get_app(); - $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER . '/' . $file, $root); $template = new FriendicaSmarty(); + + // Make sure $root ends with a slash / + if ($root !== '' && substr($root, -1, 1) !== '/') { + $root = $root . '/'; + } + + $theme = $a->getCurrentTheme(); + $filename = $template::SMARTY3_TEMPLATE_FOLDER . '/' . $file; + + if (file_exists("{$root}view/theme/$theme/$filename")) { + $template_file = "{$root}view/theme/$theme/$filename"; + } elseif (x($a->theme_info, 'extends') && file_exists(sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename))) { + $template_file = sprintf('%sview/theme/%s}/%s', $root, $a->theme_info['extends'], $filename); + } elseif (file_exists("{$root}/$filename")) { + $template_file = "{$root}/$filename"; + } else { + $template_file = "{$root}view/$filename"; + } + $template->filename = $template_file; return $template;