/** * Function to detect if a mobile device is being used. * * @return bool */ public static function detect() { // Do the most exhaustive device detection possible; other method calls // may be used instead of DetectMobileLong if you want to target a narrower // class of devices. $mobile = new \uagent_info(); return $mobile->DetectMobileLong(); }
function mobile_device_detect() { // @codingStandardsIgnoreEnd // Do the most exhaustive device detection possible; other method calls // may be used instead of DetectMobileLong if you want to target a narrower // class of devices. $mobile = new uagent_info(); return $mobile->DetectMobileLong(); }
* @copyright Copyright (C) 2009 - 2012 Matt Thomas. All rights reserved. * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html */ // Load Joomla filesystem package jimport('joomla.filesystem.file'); // Load template logic $logicFile = JPATH_THEMES . '/' . $this->template . '/elements/logic.php'; if (JFile::exists($logicFile)) { include $logicFile; } // Mobile device detection if (JFile::exists($mdetectFile)) { include_once $mdetectFile; // Instantiate the mobile object class $uagent_obj = new uagent_info(); $isMobile = $uagent_obj->DetectMobileLong(); $isTablet = $uagent_obj->DetectTierTablet(); } // Layout override $results = $layoutOverride->getIncludeFile(); // Check if mobile device has opted for desktop version if (isset($_GET['viewDesktop'])) { $_SESSION['viewDesktop'] = $_GET['viewDesktop']; } // Check if mobile device detection is turned on and, test if visitor is a mobile device, and if so, load mobile sub-template if (($mdetect && $isMobile || $mdetect && $detectTablets && $isTablet) && !isset($_SESSION['viewDesktop'])) { if (JFile::exists($mTemplate)) { include_once $mTemplate; } } elseif ($results) { $alternateIndexFile = $results;
function nbcu_page_alter($page) { $typeKit = "<script src='https://use.typekit.net/duz4krn.js'></script>\n <script>try{Typekit.load({ async: true });}catch(e){}</script>"; $ie_js_files = "\n\t<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->\n <!--[if lt IE 9]>\n <script src='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js'></script>\n <script src='https://oss.maxcdn.com/respond/1.4.2/respond.min.js'></script>\n <![endif]-->\n\t"; include_once __DIR__ . '/mobile-detect/mdetect.php'; $md = new uagent_info(); $ua = $md->Get_Uagent(); $isEdge = "false"; if (strpos($ua, 'edge') !== false) { $isEdge = "true"; } // dpm($ua); $mobileTest = $md->DetectMobileLong(); $mobileDetect = "<script type='text/javascript'>\n var useSkrollr = " . $mobileTest . ";\n var isEdge = " . $isEdge . ";\n </script>"; $ie_scripts = array('#type' => 'markup', '#markup' => $ie_js_files, '#weight' => 10000); $typekit_scripts = array('#type' => 'markup', '#markup' => $typeKit, '#weight' => 0); $mobile_detect = array('#type' => 'markup', '#markup' => $mobileDetect, '#weight' => 0); drupal_add_html_head($ie_scripts, 'ie-helpers'); drupal_add_html_head($typekit_scripts, 'typekit'); drupal_add_html_head($mobile_detect, 'mobile-detect'); }
function smallbiz_setup_mobile() { $GLOBALS["smartphone"] = false; $type = false; $urlmd5 = md5(get_bloginfo('siteurl')); if (!isset($_COOKIE[$urlmd5 . "device_type"])) { // DetectSmartphone() would restrict to, well, smartphones. // MobileLong will also show older devices the mobile layout, though they might not be able to see it well. $uagent_obj = new uagent_info(); if ($uagent_obj->DetectMobileLong()) { $type = "Mobile"; } else { $type = "Desktop"; } setcookie($urlmd5 . "device_type", $type); $_COOKIE[$urlmd5 . "device_type"] = $type; } else { $type = $_COOKIE[$urlmd5 . "device_type"]; } if (get_option('smallbiz_mobile-layout-enabled')) { if (isset($_REQUEST["ui"])) { if ($_REQUEST["ui"] == "m") { $GLOBALS["smartphone"] = true; } } else { if (isset($_COOKIE[$urlmd5 . "ui"])) { if ($_COOKIE[$urlmd5 . "ui"] == "m") { $GLOBALS["smartphone"] = true; } else { $GLOBALS["smartphone"] = false; } } else { if ($_COOKIE[$urlmd5 . "device_type"] == "Mobile") { $GLOBALS["smartphone"] = true; } } } if (!headers_sent()) { if ($GLOBALS["smartphone"]) { setcookie($urlmd5 . "ui", "m"); } else { setcookie($urlmd5 . "ui", "f"); } } } return $GLOBALS["smartphone"]; }