You are here

function textsize_get_current in Text Size 7

Same name and namespace in other branches
  1. 5 textsize.module \textsize_get_current()
  2. 6 textsize.module \textsize_get_current()

Return the current text size.

Return value

The numeric value of the current text size.

7 calls to textsize_get_current()
template_preprocess_textsize_form in includes/textsize.block.inc
Process variables for textsize-form.tpl.php.
template_preprocess_textsize_image in includes/textsize.block.inc
Process variables for textsize-image.tpl.php.
template_preprocess_textsize_text in includes/textsize.block.inc
Process variables for textsize-text.tpl.php.
textsize_form in includes/textsize.block.inc
Implement hook_form().
textsize_preprocess_html in ./textsize.module
Add body classes into the html template.

... See full list

1 string reference to 'textsize_get_current'
textsize_preprocess_html in ./textsize.module
Add body classes into the html template.

File

./textsize.module, line 188
Display a text size changer on the page for a better web accessibility.

Code

function textsize_get_current($value = 'int') {
  $textsize_increment = variable_get('textsize_increment', 6);
  $textsize_normal = variable_get('textsize_normal', 76);
  $textsize_minimum = variable_get('textsize_minimum', 50);
  $textsize_maximum = variable_get('textsize_maximum', 150);
  $textsize_current = '100';
  $textsize_post = array();
  $textsize_cookie = array();
  $textsize_cookie['textsize'] = NULL;

  // 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(check_plain($_POST['textsize_select']), $textsize_allowed)) {
      $textsize_post['textsize'] = (double) 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'] = (double) 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, 2);
  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;
  }
}