function getStyleSheetFile($deviceData) { global $gadgetString; global $styleSheetFile; $styleSheetFile = STYLE_SHEET_MEDIA_QUERIES; // by default, fall back on media queries if (!isset($gadgetString)) { $gadgetString = getIdMyGadgetStringAllDevices($deviceData); } if ($gadgetString === "Desktop") { $styleSheetFile = STYLE_SHEET_DESKTOP; } else { if ($gadgetString === "Tablet") { $styleSheetFile = STYLE_SHEET_TABLET; } else { if ($gadgetString === "iPhone") { $styleSheetFile = STYLE_SHEET_APPLE_PHONE; } else { if ($gadgetString === "Android Phone" || $gadgetString === "Mobile Phone") { $styleSheetFile = STYLE_SHEET_ANDROID_PHONE; } } } } return $styleSheetFile; }
<!DOCTYPE html> <html lang='en'> <?php $pageTitle = basename($_SERVER['PHP_SELF'], '.php'); require_once 'Mobile-Detect/Mobile_Detect.php'; require_once '../../php/IdMyGadgetMobileDetect.php'; require_once '../all_detectors/getIdMyGadgetStringAllDevices.php'; require_once '../all_detectors/printStyleSheetLinkTags.php'; $debugging = FALSE; $allowOverridesInUrl = TRUE; // Needed for footer forms to work $idMyGadget = new IdMyGadgetMobileDetect($debugging, $allowOverridesInUrl); $idMyGadget->idMyGadgetDir = '../..'; $deviceData = $idMyGadget->getDeviceData(); $gadgetString = getIdMyGadgetStringAllDevices($deviceData); ?> <head> <title><?php print $pageTitle; ?> </title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <?php $styleSheetFile = printStyleSheetLinkTags($deviceData); ?> </head> <body> <div id="container"> <h2><?php
/** * Constructor: for best results, specify a different gadgetDetector */ public function __construct($gadgetDetectorString = null, $debugging = FALSE, $allowOverridesInUrl = TRUE) { // error_log( 'Creating a base JmwsIdMyGadget object for detector "' . $gadgetDetectorString . '" - note we want to do this only once!' ); require_once 'gadget_detectors/all_detectors/getIdMyGadgetStringAllDevices.php'; if ($gadgetDetectorString === null) { $gadgetDetectorString = IdMyGadget::GADGET_DETECTOR_DETECT_MOBILE_BROWSERS; } $this->gadgetDetectorString = $gadgetDetectorString; if ($gadgetDetectorString === IdMyGadget::GADGET_DETECTOR_DETECT_MOBILE_BROWSERS) { global $usingMobilePhone; $fileToInclude = 'gadget_detectors/detect_mobile_browsers/php/detectmobilebrowser.php'; $fileToCheck = $this->idMyGadgetDir . DIRECTORY_SEPARATOR . $fileToInclude; if (file_exists($fileToCheck)) { include_once $fileToInclude; // sets $usingMobilePhone global variable } include_once 'php/IdMyGadgetDetectMobileBrowsers.php'; $this->idMyGadget = new IdMyGadgetDetectMobileBrowsers($debugging, $allowOverridesInUrl); } else { if ($gadgetDetectorString === IdMyGadget::GADGET_DETECTOR_MOBILE_DETECT) { $fileToInclude = 'gadget_detectors/mobile_detect/Mobile-Detect/Mobile_Detect.php'; $fileToCheck = $this->idMyGadgetDir . DIRECTORY_SEPARATOR . $fileToInclude; if (file_exists($fileToCheck)) { include_once $fileToInclude; } include_once 'php/IdMyGadgetMobileDetect.php'; $this->idMyGadget = new IdMyGadgetMobileDetect($debugging, $allowOverridesInUrl); } else { if ($gadgetDetectorString === IdMyGadget::GADGET_DETECTOR_TERA_WURFL) { $fileToInclude = 'gadget_detectors/tera_wurfl/Tera-Wurfl/wurfl-dbapi/TeraWurfl.php'; $fileToCheck = $this->idMyGadgetDir . DIRECTORY_SEPARATOR . $fileToInclude; if (file_exists($fileToCheck)) { include_once $fileToInclude; } include_once 'php/IdMyGadgetTeraWurfl.php'; $this->idMyGadget = new IdMyGadgetTeraWurfl($debugging, $allowOverridesInUrl); } else { error_log('Warning: device detection has been disabled in the IdMyGadget administration console options.'); include_once 'php/IdMyGadgetNoDetection.php'; $this->idMyGadget = new IdMyGadgetNoDetection($debugging, $allowOverridesInUrl); } } } if ($this->idMyGadget !== null) { $this->idMyGadget->idMyGadgetDir = $this->idMyGadgetDir; if ($this->idMyGadget->isInstalled()) { $this->deviceData = $this->idMyGadget->getDeviceData(); $this->gadgetString = getIdMyGadgetStringAllDevices($this->deviceData); if ($this->idMyGadget->detectorUsed !== IdMyGadget::GADGET_DETECTOR_NO_DETECTION) { $this->detectionEnabled = TRUE; } } else { $this->gadgetString = self::GADGET_STRING_DETECTOR_NOT_INSTALLED; } } $this->gadgetDetectorStringChar = substr($this->gadgetDetectorString, 0, 1); // part of the sanity check string $this->gadgetStringChar = substr($this->gadgetString, 0, 1); // part of the sanity check string $this->initializeJQueryMobileVars(); }