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:
authorsgiehl <stefan@piwik.org>2014-11-23 23:18:15 +0300
committersgiehl <stefan@piwik.org>2014-11-23 23:18:15 +0300
commita5d830657d050eda1b0f531387fc0a7234b28be3 (patch)
tree7d5eabb9a8fd102a107c2e4d106bcb7d037d70af /plugins
parent7819080b9b7ae22e08705e1ff7efe51a42aef9af (diff)
added method to map legacy os shorts, to ensure old archives are displayed correctly
Diffstat (limited to 'plugins')
-rw-r--r--plugins/DevicesDetection/API.php7
-rw-r--r--plugins/DevicesDetection/functions.php36
-rw-r--r--plugins/UserSettings/images/os/IOS.gifbin591 -> 594 bytes
3 files changed, 37 insertions, 6 deletions
diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php
index 3f4ba9c2c4..b6c58388b9 100644
--- a/plugins/DevicesDetection/API.php
+++ b/plugins/DevicesDetection/API.php
@@ -140,7 +140,8 @@ class API extends \Piwik\Plugin\API
{
$dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogo'));
- $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOsFullName'));
+ // use GroupBy filter to avoid duplicate rows if old (UserSettings) and new (DevicesDetection) reports were combined
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOsFullName'));
return $dataTable;
}
@@ -170,7 +171,7 @@ class API extends \Piwik\Plugin\API
public function getBrowsers($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment);
- $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFamilyFullName'));
+ $dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserName'));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserFamilyLogo'));
return $dataTable;
}
@@ -187,7 +188,7 @@ class API extends \Piwik\Plugin\API
{
$dataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserLogo'));
- $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserName'));
+ $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserNameWithVersion'));
return $dataTable;
}
diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php
index cb4c109b22..761c557e36 100644
--- a/plugins/DevicesDetection/functions.php
+++ b/plugins/DevicesDetection/functions.php
@@ -44,7 +44,7 @@ function getBrowserFamilyLogo($label)
return getBrowserLogo($label);
}
-function getBrowserName($label)
+function getBrowserNameWithVersion($label)
{
$short = substr($label, 0, 2);
$ver = substr($label, 3, 10);
@@ -56,6 +56,17 @@ function getBrowserName($label)
}
}
+function getBrowserName($label)
+{
+ $short = substr($label, 0, 2);
+ $browsers = BrowserParser::getAvailableBrowsers();
+ if (array_key_exists($short, $browsers)) {
+ return trim(ucfirst($browsers[$short]));
+ } else {
+ return Piwik::translate('General_Unknown');
+ }
+}
+
/**
* Returns the path to the logo for the given browser
*
@@ -178,7 +189,7 @@ function getOSFamilyFullName($label)
if ($label == \Piwik\Tracker\Settings::OS_BOT) {
return 'Bot';
}
- $label = OperatingSystemParser::getOsFamily($label);
+ $label = OperatingSystemParser::getOsFamily(_mapLegacyOsShortCodes($label));
if ($label == 'unknown') {
$label = Piwik::translate('General_Unknown');
@@ -194,6 +205,7 @@ function getOSFamilyFullName($label)
function getOsFamilyLogo($label)
{
+ $label = _mapLegacyOsShortCodes($label);
$osFamilies = OperatingSystemParser::getAvailableOperatingSystemFamilies();
if (!empty($label) && array_key_exists($label, $osFamilies)) {
return getOsLogo($osFamilies[$label][0]);
@@ -209,7 +221,7 @@ function getOsFullName($label)
if (!empty($label) && $label != ";") {
$os = substr($label, 0, 3);
$ver = substr($label, 4, 15);
- $name = OperatingSystemParser::getNameFromId($os, $ver);
+ $name = OperatingSystemParser::getNameFromId(_mapLegacyOsShortCodes($os), $ver);
if (!empty($name)) {
return $name;
}
@@ -217,6 +229,22 @@ function getOsFullName($label)
return Piwik::translate('General_Unknown');
}
+function _mapLegacyOsShortCodes($shortCode)
+{
+ $legacyShortCodes = array(
+ 'IPA' => 'IOS', // iPad => iOS
+ 'IPH' => 'IOS', // iPhone => iOS
+ 'IPD' => 'IOS', // iPod => iOS
+ 'WIU' => 'WII', // WiiU => Nintendo
+ '3DS' => 'NDS', // Nintendo 3DS => Nintendo Mobile
+ 'DSI' => 'NDS', // Nintendo DSi => Nintendo Mobile
+ 'PSV' => 'PSP', // PlayStation Vita => PlayStation Portable
+ 'MAE' => 'SMG', // Maemo => MeeGo
+ //'VMS' => '', // OpenVMS => ??
+ );
+ return array_key_exists($shortCode, $legacyShortCodes) ? $legacyShortCodes[$shortCode] : $shortCode;
+}
+
/**
* Returns the path to the logo for the given OS
*
@@ -232,6 +260,8 @@ function getOsLogo($short)
{
$path = 'plugins/UserSettings/images/os/%s.gif';
+ $short = _mapLegacyOsShortCodes($short);
+
// If name is given instead of short code, try to find matching shortcode
if (strlen($short) > 3) {
diff --git a/plugins/UserSettings/images/os/IOS.gif b/plugins/UserSettings/images/os/IOS.gif
index a3b970ae1b..17ef80cd53 100644
--- a/plugins/UserSettings/images/os/IOS.gif
+++ b/plugins/UserSettings/images/os/IOS.gif
Binary files differ