]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Renderer.php
Merge pull request #9039 from MrPetovan/task/frio-accent-scheme
[friendica.git] / src / Core / Renderer.php
index d0c970b9fbb3a5156ce52d12d205faee58488ecc..24f00341733530a24d097a1a1bf01f00049bda94 100644 (file)
@@ -73,7 +73,7 @@ class Renderer
         * @return string
         * @throws InternalServerErrorException
         */
-       public static function replaceMacros(string $template, array $vars)
+       public static function replaceMacros(string $template, array $vars = [])
        {
                $stamp1 = microtime(true);
 
@@ -86,10 +86,13 @@ class Renderer
                        $output = $t->replaceMacros($template, $vars);
                } catch (Exception $e) {
                        DI::logger()->critical($e->getMessage(), ['template' => $template, 'vars' => $vars]);
-                       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.'));
+                       $message = is_site_admin() ?
+                               $e->getMessage() :
+                               DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
+                       throw new InternalServerErrorException($message);
                }
 
-               DI::profiler()->saveTimestamp($stamp1, "rendering", System::callstack());
+               DI::profiler()->saveTimestamp($stamp1, "rendering");
 
                return $output;
        }
@@ -112,10 +115,13 @@ class Renderer
                        $template = $t->getTemplateFile($file, $subDir);
                } catch (Exception $e) {
                        DI::logger()->critical($e->getMessage(), ['file' => $file, 'subDir' => $subDir]);
-                       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.'));
+                       $message = is_site_admin() ?
+                               $e->getMessage() :
+                               DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
+                       throw new InternalServerErrorException($message);
                }
 
-               DI::profiler()->saveTimestamp($stamp1, "file", System::callstack());
+               DI::profiler()->saveTimestamp($stamp1, "file");
 
                return $template;
        }
@@ -134,8 +140,12 @@ class Renderer
                        $name = $v['name'];
                        self::$template_engines[$name] = $class;
                } else {
-                       DI::logger()->critical(DI::l10n()->t('template engine cannot be registered without a name.'), ['class' => $class]);
-                       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.'));
+                       $admin_message = DI::l10n()->t('template engine cannot be registered without a name.');
+                       DI::logger()->critical($admin_message, ['class' => $class]);
+                       $message = is_site_admin() ?
+                               $admin_message :
+                               DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
+                       throw new InternalServerErrorException($message);
                }
        }
 
@@ -164,8 +174,12 @@ class Renderer
                        }
                }
 
-               DI::logger()->critical(DI::l10n()->t('template engine is not registered!'), ['template_engine' => $template_engine]);
-               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.'));
+               $admin_message = DI::l10n()->t('template engine is not registered!');
+               DI::logger()->critical($admin_message, ['template_engine' => $template_engine]);
+               $message = is_site_admin() ?
+                       $admin_message :
+                       DI::l10n()->t('Friendica can\'t display this page at the moment, please contact the administrator.');
+               throw new InternalServerErrorException($message);
        }
 
        /**