implemented theme changer
All checks were successful
Build and push / Pulling repo on server (push) Successful in 3s
All checks were successful
Build and push / Pulling repo on server (push) Successful in 3s
This commit is contained in:
34
web/pages/settings/controller.php
Normal file
34
web/pages/settings/controller.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class Settings extends Page {
|
||||
|
||||
function index()
|
||||
{
|
||||
$this->set('userdata', $_SESSION['user']->data);
|
||||
$this->set('template', "settings.html");
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
$theme = $_REQUEST['theme'];
|
||||
switch($theme)
|
||||
{
|
||||
case 'light':
|
||||
case 'dark':
|
||||
$_SESSION['user']->data['theme'] = $theme;
|
||||
$_SESSION['user']->save();
|
||||
$this->redirect('/settings');
|
||||
break;
|
||||
default:
|
||||
return partial('error.html', ['errorMessage' => 'Dieses Theme existiert nicht']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function maySeeThisPage(){
|
||||
if($_SESSION['user'])
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
}
|
13
web/pages/settings/settings.html
Normal file
13
web/pages/settings/settings.html
Normal file
@ -0,0 +1,13 @@
|
||||
<form hx-post="/settings/edit" hx-target="#response">
|
||||
<div>
|
||||
<label for="theme">Farbschema</label>
|
||||
<select name="theme">
|
||||
<option value="light" <?= $_SESSION['user']->data['theme']=='light'?'selected':''; ?>>Hell</option>
|
||||
<option value="dark" <?= $_SESSION['user']->data['theme']=='dark'?'selected':''; ?>>Dunkel</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div id="response"></div>
|
||||
|
||||
<button type="submit" name="submit" value="true" class="btn btn-primary">Speichern</button>
|
||||
</form>
|
Reference in New Issue
Block a user