You are here

function _piwik_visibility_pages in Piwik Web Analytics 5

Same name and namespace in other branches
  1. 8 piwik.module \_piwik_visibility_pages()
  2. 6.2 piwik.module \_piwik_visibility_pages()
  3. 6 piwik.module \_piwik_visibility_pages()
  4. 7.2 piwik.module \_piwik_visibility_pages()
  5. 7 piwik.module \_piwik_visibility_pages()

Based on visibility setting this function returns TRUE if GA code should be added to the current page and otherwise FALSE.

2 calls to _piwik_visibility_pages()
piwik_footer in ./piwik.module
Implementation of hook_footer() to insert Javascript at the end of the page
piwik_menu in ./piwik.module

File

./piwik.module, line 532

Code

function _piwik_visibility_pages() {
  $visibility = variable_get('piwik_visibility', 0);
  $pages = variable_get('piwik_pages', '');

  // Match path if necessary.
  if (!empty($pages)) {
    if ($visibility < 2) {
      $path = drupal_get_path_alias($_GET['q']);

      // Compare with the internal and path alias (if any).
      $page_match = _piwik_match_path($path, $pages);
      if ($path != $_GET['q']) {
        $page_match = $page_match || _piwik_match_path($_GET['q'], $pages);
      }

      // When $visibility has a value of 0, the block is displayed on
      // all pages except those listed in $pages. When set to 1, it
      // is displayed only on those pages listed in $pages.
      $page_match = !($visibility xor $page_match);
    }
    else {
      $page_match = drupal_eval($pages);
    }
  }
  else {
    $page_match = TRUE;
  }
  return $page_match;
}