diff options
author | Stefan Giehl <stefan@matomo.org> | 2021-09-20 17:22:15 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-20 17:22:15 +0300 |
commit | 6fe1bf8cc16ea707c9f38c3a0b87ab88e7583329 (patch) | |
tree | c71ce48880f4e2ca4786318cc4d20b86d4b94b9e /plugins/DevicesDetection/functions.php | |
parent | e117bb50e06b8c51aef6263870ebb9d8d0749815 (diff) |
Update device detector to 4.3.1 (#18034)
* Update device detector to 4.3.1
* update submodules
* updates expected test files
* Adjust methods to fetch browser logo to have the same result with new device detector version
Diffstat (limited to 'plugins/DevicesDetection/functions.php')
-rw-r--r-- | plugins/DevicesDetection/functions.php | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php index 5bef26bfb7..b1f499e102 100644 --- a/plugins/DevicesDetection/functions.php +++ b/plugins/DevicesDetection/functions.php @@ -37,6 +37,9 @@ function getBrowserFamilyFullName($label) function getBrowserFamilyLogo($label) { $browserFamilies = BrowserParser::getAvailableBrowserFamilies(); + if (!empty($label) && in_array($label, BrowserParser::getAvailableBrowsers())) { + return getBrowserLogo($label); + } if (!empty($label) && array_key_exists($label, $browserFamilies)) { return getBrowserLogo($browserFamilies[$label][0]); } @@ -97,22 +100,28 @@ function getBrowserLogo($short) } } + if (empty($short)) { + return sprintf($path, 'UNK'); + } + $family = getBrowserFamilyFullName($short); $browserFamilies = BrowserParser::getAvailableBrowserFamilies(); - if (!empty($short) && - array_key_exists($short, BrowserParser::getAvailableBrowsers()) && + if (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]); + if (array_key_exists($family, $browserFamilies)) { + foreach ($browserFamilies[$family] as $browserShort) { + if (file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $browserShort))) { + return sprintf($path, $browserShort); + } + } } + return sprintf($path, 'UNK'); } @@ -212,7 +221,7 @@ function getDeviceTypeLogo($label) function getModelName($label) { if (strpos($label, ';') !== false) { - list($brand, $model) = explode(';', $label, 2); + [$brand, $model] = explode(';', $label, 2); } else { $brand = null; $model = $label; |