You are here

function _page_url_qr_code_block_content in Page URL QR Code Block 7

Content Generator. @global type $base_root

Return value

type

1 call to _page_url_qr_code_block_content()
page_url_qr_code_block_block_view in ./page_url_qr_code_block.module
Implements hook_block_view().

File

./page_url_qr_code_block.module, line 101
Contains module logic for page_url_qr_code_block.

Code

function _page_url_qr_code_block_content() {
  global $base_root;
  $request = request_uri();
  $alias = drupal_get_path_alias($request);
  $path = $request;
  if ($alias != $request) {
    $path = $alias;
  }
  $path = $base_root . $path;
  $url = urlencode($path);
  $width = variable_get('page_url_qr_code_width_height', 150);
  $height = variable_get('page_url_qr_code_width_height', 150);
  $alt = t(variable_get('page_url_qr_code_alt', 'QR code for this page URL'));
  $api = variable_get('page_url_qr_code_api', 'google');
  if ('liantu' == $api) {
    $barcode = "<img src='http://qr.liantu.com/api.php?bg=ffffff&amp;w={$width}&amp;text={$url}' alt='{$alt}' width='{$width}' height='{$height}' />";
  }
  else {
    $barcode = "<img src='http://chart.apis.google.com/chart?chs={$width}x{$width}&amp;cht=qr&amp;chl={$url}' alt='{$alt}' width='{$width}' height='{$height}' />";
  }
  return $barcode;
}