aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/model/Theme.php31
1 files changed, 21 insertions, 10 deletions
diff --git a/app/model/Theme.php b/app/model/Theme.php
index 36a4c6f..f146a7c 100644
--- a/app/model/Theme.php
+++ b/app/model/Theme.php
@@ -2,30 +2,41 @@
class Theme
{
- public function dark()
+ public function color()
{
- return $darkTheme = $_COOKIE['darkTheme'] ?? null;
+ return $theme = $_COOKIE['theme'] ?? null;
+ }
+
+ public function option()
+ {
+ return $theme = $_GET['theme'] ?? null;
}
public function set($theme)
{
- $time = time()+3600*24*365*10;
+ $time = time() + 3600 * 24 * 365 * 10;
if ($theme === null) {
- setcookie('darkTheme', 'on', $time, '/');
- return $_COOKIE['darkTheme'] = 'on';
+ setcookie('theme', 'dark', $time, '/');
+ return $_COOKIE['theme'] = 'dark';
}
- setcookie('darkTheme', null, $time, '/');
- return $_COOKIE['darkTheme'] = null;
+ setcookie('theme', $theme, $time, '/');
+ return $_COOKIE['theme'] = $theme;
+
}
public function toggle()
{
- $toggle = $_GET['toggle'] ?? null;
+ $theme = $this->option();
+
+ if ($theme === 'dark') {
+ $theme = $this->set($this->option());
+ return;
+ }
- if ($toggle === 'theme') {
- $theme = $this->set($this->dark());
+ if ($theme === 'light') {
+ $theme = $this->set($this->option());
}
}
}