- public static function replaceMacros($s, $vars)
- {
- $stamp1 = microtime(true);
- $a = self::getApp();
-
- // pass $baseurl to all templates
- $vars['$baseurl'] = System::baseUrl();
- $t = self::getTemplateEngine();
-
- try {
- $output = $t->replaceMacros($s, $vars);
- } catch (Exception $e) {
- echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
- exit();
- }
-
- $a->saveTimestamp($stamp1, "rendering");
-
- return $output;
- }
-
- /**
- * @brief Load a given template $s
- *
- * @param string $s Template to load.
- * @param string $root Optional.
- *
- * @return string template.
- */
- public static function getMarkupTemplate($s, $root = '')
- {
- $stamp1 = microtime(true);
- $a = self::getApp();
- $t = self::getTemplateEngine();
-
- try {
- $template = $t->getTemplateFile($s, $root);
- } catch (Exception $e) {
- echo "<pre><b>" . __FUNCTION__ . "</b>: " . $e->getMessage() . "</pre>";
- exit();
- }
-
- $a->saveTimestamp($stamp1, "file");
-
- return $template;
- }
-
- /**
- * @brief Register template engine class
+ public static function getMarkupTemplate($file, $subDir = '')
+ {
+ $stamp1 = microtime(true);
+ $t = self::getTemplateEngine();
+
+ try {
+ $template = $t->getTemplateFile($file, $subDir);
+ } catch (Exception $e) {
+ DI::logger()->critical($e->getMessage(), ['file' => $file, 'subDir' => $subDir]);
+ $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");
+
+ return $template;
+ }
+
+ /**
+ * Register template engine class