You are here

function pagestyle_print_html in Page Style 5

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

Print HTMl code in the head

1 call to pagestyle_print_html()
pagestyle_init in ./pagestyle.module
Implement hook_init().

File

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

Code

function pagestyle_print_html() {
  $uri = base_path() . drupal_get_path('module', 'pagestyle');
  $pagestyle_current = pagestyle_get_current($value = 'int');
  $pagestyle_black_white = variable_get('pagestyle_black_white', 1);
  $pagestyle_white_black = variable_get('pagestyle_white_black', 1);
  $pagestyle_yellow_blue = variable_get('pagestyle_yellow_blue', 1);
  $pagestyle_standard = variable_get('pagestyle_standard', 1);
  $pagestyle_fontweight_black_white = variable_get('pagestyle_fontweight_black_white', 'normal');
  $pagestyle_fontweight_white_black = variable_get('pagestyle_fontweight_white_black', 'bold');
  $pagestyle_fontweight_yellow_blue = variable_get('pagestyle_fontweight_yellow_blue', 'bold');
  $pagestyle_fontweight_standard = variable_get('pagestyle_fontweight_standard', 'normal');
  $pagestyle_fontweight = array(
    'black_white' => $pagestyle_fontweight_black_white,
    'white_black' => $pagestyle_fontweight_white_black,
    'yellow_blue' => $pagestyle_fontweight_yellow_blue,
    'standard' => $pagestyle_fontweight_standard,
  );
  $pagestyle_head = "";
  $pagestyle = array(
    'black_white' => t('Black') . '/' . t('White'),
    'white_black' => t('White') . '/' . t('Black'),
    'yellow_blue' => t('Yellow') . '/' . t('Blue'),
    'standard' => t('Standard'),
  );
  switch ($pagestyle_current) {
    case "black_white":
      $pagestyle_rel = array(
        'standard' => 'alternate ',
        'black_white' => '',
        'white_black' => 'alternate ',
        'yellow_blue' => 'alternate ',
      );
      break;
    case "white_black":
      $pagestyle_rel = array(
        'standard' => 'alternate ',
        'black_white' => 'alternate ',
        'white_black' => '',
        'yellow_blue' => 'alternate ',
      );
      break;
    case "yellow_blue":
      $pagestyle_rel = array(
        'standard' => 'alternate ',
        'black_white' => 'alternate ',
        'white_black' => 'alternate ',
        'yellow_blue' => '',
      );
      break;
    case "standard":
      $pagestyle_rel = array(
        'standard' => '',
        'black_white' => 'alternate ',
        'white_black' => 'alternate ',
        'yellow_blue' => 'alternate ',
      );
      break;
    default:
      $pagestyle_rel = array(
        'standard' => '',
        'black_white' => 'alternate ',
        'white_black' => 'alternate ',
        'yellow_blue' => 'alternate ',
      );
  }
  if ($pagestyle_black_white == 1) {
    $pagestyle_head = '<link rel="' . $pagestyle_rel['black_white'] . 'stylesheet" type="text/css" media="screen, projection, tty, tv" class="ps_black_white" title="' . $pagestyle['black_white'] . '" href="' . $uri . '/css/style_black_white.css" />' . "\n";
  }
  if ($pagestyle_white_black == 1) {
    $pagestyle_head .= '<link rel="' . $pagestyle_rel['white_black'] . 'stylesheet" type="text/css" media="screen, projection, tty, tv" class="ps_white_black" title="' . $pagestyle['white_black'] . '" href="' . $uri . '/css/style_white_black.css" />' . "\n";
  }
  if ($pagestyle_yellow_blue == 1) {
    $pagestyle_head .= '<link rel="' . $pagestyle_rel['yellow_blue'] . 'stylesheet" type="text/css" media="screen, projection, tty, tv" class="ps_yellow_blue" title="' . $pagestyle['yellow_blue'] . '" href="' . $uri . '/css/style_yellow_blue.css" />' . "\n";
  }
  if ($pagestyle_standard == 1) {
    $pagestyle_head .= '<link rel="' . $pagestyle_rel['standard'] . 'stylesheet" type="text/css" media="screen, projection, tty, tv" class="ps_standard" title="' . $pagestyle['standard'] . '" href="' . $uri . '/css/style_standard.css" />' . "\n";
  }

  // font-weight
  $pagestyle_head .= '<style type="text/css" media="screen, projection, tty, tv, print">
<!--
/* <![CDATA[ */' . "\n";

  // general font-weight
  if ($pagestyle_fontweight_black_white != 'normal' && $pagestyle_current == "black_white" || $pagestyle_fontweight_white_black != 'normal' && $pagestyle_current == "white_black" || $pagestyle_fontweight_yellow_blue != 'normal' && $pagestyle_current == "yellow_blue" || $pagestyle_fontweight_standard != 'normal' && $pagestyle_current == "standard") {
    $pagestyle_head .= 'body, * { font-weight: ' . $pagestyle_fontweight[$pagestyle_current] . ' !important; }' . "\n";
  }

  // font-weight class style for jQuery
  $pagestyle_head .= 'body.pagestyle_black_white, body.pagestyle_black_white * { font-weight: ' . $pagestyle_fontweight_black_white . ' !important; }' . "\n";
  $pagestyle_head .= 'body.pagestyle_white_black, body.pagestyle_white_black * { font-weight: ' . $pagestyle_fontweight_white_black . ' !important; }' . "\n";
  $pagestyle_head .= 'body.pagestyle_yellow_blue, body.pagestyle_yellow_blue * { font-weight: ' . $pagestyle_fontweight_yellow_blue . ' !important; }' . "\n";
  $pagestyle_head .= 'body.pagestyle_standard, body.pagestyle_standard * { font-weight: ' . $pagestyle_fontweight_standard . ' !important; }' . "\n";

  // admin
  if (user_access('administer pagestyle') && $_GET['q'] == 'admin/settings/pagestyle') {
    $pagestyle_head .= 'div#edit-pagestyle-black-white-wrapper label, div#edit-pagestyle-fontweight-black-white-wrapper label { font-weight: ' . $pagestyle_fontweight_black_white . '; }' . "\n";
    $pagestyle_head .= 'div#edit-pagestyle-white-black-wrapper label, div#edit-pagestyle-fontweight-white-black-wrapper label { font-weight: ' . $pagestyle_fontweight_white_black . '; }' . "\n";
    $pagestyle_head .= 'div#edit-pagestyle-yellow-blue-wrapper label, div#edit-pagestyle-fontweight-yellow-blue-wrapper label { font-weight: ' . $pagestyle_fontweight_yellow_blue . '; }' . "\n";
    $pagestyle_head .= 'div#edit-pagestyle-standard-wrapper label, div#edit-pagestyle-fontweight-standard-wrapper label { font-weight: ' . $pagestyle_fontweight_standard . '; }' . "\n";
  }
  $pagestyle_head .= '/* ]]>*/
-->
</style>' . "\n";
  drupal_set_html_head($pagestyle_head);
}