function textsize_check in Text Size 7
Same name and namespace in other branches
- 5 textsize.module \textsize_check()
- 6 textsize.module \textsize_check()
Check the cookie "textsize" value of changing (bye JavaScript) for anonymus user.
See also
1 call to textsize_check()
- textsize_init in ./
textsize.module - Implement hook_init().
File
- ./
textsize.module, line 146 - Display a text size changer on the page for a better web accessibility.
Code
function textsize_check() {
$cache = variable_get('cache', 0);
$textsize_post = array();
$textsize_cookie = array();
$textsize_cookie['textsize'] = NULL;
$textsize_post['textsize'] = 0;
// allowed values
$textsize_allowed = textsize_allowed_values();
// check the type and the content
if (isset($_POST['textsize_select'])) {
if (in_array(check_plain($_POST['textsize_select']), $textsize_allowed)) {
$textsize_post['textsize'] = 1;
}
}
if (isset($_COOKIE['textsize'])) {
if (in_array($_COOKIE['textsize'], $textsize_allowed)) {
$textsize_cookie['textsize'] = (double) filter_xss($_COOKIE['textsize']);
}
}
// set session
if ($cache == 1 && isset($_COOKIE['textsize']) && isset($_SESSION['textsize']) && $textsize_post['textsize'] == 0) {
if ($textsize_cookie['textsize'] != $_SESSION['textsize']) {
if (_textsize_set_session()) {
$_SESSION['textsize'] = $textsize_cookie['textsize'];
}
if (function_exists('drupal_goto') && user_access('access textsize content')) {
$dest['0'] = drupal_get_destination();
drupal_goto('textsize/set', $dest['0']);
}
else {
textsize_clear_cache();
}
}
}
}