From 785452873f0ee0a27fc157b482b7551560f0282d Mon Sep 17 00:00:00 2001 From: lolcat Date: Tue, 7 Nov 2023 08:04:56 -0500 Subject: fix typo --- settings.php | 121 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 43 deletions(-) (limited to 'settings.php') diff --git a/settings.php b/settings.php index 41322d6..bee31ea 100644 --- a/settings.php +++ b/settings.php @@ -1,5 +1,7 @@ "Theme", "parameter" => "theme", - "options" => [ - [ - "value" => "dark", - "text" => "Gruvbox dark" - ], - [ - "value" => "cream", - "text" => "Gruvbox cream" - ] - ] + "options" => [] ], [ "description" => "Prevent clicking background elements when image viewer is open", @@ -59,7 +52,7 @@ $settings = [ "name" => "Scrapers to use", "settings" => [ [ - "description" => "Autocomplete
Picking
Auto
changes the source dynamically depending of the page's scraper
Picking
Disabled
disables this feature
", + "description" => "Autocomplete
Picking Auto changes the source dynamically depending of the page's scraper
Warning: If you edit this field, you will need to re-add the search engine so that the new autocomplete settings are applied!
", "parameter" => "scraper_ac", "options" => [ [ @@ -242,6 +235,26 @@ $settings = [ ] ]; +/* + Set theme collection +*/ +$themes = glob("static/themes/*"); + +$settings[0]["settings"][1]["options"][] = [ + "value" => "Dark", + "text" => "Dark" +]; + +foreach($themes as $theme){ + + $theme = explode(".", basename($theme))[0]; + + $settings[0]["settings"][1]["options"][] = [ + "value" => $theme, + "text" => $theme + ]; +} + /* Set cookies */ @@ -262,28 +275,48 @@ if($_POST){ foreach($loop as $key => $value){ - foreach($settings as $title){ + if($key == "theme"){ - foreach($title["settings"] as $list){ + if($value == config::DEFAULT_THEME){ - if( - $list["parameter"] == $key && - $list["options"][0]["value"] == $value - ){ - - unset($_COOKIE[$key]); - - setcookie( - $key, - "", - [ - "expires" => -1, // removes cookie - "samesite" => "Lax", - "path" => "/" - ] - ); + unset($_COOKIE[$key]); + + setcookie( + "theme", + "", + [ + "expires" => -1, // removes cookie + "samesite" => "Lax", + "path" => "/" + ] + ); + continue; + } + }else{ + + foreach($settings as $title){ + + foreach($title["settings"] as $list){ - continue 3; + if( + $list["parameter"] == $key && + $list["options"][0]["value"] == $value + ){ + + unset($_COOKIE[$key]); + + setcookie( + $key, + "", + [ + "expires" => -1, // removes cookie + "samesite" => "Lax", + "path" => "/" + ] + ); + + continue 3; + } } } } @@ -313,19 +346,13 @@ include "lib/frontend.php"; $frontend = new frontend(); echo - '' . - '' . - '' . - '' . - 'Settings' . - '' . - '' . - '' . - '' . - '' . - '' . - '' . - 'getthemeclass() . '>'; + $frontend->load( + "header_nofilters.html", + [ + "title" => "Settings", + "class" => "" + ] + ); $left = '

Settings

' . @@ -376,6 +403,14 @@ foreach($settings as $title){ '
' . $setting["description"] . '
' . '