Skip to content
Extraits de code Groupes Projets
Valider 3d222f3b rédigé par mattab's avatar mattab
Parcourir les fichiers

fixes #3961 Adding new segment deviceType

parent 9d39c7f3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 156 ajouts et 70 suppressions
......@@ -9,9 +9,6 @@
* @category Piwik_Plugins
* @package Piwik_DevicesDetection
*/
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/functions.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php';
class Piwik_DevicesDetection_API
{
......@@ -60,6 +57,7 @@ class Piwik_DevicesDetection_API
{
$dataTable = $this->getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
$dataTable->filter('ColumnCallbackReplace', array('label', 'Piwik_getDeviceTypeLabel'));
$dataTable->filter('ColumnCallbackReplace', array('label', 'ucfirst'));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', 'Piwik_getDeviceTypeLogo'));
return $dataTable;
}
......
......@@ -9,7 +9,8 @@
* @category Piwik_Plugins
* @package Piwik_DevicesDetection
*/
require_once "UserAgentParserEnhanced/UserAgentParserEnhanced.php";
require_once PIWIK_INCLUDE_PATH . "/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php";
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/functions.php';
class Piwik_DevicesDetection extends Piwik_Plugin
{
......@@ -32,70 +33,78 @@ class Piwik_DevicesDetection extends Piwik_Plugin
/*
* Defines API reports.
* Also used to define Widgets.
* Also used to define Widgets, and Segment(s)
*
* @return array Category, Report Name, API Module, API action, Translated column name, & optional segment info
*
* @array Category, Report Name, API Module, API action, Translated column name,
* W
*/
protected $reportMetadata = array(
// device types report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_DeviceType',
'DevicesDetection',
'getType',
'DevicesDetection_DeviceType',
),
// device brands report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_DeviceBrand',
'DevicesDetection',
'getBrand',
'DevicesDetection_DeviceBrand',
),
// device model report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_DeviceModel',
'DevicesDetection',
'getModel',
'DevicesDetection_DeviceModel',
),
// device OS family report
array(
'DevicesDetection_DevicesDetection',
'DeviceDetection_OperatingSystemFamilies',
'DevicesDetection',
'getOsFamilies',
'DeviceDetection_OperatingSystemFamilies',
),
// device OS version report
array(
'DevicesDetection_DevicesDetection',
'DeviceDetection_OperatingSystemVersions',
'DevicesDetection',
'getOsVersions',
'DeviceDetection_OperatingSystemVersions',
),
// Browser family report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_BrowsersFamily',
'DevicesDetection',
'getBrowserFamilies',
'DevicesDetection_BrowsersFamily',
),
// Browser versions report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_BrowserVersions',
'DevicesDetection',
'getBrowserVersions',
'DevicesDetection_BrowserVersions',
),
);
protected function getRawMetadataReports()
{
$report = array(
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_DeviceType',
'DevicesDetection',
'getType',
'DevicesDetection_DeviceType',
// Segment
'deviceType',
'log_visit.config_device_type',
implode(", ", UserAgentParserEnhanced::$deviceTypes), // comma separated examples
create_function('$type', 'return array_search( strtolower(trim(urldecode($type))), UserAgentParserEnhanced::$deviceTypes);')
),
// device brands report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_DeviceBrand',
'DevicesDetection',
'getBrand',
'DevicesDetection_DeviceBrand',
),
// device model report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_DeviceModel',
'DevicesDetection',
'getModel',
'DevicesDetection_DeviceModel',
),
// device OS family report
array(
'DevicesDetection_DevicesDetection',
'DeviceDetection_OperatingSystemFamilies',
'DevicesDetection',
'getOsFamilies',
'DeviceDetection_OperatingSystemFamilies',
),
// device OS version report
array(
'DevicesDetection_DevicesDetection',
'DeviceDetection_OperatingSystemVersions',
'DevicesDetection',
'getOsVersions',
'DeviceDetection_OperatingSystemVersions',
),
// Browser family report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_BrowsersFamily',
'DevicesDetection',
'getBrowserFamilies',
'DevicesDetection_BrowsersFamily',
),
// Browser versions report
array(
'DevicesDetection_DevicesDetection',
'DevicesDetection_BrowserVersions',
'DevicesDetection',
'getBrowserVersions',
'DevicesDetection_BrowserVersions',
),
);
return $report;
}
public function getListHooksRegistered()
{
......@@ -106,12 +115,13 @@ class Piwik_DevicesDetection extends Piwik_Plugin
'Tracker.newVisitorInformation' => 'parseMobileVisitData',
'WidgetsList.add' => 'addWidgets',
'API.getReportMetadata' => 'getReportMetadata',
'API.getSegmentsMetadata' => 'getSegmentsMetadata',
);
}
public function addWidgets()
{
foreach ($this->reportMetadata as $report) {
foreach ($this->getRawMetadataReports() as $report) {
list($category, $name, $controllerName, $controllerAction) = $report;
if ($category == false)
continue;
......@@ -119,6 +129,33 @@ class Piwik_DevicesDetection extends Piwik_Plugin
}
}
/**
* Get segments meta data
*
* @param Piwik_Event_Notification $notification notification object
*/
public function getSegmentsMetadata($notification)
{
// Note: only one field segmented so far: deviceType
$segments =& $notification->getNotificationObject();
foreach ($this->getRawMetadataReports() as $report) {
@list($category, $name, $apiModule, $apiAction, $columnName, $segment, $sqlSegment, $acceptedValues) = $report;
if (empty($segment)) continue;
$segments[] = array(
'type' => 'dimension',
'category' => Piwik_Translate('General_Visit'),
'name' => $columnName,
'segment' => $segment,
'acceptedValues' => $acceptedValues,
'sqlSegment' => $sqlSegment,
'sqlFilter' => isset($sqlFilter) ? $sqlFilter : false,
);
}
}
/**
* @param Piwik_Event_Notification $notification notification object
*/
......@@ -127,7 +164,7 @@ class Piwik_DevicesDetection extends Piwik_Plugin
$reports = & $notification->getNotificationObject();
$i = 0;
foreach ($this->reportMetadata as $report) {
foreach ($this->getRawMetadataReports() as $report) {
list($category, $name, $apiModule, $apiAction, $columnName) = $report;
if ($category == false)
continue;
......
......@@ -14,8 +14,8 @@ require_once('spyc.php');
class UserAgentParserEnhanced
{
public static $deviceTypes = array( 'desktop', 'smartphone', 'tablet', 'feature phone', 'console', 'tv', 'car browser' );
public static $deviceTypes = array('car browser', 'console', 'desktop', 'feature phone', 'smartphone', 'tablet', 'tv');
public static $deviceBrands = array(
'AC' => 'Acer',
'AI' => 'Airness',
......
......@@ -72,7 +72,7 @@ function Piwik_getDeviceBrandLabel($label)
function Piwik_getDeviceTypeLabel($label)
{
if (isset(UserAgentParserEnhanced::$deviceTypes[$label])) {
return ucfirst(UserAgentParserEnhanced::$deviceTypes[$label]);
return UserAgentParserEnhanced::$deviceTypes[$label];
} else {
return Piwik_Translate('General_Unknown');
}
......
......@@ -107,6 +107,7 @@ class Piwik_Live_Visitor
'browserCode' => $this->getBrowserCode(),
'browserVersion' => $this->getBrowserVersion(),
'screenType' => $this->getScreenType(),
'deviceType' => $this->getDeviceType(),
'resolution' => $this->getResolution(),
'screenTypeIcon' => $this->getScreenTypeIcon(),
'plugins' => $this->getPlugins(),
......@@ -507,6 +508,14 @@ class Piwik_Live_Visitor
return Piwik_getScreenTypeFromResolution($this->details['config_resolution']);
}
function getDeviceType()
{
if(Piwik_PluginsManager::getInstance()->isPluginActivated('DevicesDetection')) {
return Piwik_getDeviceTypeLabel($this->details['config_device_type']);
}
return false;
}
function getResolution()
{
return $this->details['config_resolution'];
......
......@@ -85,6 +85,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -224,6 +225,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -346,6 +348,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -468,6 +471,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -590,6 +594,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -729,6 +734,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -851,6 +857,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -973,6 +980,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -1095,6 +1103,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -1234,6 +1243,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
......@@ -85,6 +85,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -224,6 +225,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -346,6 +348,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -468,6 +471,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -590,6 +594,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -729,6 +734,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -851,6 +857,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -973,6 +980,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -1095,6 +1103,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -1234,6 +1243,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
......@@ -86,6 +86,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -271,6 +272,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
......@@ -75,6 +75,7 @@
<browserCode>UNK</browserCode>
<browserVersion>UNK</browserVersion>
<screenType>normal</screenType>
<deviceType>Inconnu</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -179,6 +180,7 @@
<browserCode>UNK</browserCode>
<browserVersion>UNK</browserVersion>
<screenType>normal</screenType>
<deviceType>Inconnu</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
......@@ -74,6 +74,7 @@
<browserCode>IE</browserCode>
<browserVersion>7.0</browserVersion>
<screenType>unknown</screenType>
<deviceType>desktop</deviceType>
<resolution>unknown</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/unknown.gif</screenTypeIcon>
<plugins />
......@@ -158,6 +159,7 @@
<browserCode>IE</browserCode>
<browserVersion>7.0</browserVersion>
<screenType>unknown</screenType>
<deviceType>desktop</deviceType>
<resolution>unknown</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/unknown.gif</screenTypeIcon>
<plugins />
......@@ -242,6 +244,7 @@
<browserCode>IE</browserCode>
<browserVersion>7.0</browserVersion>
<screenType>unknown</screenType>
<deviceType>desktop</deviceType>
<resolution>unknown</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/unknown.gif</screenTypeIcon>
<plugins />
......
......@@ -106,6 +106,13 @@
<segment>browserVersion</segment>
<acceptedValues>1.0, 8.0, etc.</acceptedValues>
</row>
<row>
<type>dimension</type>
<category>Visit</category>
<name>Device type</name>
<segment>deviceType</segment>
<acceptedValues>desktop, smartphone, tablet, feature phone, console, tv, car browser</acceptedValues>
</row>
<row>
<type>dimension</type>
<category>Visit</category>
......
......@@ -113,6 +113,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -321,6 +322,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
......@@ -189,6 +189,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -516,6 +517,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -725,6 +727,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>normal</screenType>
<deviceType>desktop</deviceType>
<resolution>1024x768</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/normal.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
......@@ -83,6 +83,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.0</browserVersion>
<screenType>dual</screenType>
<deviceType>desktop</deviceType>
<resolution>1111x222</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/dual.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -195,6 +196,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.0</browserVersion>
<screenType>dual</screenType>
<deviceType>desktop</deviceType>
<resolution>1111x222</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/dual.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......@@ -367,6 +369,7 @@
<browserCode>FF</browserCode>
<browserVersion>3.6</browserVersion>
<screenType>dual</screenType>
<deviceType>desktop</deviceType>
<resolution>1111x222</resolution>
<screenTypeIcon>plugins/UserSettings/images/screens/dual.gif</screenTypeIcon>
<plugins>flash, java</plugins>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter