You are here

textsize.block.inc in Text Size 5

Same filename and directory in other branches
  1. 6 includes/textsize.block.inc
  2. 7 includes/textsize.block.inc

block, page and theme functions.

File

includes/textsize.block.inc
View source
<?php

/**
 * @file
 * block, page and theme functions.
 */

/**
 * Returns an array of allowed values.
 *
 * @return
 *   An array of allowed values.
 */
function textsize_allowed_values() {
  $ts_in = variable_get('textsize_increment', 5);
  $ts_no = variable_get('textsize_normal', 75);
  $ts_mi = variable_get('textsize_minimum', 50);
  $ts_ma = variable_get('textsize_maximum', 150);
  $textsize_allowed_values = array();
  if (is_numeric($ts_in) && is_numeric($ts_no) && is_numeric($ts_mi) && is_numeric($ts_ma)) {
    if ($ts_in >= 1 && $ts_no >= 1 && $ts_mi >= 1 && $ts_ma >= 3) {
      $ts_st = $ts_no - floor(($ts_no - $ts_mi) / $ts_in) * $ts_in;
      $ts_en = $ts_no + floor(($ts_ma - $ts_no) / $ts_in) * $ts_in;
      for ($value = $ts_st; $value <= $ts_en; $value = $value + $ts_in) {
        $textsize_allowed_values[] = $value;
      }
    }
  }
  return $textsize_allowed_values;
}

/**
 * Cookie expires.
 *
 * @return
 *   The cookie expires in seconds.
 */
function textsize_cookie_expires($mode = 'php') {
  $textsize_cookie_expires = variable_get('textsize_cookie_expires', 365);
  $output = $textsize_cookie_expires * 24 * 60 * 60;
  if ($mode == 'js') {
    $output = $textsize_cookie_expires;
  }
  return $output;
}

/**
 * Menu callback; increase the textsize, then redirects to the previous page.
 */
function textsize_increase() {
  $textsize_cookie_expires = textsize_cookie_expires($mode = 'php');
  $textsize_cookie_domain = variable_get('textsize_cookie_domain', base_path());
  $textsize_link_type = variable_get('textsize_link_type', 'variable');
  $ts_in = variable_get('textsize_increment', 5);
  $ts_no = variable_get('textsize_normal', 75);
  $ts_ma = variable_get('textsize_maximum', 150);
  $textsize_maximum = $ts_no + floor(($ts_ma - $ts_no) / $ts_in) * $ts_in;
  $textsize_normal_display = textsize_display($ts_no, 0);
  $textsize_maximum_display = textsize_display($textsize_maximum, 0);
  $textsize_message = variable_get('textsize_message', 1);
  $textsize_post = array();
  $textsize_cookie = array();
  $textsize_cookie['textsize'] = NULL;

  // allowed values
  $textsize_allowed = textsize_allowed_values();

  // check the type and the content
  if (in_array($_COOKIE['textsize'], $textsize_allowed)) {
    $textsize_cookie['textsize'] = (int) filter_xss($_COOKIE['textsize']);
  }

  // calculation of text size
  $ts_value = $textsize_cookie['textsize'] + $ts_in;
  $ts_value_display = textsize_display($ts_value, 0);

  // set session/cookie
  if (!isset($_COOKIE['textsize']) && $textsize_message == 1) {
    drupal_set_message(t('The text size have not been saved, because your browser do not accept cookies.'), 'error');
  }
  elseif ($textsize_link_type == 'fix' && $textsize_cookie['textsize'] == $ts_no - $ts_in && $textsize_message == 1) {
    drupal_set_message(t('The text size maximum is: %ts_max%.', array(
      '%ts_max' => textsize_display($ts_no + $ts_in, 0),
    )), 'error');
  }
  elseif ($textsize_cookie['textsize'] == $textsize_maximum && variable_get('textsize_reset', 0) == 1) {
    $_SESSION['textsize'] = $ts_no;
    setcookie("textsize", $ts_no, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size maximum is: %ts_max%.', array(
        '%ts_max' => $textsize_maximum_display,
      )), 'warning');
      drupal_set_message(t('The text size have been saved as %textsize_normal%.', array(
        '%textsize_normal' => $textsize_normal_display,
      )));
    }
  }
  elseif ($textsize_cookie['textsize'] == $textsize_maximum && $textsize_message == 1) {
    drupal_set_message(t('The text size maximum is: %ts_max%.', array(
      '%ts_max' => $textsize_maximum_display,
    )), 'error');
  }
  elseif ($textsize_link_type == 'fix' && $textsize_cookie['textsize'] == $ts_no || $textsize_link_type == 'fix' && $textsize_cookie['textsize'] == $ts_no + $ts_in) {
    $_SESSION['textsize'] = $ts_no + $ts_in;
    setcookie("textsize", $ts_no + $ts_in, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size have been saved as %ts_value%.', array(
        '%ts_value' => textsize_display($ts_no + $ts_in, 0),
      )));
    }
  }
  else {
    $_SESSION['textsize'] = $ts_value;
    setcookie("textsize", $ts_value, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size have been saved as %ts_value%.', array(
        '%ts_value' => $ts_value_display,
      )));
    }
  }
  textsize_clear_cache();
  drupal_goto();
}

/**
 * Menu callback; decrease the textsize, then redirects to the previous page.
 */
function textsize_decrease() {
  $textsize_cookie_expires = textsize_cookie_expires($mode = 'php');
  $textsize_cookie_domain = variable_get('textsize_cookie_domain', base_path());
  $textsize_link_type = variable_get('textsize_link_type', 'variable');
  $ts_in = variable_get('textsize_increment', 5);
  $ts_no = variable_get('textsize_normal', 75);
  $ts_mi = variable_get('textsize_minimum', 50);
  $textsize_minimum = $ts_no - floor(($ts_no - $ts_mi) / $ts_in) * $ts_in;
  $textsize_normal_display = textsize_display($ts_no, 0);
  $textsize_minimum_display = textsize_display($textsize_minimum, 0);
  $textsize_message = variable_get('textsize_message', 1);
  $textsize_post = array();
  $textsize_cookie = array();
  $textsize_cookie['textsize'] = NULL;

  // allowed values
  $textsize_allowed = textsize_allowed_values();

  // check the type and the content
  if (in_array($_COOKIE['textsize'], $textsize_allowed)) {
    $textsize_cookie['textsize'] = (int) filter_xss($_COOKIE['textsize']);
  }

  // calculation of text size
  $ts_value = $textsize_cookie['textsize'] - $ts_in;
  $ts_value_display = textsize_display($ts_value, 0);

  // set session/cookie
  if (!isset($_COOKIE['textsize']) && $textsize_message == 1) {
    drupal_set_message(t('The text size have not been saved, because your browser do not accept cookies.'), 'error');
  }
  elseif ($textsize_link_type == 'fix' && $textsize_cookie['textsize'] == $ts_no - $ts_in && $textsize_message == 1) {
    drupal_set_message(t('The text size minimum is: %ts_min%.', array(
      '%ts_min' => textsize_display($ts_no - $ts_in, 0),
    )), 'error');
  }
  elseif ($textsize_cookie['textsize'] == $textsize_minimum && variable_get('textsize_reset', 0) == 1) {
    $_SESSION['textsize'] = $ts_no;
    setcookie("textsize", $ts_no, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size minimum is: %ts_min%.', array(
        '%ts_min' => $textsize_minimum_display,
      )), 'warning');
      drupal_set_message(t('The text size have been saved as %textsize_normal%.', array(
        '%textsize_normal' => $textsize_normal_display,
      )));
    }
  }
  elseif ($textsize_cookie['textsize'] == $textsize_minimum && $textsize_message == 1) {
    drupal_set_message(t('The text size minimum is: %ts_min%.', array(
      '%ts_min' => $textsize_minimum,
    )), 'error');
  }
  elseif ($textsize_link_type == 'fix' && $textsize_cookie['textsize'] == $ts_no || $textsize_link_type == 'fix' && $textsize_cookie['textsize'] == $ts_no + $ts_in) {
    $_SESSION['textsize'] = $ts_no - $ts_in;
    setcookie("textsize", $ts_no - $ts_in, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size have been saved as %ts_value%.', array(
        '%ts_value' => textsize_display($ts_no - $ts_in, 0),
      )));
    }
  }
  else {
    $_SESSION['textsize'] = $ts_value;
    setcookie("textsize", $ts_value, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size have been saved as %ts_value%.', array(
        '%ts_value' => $ts_value_display,
      )));
    }
  }
  textsize_clear_cache();
  drupal_goto();
}

/**
 * Menu callback; change the textsize to normal, then redirects to the previous page.
 */
function textsize_normal() {
  $textsize_cookie_expires = textsize_cookie_expires($mode = 'php');
  $textsize_cookie_domain = variable_get('textsize_cookie_domain', base_path());
  $textsize_normal = variable_get('textsize_normal', 75);
  $textsize_normal_display = textsize_display($textsize_normal, 0);
  $textsize_message = variable_get('textsize_message', 1);

  // set session/cookie
  if (!isset($_COOKIE['textsize']) && $textsize_message == 1) {
    drupal_set_message(t('The text size have not been saved, because your browser do not accept cookies.'), 'error');
  }
  else {
    $_SESSION['textsize'] = $textsize_normal;
    setcookie("textsize", $textsize_normal, time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size have been saved as %textsize_normal%.', array(
        '%textsize_normal' => $textsize_normal_display,
      )));
    }
  }
  textsize_clear_cache();
  drupal_goto();
}

/**
 * Menu callback; change the textsize to the cookie value, then redirects to the previous page.
 */
function textsize_set() {
  $textsize_cookie_expires = textsize_cookie_expires($mode = 'php');
  $textsize_cookie_domain = variable_get('textsize_cookie_domain', base_path());
  $textsize_normal = variable_get('textsize_normal', 75);
  $textsize_message = variable_get('textsize_message', 1);
  $textsize_post = array();
  $textsize_cookie = array();

  // allowed values
  $textsize_allowed = textsize_allowed_values();

  // check the type and the content
  if (in_array($_COOKIE['textsize'], $textsize_allowed)) {
    $textsize_cookie['textsize'] = (int) filter_xss($_COOKIE['textsize']);
  }

  // set session/cookie
  if (!isset($_COOKIE['textsize']) && $textsize_message == 1) {
    drupal_set_message(t('The text size have not been saved, because your browser do not accept cookies.'), 'error');
  }
  elseif (isset($_COOKIE['textsize'])) {
    $_SESSION['textsize'] = $textsize_cookie['textsize'];
    setcookie("textsize", $textsize_cookie['textsize'], time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
    if ($textsize_message == 1) {
      drupal_set_message(t('The text size have been saved as %textsize%.', array(
        '%textsize' => textsize_display($textsize_cookie['textsize'], 0),
      )));
    }
  }
  textsize_clear_cache();
  drupal_goto();
}

/**
 * Clear defined cache tables
 */
function textsize_clear_cache() {
  $tables = array(
    'cache_page',
    'cache',
  );
  foreach ($tables as $table) {
    cache_clear_all('*', $table, TRUE);
  }
}

/**
 * Block Title
 *
 * @return
 *   "Text Size" and "Current Size" or "Zoom" and "Current Zoom".
 *
 * @see textsize_admin_settings()
 */
function textsize_block_title($title = 'title') {
  $textsize_block_title = variable_get('textsize_block_title', 'text_size');
  $textsize_block_title_text = t('Text Size');
  $textsize_current_textsize_text = t('Current Size');
  switch ($textsize_block_title) {
    case 'zoom':
      $textsize_block_title_text = t('Zoom');
      $textsize_current_textsize_text = t('Current Zoom');
      break;
  }
  if ($title == 'title') {
    return $textsize_block_title_text;
  }
  elseif ($title == 'current') {
    return $textsize_current_textsize_text;
  }
}

/**
 * Returns an array of available values for the select element in the block text size.
 *
 * @return
 *   An array of available values, for selecting the text size.
 *
 * @see textsize_form()
 */
function textsize_block_form_options() {
  $textsize_link_type = variable_get('textsize_link_type', 'variable');
  $ts_in = variable_get('textsize_increment', 5);
  $ts_no = variable_get('textsize_normal', 75);
  $ts_mi = variable_get('textsize_minimum', 50);
  $ts_ma = variable_get('textsize_maximum', 150);
  if ($textsize_link_type == 'fix') {
    $ts_st = $ts_no - $ts_in;
    $ts_en = $ts_no + $ts_in;
  }
  elseif ($textsize_link_type == 'variable') {
    $ts_st = $ts_no - floor(($ts_no - $ts_mi) / $ts_in) * $ts_in;
    $ts_en = $ts_no + floor(($ts_ma - $ts_no) / $ts_in) * $ts_in;
  }
  $options = array();
  for ($value = $ts_st; $value <= $ts_en; $value = $value + $ts_in) {
    $options[$value] = textsize_display($value, 0);
  }
  return $options;
}

/**
 * Implement hook_form().
 *
 * Generate the select form for the block.
 *
 * @see textsize_block()
 */
function textsize_form() {
  $textsize_cookie_expires = textsize_cookie_expires($mode = 'php');
  $textsize_cookie_domain = variable_get('textsize_cookie_domain', base_path());
  $textsize_block_title = textsize_block_title($title = 'title');
  $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_message = variable_get('textsize_message', 1);
  $display_current_textsize = variable_get('textsize_display_current_textsize', 'display');
  $textsize_current = textsize_get_current($value = 'int');
  $options = textsize_block_form_options();
  $textsize_post = array();
  $textsize_cookie = array();

  // allowed values
  $textsize_allowed = textsize_allowed_values();

  // check the type and the content
  if (isset($_COOKIE['textsize']) && isset($_POST['textsize_select'])) {
    if (in_array($_POST['textsize_select'], $textsize_allowed)) {
      $textsize_post['textsize'] = (string) filter_xss($_POST['textsize_select']);
    }

    // set session/cookie
    if ($textsize_post['textsize'] <= $textsize_maximum && $textsize_post['textsize'] >= $textsize_minimum) {
      setcookie("textsize", $textsize_post['textsize'], time() + $textsize_cookie_expires, $textsize_cookie_domain, "");
      $_SESSION['textsize'] = $textsize_post['textsize'];
      if ($textsize_message == 1) {
        drupal_set_message(t('The text size have been saved as %textsize_post%.', array(
          '%textsize_post' => textsize_display($textsize_post['textsize'], 0),
        )));
      }
      textsize_clear_cache();
    }
  }
  elseif (!isset($_COOKIE['textsize']) && isset($_POST['textsize_select']) && $textsize_message == 1) {
    drupal_set_message(t('The text size have not been saved, because your browser do not accept cookies.'), 'error');
  }
  $subtitle = NULL;
  if (variable_get('textsize_display_subtitle', 0) == 1) {
    $subtitle = $textsize_block_title;
  }
  $form = array();
  $form['textsize_select'] = array(
    '#type' => 'select',
    '#title' => $subtitle,
    '#name' => 'textsize_select',
    '#options' => $options,
    '#default_value' => variable_get('textsize_select', $textsize_current),
    '#weight' => 0,
    '#attributes' => array(
      'class' => 'textsize',
    ),
  );
  $form['textsize_submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#weight' => 1,
  );
  $form['#skip_duplicate_check'] = TRUE;
  return $form;
}

/**
 * Implement theme().
 *
 * @see textsize_block()
 */
function theme_textsize_text() {
  $textsize_block_title = textsize_block_title($title = 'title');
  $textsize_current_textsize_text = textsize_block_title($title = 'current');
  $dest = drupal_get_destination();
  $list_inline = variable_get('textsize_list_inline', 'list');
  $link_type = variable_get('textsize_link_type', 'variable');
  $display_links = variable_get('textsize_display_links', 'display');
  $increment = variable_get('textsize_increment', 5);
  $normal = variable_get('textsize_normal', 75);
  $display_current_textsize = variable_get('textsize_display_current_textsize', 'display');
  $textsize = textsize_get_current($value = 'display');
  $block_title = $textsize_block_title;
  $current_textsize_text = $textsize_current_textsize_text;
  $list_inline = "list";
  $subtitle_add = NULL;
  if (variable_get('textsize_display_list_inline', 0) == 1) {
    $list_inline = "inline";
    $subtitle_add = ": ";
  }
  $current_inline = "textsize_current_list";
  if (variable_get('textsize_display_current_inline', 0) == 1) {
    $current_inline = "textsize_current_inline";
  }
  $subtitle = NULL;
  $subtitle_text = NULL;
  if (variable_get('textsize_display_subtitle', 0) == 1) {
    $subtitle = "subtitle";
    $subtitle_text = $textsize_block_title . $subtitle_add;
  }
  $textsize_increase = NULL;
  if (variable_get('textsize_display_increase', 1) == 1) {
    $textsize_increase = "textsize_increase";
  }
  $textsize_decrease = NULL;
  if (variable_get('textsize_display_decrease', 1) == 1) {
    $textsize_decrease = "textsize_decrease";
  }
  $textsize_normal = NULL;
  if (variable_get('textsize_display_normal', 1) == 1) {
    $textsize_normal = "textsize_normal";
  }
  $display_links = "display";
  if (variable_get('textsize_display_links', 1) == 0) {
    $display_links = "display_hidden";
  }
  $current_textsize = NULL;
  $display_current_textsize = "display";
  $display_current_textsize_text = "display";
  switch (variable_get('textsize_display_current_text_value', 'text_value')) {
    case "text_value":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display";
      $display_current_textsize_text = "display";
      break;
    case "value":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display";
      $display_current_textsize_text = "display_hidden";
      break;
    case "hidden":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display_hidden";
      $display_current_textsize_text = "display_hidden";
      break;
    case "remove":
      $display_current_textsize = "display_hidden";
      $display_current_textsize_text = "display_hidden";
      break;
  }
  if ($subtitle) {
    $output .= '<h3 class="' . $list_inline . '">' . $subtitle_text . '</h3>' . "\n";
  }
  $output .= '<ul class="textsize_' . $list_inline . '">' . "\n";
  if ($textsize_increase) {
    $output .= '  <li class="ts_increase_' . check_plain($link_type) . '">' . l('<span class="' . $display_links . '">' . t('Increase') . '</span>', 'textsize/increase', $attributes = array(
      'title' => $block_title . ': ' . t('Increase') . ' +' . $increment . '%',
      'class' => 'ts_icon ts_increase_' . check_plain($link_type) . ' textsize_increase text_' . $display_links,
    ), $query = $dest, $fragment = NULL, $absolute = FALSE, $html = TRUE) . '</li>' . "\n";
  }
  if ($textsize_decrease) {
    $output .= '  <li class="ts_decrease_' . check_plain($link_type) . '">' . l('<span class="' . $display_links . '">' . t('Decrease') . '</span>', 'textsize/decrease', $attributes = array(
      'title' => $block_title . ': ' . t('Decrease') . ' -' . $increment . '%',
      'class' => 'ts_icon ts_decrease_' . check_plain($link_type) . ' textsize_decrease text_' . $display_links,
    ), $query = $dest, $fragment = NULL, $absolute = FALSE, $html = TRUE) . '</li>' . "\n";
  }
  if ($textsize_normal) {
    $output .= '  <li class="ts_normal_' . check_plain($link_type) . '">' . l('<span class="' . $display_links . '">' . t('Normal') . '</span>', 'textsize/normal', $attributes = array(
      'title' => $block_title . ': ' . t('Normal') . ' =' . $normal . '%',
      'class' => 'ts_icon ts_normal_' . check_plain($link_type) . ' textsize_normal text_' . $display_links,
    ), $query = $dest, $fragment = NULL, $absolute = FALSE, $html = TRUE) . '</li>' . "\n";
  }
  $output .= '</ul>' . "\n";
  if ($current_textsize) {
    $output .= '<p class="textsize_current ' . $current_inline . ' ' . $display_current_textsize . ' current_text_' . $display_current_textsize_text . '"><span class="' . $display_current_textsize_text . '">' . $current_textsize_text . ': </span><span id="textsize_current" title="' . $current_textsize_text . ': ' . $textsize . '%">' . $textsize . '%</span></p>' . "\n";
  }
  $output .= '<div class="ts_clear"></div>' . "\n";
  return $output;
}

/**
 * Implement theme().
 *
 * @see textsize_block()
 */
function theme_textsize_image() {
  $textsize_block_title = textsize_block_title($title = 'title');
  $textsize_current_textsize_text = textsize_block_title($title = 'current');
  $dest = drupal_get_destination();
  $list_inline = variable_get('textsize_list_inline', 'list');
  $link_type = variable_get('textsize_link_type', 'variable');
  $display_links = variable_get('textsize_display_links', 'display');
  $increment = variable_get('textsize_increment', 5);
  $normal = variable_get('textsize_normal', 75);
  $display_current_textsize = variable_get('textsize_display_current_textsize', 'display');
  $textsize = textsize_get_current($value = 'display');
  $block_title = $textsize_block_title;
  $current_textsize_text = $textsize_current_textsize_text;
  $list_inline = "list";
  $subtitle_add = NULL;
  if (variable_get('textsize_display_list_inline', 0) == 1) {
    $list_inline = "inline";
    $subtitle_add = ": ";
  }
  $current_inline = "textsize_current_list";
  if (variable_get('textsize_display_current_inline', 0) == 1) {
    $current_inline = "textsize_current_inline";
  }
  $subtitle = NULL;
  $subtitle_text = NULL;
  if (variable_get('textsize_display_subtitle', 0) == 1) {
    $subtitle = "subtitle";
    $subtitle_text = $textsize_block_title . $subtitle_add;
  }
  $textsize_increase = NULL;
  if (variable_get('textsize_display_increase', 1) == 1) {
    $textsize_increase = "textsize_increase";
  }
  $textsize_decrease = NULL;
  if (variable_get('textsize_display_decrease', 1) == 1) {
    $textsize_decrease = "textsize_decrease";
  }
  $textsize_normal = NULL;
  if (variable_get('textsize_display_normal', 1) == 1) {
    $textsize_normal = "textsize_normal";
  }
  $display_links = "display";
  if (variable_get('textsize_display_links', 1) == 0) {
    $display_links = "display_hidden";
  }
  $current_textsize = NULL;
  $display_current_textsize = "display";
  $display_current_textsize_text = "display";
  switch (variable_get('textsize_display_current_text_value', 'text_value')) {
    case "text_value":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display";
      $display_current_textsize_text = "display";
      break;
    case "value":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display";
      $display_current_textsize_text = "display_hidden";
      break;
    case "hidden":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display_hidden";
      $display_current_textsize_text = "display_hidden";
      break;
    case "remove":
      $display_current_textsize = "display_hidden";
      $display_current_textsize_text = "display_hidden";
      break;
  }
  if ($subtitle) {
    $output .= '<h3 class="' . $list_inline . '">' . $subtitle_text . '</h3>' . "\n";
  }
  $output .= '<ul class="textsize_' . $list_inline . '">' . "\n";
  if ($textsize_increase) {
    $output .= '  <li class="ts_increase_' . check_plain($link_type) . '">' . l('<img src="' . base_path() . drupal_get_path("module", "textsize") . '/images/increase_16.gif" alt=' . t('Increase') . ' class="ts_increase ts_rollover" />', 'textsize/increase', $attributes = array(
      'title' => $block_title . ': ' . t('Increase') . ' +' . $increment . '%',
      'class' => 'ts_increase_' . check_plain($link_type) . ' text_display_hidden ts_rollover',
    ), $query = $dest, $fragment = NULL, $absolute = FALSE, $html = TRUE) . '</li>' . "\n";
  }
  if ($textsize_decrease) {
    $output .= '  <li class="ts_decrease_' . check_plain($link_type) . '">' . l('<img src="' . base_path() . drupal_get_path("module", "textsize") . '/images/decrease_16.gif" alt=' . t('Decrease') . ' class="ts_decrease ts_rollover" />', 'textsize/decrease', $attributes = array(
      'title' => $block_title . ': ' . t('Decrease') . ' -' . $increment . '%',
      'class' => 'ts_decrease_' . check_plain($link_type) . ' text_display_hidden ts_rollover',
    ), $query = $dest, $fragment = NULL, $absolute = FALSE, $html = TRUE) . '</li>' . "\n";
  }
  if ($textsize_normal) {
    $output .= '  <li class="ts_normal_' . check_plain($link_type) . '">' . l('<img src="' . base_path() . drupal_get_path("module", "textsize") . '/images/normal_16.gif" alt=' . t('Normal') . ' class="ts_normal ts_rollover" />', 'textsize/normal', $attributes = array(
      'title' => $block_title . ': ' . t('Normal') . ' =' . $normal . '%',
      'class' => 'ts_normal_' . check_plain($link_type) . ' text_display_hidden ts_rollover',
    ), $query = $dest, $fragment = NULL, $absolute = FALSE, $html = TRUE) . '</li>' . "\n";
  }
  $output .= '</ul>' . "\n";
  if ($current_textsize) {
    $output .= '<p class="textsize_current ' . $current_inline . ' ' . $display_current_textsize . ' current_text_' . $display_current_textsize_text . '"><span class="' . $display_current_textsize_text . '">' . $current_textsize_text . ': </span><span id="textsize_current" title="' . $current_textsize_text . ': ' . $textsize . '%">' . $textsize . '%</span></p>' . "\n";
  }
  $output .= '<div class="ts_clear"></div>' . "\n";
  return $output;
}

/**
 * Implement theme().
 *
 * @see textsize_form()
 */
function theme_textsize_form($form) {
  $textsize_current_textsize_text = textsize_block_title($title = 'current');
  $display_current_textsize = variable_get('textsize_display_current_textsize', 'display');
  $textsize = textsize_get_current($value = 'display');
  $current_textsize_text = $textsize_current_textsize_text;
  $list_inline = "list";
  if (variable_get('textsize_display_list_inline', 0) == 1) {
    $list_inline = "inline";
  }
  $current_inline = "textsize_current_list";
  if (variable_get('textsize_display_current_inline', 0) == 1) {
    $current_inline = "textsize_current_inline";
  }
  $current_textsize = NULL;
  $display_current_textsize = "display";
  $display_current_textsize_text = "display";
  switch (variable_get('textsize_display_current_text_value', 'text_value')) {
    case "text_value":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display";
      $display_current_textsize_text = "display";
      break;
    case "value":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display";
      $display_current_textsize_text = "display_hidden";
      break;
    case "hidden":
      $current_textsize = "current_textsize";
      $display_current_textsize = "display_hidden";
      $display_current_textsize_text = "display_hidden";
      break;
    case "remove":
      $display_current_textsize = "display_hidden";
      $display_current_textsize_text = "display_hidden";
      break;
  }
  $output = '<div id="textsize" class="textsize_' . $list_inline . ' ' . $current_inline . '">' . "\n";
  $output .= drupal_render($form);
  if ($current_textsize) {
    $output .= '<p class="textsize_current ' . $current_inline . ' ' . $display_current_textsize . ' current_text_' . $display_current_textsize_text . ' text_display"><span class="' . $display_current_textsize_text . '">' . $current_textsize_text . ': </span><span id="textsize_current" title="' . $current_textsize_text . ': ' . $textsize . '%">' . $textsize . '%</span></p>' . "\n";
  }
  $output .= '</div>' . "\n";
  $output .= '<div class="ts_clear"></div>' . "\n";
  return $output;
}

Functions

Namesort descending Description
textsize_allowed_values Returns an array of allowed values.
textsize_block_form_options Returns an array of available values for the select element in the block text size.
textsize_block_title Block Title
textsize_clear_cache Clear defined cache tables
textsize_cookie_expires Cookie expires.
textsize_decrease Menu callback; decrease the textsize, then redirects to the previous page.
textsize_form Implement hook_form().
textsize_increase Menu callback; increase the textsize, then redirects to the previous page.
textsize_normal Menu callback; change the textsize to normal, then redirects to the previous page.
textsize_set Menu callback; change the textsize to the cookie value, then redirects to the previous page.
theme_textsize_form Implement theme().
theme_textsize_image Implement theme().
theme_textsize_text Implement theme().