X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FRender%2FFriendicaSmartyEngine.php;h=5d7ed6c0c94dbb353e01f07c8d16925c5543421c;hb=46cd39fb34613f4b331793f19c0e562f93125066;hp=668b91ea5b5745c409d0f8b3a7919a4e16d73d44;hpb=c6ba92c43d664430d2471a0ce7ad727126199d80;p=friendica.git
diff --git a/src/Render/FriendicaSmartyEngine.php b/src/Render/FriendicaSmartyEngine.php
index 668b91ea5b..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);
}
}
/**
* @inheritDoc
*/
- public function replaceMacros(string $template, array $vars)
+ public function testInstall(array &$errors = null)
+ {
+ $this->smarty->testInstall($errors);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function replaceMacros(string $template, array $vars): string
{
if (!Strings::startsWith($template, self::FILE_PREFIX)) {
$template = self::STRING_PREFIX . $template;
@@ -64,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);