mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-29 07:12:15 +09:00
Add rx_color_scheme cookie for detecting and setting color scheme
This commit is contained in:
parent
6d4fe58c2f
commit
9fffc050b4
4 changed files with 57 additions and 0 deletions
|
|
@ -2683,6 +2683,41 @@ class Context
|
|||
{
|
||||
return self::$_instance->canonical_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current color scheme (none, light, dark)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getColorScheme(): string
|
||||
{
|
||||
if (isset($_COOKIE['rx_color_scheme']) && in_array($_COOKIE['rx_color_scheme'], ['light', 'dark']))
|
||||
{
|
||||
return strval($_COOKIE['rx_color_scheme']);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'none';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color scheme (none, light, dark)
|
||||
*
|
||||
* @param string $color_scheme
|
||||
* @return void
|
||||
*/
|
||||
public static function setColorScheme(string $color_scheme)
|
||||
{
|
||||
if (in_array($color_scheme, ['light', 'dark']))
|
||||
{
|
||||
setcookie('rx_color_scheme', $color_scheme, time() + 86400 * 365, \RX_BASEURL, null, !!config('session.use_ssl_cookies'));
|
||||
}
|
||||
else
|
||||
{
|
||||
setcookie('rx_color_scheme', 'deleted', time() - 86400, \RX_BASEURL, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* End of file Context.class.php */
|
||||
/* Location: ./classes/context/Context.class.php */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue