public function getAllOs() { $allOs = array_keys(OperatingSystem::getAvailableOperatingSystems()); $allOs = array_map(function ($os) { return array($os); }, $allOs); return $allOs; }
public function showList() { Piwik::checkUserHasSomeAdminAccess(); $view = new View('@DevicesDetection/list'); $type = Common::getRequestVar('type', 'brands', 'string'); $list = array(); switch ($type) { case 'brands': $availableBrands = \DeviceDetector\Parser\Device\DeviceParserAbstract::$deviceBrands; foreach ($availableBrands as $short => $name) { if ($name != 'Unknown') { $list[$name] = getBrandLogo($name); } } break; case 'browsers': $availableBrowsers = \DeviceDetector\Parser\Client\Browser::getAvailableBrowsers(); foreach ($availableBrowsers as $short => $name) { $list[$name] = getBrowserLogo($short); } break; case 'browserfamilies': $availableBrowserFamilies = \DeviceDetector\Parser\Client\Browser::getAvailableBrowserFamilies(); foreach ($availableBrowserFamilies as $name => $browsers) { $list[$name] = getBrowserFamilyLogo($name); } break; case 'os': $availableOSs = \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystems(); foreach ($availableOSs as $short => $name) { $list[$name] = getOsLogo($short); } break; case 'osfamilies': $osFamilies = \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystemFamilies(); foreach ($osFamilies as $name => $oss) { $list[$name] = getOsFamilyLogo($name); } break; case 'devicetypes': $deviceTypes = \DeviceDetector\Parser\Device\DeviceParserAbstract::getAvailableDeviceTypes(); foreach ($deviceTypes as $name => $id) { $list[$name] = getDeviceTypeLogo($name); } break; } $view->itemList = $list; return $view->render(); }
*/ include __DIR__ . '/../vendor/autoload.php'; ?> ## What Device Detector is able to detect The lists below are auto generated and updated from time to time. Some of them might not be complete. *Last update: <?php echo date('Y/m/d'); ?> * ### List of detected operating systems: <?php echo implode(', ', \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystems()); ?> ### List of detected browsers: <?php echo implode(', ', \DeviceDetector\Parser\Client\Browser::getAvailableBrowsers()); ?> ### List of detected browser engines: <?php echo implode(', ', \DeviceDetector\Parser\Client\Browser\Engine::getAvailableEngines()); ?>
/** * Returns the path to the logo for the given OS * * First try to find a logo for the given short code * If none can be found try to find a logo for the os family * Return unknown logo otherwise * * @param string $short Shortcode or name of OS * * @return string path to image */ function getOsLogo($short) { $path = 'plugins/DevicesDetection/images/os/%s.gif'; $short = _mapLegacyOsShortCodes($short); // If name is given instead of short code, try to find matching shortcode if (strlen($short) > 3) { if (in_array($short, OperatingSystemParser::getAvailableOperatingSystems())) { $short = array_search($short, OperatingSystemParser::getAvailableOperatingSystems()); } else { $short = substr($short, 0, 3); } } $family = getOSFamilyFullName($short); $osFamilies = OperatingSystemParser::getAvailableOperatingSystemFamilies(); if (!empty($short) && array_key_exists($short, OperatingSystemParser::getAvailableOperatingSystems()) && file_exists(PIWIK_INCLUDE_PATH . '/' . sprintf($path, $short))) { return sprintf($path, $short); } elseif (!empty($family) && array_key_exists($family, $osFamilies) && file_exists(PIWIK_INCLUDE_PATH . '/' . sprintf($path, $osFamilies[$family][0]))) { return sprintf($path, $osFamilies[$family][0]); } return sprintf($path, 'UNK'); }
public function testAllBrowsersTested() { $allBrowsers = array_keys(OperatingSystem::getAvailableOperatingSystems()); $osNotTested = array_diff($allBrowsers, self::$osTested); $this->assertEmpty($osNotTested, 'Following browsers are not tested: ' . implode(', ', $osNotTested)); }