Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2020-07-15 12:05:06 +0300
committerGitHub <noreply@github.com>2020-07-15 12:05:06 +0300
commite2d9aac66838b342c75c92443e0a06b30f6d0447 (patch)
tree9d61fb3aa5b3e792826c26cfed0e22878d8233fb /plugins/DevicesDetection/functions.php
parentb3729803e9047450ae158c9f4e496919f6a704e5 (diff)
Make it possible to detect other clients than Browsers (#16197)
* Adds new client type column and extend browser column width, so it's possible to store full client names * store full client names if it's not a browser * updates expected test files * updates expected UI files * fix column type
Diffstat (limited to 'plugins/DevicesDetection/functions.php')
-rw-r--r--plugins/DevicesDetection/functions.php46
1 files changed, 44 insertions, 2 deletions
diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php
index 65fc1d2833..877f426724 100644
--- a/plugins/DevicesDetection/functions.php
+++ b/plugins/DevicesDetection/functions.php
@@ -45,11 +45,14 @@ function getBrowserFamilyLogo($label)
function getBrowserNameWithVersion($label)
{
- $short = substr($label, 0, 2);
- $ver = substr($label, 3, 10);
+ $pos = strrpos($label, ';');
+ $short = substr($label, 0, $pos);
+ $ver = substr($label, $pos+1);
$browsers = BrowserParser::getAvailableBrowsers();
if ($short && array_key_exists($short, $browsers)) {
return trim(ucfirst($browsers[$short]) . ' ' . $ver);
+ } else if (strlen($short) > 2 && $short !== 'UNK') {
+ return trim($short . ' ' . $ver);
} else {
return Piwik::translate('General_Unknown');
}
@@ -61,6 +64,8 @@ function getBrowserName($label)
$browsers = BrowserParser::getAvailableBrowsers();
if ($short && array_key_exists($short, $browsers)) {
return trim(ucfirst($browsers[$short]));
+ } else if (strlen($label) > 2 && strpos($label, 'UNK') === false) {
+ return $label;
} else {
return Piwik::translate('General_Unknown');
}
@@ -120,6 +125,43 @@ function getDeviceBrandLabel($label)
}
}
+function getClientTypeMapping()
+{
+ return [
+ 1 => 'browser',
+ 2 => 'library',
+ 3 => 'feed reader',
+ 4 => 'mediaplayer',
+ 5 => 'mobile app',
+ 6 => 'pim',
+ ];
+}
+
+function getClientTypeLabel($label)
+{
+ $translations = [
+ 'browser' => 'DevicesDetection_ColumnBrowser',
+ 'library' => 'DevicesDetection_Library',
+ 'feed reader' => 'DevicesDetection_FeedReader',
+ 'mediaplayer' => 'DevicesDetection_MediaPlayer',
+ 'mobile app' => 'DevicesDetection_MobileApp',
+ 'pim' => 'DevicesDetection_Pim',
+ ];
+
+ $clientTypes = getClientTypeMapping();
+
+ if (is_numeric($label) &&
+ array_key_exists($label, $clientTypes) &&
+ isset($translations[$clientTypes[$label]])) {
+
+ return Piwik::translate($translations[$clientTypes[$label]]);
+ } else if (isset($translations[$label])) {
+ return Piwik::translate($translations[$label]);
+ } else {
+ return Piwik::translate('General_Unknown');
+ }
+}
+
function getDeviceTypeLabel($label)
{
$translations = array(