function environment_indicator_init in Environment Indicator 7
Same name and namespace in other branches
- 6 environment_indicator.module \environment_indicator_init()
Implement hook_init().
File
- ./
environment_indicator.module, line 68 - Adds a coloured strip to the side of the site informing the user which environment they are in (Development, Staging Production etc).
Code
function environment_indicator_init() {
if (!user_access('access environment indicator') || !variable_get('environment_indicator_enabled', 1)) {
return;
}
// Do not show the indicator on select pages.
$off_pages = variable_get('environment_indicator_suppress_pages', "imagecrop/*\nmedia/browser");
$path = drupal_get_path_alias($_GET['q']);
// Compare with the internal and path alias (if any).
$page_match = drupal_match_path($path, $off_pages);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $off_pages);
}
if ($page_match) {
return;
}
$path = drupal_get_path('module', 'environment_indicator');
drupal_add_css($path . '/environment_indicator.css', array(
'every_page' => TRUE,
));
// Performance: Defer execution.
drupal_add_js($path . '/environment_indicator.min.js');
drupal_add_js($path . '/environment_indicator.js', array(
'preprocess' => FALSE,
));
if ($setting = variable_get('environment_indicator_margin', 1)) {
$settings['margin'] = check_plain($setting);
}
if ($setting = variable_get('environment_indicator_position', 'left')) {
$settings['position'] = check_plain($setting);
}
if ($setting = variable_get('environment_indicator_text', 'ENVIRONMENT INDICATOR')) {
$settings['text'] = check_plain($setting);
}
if ($setting = variable_get('environment_indicator_color', '#d00c0c')) {
$settings['color'] = check_plain($setting);
}
drupal_add_js(array(
'environment_indicator' => $settings,
), 'setting');
}