You are here

function mobile_tools_block_message in Mobile Tools 7.2

Same name and namespace in other branches
  1. 6.3 mobile_tools.module \mobile_tools_block_message()
  2. 6 mobile_tools.module \mobile_tools_block_message()
  3. 7.3 mobile_tools.module \mobile_tools_block_message()

Helper function returning the configurable message for the notification

Return value

string Returns an item list of links or a notification message.

1 call to mobile_tools_block_message()
mobile_tools_block_view in ./mobile_tools.module
Implements hook_block_view().

File

./mobile_tools.module, line 498
Functionality to ease the creation of mixed device environments.

Code

function mobile_tools_block_message() {

  // If automatic redirection is enabled, disable the switch links
  if (variable_get('mobile_tools_redirect', FALSE)) {
    return t('Automatic redirection is active. Manual switching is disabled.');
  }

  // Get the active device group
  $active_groups = mobile_tools_get_active_device_group(TRUE);

  // Get the full list of device groups
  $device_groups = mobile_tools_device_groups();
  foreach ($active_groups as $key => $group) {

    // Eliminate the active group from the list of links
    unset($device_groups[$group['id']]);
  }

  // Prepare the formatted array for theme_item_list().
  $items = array();

  // Get the current path
  $path = purl_get_normal_path(themekey_get_q());
  foreach ($device_groups as $id => $name) {

    // Get the link text
    $text = mobile_tools_switch_link_text($id);

    // Load the options required for PURL to rewrite the generated link.
    $options = mobile_tools_switch_options($id);

    // Generate the link
    $items[] = l(t($text, array(
      '@device' => $name,
    )), $path, $options);
  }
  return theme('item_list', array(
    'items' => $items,
  ));
}