From cc434a53547a81eee5112b43683ee36bbf50b3a4 Mon Sep 17 00:00:00 2001 From: Thedro Neely Date: Sun, 21 Apr 2019 14:27:13 -0400 Subject: app/model/Theme: Use the theme parameter --- app/model/Theme.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'app/model') 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()); } } } -- cgit v1.2.3