You are here

function google_analytics_counter_display in Google Analytics Counter 7.2

Same name and namespace in other branches
  1. 6.2 google_analytics_counter.module \google_analytics_counter_display()
  2. 6 google_analytics_counter.module \google_analytics_counter_display()
  3. 7.3 google_analytics_counter.module \google_analytics_counter_display()
  4. 7 google_analytics_counter.module \google_analytics_counter_display()

Displays the count.

2 calls to google_analytics_counter_display()
google_analytics_counter_block_view in ./google_analytics_counter.module
Implements hook_block_view().
replace_google_analytics_counter_tags in ./google_analytics_counter.module
Finds [gac|...] tags and replaces them by actual values.

File

./google_analytics_counter.module, line 223
Basic functions for this module.

Code

function google_analytics_counter_display($path = '') {
  if ($path == '') {

    //$path = $_GET['q'];

    //dpm($language);

    //$path = $lprefix.$path;

    // We need a path that includes the language prefix, if any. E.g. en/my/path (of /en/my/path - the initial slash will be dealt with later).
    $path = parse_url("http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}", PHP_URL_PATH);

    // @TODO: Works OK on non-Apache servers?
  }

  //dpm($path);

  // Check all paths, to be sure.

  //$path = check_plain($path);
  $block_content = '';

  //$block_content .= '<span id="google-analytics-counter-' . md5($path) . '">';
  $block_content .= '<span class="google-analytics-counter">';
  $count = google_analytics_counter_get_sum_per_path($path);
  if ($count == '') {

    // If unknown, for some reason.
    $block_content .= 0;

    // Better than t('N/A').
  }
  else {
    $block_content .= $count;
  }
  $block_content .= '</span>';
  return $block_content;
}