function bu_page_build in Browser update 7
Implements hook_page_build().
File
- ./
bu.module, line 21 - Browser update module.
Code
function bu_page_build(&$page) {
$pages = variable_get('bu_pages', '');
// Match path if necessary.
$page_match = TRUE;
if ($pages) {
$visibility = variable_get('bu_visibility', BU_VISIBILITY_NOTLISTED);
// Convert path to lowercase. This allows comparison of the same path
// with different case. Ex: /Page, /page, /PAGE.
$pages = drupal_strtolower($pages);
// Convert the Drupal path to lowercase.
$path = drupal_strtolower(drupal_get_path_alias(current_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 $block->visibility has a value of 0 (BLOCK_VISIBILITY_NOTLISTED),
// the block is displayed on all pages except those listed in $block->pages.
// When set to 1 (BLOCK_VISIBILITY_LISTED), it is displayed only on those
// pages listed in $block->pages.
$page_match = !($visibility xor $page_match);
}
if ($page_match) {
// Get the first key of the page array so we can attach to it.
$first_key = element_children($page);
$first_key = array_shift($first_key);
$page[$first_key]['#attached']['js'][] = array(
'data' => bu_get_settings(),
'type' => 'setting',
'scope' => 'header',
);
$page[$first_key]['#attached']['js'][] = array(
'data' => drupal_get_path('module', 'bu') . '/bu.js',
'type' => 'file',
'scope' => 'header',
);
}
}