getOsFamily() 공개 정적인 메소드

Returns the operating system family for the given operating system
public static getOsFamily ( $osLabel ) : boolean | string
$osLabel
리턴 boolean | string If false, "Unknown"
예제 #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();
 }
예제 #2
0
파일: Device.php 프로젝트: speedwork/view
 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);
 }
예제 #3
0
function getOSFamilyFullName($label)
{
    if ($label == \Piwik\Tracker\Settings::OS_BOT) {
        return 'Bot';
    }
    $label = OperatingSystemParser::getOsFamily(_mapLegacyOsShortCodes($label));
    if ($label == 'unknown') {
        $label = Piwik::translate('General_Unknown');
    } else {
        if ($label == 'Gaming Console') {
            $label = Piwik::translate('DevicesDetection_Console');
        }
    }
    if ($label !== false) {
        return $label;
    }
    return Piwik::translate('General_Unknown');
}
예제 #4
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;
 }
예제 #5
0
function getOSFamilyFullNameExtended($label)
{
    if ($label == \Piwik\Tracker\Settings::OS_BOT) {
        return 'Bot';
    }
    $label = OperatingSystemParser::getOsFamily($label);
    if ($label !== false) {
        return $label;
    }
    return Piwik::translate('General_Unknown');
}
 public function getOSFamily()
 {
     return OperatingSystem::getOsFamily($this->deviceDetector->getOs('short_name'));
 }