You are here

function mobile_switch_page_alter in Mobile Switch 7.2

Same name and namespace in other branches
  1. 7 mobile_switch.module \mobile_switch_page_alter()

Implements hook_page_alter().

Display a Mobile Switch debugging message.

File

./mobile_switch.module, line 424
Provides various functionalities to develop mobile ready websites.

Code

function mobile_switch_page_alter(&$page) {
  $get['display_mobiledetectinfo'] = variable_get('mobile_switch_display_mobiledetectinfo', 0);

  // The debugging informations.
  if ($get['display_mobiledetectinfo']) {
    if (mobile_switch_administer()) {
      $browser = mobile_switch_mobile_detect();

      // Makes human readable boolean values.
      $browser_human_val = array();
      foreach ($browser as $key => $value) {
        $browser_human_val[$key] = is_bool($value) ? $value ? '1' : '0' : $value;
      }

      // Check theme switch usage or theme cookie exists
      // and extends with it the debugging information.
      $theme_cookie = _mobile_switch_check_theme_cookie_use();
      if ($theme_cookie) {
        $theme_cookie_array = array(
          t('Theme switch cookie') => $theme_cookie,
        );
        $browser_human_val = array_merge($browser_human_val, $theme_cookie_array);
      }
      $message = t('!mobile-switch debugging information', array(
        '!mobile-switch' => l(t('Mobile Switch'), 'admin/config/user-interface/mobile-switch'),
      )) . ':<br />';
      $message .= _mobile_switch_get_mobile_detect_details($browser_human_val);
      drupal_set_message($message);
    }
  }
}