function textsize_get_current in Text Size 5
Same name and namespace in other branches
- 6 textsize.module \textsize_get_current()
- 7 textsize.module \textsize_get_current()
Return the current text size.
Return value
The numeric value of the current text size.
5 calls to textsize_get_current()
- textsize_form in includes/
textsize.block.inc - Implement hook_form().
- textsize_print_html in ./
textsize.module - Print HTMl code in the head.
- theme_textsize_form in includes/
textsize.block.inc - Implement theme().
- theme_textsize_image in includes/
textsize.block.inc - Implement theme().
- theme_textsize_text in includes/
textsize.block.inc - Implement theme().
File
- ./
textsize.module, line 159 - Display a text size changer on the page for a better web accessibility.
Code
function textsize_get_current($value = 'int') {
$textsize_normal = variable_get('textsize_normal', 75);
$textsize_increment = variable_get('textsize_increment', 5);
$textsize_minimum = variable_get('textsize_minimum', 50);
$textsize_maximum = variable_get('textsize_maximum', 150);
$textsize_current = '100';
$textsize_post = array();
$textsize_cookie = array();
// allowed values
$textsize_allowed = textsize_allowed_values();
// define the value for return
if (!isset($_COOKIE['textsize'])) {
$textsize_current = $textsize_normal;
}
elseif (isset($_POST['textsize_select']) && isset($_COOKIE['textsize'])) {
// check the type and the content
if (in_array($_POST['textsize_select'], $textsize_allowed)) {
$textsize_post['textsize'] = (int) filter_xss($_POST['textsize_select']);
}
if ($textsize_post['textsize'] <= $textsize_maximum && $textsize_post['textsize'] >= $textsize_minimum && isset($_COOKIE['textsize'])) {
$textsize_current = $textsize_post['textsize'];
}
}
elseif (isset($_COOKIE['textsize'])) {
$textsize_cookie = array();
$textsize_cookie['textsize'] = '100';
// check the type and the content
if (in_array($_COOKIE['textsize'], $textsize_allowed)) {
$textsize_cookie['textsize'] = (int) filter_xss($_COOKIE['textsize']);
}
if ($textsize_cookie['textsize'] <= $textsize_maximum && $textsize_cookie['textsize'] >= $textsize_minimum) {
$textsize_current = $textsize_cookie['textsize'];
}
}
else {
$textsize_current = $textsize_normal;
}
$textsize_current_display = textsize_display($textsize_current, 0);
if ($value == 'int' or $value == 'display' && variable_get('textsize_display', 1) == 0) {
return $textsize_current;
}
elseif ($value == 'display' && variable_get('textsize_display', 1) == 1) {
return $textsize_current_display;
}
}