X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FRender%2FFriendicaSmartyEngine.php;h=5d7ed6c0c94dbb353e01f07c8d16925c5543421c;hb=46cd39fb34613f4b331793f19c0e562f93125066;hp=6884364c2678ae14f93b68e497e38e284b5858ca;hpb=346f99b87798322866c2f95afdb23d82923f3d2c;p=friendica.git
diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php
index 6884364c26..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')) {
- echo "ERROR: folder view/smarty3/ must be writable by webserver.";
- exit();
+ $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);
}
}
@@ -64,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;
@@ -72,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);