aboutsummaryrefslogtreecommitdiff
path: root/app/model
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2019-04-18 02:07:33 -0400
committerThedro Neely <thedroneely@gmail.com>2019-04-18 02:07:33 -0400
commit5452369c8c4af48254d331ed3bbe3f79c489e665 (patch)
tree3a8724e85b9e3e47f4bae1a8e7ed9ebe68a71246 /app/model
parent6e8bedd4551edaaa50b628d4648a7b7b95351309 (diff)
downloadthedroneely.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.php31
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());
+ }
+ }
+}