private function addTopMenuMobileApp(MenuTop $menu) { if (empty($_SERVER['HTTP_USER_AGENT'])) { return; } if (!class_exists("DeviceDetector")) { throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to have update Composer. <br>php composer.phar update"); } $ua = new \DeviceDetector($_SERVER['HTTP_USER_AGENT']); $ua->parse(); $os = $ua->getOs('short_name'); if ($os && in_array($os, array('AND', 'IOS'))) { $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4); } }
protected function loadInfo() { list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins(); $resolution = $this->request->getParam('res'); $userAgent = $this->request->getUserAgent(); $deviceDetector = new \DeviceDetector($userAgent); $deviceDetector->setCache(new CacheFile('tracker', 86400)); $deviceDetector->parse(); $aBrowserInfo = $deviceDetector->getBrowser(); $browserName = !empty($aBrowserInfo['short_name']) ? $aBrowserInfo['short_name'] : 'UNK'; $browserVersion = !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : ''; $os = $deviceDetector->getOS(); $os = empty($os['short_name']) ? 'UNK' : $os['short_name']; $browserLang = substr($this->request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db $configurationHash = $this->getConfigHash($os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $this->ipAddress, $browserLang); $this->params = array('config_id' => $configurationHash, 'config_os' => $os, 'config_browser_name' => $browserName, 'config_browser_version' => $browserVersion, 'config_resolution' => $resolution, 'config_pdf' => $plugin_PDF, 'config_flash' => $plugin_Flash, 'config_java' => $plugin_Java, 'config_director' => $plugin_Director, 'config_quicktime' => $plugin_Quicktime, 'config_realplayer' => $plugin_RealPlayer, 'config_windowsmedia' => $plugin_WindowsMedia, 'config_gears' => $plugin_Gears, 'config_silverlight' => $plugin_Silverlight, 'config_cookie' => $plugin_Cookie, 'location_browser_lang' => $browserLang); }
protected function getDevice($userAgent) { if (!class_exists('DeviceDetector')) { throw new \LogicException('class DeviceDetector is exists. UserAgentTheme require "piwik/device-detector": "~1.0" '); } if (is_null($this->device)) { $deviceDetector = new \DeviceDetector($userAgent); $deviceDetector->parse(); $device = $deviceDetector->getDevice(); /* \DeviceDetector::$deviceTypes = array( 'desktop', // 0 'smartphone', // 1 'tablet', // 2 'feature phone', // 3 'console', // 4 'tv', // 5 'car browser', // 6 'smart display', // 7 'camera' // 8 ); */ $this->device = $device === '' ? '' : \DeviceDetector::$deviceTypes[$device]; } return $this->device; }