X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FRender%2FFriendicaSmartyEngine.php;h=5d7ed6c0c94dbb353e01f07c8d16925c5543421c;hb=131695cb1167a831dbe87a0f2b1bde755dabd55f;hp=9b3739d987e8ec90e6e516f6881c0742a72579cc;hpb=ef9b51e631affd0d0c1d6f763c2d6c4d4d9675e5;p=friendica.git diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php index 9b3739d987..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')) { - DI::logger()->critical(DI::l10n()->t('The folder view/smarty3/ must be writable by webserver.')); - throw new InternalServerErrorException(DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator or check the Friendica log for errors.')); + $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 = DI::app()->isSiteAdmin() ? + $admin_message : + DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.'); + throw new ServiceUnavailableException($message); } } @@ -65,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; @@ -73,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);