function AdvisingScreen::determine_mobile_device

6.x AdvisingScreen.php AdvisingScreen::determine_mobile_device()

This function will attempt to determine automatically if we are on a mobile device. If so, it will set $this->page_is_mobile = TRUE

File

classes/AdvisingScreen.php, line 79

Class

AdvisingScreen

Code

function determine_mobile_device() {
  depricated_message('determine_mobile_device is depricated');

  $user_agent = $_SERVER ['HTTP_USER_AGENT'];

  $look_for = array(
    "ipod",
    "iphone",
    "android",
    "opera mini",
    "blackberry",
    "(pre\/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine)",
    "(iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)",
    "(smartphone|iemobile)",
  );

  foreach ($look_for as $test_agent) {
    if (preg_match('/' . $test_agent . '/i', $user_agent)) {
      $this->page_is_mobile = true;
      break;
    }
  }


  $GLOBALS ["fp_page_is_mobile"] = $this->page_is_mobile;

}