Merge pull request #713 from Zankaria/update-template-datetime

Update template datetime
This commit is contained in:
Lorenzo Yario
2024-05-09 22:47:52 -07:00
committed by GitHub
6 changed files with 47 additions and 51 deletions

View File

@@ -60,7 +60,7 @@ function Element($templateFile, array $options) {
}
// Read the template file
if (@file_get_contents("{$config['dir']['template']}/${templateFile}")) {
if (@file_get_contents("{$config['dir']['template']}/{$templateFile}")) {
$body = $twig->render($templateFile, $options);
if ($config['minify_html'] && preg_match('/\.html$/', $templateFile)) {
@@ -69,7 +69,7 @@ function Element($templateFile, array $options) {
return $body;
} else {
throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
throw new Exception("Template file '{$templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
}
}
@@ -141,7 +141,6 @@ class Tinyboard extends Twig\Extension\AbstractExtension
return array(
new Twig\TwigFunction('time', 'time'),
new Twig\TwigFunction('floor', 'floor'),
new Twig\TwigFunction('timezone', 'twig_timezone_function'),
new Twig\TwigFunction('hiddenInputs', 'hiddenInputs'),
new Twig\TwigFunction('hiddenInputsHash', 'hiddenInputsHash'),
new Twig\TwigFunction('ratio', 'twig_ratio_function'),
@@ -162,17 +161,14 @@ class Tinyboard extends Twig\Extension\AbstractExtension
}
}
function twig_timezone_function() {
return 'Z';
}
function twig_push_filter($array, $value) {
array_push($array, $value);
return $array;
}
function twig_date_filter($date, $format) {
return gmstrftime($format, $date);
$date = new DateTime($date, new DateTimeZone('UTC'));
return $date->format($format);
}
function twig_hasPermission_filter($mod, $permission, $board = null) {