You are here

mobile_tools_browscap.module in Mobile Tools 7.2

Same filename and directory in other branches
  1. 7.3 mobile_tools_browscap/mobile_tools_browscap.module

File

mobile_tools_browscap/mobile_tools_browscap.module
View source
<?php

/**
 * Implements hook_is_mobile_device().
 */
function mobile_tools_browscap_is_mobile_device() {
  $info = browscap_get_browser();

  // detect device type
  if ($info['ismobiledevice']) {
    $type = 'mobile';
  }
  else {
    $type = 'desktop';
  }
  $groups = mt_browscap_device_groups();
  $group = '';
  if (in_array($info['browser'], $groups)) {
    $group = array_search($info['browser'], $groups);
  }
  return array(
    'type' => $type,
    'group' => $group,
  );
}

/**
 * Implements hook_device_groups().
 */
function mobile_tools_browscap_device_groups() {
  return array(
    'iphone' => 'iPhone',
    'ipod' => 'iPod',
    'android' => 'Android',
    'opera_mini' => 'Opera Mini',
    'blackberry' => 'BlackBerry',
  );
}

Functions

Namesort descending Description
mobile_tools_browscap_device_groups Implements hook_device_groups().
mobile_tools_browscap_is_mobile_device Implements hook_is_mobile_device().