You are here

function yandex_metrics_show_counter in Yandex.Metrics 6.2

Same name and namespace in other branches
  1. 8.3 yandex_metrics.module \yandex_metrics_show_counter()
  2. 8.2 yandex_metrics.module \yandex_metrics_show_counter()
  3. 6 yandex_metrics.module \yandex_metrics_show_counter()
  4. 7.3 yandex_metrics.module \yandex_metrics_show_counter()
  5. 7 yandex_metrics.module \yandex_metrics_show_counter()
  6. 7.2 yandex_metrics.module \yandex_metrics_show_counter()

Returns FALSE if we need to disable counter on page.

Return value

bool

1 call to yandex_metrics_show_counter()
yandex_metrics_footer in ./yandex_metrics.module
Implementation of hook_footer. Adds Yandex.Metrics counter code to the site footer.

File

./yandex_metrics.module, line 166
The main code of Yandex.Metrics Counter module.

Code

function yandex_metrics_show_counter() {
  $pages = variable_get('yandex_metrics_pages', YANDEX_METRICS_PAGES);
  $visibility = variable_get('yandex_metrics_visibility', 0);
  $urls_equal = FALSE;
  if (!empty($pages)) {
    $pages_in_lowcase = drupal_strtolower($pages);
    $current_path = drupal_strtolower(drupal_get_path_alias($_GET['q']));

    // Compare internal and path alias.
    $path_match = drupal_match_path($current_path, $pages_in_lowcase);
    if ($path_match) {
      $urls_equal = TRUE;
    }
    else {

      // If path alias doesn't equal with $_GET['q'] then compare internal and $_GET['q'].
      $path_match = drupal_match_path($_GET['q'], $pages_in_lowcase);
      if ($current_path != $_GET['q'] && $path_match) {
        $urls_equal = TRUE;
      }
    }
  }
  if (!$visibility && $urls_equal) {
    return FALSE;
  }
  elseif (!$visibility && !$urls_equal) {
    return TRUE;
  }
  elseif ($visibility && $urls_equal) {
    return TRUE;
  }
  elseif ($visibility && !$urls_equal) {
    return FALSE;
  }
}