You are here

function mobile_tools_is_mobile_device in Mobile Tools 6.2

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

Determine if the current user agent represents a mobile device.

Return value

array An associative array with the following keys:

  • 'type' either 'desktop' or 'mobile'
  • 'group' the device group this device belongs to, e.g. 'iphone'
2 calls to mobile_tools_is_mobile_device()
mobile_tools_get_device in ./mobile_tools.module
Get $device object.
mobile_tools_is_mobile_ctools_access_check in plugins/access/is_mobile.inc
Check for access.

File

./mobile_tools.module, line 412
Primarily Drupal hooks.

Code

function mobile_tools_is_mobile_device() {
  static $browser;
  if (!isset($browser)) {
    $module = variable_get('mobile-tools-device-detection', NULL);
    if (isset($module)) {
      drupal_load('module', $module);
      $browser = module_invoke($module, 'detect_mobile_device');
    }
    else {
      $browser = array(
        'type' => 'desktop',
        'group' => '',
      );
    }
  }
  return $browser;
}