Rewrote Cookie handling to new Global Class.

This commit is contained in:
Markus Birth 2014-09-23 13:39:47 +02:00
parent ca5bb8be8d
commit 859df34de6

View File

@ -302,51 +302,42 @@ require_once __DIR__ . '/core.php';
//get the stored settings and authentification data from the cookie //get the stored settings and authentification data from the cookie
function load_cookie_settings() function load_cookie_settings()
{ {
global $cookie, $lang, $style; global $lang, $style;
if ($cookie === null) { // language
$cookie = new cookie(); if ($GLOBALS['container']->get('ocde.cookie')->is_set('lang'))
{
$lang = $GLOBALS['container']->get('ocde.cookie')->get('lang');
} }
//speach // style
if ($cookie->is_set('lang')) if ($GLOBALS['container']->get('ocde.cookie')->is_set('style'))
{ {
$lang = $cookie->get('lang'); $style = $GLOBALS['container']->get('ocde.cookie')->get('style');
}
//style
if ($cookie->is_set('style'))
{
$style = $cookie->get('style');
} }
} }
//store the cookie vars //store the cookie vars
function write_cookie_settings() function write_cookie_settings()
{ {
global $cookie, $lang, $style; global $lang, $style;
//language //language
$cookie->set('lang', $lang); $GLOBALS['container']->get('ocde.cookie')->set('lang', $lang);
//style //style
$cookie->set('style', $style); $GLOBALS['container']->get('ocde.cookie')->set('style', $style);
//send cookie //send cookie
$cookie->header(); $GLOBALS['container']->get('ocde.cookie')->header();
} }
//returns the cookie value, otherwise false //returns the cookie value, otherwise false
function get_cookie_setting($name) function get_cookie_setting($name)
{ {
global $cookie; if ($GLOBALS['container']->get('ocde.cookie')->is_set($name)) {
return $GLOBALS['container']->get('ocde.cookie')->get($name);
if ($cookie->is_set($name)) } else {
{
return $cookie->get($name);
}
else
{
return false; return false;
} }
} }
@ -354,8 +345,7 @@ require_once __DIR__ . '/core.php';
//sets the cookie value //sets the cookie value
function set_cookie_setting($name, $value) function set_cookie_setting($name, $value)
{ {
global $cookie; $GLOBALS['container']->get('ocde.cookie')->set($name, $value);
$cookie->set($name, $value);
} }
//set a template replacement //set a template replacement