X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FRender%2FFriendicaSmartyEngine.php;h=5d7ed6c0c94dbb353e01f07c8d16925c5543421c;hb=131695cb1167a831dbe87a0f2b1bde755dabd55f;hp=0f5ee21f27ea3fc6bdc8593b91266ad11448e65b;hpb=e3f8a653a143de57d3e8fb705ebc541ac1ac2258;p=friendica.git diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php index 0f5ee21f27..5d7ed6c0c9 100644 --- a/src/Render/FriendicaSmartyEngine.php +++ b/src/Render/FriendicaSmartyEngine.php @@ -1,6 +1,6 @@ theme = $theme; + $this->theme = $theme; $this->theme_info = $theme_info; - $this->smarty = new FriendicaSmarty($this->theme, $this->theme_info); - if (!is_writable(DI::basePath() . '/view/smarty3')) { - $admin_message = DI::l10n()->t('The folder view/smarty3/ must be writable by webserver.'); + $work_dir = DI::config()->get('smarty3', 'config_dir'); + $use_sub_dirs = DI::config()->get('smarty3', 'use_sub_dirs'); + + $this->smarty = new FriendicaSmarty($this->theme, $this->theme_info, $work_dir, $use_sub_dirs); + + if (!is_writable($work_dir)) { + $admin_message = DI::l10n()->t('The folder %s must be writable by webserver.', $work_dir); DI::logger()->critical($admin_message); - $message = is_site_admin() ? + $message = DI::app()->isSiteAdmin() ? $admin_message : DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.'); - throw new InternalServerErrorException($message); + throw new ServiceUnavailableException($message); } } @@ -69,7 +73,7 @@ final class FriendicaSmartyEngine extends TemplateEngine /** * @inheritDoc */ - public function replaceMacros(string $template, array $vars) + public function replaceMacros(string $template, array $vars): string { if (!Strings::startsWith($template, self::FILE_PREFIX)) { $template = self::STRING_PREFIX . $template; @@ -77,7 +81,7 @@ final class FriendicaSmartyEngine extends TemplateEngine // "middleware": inject variables into templates $arr = [ - 'template' => basename($this->smarty->filename), + 'template' => basename($this->smarty->filename ?? ''), 'vars' => $vars ]; Hook::callAll('template_vars', $arr);