X-Git-Url: https://git.cweiske.de/anoweco.git/blobdiff_plain/6c7675f8f675d5a2ca5f863d95b3c1d881f9af3f..HEAD:/www/www-header.php diff --git a/www/www-header.php b/www/www-header.php index 3a7d606..ec7e8b3 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -4,10 +4,8 @@ require_once __DIR__ . '/../src/anoweco/autoload.php'; header("Access-Control-Allow-Origin: *"); -\Twig_Autoloader::register(); - -$loader = new \Twig_Loader_Filesystem(__DIR__ . '/../data/templates/'); -$twig = new \Twig_Environment( +$loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../data/templates/'); +$twig = new \Twig\Environment( $loader, array( //'cache' => '/path/to/compilation_cache', @@ -67,7 +65,7 @@ function error($description, $status = 'HTTP/1.0 400 Bad Request') function render($tplname, $vars = array(), $return = false) { - $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm'); + $template = $GLOBALS['twig']->load($tplname . '.htm'); if ($return) { return $template->render($vars); @@ -75,4 +73,13 @@ function render($tplname, $vars = array(), $return = false) echo $template->render($vars); } } -?> \ No newline at end of file + +/** + * No trailing slash + */ +function getBaseUrl() +{ + return $_SERVER['REQUEST_SCHEME'] + . '://' . $_SERVER['HTTP_HOST']; +} +?>