function _js_injector_visibility_pages in JS injector 8
Same name and namespace in other branches
- 7.2 js_injector.module \_js_injector_visibility_pages()
Based on visibility setting this function returns TRUE if the JS injector rule code should be added to the current page and otherwise FALSE.
Code ported from googleanalytics.module
1 call to _js_injector_visibility_pages()
- js_injector_page_build in ./
js_injector.module - Implements hook_page_build().
File
- ./
js_injector.module, line 99 - js_injector.module
Code
function _js_injector_visibility_pages($rule) {
$visibility = $rule->page_visibility;
$setting_pages = $rule->page_visibility_pages;
// Match path if necessary.
if (!empty($setting_pages)) {
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($setting_pages);
if ($visibility < 2) {
// Convert the Drupal path to lowercase.
$path = drupal_strtolower(request_path());
// Compare the lowercase internal and lowercase path alias (if any).
$page_match = drupal_match_path($path, $pages);
if ($path != current_path()) {
$page_match = $page_match || drupal_match_path(current_path(), $pages);
}
// When $visibility has a value of 0, the tracking code 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 = FALSE;
}
}
else {
$page_match = TRUE;
}
return $page_match;
}