]> git.mxchange.org Git - friendica.git/blobdiff - src/Render/FriendicaSmartyEngine.php
Merge remote-tracking branch 'upstream/develop' into conversation-receivers
[friendica.git] / src / Render / FriendicaSmartyEngine.php
index 668b91ea5b5745c409d0f8b3a7919a4e16d73d44..6fc8f4480676eb892583c7f113968ff2bd4fc243 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -23,6 +23,7 @@ namespace Friendica\Render;
 
 use Friendica\Core\Hook;
 use Friendica\DI;
+use Friendica\Network\HTTPException\ServiceUnavailableException;
 use Friendica\Util\Strings;
 
 /**
@@ -48,11 +49,23 @@ final class FriendicaSmartyEngine extends TemplateEngine
                $this->smarty = new FriendicaSmarty($this->theme, $this->theme_info);
 
                if (!is_writable(DI::basePath() . '/view/smarty3')) {
-                       echo "<b>ERROR:</b> folder <tt>view/smarty3/</tt> must be writable by webserver.";
-                       exit();
+                       $admin_message = DI::l10n()->t('The folder view/smarty3/ must be writable by webserver.');
+                       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 testInstall(array &$errors = null)
+       {
+               $this->smarty->testInstall($errors);
+       }
+
        /**
         * @inheritDoc
         */
@@ -70,6 +83,8 @@ final class FriendicaSmartyEngine extends TemplateEngine
                Hook::callAll('template_vars', $arr);
                $vars = $arr['vars'];
 
+               $this->smarty->clearAllAssign();
+
                foreach ($vars as $key => $value) {
                        if ($key[0] === '$') {
                                $key = substr($key, 1);