diff --git a/plugins/DevicesDetection/API.php b/plugins/DevicesDetection/API.php index 3f4ba9c2c44faa0f9cd7cfda9965e05f6f3bf2e2..a90cd37219a8f47135d0c1ca58e5217f6633254f 100644 --- a/plugins/DevicesDetection/API.php +++ b/plugins/DevicesDetection/API.php @@ -136,9 +136,12 @@ class API extends \Piwik\Plugin\API * @param bool|string $segment * @return DataTable */ - public function getOsVersions($idSite, $period, $date, $segment = false) + public function getOsVersions($idSite, $period, $date, $segment = false, $addShortLabel = true) { $dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment); + if ($addShortLabel) { + $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'shortLabel', __NAMESPACE__ . '\getOsShortName')); + } $dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogo')); $dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOsFullName')); return $dataTable; diff --git a/plugins/DevicesDetection/Visitor.php b/plugins/DevicesDetection/Visitor.php index efcc69b196c720792f3755731c9c1b9cd5b0991a..c7a68d1c59f9149ad6c93bbd0f320c45b2fb2dfc 100644 --- a/plugins/DevicesDetection/Visitor.php +++ b/plugins/DevicesDetection/Visitor.php @@ -36,35 +36,7 @@ class Visitor public function getOperatingSystemShortName() { - $shortNameMapping = array( - 'PS3' => 'PS3', - 'PSP' => 'PSP', - 'WII' => 'Wii', - 'WIU' => 'Wii U', - 'NDS' => 'DS', - 'DSI' => 'DSi', - '3DS' => '3DS', - 'PSV' => 'PS Vita', - 'WI8' => 'Win 8', - 'WI7' => 'Win 7', - 'WVI' => 'Win Vista', - 'WS3' => 'Win S2003', - 'WXP' => 'Win XP', - 'W98' => 'Win 98', - 'W2K' => 'Win 2000', - 'WNT' => 'Win NT', - 'WME' => 'Win Me', - 'W95' => 'Win 95', - 'WPH' => 'WinPhone', - 'WMO' => 'WinMo', - 'WCE' => 'Win CE', - 'WOS' => 'webOS', - ); - $osShort = $this->details['config_os']; - if (array_key_exists($osShort, $shortNameMapping)) { - return $shortNameMapping[$osShort]; - } - return getOsFullName($osShort); + return getOsShortName($this->details['config_os']); } public function getOperatingSystemIcon() diff --git a/plugins/DevicesDetection/functions.php b/plugins/DevicesDetection/functions.php index cb4c109b22f9895970e613469679fcdf9596369f..7a797d42a1d65e8ef6825cfa152e7c0251918e4c 100644 --- a/plugins/DevicesDetection/functions.php +++ b/plugins/DevicesDetection/functions.php @@ -217,6 +217,38 @@ function getOsFullName($label) return Piwik::translate('General_Unknown'); } +function getOsShortName($label) +{ + $shortNameMapping = array( + 'PS3' => 'PS3', + 'PSP' => 'PSP', + 'WII' => 'Wii', + 'WIU' => 'Wii U', + 'NDS' => 'DS', + 'DSI' => 'DSi', + '3DS' => '3DS', + 'PSV' => 'PS Vita', + 'WI8' => 'Win 8', + 'WI7' => 'Win 7', + 'WVI' => 'Win Vista', + 'WS3' => 'Win S2003', + 'WXP' => 'Win XP', + 'W98' => 'Win 98', + 'W2K' => 'Win 2000', + 'WNT' => 'Win NT', + 'WME' => 'Win Me', + 'W95' => 'Win 95', + 'WPH' => 'WinPhone', + 'WMO' => 'WinMo', + 'WCE' => 'Win CE', + 'WOS' => 'webOS', + ); + if (array_key_exists($label, $shortNameMapping)) { + return $shortNameMapping[$label]; + } + return getOsFullName($label); +} + /** * Returns the path to the logo for the given OS *