Returns list of all available browser families
public static getAvailableBrowserFamilies ( ) : array | ||
return | array |
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(); }
/** * Returns the path to the logo for the given browser * * First try to find a logo for the given short code * If none can be found try to find a logo for the browser family * Return unkown logo otherwise * * @param string $short Shortcode or name of browser * * @return string path to image */ function getBrowserLogoExtended($short) { $path = 'plugins/UserSettings/images/browsers/%s.gif'; // If name is given instead of short code, try to find matching shortcode if (strlen($short) > 2) { if (in_array($short, BrowserParser::getAvailableBrowsers())) { $flippedBrowsers = array_flip(BrowserParser::getAvailableBrowsers()); $short = $flippedBrowsers[$short]; } else { $short = substr($short, 0, 2); } } $family = getBrowserFamilyFullNameExtended($short); $browserFamilies = BrowserParser::getAvailableBrowserFamilies(); if (!empty($short) && array_key_exists($short, BrowserParser::getAvailableBrowsers()) && file_exists(PIWIK_INCLUDE_PATH . '/' . sprintf($path, $short))) { return sprintf($path, $short); } elseif (!empty($short) && array_key_exists($family, $browserFamilies) && file_exists(PIWIK_INCLUDE_PATH . '/' . sprintf($path, $browserFamilies[$family][0]))) { return sprintf($path, $browserFamilies[$family][0]); } return sprintf($path, 'UNK'); }
public function testGetAvailableBrowserFamilies() { $this->assertGreaterThan(5, Browser::getAvailableBrowserFamilies()); }