diff options
author | Thedro Neely <thedroneely@gmail.com> | 2019-04-18 02:07:33 -0400 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2019-04-18 02:07:33 -0400 |
commit | 5452369c8c4af48254d331ed3bbe3f79c489e665 (patch) | |
tree | 3a8724e85b9e3e47f4bae1a8e7ed9ebe68a71246 /app/model | |
parent | 6e8bedd4551edaaa50b628d4648a7b7b95351309 (diff) | |
download | thedroneely.com-5452369c8c4af48254d331ed3bbe3f79c489e665.tar.gz thedroneely.com-5452369c8c4af48254d331ed3bbe3f79c489e665.tar.bz2 thedroneely.com-5452369c8c4af48254d331ed3bbe3f79c489e665.zip |
app/model/Theme: Add dark theme
Diffstat (limited to 'app/model')
-rw-r--r-- | app/model/Theme.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/model/Theme.php b/app/model/Theme.php new file mode 100644 index 0000000..36a4c6f --- /dev/null +++ b/app/model/Theme.php @@ -0,0 +1,31 @@ +<?php + +class Theme +{ + public function dark() + { + return $darkTheme = $_COOKIE['darkTheme'] ?? null; + } + + public function set($theme) + { + $time = time()+3600*24*365*10; + + if ($theme === null) { + setcookie('darkTheme', 'on', $time, '/'); + return $_COOKIE['darkTheme'] = 'on'; + } + + setcookie('darkTheme', null, $time, '/'); + return $_COOKIE['darkTheme'] = null; + } + + public function toggle() + { + $toggle = $_GET['toggle'] ?? null; + + if ($toggle === 'theme') { + $theme = $this->set($this->dark()); + } + } +} |