X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/925eaabf42cbbbe2ceac8e1bb95c11ec8be5f375..785ac71d1e7ccf8d8af0c49ac107f1be45133f5b:/www/www-header.php diff --git a/www/www-header.php b/www/www-header.php index c0b18d3..41b5e47 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -1,5 +1,7 @@ true ) ); +$twig->addFunction('ntext', new \Twig_Function_Function('\phorkie\ntext')); +function ntext($value, $singular, $plural) +{ + if (abs($value) == 1) { + return sprintf($singular, $value); + } + return sprintf($plural, $value); +} //$twig->addExtension(new \Twig_Extension_Debug()); -function render($tplname, $vars) +if (!isset($noSecurityCheck) || $noSecurityCheck !== true) { + require __DIR__ . '/www-security.php'; +} + +function render($tplname, $vars = array()) { $vars['css'] = $GLOBALS['phorkie']['cfg']['css']; $vars['title'] = $GLOBALS['phorkie']['cfg']['title']; $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar']; + if (isset($_SESSION['identity'])) { + $vars['identity'] = $_SESSION['identity']; + $vars['name'] = $_SESSION['name']; + $vars['email'] = $_SESSION['email']; + } + $vars['db'] = new Database(); $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm'); echo $template->render($vars); @@ -72,4 +102,4 @@ function redirect($target) header('Location: ' . $target); exit(); } -?> \ No newline at end of file +?>