You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
42 lines
1.0 KiB
<?php
|
|
|
|
namespace Data\Core;
|
|
|
|
use Shared\Log;
|
|
|
|
class Preferences {
|
|
private string $cookie;
|
|
private array $theme;
|
|
|
|
public function __construct(){
|
|
if (isset($_COOKIE['preferences'])){
|
|
$this->cookie = $_COOKIE['preferences'];
|
|
} else {
|
|
if(setcookie('preferences', 'base_theme', time()+(3600*24)*7)){
|
|
$this->cookie = 'base_theme';
|
|
}
|
|
}
|
|
$this->theme = array(
|
|
'base_theme',
|
|
'dark_theme',
|
|
'pink_theme'
|
|
);
|
|
}
|
|
|
|
public function majCookie(string $maj){
|
|
try{
|
|
foreach($this->theme as $t){
|
|
$this->cookie = $maj;
|
|
setcookie('preferences', $maj);
|
|
}
|
|
} catch (\Exception $e){
|
|
throw new \ValueError;
|
|
}
|
|
}
|
|
|
|
public function getCookie():string{
|
|
return $this->cookie ?? "base_theme";
|
|
}
|
|
}
|
|
|
|
?>
|