mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
Move getColorScheme/setColorScheme methods to UA class
This commit is contained in:
parent
e3db1b7cd8
commit
6200e8d4ae
2 changed files with 37 additions and 37 deletions
|
|
@ -2368,7 +2368,7 @@ class Context
|
|||
public static function getBodyClass()
|
||||
{
|
||||
$class_list = self::$_instance->body_class;
|
||||
if (($color_scheme = self::getColorScheme()) !== 'none')
|
||||
if (($color_scheme = Rhymix\Framework\UA::getColorScheme()) !== 'none')
|
||||
{
|
||||
$class_list[] = 'color_scheme_' . $color_scheme;
|
||||
}
|
||||
|
|
@ -2687,42 +2687,6 @@ 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']))
|
||||
{
|
||||
$_COOKIE['rx_color_scheme'] = $color_scheme;
|
||||
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 */
|
||||
|
|
|
|||
|
|
@ -439,4 +439,40 @@ class UA
|
|||
return 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current color scheme (auto, 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 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color scheme (auto, light, dark)
|
||||
*
|
||||
* @param string $color_scheme
|
||||
* @return void
|
||||
*/
|
||||
public static function setColorScheme(string $color_scheme)
|
||||
{
|
||||
if (in_array($color_scheme, ['light', 'dark']))
|
||||
{
|
||||
$_COOKIE['rx_color_scheme'] = $color_scheme;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue