You are here

function pagestyle_get_current in Page Style 5

Same name and namespace in other branches
  1. 6 pagestyle.module \pagestyle_get_current()
  2. 7 pagestyle.module \pagestyle_get_current()

Return the current page style.

Return value

The text value of the current page style.

6 calls to pagestyle_get_current()
pagestyle_form in includes/pagestyle.block.inc
Implement hook_form().
pagestyle_print_html in ./pagestyle.module
Print HTMl code in the head
pagestyle_print_js_css in ./pagestyle.module
Print Javascript and CSS in the head.
theme_pagestyle_form in includes/pagestyle.block.inc
Implement theme().
theme_pagestyle_image in includes/pagestyle.block.inc
Implement theme().

... See full list

File

./pagestyle.module, line 165
Display a style changer on the page and in the browser menue for a better web accessibility.

Code

function pagestyle_get_current($value = 'int') {
  $pagestyle_normal = variable_get('pagestyle_normal', 'standard');
  $pagestyle_current = 'standard';
  $pagestyle_current_name = t('Standard');
  $pagestyle = array(
    'black_white' => t('Black') . '/' . t('White'),
    'white_black' => t('White') . '/' . t('Black'),
    'yellow_blue' => t('Yellow') . '/' . t('Blue'),
    'standard' => t('Standard'),
  );
  $pagestyle_post = array();
  $pagestyle_cookie = array();

  // allowed values
  $pagestyle_allowed = pagestyle_allowed_values();

  // define the value for return
  if (!isset($_COOKIE['pagestyle'])) {
    $pagestyle_current = $pagestyle_normal;
    $pagestyle_current_name = $pagestyle[$pagestyle_normal];
  }
  elseif (isset($_POST['pagestyle_select']) && isset($_COOKIE['pagestyle'])) {

    // check the type and the content
    if (in_array($_POST['pagestyle_select'], $pagestyle_allowed)) {
      $pagestyle_post['pagestyle'] = (string) filter_xss($_POST['pagestyle_select']);
    }
    $pagestyle_current = $pagestyle_post['pagestyle'];
    $pagestyle_current_name = $pagestyle[$pagestyle_post['pagestyle']];
  }
  elseif (isset($_COOKIE['pagestyle'])) {

    // check the type and the content
    if (in_array($_COOKIE['pagestyle'], $pagestyle_allowed)) {
      $pagestyle_cookie['pagestyle'] = (string) filter_xss($_COOKIE['pagestyle']);
    }
    $pagestyle_current = $pagestyle_cookie['pagestyle'];
    $pagestyle_current_name = $pagestyle[$pagestyle_cookie['pagestyle']];
  }
  else {
    $pagestyle_current = 'standard';
    $pagestyle_current_name = $pagestyle[$pagestyle_normal];
  }
  if ($value == 'int') {
    return $pagestyle_current;
  }
  elseif ($value == 'name') {
    return $pagestyle_current_name;
  }
}