function _AdvisingScreen::determine_mobile_device

4.x _AdvisingScreen.php _AdvisingScreen::determine_mobile_device()
5.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

1 call to _AdvisingScreen::determine_mobile_device()
_AdvisingScreen::__construct in classes/_AdvisingScreen.php
This is the constructor. Must be named this for inheritence to work correctly.

File

classes/_AdvisingScreen.php, line 82

Class

_AdvisingScreen

Code

function determine_mobile_device() {
  $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;

}