function _environment_indicator_switcher_menu in Environment Indicator 7.2
Same name and namespace in other branches
- 8.2 environment_indicator.module \_environment_indicator_switcher_menu()
Helper function to generate a menu with the environments to switch to.
1 call to _environment_indicator_switcher_menu()
- environment_indicator_navbar in ./
environment_indicator.module - Implements hook_navbar().
File
- ./
environment_indicator.module, line 720 - Module implementation file.
Code
function _environment_indicator_switcher_menu() {
$links = array();
$environments = environment_indicator_get_all(TRUE);
if (empty($environments)) {
$links['empty'] = array(
'title' => '- ' . t('There are no other environments available.') . ' -',
'href' => current_path(),
'attributes' => array(
'class' => array(
'navbar-menu-item-indicator',
'navbar-menu-item',
),
),
);
}
if (!($current_environment = environment_indicator_get_active())) {
return NULL;
}
foreach ($environments as $machine => $environment) {
if ($machine != $current_environment['machine']) {
$links[$environment->machine] = array(
'title' => t('Open in: @name', array(
'@name' => $environment->name,
)),
'href' => 'http://' . $environment->regexurl . '/' . current_path(),
'html' => TRUE,
'attributes' => array(
'title' => t('Open the current page in the environment: @name', array(
'@name' => $environment->name,
)),
'class' => array(
'navbar-menu-item-indicator',
'navbar-menu-item',
),
'style' => 'background-color: ' . $environment->settings['color'] . '; color: ' . $environment->settings['text_color'] . ';',
),
);
}
}
return array(
'#heading' => t('Environment indicator'),
'navbar_indicators' => array(
'#theme' => 'links__navbar_user',
'#links' => $links,
'#attributes' => array(
'class' => array(
'menu',
'navbar-menu-environment-indicator',
),
),
),
);
}