id/views/settings_region.php

68 lines
1.9 KiB
PHP
Raw Normal View History

2024-07-27 12:07:27 +00:00
<?php
function update_language(): void
{
global $user;
set_user_language($_POST['lang'], $user['id']);
location('/settings/region');
}
if (isset($path[3])) {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
switch ($path[3]) {
case 'set_language':
update_language();
break;
default:
location('/settings/region');
exit;
}
} else {
location('/settings/region');
}
}
?>
<!doctype html>
<html>
<head>
<?php require 'partials/head.php'; ?>
<title><?= get_string('page.settings'); ?> ~> ByeCorps ID </title>
<link rel="stylesheet" href="/styles/dashboard.css" />
</head>
<body>
<?php include "partials/header.php" ?>
<main>
<h1><span class="fa-solid fa-fw fa-cog"></span> <?= get_string('page.settings'); ?></h1>
<div class="grid">
<?php include 'partials/settings_list.php' ?>
<div class="settingsthingy">
<h2><?= get_string('settings.region') ?></h2>
<p>Here you can set the language ByeCorps ID is displayed in.</p>
<form action="/settings/region/set_language" method="post">
<div class="language-selector">
<?php
foreach (LANGAUGES as $lang) {
$checked = '';
if ($lang['code'] == $_SESSION['lang']) {
$checked = 'checked="checked"';
}
echo '<label>
<input type="radio" name="lang" '.$checked.' id="lang" value="'. $lang['code'] . '" />
'. $lang['name'] .'
</label>';
}
?>
</div>
<button class='primary' type="submit"><?= get_string('button.submit') ?></button>
</form>
</div>
</div>
</main>
<?php include 'partials/footer.php' ?>
</body>
</html>