X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FRender%2FFriendicaSmartyEngine.php;h=5d7ed6c0c94dbb353e01f07c8d16925c5543421c;hb=131695cb1167a831dbe87a0f2b1bde755dabd55f;hp=2c76ff0255f6cd00f893fd2c5c20ed95eee7f04d;hpb=8b05af176c100ea1e4c9dfd9e902d55efca92ea2;p=friendica.git diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php index 2c76ff0255..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,12 +81,14 @@ 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); $vars = $arr['vars']; + $this->smarty->clearAllAssign(); + foreach ($vars as $key => $value) { if ($key[0] === '$') { $key = substr($key, 1);