View source
<?php
define('BU_VISIBILITY_NOTLISTED', 0);
define('BU_VISIBILITY_LISTED', 1);
function bu_page_build(&$page) {
$pages = variable_get('bu_pages', '');
$page_match = TRUE;
if ($pages) {
$visibility = variable_get('bu_visibility', BU_VISIBILITY_NOTLISTED);
$pages = drupal_strtolower($pages);
$path = drupal_strtolower(drupal_get_path_alias(current_path()));
$page_match = drupal_match_path($path, $pages);
if ($path != current_path()) {
$page_match = $page_match || drupal_match_path(current_path(), $pages);
}
$page_match = !($visibility xor $page_match);
}
if ($page_match) {
$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',
);
}
}
function bu_menu() {
$items = array();
$items['admin/config/services/bu'] = array(
'title' => 'Browser update',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'bu_admin_settings',
),
'access arguments' => array(
'administer browser-update',
),
'file' => 'bu.admin.inc',
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function bu_permission() {
return array(
'administer browser-update' => array(
'title' => t('Administer Browser-update'),
'description' => t('Administer Browser-update settings.'),
),
);
}
function bu_get_settings() {
return array(
'bu' => array(
'source' => variable_get('bu_settings_source', '//browser-update.org/update.js'),
'show_source' => variable_get('bu_settings_show_source', '//browser-update.org/update.show.min.js'),
'firefox' => variable_get('bu_browsers_firefox', '-4'),
'ie' => variable_get('bu_browsers_ie', '-6'),
'opera' => variable_get('bu_browsers_opera', '-4'),
'safari' => variable_get('bu_browsers_safari', '-2'),
'chrome' => variable_get('bu_browsers_chrome', '-4'),
'insecure' => variable_get('bu_settings_insecure', TRUE),
'unsupported' => variable_get('bu_settings_unsupported', FALSE),
'mobile' => variable_get('bu_settings_mobile', TRUE),
'position' => variable_get('bu_settings_position', 'top'),
'text' => variable_get('bu_settings_text', ''),
'reminder' => (int) variable_get('bu_settings_reminder', 3),
'reminder_closed' => (int) variable_get('bu_settings_reminder_closed', 3),
'debug' => (bool) variable_get('bu_settings_debug', 0),
'blank' => (bool) variable_get('bu_settings_blank', 0),
'hide_ignore' => (bool) variable_get('bu_settings_hide_ignore', FALSE),
),
);
}