getBrowserFamily() public static method

public static getBrowserFamily ( string $browserLabel ) : boolean | string
$browserLabel string
return boolean | string If false, "Unknown"
Ejemplo n.º 1
0
 public function detection()
 {
     Piwik::checkUserHasSomeAdminAccess();
     $view = new View('@DevicesDetection/detection');
     $this->setBasicVariablesView($view);
     ControllerAdmin::setBasicVariablesAdminView($view);
     $userAgent = Common::getRequestVar('ua', $_SERVER['HTTP_USER_AGENT'], 'string');
     $uaParser = new DeviceDetector($userAgent);
     $uaParser->parse();
     $view->userAgent = $userAgent;
     $view->browser_name = $uaParser->getClient('name');
     $view->browser_short_name = $uaParser->getClient('short_name');
     $view->browser_version = $uaParser->getClient('version');
     $view->browser_logo = getBrowserLogo($uaParser->getClient('short_name'));
     $view->browser_family = \DeviceDetector\Parser\Client\Browser::getBrowserFamily($uaParser->getClient('short_name'));
     $view->browser_family_logo = getBrowserFamilyLogo($view->browser_family);
     $view->os_name = $uaParser->getOs('name');
     $view->os_logo = getOsLogo($uaParser->getOs('short_name'));
     $view->os_short_name = $uaParser->getOs('short_name');
     $view->os_family = \DeviceDetector\Parser\OperatingSystem::getOsFamily($uaParser->getOs('short_name'));
     $view->os_family_logo = getOsFamilyLogo($view->os_family);
     $view->os_version = $uaParser->getOs('version');
     $view->device_type = getDeviceTypeLabel($uaParser->getDeviceName());
     $view->device_type_logo = getDeviceTypeLogo($uaParser->getDeviceName());
     $view->device_model = $uaParser->getModel();
     $view->device_brand = getDeviceBrandLabel($uaParser->getBrand());
     $view->device_brand_logo = getBrandLogo($uaParser->getBrand());
     return $view->render();
 }
Ejemplo n.º 2
0
 public function detect($userAgent = null, $advanced = false)
 {
     $userAgent = $userAgent ?: env('HTTP_USER_AGENT');
     DeviceParserAbstract::setVersionTruncation(DeviceParserAbstract::VERSION_TRUNCATION_NONE);
     $detect = new DeviceDetector($userAgent);
     $detect->parse();
     $return = [];
     if ($detect->isBot()) {
         $return['bot'] = $detect->getBot();
         return $return;
     }
     //device wrapper
     $devicelist = ['desktop' => 'computer', 'smartphone' => 'phone', 'tablet' => 'tablet', 'feature phone' => 'phone'];
     $os = $detect->getOs();
     $client = $detect->getClient();
     $devicename = $detect->getDeviceName();
     $devicetype = isset($devicelist[$devicename]) ? $devicelist[$devicename] : 'computer';
     //legacy params
     $return['device'] = $devicename;
     $return['type'] = $devicetype;
     $return['brand'] = $detect->getBrandName();
     $return['os'] = $os['name'];
     $return['os_version'] = $os['version'];
     $return['os_code'] = $os['short_name'];
     $return['browser'] = $client['name'];
     $return['browser_version'] = $client['version'];
     $return['browser_code'] = $client['short_name'];
     $return['browser_type'] = $client['type'];
     $return['browser_engine'] = $client['engine'];
     if (!$advanced) {
         return array_map('trim', $return);
     }
     //advanced params
     $osFamily = OperatingSystem::getOsFamily($os['short_name']);
     $return['os_family'] = $osFamily !== false ? $osFamily : 'Unknown';
     $return['model'] = $detect->getModel();
     $browserFamily = Browser::getBrowserFamily($client['short_name']);
     $return['browser_family'] = $browserFamily !== false ? $browserFamily : 'Unknown';
     $touch = $detect->isTouchEnabled();
     $return['touch'] = $touch[0];
     unset($os, $client, $osFamily, $browserFamily, $touch);
     return array_map('trim', $return);
 }
Ejemplo n.º 3
0
 /**
  * Parses a useragent and returns the detected data
  *
  * ATTENTION: Use that method only for testing or very small applications
  * To get fast results from DeviceDetector you need to make your own implementation,
  * that should use one of the caching mechanisms. See README.md for more information.
  *
  * @internal
  * @deprecated
  *
  * @param string $ua UserAgent to parse
  *
  * @return array
  */
 public static function getInfoFromUserAgent($ua)
 {
     $deviceDetector = new DeviceDetector($ua);
     $deviceDetector->parse();
     if ($deviceDetector->isBot()) {
         return array('user_agent' => $deviceDetector->getUserAgent(), 'bot' => $deviceDetector->getBot());
     }
     $osFamily = OperatingSystem::getOsFamily($deviceDetector->getOs('short_name'));
     $browserFamily = \DeviceDetector\Parser\Client\Browser::getBrowserFamily($deviceDetector->getClient('short_name'));
     $processed = array('user_agent' => $deviceDetector->getUserAgent(), 'os' => $deviceDetector->getOs(), 'client' => $deviceDetector->getClient(), 'device' => array('type' => $deviceDetector->getDeviceName(), 'brand' => $deviceDetector->getBrand(), 'model' => $deviceDetector->getModel()), 'os_family' => $osFamily !== false ? $osFamily : 'Unknown', 'browser_family' => $browserFamily !== false ? $browserFamily : 'Unknown');
     return $processed;
 }
 public function getBrowserFamily()
 {
     return Browser::getBrowserFamily($this->deviceDetector->getClient('short_name'));
 }