function pagestyle_check in Page Style 5
Same name and namespace in other branches
- 6 pagestyle.module \pagestyle_check()
- 7 pagestyle.module \pagestyle_check()
Check the cookie "pagestyle" value of changing (bye JavaScript) for anonymus user.
See also
1 call to pagestyle_check()
- pagestyle_init in ./
pagestyle.module - Implement hook_init().
File
- ./
pagestyle.module, line 121 - Display a style changer on the page and in the browser menue for a better web accessibility.
Code
function pagestyle_check() {
$cache = variable_get('cache', 0);
$pagestyle_post = array();
$pagestyle_cookie = array();
$pagestyle_post['pagestyle'] = 0;
// allowed values
$pagestyle_allowed = pagestyle_allowed_values();
// check the type and the content
if (isset($_POST['pagestyle_select'])) {
if (in_array($_POST['pagestyle_select'], $pagestyle_allowed)) {
$pagestyle_post['pagestyle'] = 1;
}
}
if (isset($_COOKIE['pagestyle'])) {
if (in_array($_COOKIE['pagestyle'], $pagestyle_allowed)) {
if (function_exists('filter_xss')) {
$pagestyle_cookie['pagestyle'] = (string) filter_xss($_COOKIE['pagestyle']);
}
else {
$pagestyle_cookie['pagestyle'] = $_COOKIE['pagestyle'];
}
}
}
// set session
if ($cache != 0 && isset($_COOKIE['pagestyle']) && isset($_SESSION['pagestyle']) && $pagestyle_post['pagestyle'] != 1) {
if ($pagestyle_cookie['pagestyle'] != $_SESSION['pagestyle']) {
$_SESSION['pagestyle'] = $pagestyle_cookie['pagestyle'];
if (function_exists('drupal_goto')) {
$dest['0'] = drupal_get_destination();
drupal_goto('pagestyle/set', $dest['0']);
}
else {
pagestyle_clear_cache();
}
}
}
}