Example #1
0
 public static function dieWith404($reason = '', $salic = null)
 {
     if (empty($salic)) {
         $salic = new Salic(LangSettings::get()->default);
     }
     if (!empty($reason)) {
         echo "<!-- {$reason} -->";
         // TODO: display 404 reason
     }
     $salic->initTwig();
     $salic->render404();
     exit;
 }
Example #2
0
}
// LANGUAGE SELECTION
try {
    if (array_key_exists('lang', $_GET)) {
        $lang = $_GET['lang'];
        if (!Settings\LangSettings::get()->exists($lang)) {
            Utils::dieWith404("the language '{$lang}' is invalid.");
        }
    } else {
        $lang = Utils::getDefaultLanguageFromHeader();
        // language is not given, redirect to the best one
        http_response_code(302);
        //TODO: how to redirect properly for localisation?
        header("Location:/{$lang}/{$page}");
        echo "Redirect: <a href='/{$lang}/{$page}'>/{$lang}/{$page}</a>";
        exit;
    }
} catch (\Exception $e) {
    Utils::dieWithError($e, 'Language determination');
    exit;
}
$salic = new Salic($lang);
$salic->initTwig();
if (empty($page)) {
    try {
        $page = NavSettings::get()->homepage;
    } catch (\Exception $e) {
        Utils::dieWithError($e, 'Homepage determination', $salic);
    }
}
$salic->renderPage($page);
Example #3
0
 protected function doRenderPage($templatefile, $vars)
 {
     $vars['parent_template'] = $templatefile;
     parent::doRenderPage('@salic/edit.html.twig', $vars);
 }