update Piwik to version 2.16 (fixes #91)
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
use DeviceDetector\Parser\Device\DeviceParserAbstract;
|
||||
use Piwik\Archive;
|
||||
use Piwik\DataTable;
|
||||
use Piwik\Metrics;
|
||||
|
|
@ -33,7 +34,6 @@ class API extends \Piwik\Plugin\API
|
|||
Piwik::checkUserHasViewAccess($idSite);
|
||||
$archive = Archive::build($idSite, $period, $date, $segment);
|
||||
$dataTable = $archive->getDataTable($name);
|
||||
$dataTable->filter('Sort', array(Metrics::INDEX_NB_VISITS));
|
||||
$dataTable->queueFilter('ReplaceColumnNames');
|
||||
$dataTable->queueFilter('ReplaceSummaryRowLabel');
|
||||
return $dataTable;
|
||||
|
|
@ -50,11 +50,39 @@ class API extends \Piwik\Plugin\API
|
|||
public function getType($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$dataTable = $this->getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
|
||||
// ensure all device types are in the list
|
||||
$this->ensureDefaultRowsInTable($dataTable);
|
||||
|
||||
$mapping = DeviceParserAbstract::getAvailableDeviceTypeNames();
|
||||
$dataTable->filter('AddSegmentByLabelMapping', array('deviceType', $mapping));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
|
||||
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
protected function ensureDefaultRowsInTable($dataTable)
|
||||
{
|
||||
$requiredRows = array_fill(0, count(DeviceParserAbstract::getAvailableDeviceTypes()), Metrics::INDEX_NB_VISITS);
|
||||
|
||||
$dataTables = array($dataTable);
|
||||
|
||||
if (!($dataTable instanceof DataTable\Map)) {
|
||||
foreach ($dataTables as $table) {
|
||||
if ($table->getRowsCount() == 0) {
|
||||
continue;
|
||||
}
|
||||
foreach ($requiredRows as $requiredRow => $key) {
|
||||
$row = $table->getRowFromLabel($requiredRow);
|
||||
if (empty($row)) {
|
||||
$table->addRowsFromSimpleArray(array(
|
||||
array('label' => $requiredRow, $key => 0)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets datatable displaying number of visits by device manufacturer name
|
||||
* @param int $idSite
|
||||
|
|
@ -68,6 +96,7 @@ class API extends \Piwik\Plugin\API
|
|||
$dataTable = $this->getDataTable('DevicesDetection_brands', $idSite, $period, $date, $segment);
|
||||
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceBrandLabel'));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrandLogo'));
|
||||
$dataTable->filter('AddSegmentByLabel', array('deviceBrand'));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
|
|
@ -97,8 +126,62 @@ class API extends \Piwik\Plugin\API
|
|||
public function getOsFamilies($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$dataTable = $this->getDataTable('DevicesDetection_os', $idSite, $period, $date, $segment);
|
||||
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamilyFullNameExtended'));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsFamilyLogoExtended'));
|
||||
|
||||
// handle legacy archives
|
||||
if ($dataTable instanceof DataTable\Map || !$dataTable->getRowsCount()) {
|
||||
$versionDataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
|
||||
$dataTable = $this->mergeDataTables($dataTable, $versionDataTable);
|
||||
}
|
||||
|
||||
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getOSFamilyFullName'));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsFamilyLogo'));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* That methods handles the fallback to version datatables to calculate those without versions.
|
||||
*
|
||||
* Unlike DevicesDetection plugin now, the UserSettings plugin did not store archives holding the os and browser data without
|
||||
* their version number. The "version-less" reports were always generated out of the "version-containing" archives .
|
||||
* For big archives (month/year) that ment that some of the data was truncated, due to the datatable entry limit.
|
||||
* To avoid that data loss / inaccuracy in the future, DevicesDetection plugin will also store archives without the version.
|
||||
* For data archived before DevicesDetection plugin was enabled, those archives do not exist, so we try to calculate
|
||||
* them here from the "version-containing" reports if possible.
|
||||
*
|
||||
* @param DataTable\DataTableInterface $dataTable
|
||||
* @param DataTable\DataTableInterface $dataTable2
|
||||
* @return DataTable\DataTableInterface
|
||||
*/
|
||||
protected function mergeDataTables(DataTable\DataTableInterface $dataTable, DataTable\DataTableInterface $dataTable2)
|
||||
{
|
||||
if ($dataTable instanceof DataTable\Map) {
|
||||
$dataTables = $dataTable->getDataTables();
|
||||
|
||||
foreach ($dataTables as $label => $table) {
|
||||
|
||||
$versionDataTables = $dataTable2->getDataTables();
|
||||
|
||||
if (!array_key_exists($label, $versionDataTables)) {
|
||||
continue;
|
||||
}
|
||||
$newDataTable = $this->mergeDataTables($table, $versionDataTables[$label]);
|
||||
$dataTable->addTable($newDataTable, $label);
|
||||
}
|
||||
|
||||
} else if (!$dataTable->getRowsCount() && $dataTable2->getRowsCount()) {
|
||||
$dataTable2->filter('GroupBy', array('label', function ($label) {
|
||||
if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches)) {
|
||||
return $matches[1]; // should match for browsers
|
||||
}
|
||||
if (strpos($label, ';')) {
|
||||
return substr($label, 0, 3); // should match for os
|
||||
}
|
||||
return $label;
|
||||
}));
|
||||
return $dataTable2;
|
||||
}
|
||||
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
|
|
@ -113,9 +196,12 @@ class API extends \Piwik\Plugin\API
|
|||
public function getOsVersions($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$dataTable = $this->getDataTable('DevicesDetection_osVersions', $idSite, $period, $date, $segment);
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogoExtended'));
|
||||
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getOsFullNameExtended'));
|
||||
|
||||
$segments = array('operatingSystemCode', 'operatingSystemVersion');
|
||||
$dataTable->filter('AddSegmentByLabel', array($segments, Archiver::BROWSER_SEPARATOR));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getOsLogo'));
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
|
@ -126,12 +212,39 @@ class API extends \Piwik\Plugin\API
|
|||
* @param string $date
|
||||
* @param bool|string $segment
|
||||
* @return DataTable
|
||||
*
|
||||
* @deprecated since 2.9.0 Use {@link getBrowsers} instead.
|
||||
*/
|
||||
public function getBrowserFamilies($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$table = $this->getBrowsers($idSite, $period, $date, $segment);
|
||||
// this one will not be sorted automatically by nb_visits since there is no Report class for it.
|
||||
$table->filter('Sort', array(Metrics::INDEX_NB_VISITS, 'desc'));
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets datatable displaying number of visits by Browser (Without version)
|
||||
* @param int $idSite
|
||||
* @param string $period
|
||||
* @param string $date
|
||||
* @param bool|string $segment
|
||||
* @return DataTable
|
||||
*/
|
||||
public function getBrowsers($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$dataTable = $this->getDataTable('DevicesDetection_browsers', $idSite, $period, $date, $segment);
|
||||
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserFamilyFullNameExtended'));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserFamilyLogoExtended'));
|
||||
$dataTable->filter('AddSegmentValue');
|
||||
|
||||
// handle legacy archives
|
||||
if ($dataTable instanceof DataTable\Map || !$dataTable->getRowsCount()) {
|
||||
$versionDataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
|
||||
$dataTable = $this->mergeDataTables($dataTable, $versionDataTable);
|
||||
}
|
||||
|
||||
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserName'));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserFamilyLogo'));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
|
|
@ -146,8 +259,28 @@ class API extends \Piwik\Plugin\API
|
|||
public function getBrowserVersions($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$dataTable = $this->getDataTable('DevicesDetection_browserVersions', $idSite, $period, $date, $segment);
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserLogoExtended'));
|
||||
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserNameExtended'));
|
||||
|
||||
$segments = array('browserCode', 'browserVersion');
|
||||
$dataTable->filter('AddSegmentByLabel', array($segments, Archiver::BROWSER_SEPARATOR));
|
||||
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrowserLogo'));
|
||||
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getBrowserNameWithVersion'));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets datatable displaying number of visits by Browser engine (eg. Trident, Gecko, Blink,...)
|
||||
* @param int $idSite
|
||||
* @param string $period
|
||||
* @param string $date
|
||||
* @param bool|string $segment
|
||||
* @return DataTable
|
||||
*/
|
||||
public function getBrowserEngines($idSite, $period, $date, $segment = false)
|
||||
{
|
||||
$dataTable = $this->getDataTable('DevicesDetection_browserEngines', $idSite, $period, $date, $segment);
|
||||
$dataTable->filter('AddSegmentValue');
|
||||
// use GroupBy filter to avoid duplicate rows if old (UserSettings) and new (DevicesDetection) reports were combined
|
||||
$dataTable->filter('GroupBy', array('label', __NAMESPACE__ . '\getBrowserEngineName'));
|
||||
return $dataTable;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -13,20 +13,23 @@ use Piwik\Metrics;
|
|||
|
||||
class Archiver extends \Piwik\Plugin\Archiver
|
||||
{
|
||||
const BROWSER_SEPARATOR = ';';
|
||||
const DEVICE_TYPE_RECORD_NAME = 'DevicesDetection_types';
|
||||
const DEVICE_BRAND_RECORD_NAME = 'DevicesDetection_brands';
|
||||
const DEVICE_MODEL_RECORD_NAME = 'DevicesDetection_models';
|
||||
const OS_RECORD_NAME = 'DevicesDetection_os';
|
||||
const OS_VERSION_RECORD_NAME = 'DevicesDetection_osVersions';
|
||||
const BROWSER_RECORD_NAME = 'DevicesDetection_browsers';
|
||||
const BROWSER_ENGINE_RECORD_NAME = 'DevicesDetection_browserEngines';
|
||||
const BROWSER_VERSION_RECORD_NAME = 'DevicesDetection_browserVersions';
|
||||
|
||||
const DEVICE_TYPE_FIELD = "config_device_type";
|
||||
const DEVICE_BRAND_FIELD = "config_device_brand";
|
||||
const DEVICE_MODEL_FIELD = "config_device_model";
|
||||
const DEVICE_MODEL_FIELD = "CONCAT(log_visit.config_device_brand, ';', log_visit.config_device_model)";
|
||||
const OS_FIELD = "config_os";
|
||||
const OS_VERSION_FIELD = "CONCAT(log_visit.config_os, ';', log_visit.config_os_version)";
|
||||
const OS_VERSION_FIELD = "CONCAT(log_visit.config_os, ';', COALESCE(log_visit.config_os_version, ''))";
|
||||
const BROWSER_FIELD = "config_browser_name";
|
||||
const BROWSER_ENGINE_FIELD = "config_browser_engine";
|
||||
const BROWSER_VERSION_DIMENSION = "CONCAT(log_visit.config_browser_name, ';', log_visit.config_browser_version)";
|
||||
|
||||
public function aggregateDayReport()
|
||||
|
|
@ -37,6 +40,7 @@ class Archiver extends \Piwik\Plugin\Archiver
|
|||
$this->aggregateByLabel(self::OS_FIELD, self::OS_RECORD_NAME);
|
||||
$this->aggregateByLabel(self::OS_VERSION_FIELD, self::OS_VERSION_RECORD_NAME);
|
||||
$this->aggregateByLabel(self::BROWSER_FIELD, self::BROWSER_RECORD_NAME);
|
||||
$this->aggregateByLabel(self::BROWSER_ENGINE_FIELD, self::BROWSER_ENGINE_RECORD_NAME);
|
||||
$this->aggregateByLabel(self::BROWSER_VERSION_DIMENSION, self::BROWSER_VERSION_RECORD_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -49,11 +53,21 @@ class Archiver extends \Piwik\Plugin\Archiver
|
|||
self::OS_RECORD_NAME,
|
||||
self::OS_VERSION_RECORD_NAME,
|
||||
self::BROWSER_RECORD_NAME,
|
||||
self::BROWSER_ENGINE_RECORD_NAME,
|
||||
self::BROWSER_VERSION_RECORD_NAME
|
||||
);
|
||||
|
||||
$columnsAggregationOperation = null;
|
||||
|
||||
foreach ($dataTablesToSum as $dt) {
|
||||
$this->getProcessor()->aggregateDataTableRecords(
|
||||
$dt, $this->maximumRows, $this->maximumRows, $columnToSort = "nb_visits");
|
||||
$dt,
|
||||
$this->maximumRows,
|
||||
$this->maximumRows,
|
||||
$columnToSort = 'nb_visits',
|
||||
$columnsAggregationOperation,
|
||||
$columnsToRenameAfterAggregation = null,
|
||||
$countRowsRecursive = array());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
20
www/analytics/plugins/DevicesDetection/Columns/Base.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\DeviceDetectorFactory;
|
||||
use Piwik\Plugin\Dimension\VisitDimension;
|
||||
|
||||
abstract class Base extends VisitDimension
|
||||
{
|
||||
protected function getUAParser($userAgent)
|
||||
{
|
||||
return DeviceDetectorFactory::getInstance($userAgent);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\DevicesDetection\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class BrowserEngine extends Base
|
||||
{
|
||||
protected $columnName = 'config_browser_engine';
|
||||
protected $columnType = 'VARCHAR(10) NOT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('browserEngine');
|
||||
$segment->setName('DevicesDetection_BrowserEngine');
|
||||
$segment->setAcceptedValues('Trident, WebKit, Presto, Gecko, Blink, etc.');
|
||||
$segment->setSuggestedValuesCallback('\DeviceDetector\Parser\Client\Browser\Engine::getAvailableEngines');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_BrowserEngine');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
$aBrowserInfo = $parser->getClient();
|
||||
|
||||
if (!empty($aBrowserInfo['engine'])) {
|
||||
|
||||
return $aBrowserInfo['engine'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\DevicesDetection\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class BrowserName extends Base
|
||||
{
|
||||
protected $columnName = 'config_browser_name';
|
||||
protected $columnType = 'VARCHAR(10) NOT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('browserCode');
|
||||
$segment->setName('DevicesDetection_ColumnBrowser');
|
||||
$segment->setAcceptedValues('FF, IE, CH, SF, OP, etc.');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_ColumnBrowser');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
$aBrowserInfo = $parser->getClient();
|
||||
|
||||
if (!empty($aBrowserInfo['short_name'])) {
|
||||
|
||||
return $aBrowserInfo['short_name'];
|
||||
}
|
||||
|
||||
return 'UNK';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\DevicesDetection\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class BrowserVersion extends Base
|
||||
{
|
||||
protected $columnName = 'config_browser_version';
|
||||
protected $columnType = 'VARCHAR(20) NOT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('browserVersion');
|
||||
$segment->setName('DevicesDetection_BrowserVersion');
|
||||
$segment->setAcceptedValues('1.0, 8.0, etc.');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_BrowserVersion');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
$aBrowserInfo = $parser->getClient();
|
||||
|
||||
if (!empty($aBrowserInfo['version'])) {
|
||||
|
||||
return $aBrowserInfo['version'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use DeviceDetector\Parser\Device\DeviceParserAbstract;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\DevicesDetection\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class DeviceBrand extends Base
|
||||
{
|
||||
protected $columnName = 'config_device_brand';
|
||||
protected $columnType = 'VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_DeviceBrand');
|
||||
}
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$brands = DeviceParserAbstract::$deviceBrands;
|
||||
$brandList = implode(", ", $brands);
|
||||
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('deviceBrand');
|
||||
$segment->setName('DevicesDetection_DeviceBrand');
|
||||
$segment->setAcceptedValues($brandList);
|
||||
$segment->setSqlFilter(function ($brand) use ($brandList, $brands) {
|
||||
if ($brand == Piwik::translate('General_Unknown')) {
|
||||
return '';
|
||||
}
|
||||
$index = array_search(trim(urldecode($brand)), $brands);
|
||||
if ($index === false) {
|
||||
throw new \Exception("deviceBrand segment must be one of: $brandList");
|
||||
}
|
||||
return $index;
|
||||
});
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
return $parser->getBrand();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class DeviceModel extends Base
|
||||
{
|
||||
protected $columnName = 'config_device_model';
|
||||
protected $columnType = 'VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_DeviceModel');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
return $parser->getModel();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use DeviceDetector;
|
||||
use Exception;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
use DeviceDetector\Parser\Device\DeviceParserAbstract as DeviceParser;
|
||||
|
||||
class DeviceType extends Base
|
||||
{
|
||||
protected $columnName = 'config_device_type';
|
||||
protected $columnType = 'TINYINT( 100 ) NULL DEFAULT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$deviceTypes = DeviceParser::getAvailableDeviceTypeNames();
|
||||
$deviceTypeList = implode(", ", $deviceTypes);
|
||||
|
||||
$segment = new Segment();
|
||||
$segment->setCategory('General_Visit');
|
||||
$segment->setSegment('deviceType');
|
||||
$segment->setName('DevicesDetection_DeviceType');
|
||||
$segment->setAcceptedValues($deviceTypeList);
|
||||
$segment->setSqlFilter(function ($type) use ($deviceTypeList, $deviceTypes) {
|
||||
$index = array_search(strtolower(trim(urldecode($type))), $deviceTypes);
|
||||
if ($index === false) {
|
||||
throw new Exception("deviceType segment must be one of: $deviceTypeList");
|
||||
}
|
||||
return $index;
|
||||
});
|
||||
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_DeviceType');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
return $parser->getDevice();
|
||||
}
|
||||
}
|
||||
57
www/analytics/plugins/DevicesDetection/Columns/Os.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\DevicesDetection\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Settings;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class Os extends Base
|
||||
{
|
||||
protected $columnName = 'config_os';
|
||||
protected $columnType = 'CHAR(3) NOT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('operatingSystemCode');
|
||||
$segment->setName('DevicesDetection_ColumnOperatingSystem');
|
||||
$segment->setAcceptedValues('WIN, MAC, LIN, AND, IPD, etc.');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_OperatingSystemFamily');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
if ($parser->isBot()) {
|
||||
$os = Settings::OS_BOT;
|
||||
} else {
|
||||
$os = $parser->getOS();
|
||||
$os = empty($os['short_name']) ? 'UNK' : $os['short_name'];
|
||||
}
|
||||
|
||||
return $os;
|
||||
}
|
||||
}
|
||||
49
www/analytics/plugins/DevicesDetection/Columns/OsVersion.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Columns;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugins\DevicesDetection\Segment;
|
||||
use Piwik\Tracker\Request;
|
||||
use Piwik\Tracker\Visitor;
|
||||
use Piwik\Tracker\Action;
|
||||
|
||||
class OsVersion extends Base
|
||||
{
|
||||
protected $columnName = 'config_os_version';
|
||||
protected $columnType = 'VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL';
|
||||
|
||||
protected function configureSegments()
|
||||
{
|
||||
$segment = new Segment();
|
||||
$segment->setSegment('operatingSystemVersion');
|
||||
$segment->setName('DevicesDetection_ColumnOperatingSystemVersion');
|
||||
$segment->setAcceptedValues('XP, 7, 2.3, 5.1, ...');
|
||||
$this->addSegment($segment);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return Piwik::translate('DevicesDetection_OperatingSystemVersions');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param Visitor $visitor
|
||||
* @param Action|null $action
|
||||
* @return mixed
|
||||
*/
|
||||
public function onNewVisit(Request $request, Visitor $visitor, $action)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
$parser = $this->getUAParser($userAgent);
|
||||
|
||||
return $parser->getOs('version');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -8,64 +8,58 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
use DeviceDetector\DeviceDetector;
|
||||
use Piwik\Common;
|
||||
use Piwik\Db;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ControllerAdmin;
|
||||
use Piwik\Plugin\Manager AS PluginManager;
|
||||
use Piwik\Plugin\Report;
|
||||
use Piwik\View;
|
||||
use Piwik\ViewDataTable\Factory;
|
||||
use DeviceDetector;
|
||||
|
||||
class Controller extends \Piwik\Plugin\Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$view = new View('@DevicesDetection/index');
|
||||
$view->deviceTypes = $view->deviceModels = $view->deviceBrands = $view->osReport = $view->browserReport = "blank";
|
||||
$view->deviceTypes = $this->getType(true);
|
||||
$view->deviceBrands = $this->getBrand(true);
|
||||
$view->deviceModels = $this->getModel(true);
|
||||
$view->osReport = $this->getOsFamilies(true);
|
||||
$view->browserReport = $this->getBrowserFamilies(true);
|
||||
return $this->devices();
|
||||
}
|
||||
|
||||
public function devices()
|
||||
{
|
||||
$view = new View('@DevicesDetection/devices');
|
||||
$view->deviceTypes = $this->renderReport('getType');
|
||||
$view->deviceBrands = $this->renderReport('getBrand');
|
||||
$view->deviceModels = $this->renderReport('getModel');
|
||||
|
||||
$isResolutionEnabled = PluginManager::getInstance()->isPluginActivated('Resolution');
|
||||
if ($isResolutionEnabled) {
|
||||
$view->resolutions = $this->renderReport(Report::factory('Resolution', 'getResolution'));
|
||||
}
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function getType()
|
||||
public function software()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
$view = new View('@DevicesDetection/software');
|
||||
$view->osReport = $this->renderReport('getOsVersions');
|
||||
$view->browserReport = $this->renderReport('getBrowsers');
|
||||
$view->browserEngineReport = $this->renderReport('getBrowserEngines');
|
||||
|
||||
$isResolutionEnabled = PluginManager::getInstance()->isPluginActivated('Resolution');
|
||||
if ($isResolutionEnabled) {
|
||||
$view->configurations = $this->renderReport(Report::factory('Resolution', 'getConfiguration'));
|
||||
}
|
||||
|
||||
$isDevicePluginsEnabled = PluginManager::getInstance()->isPluginActivated('DevicePlugins');
|
||||
if ($isDevicePluginsEnabled) {
|
||||
$view->browserPlugins = $this->renderReport(Report::factory('DevicePlugins', 'getPlugin'));
|
||||
}
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
public function getBrand()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getModel()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getOsFamilies()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getOsVersions()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getBrowserFamilies()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function getBrowserVersions()
|
||||
{
|
||||
return $this->renderReport(__FUNCTION__);
|
||||
}
|
||||
|
||||
public function deviceDetection()
|
||||
public function detection()
|
||||
{
|
||||
Piwik::checkUserHasSomeAdminAccess();
|
||||
|
||||
|
|
@ -75,26 +69,27 @@ class Controller extends \Piwik\Plugin\Controller
|
|||
|
||||
$userAgent = Common::getRequestVar('ua', $_SERVER['HTTP_USER_AGENT'], 'string');
|
||||
|
||||
$parsedUA = DeviceDetector::getInfoFromUserAgent($userAgent);
|
||||
$uaParser = new DeviceDetector($userAgent);
|
||||
$uaParser->parse();
|
||||
|
||||
$view->userAgent = $userAgent;
|
||||
$view->browser_name = $parsedUA['browser']['name'];
|
||||
$view->browser_short_name = $parsedUA['browser']['short_name'];
|
||||
$view->browser_version = $parsedUA['browser']['version'];
|
||||
$view->browser_logo = getBrowserLogoExtended($parsedUA['browser']['short_name']);
|
||||
$view->browser_family = $parsedUA['browser_family'];
|
||||
$view->browser_family_logo = getBrowserFamilyLogoExtended($parsedUA['browser_family']);
|
||||
$view->os_name = $parsedUA['os']['name'];
|
||||
$view->os_logo = getOsLogoExtended($parsedUA['os']['short_name']);
|
||||
$view->os_short_name = $parsedUA['os']['short_name'];
|
||||
$view->os_family = $parsedUA['os_family'];
|
||||
$view->os_family_logo = getOsFamilyLogoExtended($parsedUA['os_family']);
|
||||
$view->os_version = $parsedUA['os']['version'];
|
||||
$view->device_type = getDeviceTypeLabel($parsedUA['device']['type']);
|
||||
$view->device_type_logo = getDeviceTypeLogo($parsedUA['device']['type']);
|
||||
$view->device_model = $parsedUA['device']['model'];
|
||||
$view->device_brand = getDeviceBrandLabel($parsedUA['device']['brand']);
|
||||
$view->device_brand_logo = getBrandLogo($view->device_brand);
|
||||
$view->browser_name = $uaParser->getClient('name');
|
||||
$view->browser_short_name = $uaParser->getClient('short_name');
|
||||
$view->browser_version = $uaParser->getClient('version');
|
||||
$view->browser_logo = getBrowserLogo($uaParser->getClient('short_name'));
|
||||
$view->browser_family = \DeviceDetector\Parser\Client\Browser::getBrowserFamily($uaParser->getClient('short_name'));
|
||||
$view->browser_family_logo = getBrowserFamilyLogo($view->browser_family);
|
||||
$view->os_name = $uaParser->getOs('name');
|
||||
$view->os_logo = getOsLogo($uaParser->getOs('short_name'));
|
||||
$view->os_short_name = $uaParser->getOs('short_name');
|
||||
$view->os_family = \DeviceDetector\Parser\OperatingSystem::getOsFamily($uaParser->getOs('short_name'));
|
||||
$view->os_family_logo = getOsFamilyLogo($view->os_family);
|
||||
$view->os_version = $uaParser->getOs('version');
|
||||
$view->device_type = getDeviceTypeLabel($uaParser->getDeviceName());
|
||||
$view->device_type_logo = getDeviceTypeLogo($uaParser->getDeviceName());
|
||||
$view->device_model = $uaParser->getModel();
|
||||
$view->device_brand = getDeviceBrandLabel($uaParser->getBrand());
|
||||
$view->device_brand_logo = getBrandLogo($uaParser->getBrand());
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
|
@ -111,9 +106,9 @@ class Controller extends \Piwik\Plugin\Controller
|
|||
|
||||
switch ($type) {
|
||||
case 'brands':
|
||||
$availableBrands = DeviceDetector::$deviceBrands;
|
||||
$availableBrands = \DeviceDetector\Parser\Device\DeviceParserAbstract::$deviceBrands;
|
||||
|
||||
foreach ($availableBrands AS $short => $name) {
|
||||
foreach ($availableBrands as $short => $name) {
|
||||
if ($name != 'Unknown') {
|
||||
$list[$name] = getBrandLogo($name);
|
||||
}
|
||||
|
|
@ -121,45 +116,41 @@ class Controller extends \Piwik\Plugin\Controller
|
|||
break;
|
||||
|
||||
case 'browsers':
|
||||
$availableBrowsers = DeviceDetector::$browsers;
|
||||
$availableBrowsers = \DeviceDetector\Parser\Client\Browser::getAvailableBrowsers();
|
||||
|
||||
foreach ($availableBrowsers AS $short => $name) {
|
||||
$list[$name] = getBrowserLogoExtended($short);
|
||||
foreach ($availableBrowsers as $short => $name) {
|
||||
$list[$name] = getBrowserLogo($short);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'browserfamilies':
|
||||
$availableBrowserFamilies = DeviceDetector::$browserFamilies;
|
||||
$availableBrowserFamilies = \DeviceDetector\Parser\Client\Browser::getAvailableBrowserFamilies();
|
||||
|
||||
foreach ($availableBrowserFamilies AS $name => $browsers) {
|
||||
$list[$name] = getBrowserFamilyLogoExtended($name);
|
||||
foreach ($availableBrowserFamilies as $name => $browsers) {
|
||||
$list[$name] = getBrowserFamilyLogo($name);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'os':
|
||||
$availableOSs = DeviceDetector::$osShorts;
|
||||
$availableOSs = \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystems();
|
||||
|
||||
foreach ($availableOSs AS $name => $short) {
|
||||
if ($name != 'Bot') {
|
||||
$list[$name] = getOsLogoExtended($short);
|
||||
}
|
||||
foreach ($availableOSs as $short => $name) {
|
||||
$list[$name] = getOsLogo($short);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'osfamilies':
|
||||
$osFamilies = DeviceDetector::$osFamilies;
|
||||
$osFamilies = \DeviceDetector\Parser\OperatingSystem::getAvailableOperatingSystemFamilies();
|
||||
|
||||
foreach ($osFamilies AS $name => $oss) {
|
||||
if ($name != 'Bot') {
|
||||
$list[$name] = getOsFamilyLogoExtended($name);
|
||||
}
|
||||
foreach ($osFamilies as $name => $oss) {
|
||||
$list[$name] = getOsFamilyLogo($name);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'devicetypes':
|
||||
$deviceTypes = DeviceDetector::$deviceTypes;
|
||||
$deviceTypes = \DeviceDetector\Parser\Device\DeviceParserAbstract::getAvailableDeviceTypes();
|
||||
|
||||
foreach ($deviceTypes AS $name) {
|
||||
foreach ($deviceTypes as $name => $id) {
|
||||
$list[$name] = getDeviceTypeLogo($name);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -9,372 +9,61 @@
|
|||
|
||||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
use Exception;
|
||||
|
||||
use Piwik\ArchiveProcessor;
|
||||
use Piwik\CacheFile;
|
||||
use Piwik\Common;
|
||||
use Piwik\Config;
|
||||
use Piwik\Db;
|
||||
use Piwik\Menu\MenuAdmin;
|
||||
use Piwik\Menu\MenuMain;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\WidgetsList;
|
||||
use DeviceDetector;
|
||||
|
||||
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/functions.php';
|
||||
|
||||
class DevicesDetection extends \Piwik\Plugin
|
||||
{
|
||||
/**
|
||||
* @see Piwik\Plugin::getInformation
|
||||
* @see Piwik\Plugin::registerEvents
|
||||
*/
|
||||
public function getInformation()
|
||||
public function registerEvents()
|
||||
{
|
||||
return array(
|
||||
'description' => "[Beta Plugin] " . Piwik::translate("DevicesDetection_PluginDescription"),
|
||||
'authors' => array(array('name' => 'Piwik PRO', 'homepage' => 'http://piwik.pro')),
|
||||
'version' => '1.14',
|
||||
'license' => 'GPL v3+',
|
||||
'license_homepage' => 'http://www.gnu.org/licenses/gpl.html'
|
||||
'Live.getAllVisitorDetails' => 'extendVisitorDetails',
|
||||
'Request.getRenamedModuleAndAction' => 'renameUserSettingsModuleAndAction',
|
||||
);
|
||||
}
|
||||
|
||||
/** The set of related reports displayed under the 'Operating Systems' header. */
|
||||
private $osRelatedReports = null;
|
||||
private $browserRelatedReports = null;
|
||||
|
||||
public function __construct()
|
||||
public function extendVisitorDetails(&$visitor, $details)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->osRelatedReports = array(
|
||||
'DevicesDetection.getOsFamilies' => Piwik::translate('DevicesDetection_OperatingSystemFamilies'),
|
||||
'DevicesDetection.getOsVersions' => Piwik::translate('DevicesDetection_OperatingSystemVersions')
|
||||
);
|
||||
$this->browserRelatedReports = array(
|
||||
'DevicesDetection.getBrowserFamilies' => Piwik::translate('UserSettings_BrowserFamilies'),
|
||||
'DevicesDetection.getBrowserVersions' => Piwik::translate('DevicesDetection_BrowserVersions')
|
||||
);
|
||||
$instance = new Visitor($details);
|
||||
|
||||
$visitor['deviceType'] = $instance->getDeviceType();
|
||||
$visitor['deviceTypeIcon'] = $instance->getDeviceTypeIcon();
|
||||
$visitor['deviceBrand'] = $instance->getDeviceBrand();
|
||||
$visitor['deviceModel'] = $instance->getDeviceModel();
|
||||
$visitor['operatingSystem'] = $instance->getOperatingSystem();
|
||||
$visitor['operatingSystemName'] = $instance->getOperatingSystemName();
|
||||
$visitor['operatingSystemIcon'] = $instance->getOperatingSystemIcon();
|
||||
$visitor['operatingSystemCode'] = $instance->getOperatingSystemCode();
|
||||
$visitor['operatingSystemVersion'] = $instance->getOperatingSystemVersion();
|
||||
$visitor['browserFamily'] = $instance->getBrowserEngine();
|
||||
$visitor['browserFamilyDescription'] = $instance->getBrowserEngineDescription();
|
||||
$visitor['browser'] = $instance->getBrowser();
|
||||
$visitor['browserName'] = $instance->getBrowserName();
|
||||
$visitor['browserIcon'] = $instance->getBrowserIcon();
|
||||
$visitor['browserCode'] = $instance->getBrowserCode();
|
||||
$visitor['browserVersion'] = $instance->getBrowserVersion();
|
||||
}
|
||||
|
||||
protected function getRawMetadataDeviceType()
|
||||
public function renameUserSettingsModuleAndAction(&$module, &$action)
|
||||
{
|
||||
$deviceTypeList = implode(", ", DeviceDetector::$deviceTypes);
|
||||
|
||||
$deviceTypeLabelToCode = function ($type) use ($deviceTypeList) {
|
||||
$index = array_search(strtolower(trim(urldecode($type))), DeviceDetector::$deviceTypes);
|
||||
if ($index === false) {
|
||||
throw new Exception("deviceType segment must be one of: $deviceTypeList");
|
||||
}
|
||||
return $index;
|
||||
};
|
||||
|
||||
return array(
|
||||
'DevicesDetection_DevicesDetection',
|
||||
'DevicesDetection_DeviceType',
|
||||
'DevicesDetection',
|
||||
'getType',
|
||||
'DevicesDetection_DeviceType',
|
||||
|
||||
// Segment
|
||||
'deviceType',
|
||||
'log_visit.config_device_type',
|
||||
$deviceTypeList,
|
||||
$deviceTypeLabelToCode
|
||||
$movedMethods = array(
|
||||
'index' => 'software',
|
||||
'getBrowser' => 'getBrowsers',
|
||||
'getBrowserVersion' => 'getBrowserVersions',
|
||||
'getMobileVsDesktop' => 'getType',
|
||||
'getOS' => 'getOsVersions',
|
||||
'getOSFamily' => 'getOsFamilies',
|
||||
'getBrowserType' => 'getBrowserEngines',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Piwik\Plugin::getListHooksRegistered
|
||||
*/
|
||||
public function getListHooksRegistered()
|
||||
{
|
||||
return array(
|
||||
'Menu.Reporting.addItems' => 'addMenu',
|
||||
'Menu.Admin.addItems' => 'addAdminMenu',
|
||||
'Tracker.newVisitorInformation' => 'parseMobileVisitData',
|
||||
'WidgetsList.addWidgets' => 'addWidgets',
|
||||
'API.getReportMetadata' => 'getReportMetadata',
|
||||
'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata',
|
||||
'ViewDataTable.configure' => 'configureViewDataTable',
|
||||
);
|
||||
}
|
||||
|
||||
public function addAdminMenu()
|
||||
{
|
||||
MenuAdmin::getInstance()->add(
|
||||
'CoreAdminHome_MenuDiagnostic', 'DevicesDetection_DeviceDetection',
|
||||
array('module' => 'DevicesDetection', 'action' => 'deviceDetection'),
|
||||
Piwik::isUserHasSomeAdminAccess(),
|
||||
$order = 40
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines API reports.
|
||||
* Also used to define Widgets, and Segment(s)
|
||||
*
|
||||
* @return array Category, Report Name, API Module, API action, Translated column name, & optional segment info
|
||||
*/
|
||||
protected function getRawMetadataReports()
|
||||
{
|
||||
|
||||
$report = array(
|
||||
// device type report (tablet, desktop, mobile...)
|
||||
$this->getRawMetadataDeviceType(),
|
||||
|
||||
// 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',
|
||||
'DevicesDetection_OperatingSystemFamilies',
|
||||
'DevicesDetection',
|
||||
'getOsFamilies',
|
||||
'DevicesDetection_OperatingSystemFamilies',
|
||||
),
|
||||
// device OS version report
|
||||
array(
|
||||
'DevicesDetection_DevicesDetection',
|
||||
'DevicesDetection_OperatingSystemVersions',
|
||||
'DevicesDetection',
|
||||
'getOsVersions',
|
||||
'DevicesDetection_OperatingSystemVersions',
|
||||
),
|
||||
// Browser family report
|
||||
array(
|
||||
'DevicesDetection_DevicesDetection',
|
||||
'UserSettings_BrowserFamilies',
|
||||
'DevicesDetection',
|
||||
'getBrowserFamilies',
|
||||
'UserSettings_BrowserFamilies',
|
||||
),
|
||||
// Browser versions report
|
||||
array(
|
||||
'DevicesDetection_DevicesDetection',
|
||||
'DevicesDetection_BrowserVersions',
|
||||
'DevicesDetection',
|
||||
'getBrowserVersions',
|
||||
'DevicesDetection_BrowserVersions',
|
||||
),
|
||||
);
|
||||
return $report;
|
||||
}
|
||||
|
||||
public function addWidgets()
|
||||
{
|
||||
foreach ($this->getRawMetadataReports() as $report) {
|
||||
list($category, $name, $controllerName, $controllerAction) = $report;
|
||||
if ($category == false)
|
||||
continue;
|
||||
WidgetsList::add($category, $name, $controllerName, $controllerAction);
|
||||
if ($module == 'UserSettings' && array_key_exists($action, $movedMethods)) {
|
||||
$module = 'DevicesDetection';
|
||||
$action = $movedMethods[$action];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get segments meta data
|
||||
*/
|
||||
public function getSegmentsMetadata(&$segments)
|
||||
{
|
||||
// Note: only one field segmented so far: deviceType
|
||||
foreach ($this->getRawMetadataReports() as $report) {
|
||||
@list($category, $name, $apiModule, $apiAction, $columnName, $segment, $sqlSegment, $acceptedValues, $sqlFilter) = $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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getReportMetadata(&$reports)
|
||||
{
|
||||
$i = 0;
|
||||
foreach ($this->getRawMetadataReports() as $report) {
|
||||
list($category, $name, $apiModule, $apiAction, $columnName) = $report;
|
||||
if ($category == false)
|
||||
continue;
|
||||
|
||||
$report = array(
|
||||
'category' => Piwik::translate($category),
|
||||
'name' => Piwik::translate($name),
|
||||
'module' => $apiModule,
|
||||
'action' => $apiAction,
|
||||
'dimension' => Piwik::translate($columnName),
|
||||
'order' => $i++
|
||||
);
|
||||
|
||||
$translation = $name . 'Documentation';
|
||||
$translated = Piwik::translate($translation, '<br />');
|
||||
if ($translated != $translation) {
|
||||
$report['documentation'] = $translated;
|
||||
}
|
||||
|
||||
$reports[] = $report;
|
||||
}
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
// we catch the exception
|
||||
try {
|
||||
$q1 = "ALTER TABLE `" . Common::prefixTable("log_visit") . "`
|
||||
ADD `config_os_version` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_os` ,
|
||||
ADD `config_device_type` TINYINT( 100 ) NULL DEFAULT NULL AFTER `config_browser_version` ,
|
||||
ADD `config_device_brand` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_type` ,
|
||||
ADD `config_device_model` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_brand`";
|
||||
Db::exec($q1);
|
||||
|
||||
} catch (Exception $e) {
|
||||
if (!Db::get()->isErrNo($e, '1060')) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function parseMobileVisitData(&$visitorInfo, \Piwik\Tracker\Request $request)
|
||||
{
|
||||
$userAgent = $request->getUserAgent();
|
||||
|
||||
$UAParser = new DeviceDetector($userAgent);
|
||||
$UAParser->setCache(new CacheFile('tracker', 86400));
|
||||
$UAParser->parse();
|
||||
$deviceInfo['config_browser_name'] = $UAParser->getBrowser("short_name");
|
||||
$deviceInfo['config_browser_version'] = $UAParser->getBrowser("version");
|
||||
$deviceInfo['config_os'] = $UAParser->getOs("short_name");
|
||||
$deviceInfo['config_os_version'] = $UAParser->getOs("version");
|
||||
$deviceInfo['config_device_type'] = $UAParser->getDevice();
|
||||
$deviceInfo['config_device_model'] = $UAParser->getModel();
|
||||
$deviceInfo['config_device_brand'] = $UAParser->getBrand();
|
||||
|
||||
$visitorInfo = array_merge($visitorInfo, $deviceInfo);
|
||||
Common::printDebug("Device Detection:");
|
||||
Common::printDebug($deviceInfo);
|
||||
}
|
||||
|
||||
public function addMenu()
|
||||
{
|
||||
MenuMain::getInstance()->add('General_Visitors', 'DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index'));
|
||||
}
|
||||
|
||||
public function configureViewDataTable(ViewDataTable $view)
|
||||
{
|
||||
switch ($view->requestConfig->apiMethodToRequestDataTable) {
|
||||
case 'DevicesDetection.getType':
|
||||
$this->configureViewForGetType($view);
|
||||
break;
|
||||
case 'DevicesDetection.getBrand':
|
||||
$this->configureViewForGetBrand($view);
|
||||
break;
|
||||
case 'DevicesDetection.getModel':
|
||||
$this->configureViewForGetModel($view);
|
||||
break;
|
||||
case 'DevicesDetection.getOsFamilies':
|
||||
$this->configureViewForGetOsFamilies($view);
|
||||
break;
|
||||
case 'DevicesDetection.getOsVersions':
|
||||
$this->configureViewForGetOsVersions($view);
|
||||
break;
|
||||
case 'DevicesDetection.getBrowserFamilies':
|
||||
$this->configureViewForGetBrowserFamilies($view);
|
||||
break;
|
||||
case 'DevicesDetection.getBrowserVersions':
|
||||
$this->configureViewForGetBrowserVersions($view);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function configureViewForGetType(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelTypes"));
|
||||
}
|
||||
|
||||
private function configureViewForGetBrand(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelBrands"));
|
||||
}
|
||||
|
||||
private function configureViewForGetModel(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelModels"));
|
||||
}
|
||||
|
||||
private function configureViewForGetOsFamilies(ViewDataTable $view)
|
||||
{
|
||||
$view->config->title = Piwik::translate('DevicesDetection_OperatingSystemFamilies');
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("UserSettings_OperatingSystemFamily"));
|
||||
$view->config->addRelatedReports($this->getOsRelatedReports());
|
||||
}
|
||||
|
||||
private function configureViewForGetOsVersions(ViewDataTable $view)
|
||||
{
|
||||
$view->config->title = Piwik::translate('DevicesDetection_OperatingSystemVersions');
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelSystemVersion"));
|
||||
$view->config->addRelatedReports($this->getOsRelatedReports());
|
||||
}
|
||||
|
||||
private function configureViewForGetBrowserFamilies(ViewDataTable $view)
|
||||
{
|
||||
$view->config->title = Piwik::translate('UserSettings_BrowserFamilies');
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelBrowserFamily"));
|
||||
$view->config->addRelatedReports($this->getBrowserRelatedReports());
|
||||
}
|
||||
|
||||
private function configureViewForGetBrowserVersions(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("UserSettings_ColumnBrowserVersion"));
|
||||
$view->config->addRelatedReports($this->getBrowserRelatedReports());
|
||||
}
|
||||
|
||||
private function getOsRelatedReports()
|
||||
{
|
||||
return array(
|
||||
'DevicesDetection.getOsFamilies' => Piwik::translate('DevicesDetection_OperatingSystemFamilies'),
|
||||
'DevicesDetection.getOsVersions' => Piwik::translate('DevicesDetection_OperatingSystemVersions')
|
||||
);
|
||||
}
|
||||
|
||||
private function getBrowserRelatedReports()
|
||||
{
|
||||
return array(
|
||||
'DevicesDetection.getBrowserFamilies' => Piwik::translate('UserSettings_BrowserFamilies'),
|
||||
'DevicesDetection.getBrowserVersions' => Piwik::translate('DevicesDetection_BrowserVersions')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
33
www/analytics/plugins/DevicesDetection/Menu.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
use Piwik\Menu\MenuAdmin;
|
||||
use Piwik\Menu\MenuReporting;
|
||||
use Piwik\Piwik;
|
||||
|
||||
/**
|
||||
*/
|
||||
class Menu extends \Piwik\Plugin\Menu
|
||||
{
|
||||
public function configureAdminMenu(MenuAdmin $menu)
|
||||
{
|
||||
if (Piwik::isUserHasSomeAdminAccess()) {
|
||||
$menu->addDiagnosticItem('DevicesDetection_DeviceDetection',
|
||||
$this->urlForAction('detection'),
|
||||
$order = 40);
|
||||
}
|
||||
}
|
||||
|
||||
public function configureReportingMenu(MenuReporting $menu)
|
||||
{
|
||||
$menu->addVisitorsItem('DevicesDetection_Devices', $this->urlForAction('devices'));
|
||||
$menu->addVisitorsItem('DevicesDetection_Software', $this->urlForAction('software'));
|
||||
}
|
||||
}
|
||||
19
www/analytics/plugins/DevicesDetection/Reports/Base.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Metrics;
|
||||
|
||||
abstract class Base extends \Piwik\Plugin\Report
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->category = 'DevicesDetection_DevicesDetection';
|
||||
}
|
||||
}
|
||||
34
www/analytics/plugins/DevicesDetection/Reports/GetBrand.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\DeviceBrand;
|
||||
|
||||
class GetBrand extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new DeviceBrand();
|
||||
$this->name = Piwik::translate('DevicesDetection_DeviceBrand');
|
||||
$this->documentation = ''; // TODO
|
||||
$this->order = 1;
|
||||
$this->widgetTitle = 'DevicesDetection_DeviceBrand';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = true;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelBrands"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\CoreVisualizations\Visualizations\JqplotGraph\Pie;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\BrowserEngine;
|
||||
|
||||
class GetBrowserEngines extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new BrowserEngine();
|
||||
$this->name = Piwik::translate('DevicesDetection_BrowserEngines');
|
||||
$this->documentation = Piwik::translate('DevicesDetection_BrowserEngineDocumentation', '<br />');
|
||||
$this->order = 7;
|
||||
$this->widgetTitle = 'DevicesDetection_BrowserEngines';
|
||||
}
|
||||
|
||||
public function getDefaultTypeViewDataTable()
|
||||
{
|
||||
return Pie::ID;
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', $this->dimension->getName());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\BrowserVersion;
|
||||
|
||||
class GetBrowserVersions extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new BrowserVersion();
|
||||
$this->name = Piwik::translate('DevicesDetection_BrowserVersion');
|
||||
$this->documentation = ''; // TODO
|
||||
$this->order = 2;
|
||||
$this->widgetTitle = 'DevicesDetection_BrowserVersion';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = true;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', $this->dimension->getName());
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
self::factory('DevicesDetection', 'getBrowsers'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\BrowserName;
|
||||
|
||||
class GetBrowsers extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new BrowserName();
|
||||
$this->name = Piwik::translate('DevicesDetection_WidgetBrowsers');
|
||||
$this->documentation = Piwik::translate('DevicesDetection_WidgetBrowsersDocumentation', '<br />');
|
||||
$this->order = 1;
|
||||
$this->widgetTitle = 'DevicesDetection_WidgetBrowsers';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->title = $this->name;
|
||||
$view->config->show_search = true;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', $this->dimension->getName());
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
self::factory('DevicesDetection', 'getBrowserVersions'),
|
||||
);
|
||||
}
|
||||
}
|
||||
34
www/analytics/plugins/DevicesDetection/Reports/GetModel.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\DeviceModel;
|
||||
|
||||
class GetModel extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new DeviceModel();
|
||||
$this->name = Piwik::translate('DevicesDetection_DeviceModel');
|
||||
$this->documentation = ''; // TODO
|
||||
$this->order = 2;
|
||||
$this->widgetTitle = 'DevicesDetection_DeviceModel';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->show_search = true;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelModels"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\Os;
|
||||
|
||||
class GetOsFamilies extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new Os();
|
||||
$this->name = Piwik::translate('DevicesDetection_OperatingSystemFamilies');
|
||||
$this->documentation = ''; // TODO
|
||||
$this->order = 3;
|
||||
$this->widgetTitle = 'DevicesDetection_OperatingSystemFamilies';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->title = $this->name;
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', $this->dimension->getName());
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
self::factory('DevicesDetection', 'getOsVersions'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\OsVersion;
|
||||
|
||||
class GetOsVersions extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new OsVersion();
|
||||
$this->name = Piwik::translate('DevicesDetection_OperatingSystemVersions');
|
||||
$this->documentation = ''; // TODO
|
||||
$this->order = 4;
|
||||
$this->widgetTitle = 'DevicesDetection_OperatingSystemVersions';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$view->config->title = $this->name;
|
||||
$view->config->show_search = true;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelSystemVersion"));
|
||||
}
|
||||
|
||||
public function getRelatedReports()
|
||||
{
|
||||
return array(
|
||||
self::factory('DevicesDetection', 'getOsFamilies'),
|
||||
);
|
||||
}
|
||||
}
|
||||
37
www/analytics/plugins/DevicesDetection/Reports/GetType.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection\Reports;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Plugin\ViewDataTable;
|
||||
use Piwik\Plugins\DevicesDetection\Columns\DeviceType;
|
||||
use DeviceDetector\Parser\Device\DeviceParserAbstract as DeviceParser;
|
||||
|
||||
class GetType extends Base
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
$this->dimension = new DeviceType();
|
||||
$this->name = Piwik::translate('DevicesDetection_DeviceType');
|
||||
$this->documentation = ''; // TODO
|
||||
$this->order = 0;
|
||||
$this->widgetTitle = 'DevicesDetection_DeviceType';
|
||||
}
|
||||
|
||||
public function configureView(ViewDataTable $view)
|
||||
{
|
||||
$unknownTypeCount = 1;
|
||||
$view->requestConfig->filter_limit = $unknownTypeCount + count(DeviceParser::getAvailableDeviceTypeNames());
|
||||
$view->config->show_search = false;
|
||||
$view->config->show_exclude_low_population = false;
|
||||
$view->config->addTranslation('label', Piwik::translate("DevicesDetection_dataTableLabelTypes"));
|
||||
}
|
||||
|
||||
}
|
||||
21
www/analytics/plugins/DevicesDetection/Segment.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
/**
|
||||
* UserSettings segment base class.
|
||||
*
|
||||
*/
|
||||
class Segment extends \Piwik\Plugin\Segment
|
||||
{
|
||||
protected function init()
|
||||
{
|
||||
$this->setCategory('General_Visit');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -15,7 +15,7 @@ use Piwik\Updates;
|
|||
|
||||
class Updates_1_14 extends Updates
|
||||
{
|
||||
static function getSql()
|
||||
public function getMigrationQueries(Updater $updater)
|
||||
{
|
||||
return array(
|
||||
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
|
||||
|
|
@ -29,9 +29,9 @@ class Updates_1_14 extends Updates
|
|||
return true;
|
||||
}
|
||||
|
||||
static function update()
|
||||
public function doUpdate(Updater $updater)
|
||||
{
|
||||
Updater::updateDatabase(__FILE__, self::getSql());
|
||||
$updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
101
www/analytics/plugins/DevicesDetection/Visitor.php
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/functions.php';
|
||||
|
||||
class Visitor
|
||||
{
|
||||
private $details = array();
|
||||
|
||||
public function __construct($details)
|
||||
{
|
||||
$this->details = $details;
|
||||
}
|
||||
|
||||
public function getDeviceType()
|
||||
{
|
||||
return getDeviceTypeLabel($this->details['config_device_type']);
|
||||
}
|
||||
|
||||
public function getDeviceTypeIcon()
|
||||
{
|
||||
return getDeviceTypeLogo($this->details['config_device_type']);
|
||||
}
|
||||
|
||||
public function getDeviceBrand()
|
||||
{
|
||||
return getDeviceBrandLabel($this->details['config_device_brand']);
|
||||
}
|
||||
|
||||
public function getDeviceModel()
|
||||
{
|
||||
return $this->details['config_device_model'];
|
||||
}
|
||||
|
||||
public function getOperatingSystemCode()
|
||||
{
|
||||
return $this->details['config_os'];
|
||||
}
|
||||
|
||||
public function getOperatingSystem()
|
||||
{
|
||||
return getOsFullName($this->details['config_os'] . ";" . $this->details['config_os_version']);
|
||||
}
|
||||
|
||||
public function getOperatingSystemName()
|
||||
{
|
||||
return getOsFullName($this->details['config_os']);
|
||||
}
|
||||
|
||||
public function getOperatingSystemVersion()
|
||||
{
|
||||
return $this->details['config_os_version'];
|
||||
}
|
||||
|
||||
public function getOperatingSystemIcon()
|
||||
{
|
||||
return getOsLogo($this->details['config_os']);
|
||||
}
|
||||
|
||||
public function getBrowserEngineDescription()
|
||||
{
|
||||
return getBrowserEngineName($this->getBrowserEngine());
|
||||
}
|
||||
|
||||
public function getBrowserEngine()
|
||||
{
|
||||
return $this->details['config_browser_engine'];
|
||||
}
|
||||
|
||||
public function getBrowserCode()
|
||||
{
|
||||
return $this->details['config_browser_name'];
|
||||
}
|
||||
|
||||
public function getBrowserVersion()
|
||||
{
|
||||
return $this->details['config_browser_version'];
|
||||
}
|
||||
|
||||
public function getBrowser()
|
||||
{
|
||||
return getBrowserNameWithVersion($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
|
||||
}
|
||||
|
||||
public function getBrowserName()
|
||||
{
|
||||
return getBrowserName($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
|
||||
}
|
||||
|
||||
public function getBrowserIcon()
|
||||
{
|
||||
return getBrowserLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -10,22 +10,24 @@
|
|||
namespace Piwik\Plugins\DevicesDetection;
|
||||
|
||||
use Piwik\Piwik;
|
||||
use DeviceDetector;
|
||||
use DeviceDetector\Parser\OperatingSystem AS OperatingSystemParser;
|
||||
use DeviceDetector\Parser\Device\DeviceParserAbstract AS DeviceParser;
|
||||
use DeviceDetector\Parser\Client\Browser AS BrowserParser;
|
||||
|
||||
function getBrandLogo($label)
|
||||
{
|
||||
$label = str_replace(" ", "_", $label);
|
||||
$label = preg_replace("/[^a-z0-9_-]+/i", "_", $label);
|
||||
$path = dirname(__FILE__) . '/images/brand/' . $label . '.ico';
|
||||
if (file_exists($path)) {
|
||||
return 'plugins/DevicesDetection/images/brand/' . $label . '.ico';
|
||||
} else {
|
||||
return 'plugins/DevicesDetection/images/brand/unknown.ico';
|
||||
return 'plugins/DevicesDetection/images/brand/Unknown.ico';
|
||||
}
|
||||
}
|
||||
|
||||
function getBrowserFamilyFullNameExtended($label)
|
||||
function getBrowserFamilyFullName($label)
|
||||
{
|
||||
foreach (DeviceDetector::$browserFamilies as $name => $family) {
|
||||
foreach (BrowserParser::getAvailableBrowserFamilies() as $name => $family) {
|
||||
if (in_array($label, $family)) {
|
||||
return $name;
|
||||
}
|
||||
|
|
@ -33,20 +35,33 @@ function getBrowserFamilyFullNameExtended($label)
|
|||
return Piwik::translate('General_Unknown');
|
||||
}
|
||||
|
||||
function getBrowserFamilyLogoExtended($label)
|
||||
function getBrowserFamilyLogo($label)
|
||||
{
|
||||
if (array_key_exists($label, DeviceDetector::$browserFamilies)) {
|
||||
return getBrowserLogoExtended(DeviceDetector::$browserFamilies[$label][0]);
|
||||
$browserFamilies = BrowserParser::getAvailableBrowserFamilies();
|
||||
if (!empty($label) && array_key_exists($label, $browserFamilies)) {
|
||||
return getBrowserLogo($browserFamilies[$label][0]);
|
||||
}
|
||||
return getBrowserLogoExtended($label);
|
||||
return getBrowserLogo($label);
|
||||
}
|
||||
|
||||
function getBrowserNameExtended($label)
|
||||
function getBrowserNameWithVersion($label)
|
||||
{
|
||||
$short = substr($label, 0, 2);
|
||||
$ver = substr($label, 3, 10);
|
||||
if (array_key_exists($short, DeviceDetector::$browsers)) {
|
||||
return trim(ucfirst(DeviceDetector::$browsers[$short]) . ' ' . $ver);
|
||||
$browsers = BrowserParser::getAvailableBrowsers();
|
||||
if ($short && array_key_exists($short, $browsers)) {
|
||||
return trim(ucfirst($browsers[$short]) . ' ' . $ver);
|
||||
} else {
|
||||
return Piwik::translate('General_Unknown');
|
||||
}
|
||||
}
|
||||
|
||||
function getBrowserName($label)
|
||||
{
|
||||
$short = substr($label, 0, 2);
|
||||
$browsers = BrowserParser::getAvailableBrowsers();
|
||||
if ($short && array_key_exists($short, $browsers)) {
|
||||
return trim(ucfirst($browsers[$short]));
|
||||
} else {
|
||||
return Piwik::translate('General_Unknown');
|
||||
}
|
||||
|
|
@ -63,35 +78,44 @@ function getBrowserNameExtended($label)
|
|||
*
|
||||
* @return string path to image
|
||||
*/
|
||||
function getBrowserLogoExtended($short)
|
||||
function getBrowserLogo($short)
|
||||
{
|
||||
$path = 'plugins/UserSettings/images/browsers/%s.gif';
|
||||
$path = 'plugins/DevicesDetection/images/browsers/%s.gif';
|
||||
|
||||
// If name is given instead of short code, try to find matching shortcode
|
||||
if (strlen($short) > 2) {
|
||||
|
||||
if (in_array($short, DeviceDetector::$browsers)) {
|
||||
$flippedBrowsers = array_flip(DeviceDetector::$browsers);
|
||||
if (in_array($short, BrowserParser::getAvailableBrowsers())) {
|
||||
$flippedBrowsers = array_flip(BrowserParser::getAvailableBrowsers());
|
||||
$short = $flippedBrowsers[$short];
|
||||
} else {
|
||||
$short = substr($short, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
$family = getBrowserFamilyFullNameExtended($short);
|
||||
$family = getBrowserFamilyFullName($short);
|
||||
|
||||
$browserFamilies = BrowserParser::getAvailableBrowserFamilies();
|
||||
|
||||
if (!empty($short) &&
|
||||
array_key_exists($short, BrowserParser::getAvailableBrowsers()) &&
|
||||
file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $short))) {
|
||||
|
||||
if (array_key_exists($short, DeviceDetector::$browsers) && file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $short))) {
|
||||
return sprintf($path, $short);
|
||||
} elseif (array_key_exists($family, DeviceDetector::$browserFamilies) && file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, DeviceDetector::$browserFamilies[$family][0]))) {
|
||||
return sprintf($path, DeviceDetector::$browserFamilies[$family][0]);
|
||||
|
||||
} elseif (!empty($short) &&
|
||||
array_key_exists($family, $browserFamilies) &&
|
||||
file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $browserFamilies[$family][0]))) {
|
||||
|
||||
return sprintf($path, $browserFamilies[$family][0]);
|
||||
}
|
||||
return sprintf($path, 'UNK');
|
||||
}
|
||||
|
||||
function getDeviceBrandLabel($label)
|
||||
{
|
||||
if (array_key_exists($label, DeviceDetector::$deviceBrands)) {
|
||||
return ucfirst(DeviceDetector::$deviceBrands[$label]);
|
||||
if (array_key_exists($label, DeviceParser::$deviceBrands)) {
|
||||
return ucfirst(DeviceParser::$deviceBrands[$label]);
|
||||
} else {
|
||||
return Piwik::translate('General_Unknown');
|
||||
}
|
||||
|
|
@ -103,15 +127,23 @@ function getDeviceTypeLabel($label)
|
|||
'desktop' => 'General_Desktop',
|
||||
'smartphone' => 'DevicesDetection_Smartphone',
|
||||
'tablet' => 'DevicesDetection_Tablet',
|
||||
'phablet' => 'DevicesDetection_Phablet',
|
||||
'feature phone' => 'DevicesDetection_FeaturePhone',
|
||||
'console' => 'DevicesDetection_Console',
|
||||
'tv' => 'DevicesDetection_TV',
|
||||
'car browser' => 'DevicesDetection_CarBbrowser',
|
||||
'car browser' => 'DevicesDetection_CarBrowser',
|
||||
'smart display' => 'DevicesDetection_SmartDisplay',
|
||||
'camera' => 'DevicesDetection_Camera'
|
||||
'camera' => 'DevicesDetection_Camera',
|
||||
'portable media player' => 'DevicesDetection_PortableMediaPlayer',
|
||||
);
|
||||
if (isset(DeviceDetector::$deviceTypes[$label]) && isset($translations[DeviceDetector::$deviceTypes[$label]])) {
|
||||
return Piwik::translate($translations[DeviceDetector::$deviceTypes[$label]]);
|
||||
|
||||
$deviceTypes = DeviceParser::getAvailableDeviceTypes();
|
||||
|
||||
if (is_numeric($label) &&
|
||||
in_array($label, $deviceTypes) &&
|
||||
isset($translations[array_search($label, $deviceTypes)])) {
|
||||
|
||||
return Piwik::translate($translations[array_search($label, $deviceTypes)]);
|
||||
} else if (isset($translations[$label])) {
|
||||
return Piwik::translate($translations[$label]);
|
||||
} else {
|
||||
|
|
@ -121,8 +153,8 @@ function getDeviceTypeLabel($label)
|
|||
|
||||
function getDeviceTypeLogo($label)
|
||||
{
|
||||
if (is_numeric($label) && isset(DeviceDetector::$deviceTypes[$label])) {
|
||||
$label = DeviceDetector::$deviceTypes[$label];
|
||||
if (is_numeric($label) && in_array($label, DeviceParser::getAvailableDeviceTypes())) {
|
||||
$label = array_search($label, DeviceParser::getAvailableDeviceTypes());
|
||||
}
|
||||
|
||||
$label = strtolower($label);
|
||||
|
|
@ -148,35 +180,59 @@ function getDeviceTypeLogo($label)
|
|||
|
||||
function getModelName($label)
|
||||
{
|
||||
if (!$label) {
|
||||
return Piwik::translate('General_Unknown');
|
||||
if (strpos($label, ';') !== false) {
|
||||
list($brand, $model) = explode(';', $label, 2);
|
||||
} else {
|
||||
$brand = null;
|
||||
$model = $label;
|
||||
}
|
||||
return $label;
|
||||
if (!$model) {
|
||||
$model = Piwik::translate('General_Unknown');
|
||||
}
|
||||
if (!$brand) {
|
||||
return $model;
|
||||
}
|
||||
return getDeviceBrandLabel($brand) . ' - ' . $model;
|
||||
}
|
||||
|
||||
function getOSFamilyFullNameExtended($label)
|
||||
function getOSFamilyFullName($label)
|
||||
{
|
||||
$label = DeviceDetector::getOsFamily($label);
|
||||
if($label !== false) {
|
||||
if ($label == \Piwik\Tracker\Settings::OS_BOT) {
|
||||
return 'Bot';
|
||||
}
|
||||
$label = OperatingSystemParser::getOsFamily(_mapLegacyOsShortCodes($label));
|
||||
|
||||
if ($label == 'unknown') {
|
||||
$label = Piwik::translate('General_Unknown');
|
||||
} else if ($label == 'Gaming Console') {
|
||||
$label = Piwik::translate('DevicesDetection_Console');
|
||||
}
|
||||
|
||||
if ($label !== false) {
|
||||
return $label;
|
||||
}
|
||||
return Piwik::translate('General_Unknown');
|
||||
}
|
||||
|
||||
function getOsFamilyLogoExtended($label)
|
||||
function getOsFamilyLogo($label)
|
||||
{
|
||||
if (array_key_exists($label, DeviceDetector::$osFamilies)) {
|
||||
return getOsLogoExtended(DeviceDetector::$osFamilies[$label][0]);
|
||||
$label = _mapLegacyOsShortCodes($label);
|
||||
$osFamilies = OperatingSystemParser::getAvailableOperatingSystemFamilies();
|
||||
if (!empty($label) && array_key_exists($label, $osFamilies)) {
|
||||
return getOsLogo($osFamilies[$label][0]);
|
||||
}
|
||||
return getOsLogoExtended($label);
|
||||
return getOsLogo($label);
|
||||
}
|
||||
|
||||
function getOsFullNameExtended($label)
|
||||
function getOsFullName($label)
|
||||
{
|
||||
if (substr($label, 0, 3) == \Piwik\Tracker\Settings::OS_BOT) {
|
||||
return 'Bot';
|
||||
}
|
||||
if (!empty($label) && $label != ";") {
|
||||
$os = substr($label, 0, 3);
|
||||
$ver = substr($label, 4, 15);
|
||||
$name = DeviceDetector::getOsNameFromId($os, $ver);
|
||||
$name = OperatingSystemParser::getNameFromId(_mapLegacyOsShortCodes($os), $ver);
|
||||
if (!empty($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
|
@ -184,37 +240,117 @@ function getOsFullNameExtended($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
|
||||
'W10' => 'WIN',
|
||||
'W2K' => 'WIN',
|
||||
'W31' => 'WIN',
|
||||
'WI7' => 'WIN',
|
||||
'WI8' => 'WIN',
|
||||
'W81' => 'WIN',
|
||||
'W95' => 'WIN',
|
||||
'W98' => 'WIN',
|
||||
'WME' => 'WIN',
|
||||
'WNT' => 'WIN',
|
||||
'WS3' => 'WIN',
|
||||
'WVI' => 'WIN',
|
||||
'WXP' => 'WIN',
|
||||
//'VMS' => '', // OpenVMS => ??
|
||||
);
|
||||
return ($shortCode && array_key_exists($shortCode, $legacyShortCodes)) ? $legacyShortCodes[$shortCode] : $shortCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the logo for the given OS
|
||||
*
|
||||
* First try to find a logo for the given short code
|
||||
* If none can be found try to find a logo for the os family
|
||||
* Return unkown logo otherwise
|
||||
* Return unknown logo otherwise
|
||||
*
|
||||
* @param string $short Shortcode or name of OS
|
||||
*
|
||||
* @return string path to image
|
||||
*/
|
||||
function getOsLogoExtended($short)
|
||||
function getOsLogo($short)
|
||||
{
|
||||
$path = 'plugins/UserSettings/images/os/%s.gif';
|
||||
$path = 'plugins/DevicesDetection/images/os/%s.gif';
|
||||
|
||||
$short = _mapLegacyOsShortCodes($short);
|
||||
|
||||
// If name is given instead of short code, try to find matching shortcode
|
||||
if (strlen($short) > 3) {
|
||||
|
||||
if (array_key_exists($short, DeviceDetector::$osShorts)) {
|
||||
$short = DeviceDetector::$osShorts[$short];
|
||||
if (in_array($short, OperatingSystemParser::getAvailableOperatingSystems())) {
|
||||
$short = array_search($short, OperatingSystemParser::getAvailableOperatingSystems());
|
||||
} else {
|
||||
$short = substr($short, 0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
$family = getOsFamilyFullNameExtended($short);
|
||||
$family = getOSFamilyFullName($short);
|
||||
$osFamilies = OperatingSystemParser::getAvailableOperatingSystemFamilies();
|
||||
|
||||
if (!empty($short) &&
|
||||
array_key_exists($short, OperatingSystemParser::getAvailableOperatingSystems()) &&
|
||||
file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $short))) {
|
||||
|
||||
if (in_array($short, DeviceDetector::$osShorts) && file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $short))) {
|
||||
return sprintf($path, $short);
|
||||
} elseif (array_key_exists($family, DeviceDetector::$osFamilies) && file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, DeviceDetector::$osFamilies[$family][0]))) {
|
||||
return sprintf($path, DeviceDetector::$osFamilies[$family][0]);
|
||||
|
||||
} elseif (!empty($family) &&
|
||||
array_key_exists($family, $osFamilies) &&
|
||||
file_exists(PIWIK_INCLUDE_PATH.'/'.sprintf($path, $osFamilies[$family][0]))) {
|
||||
|
||||
return sprintf($path, $osFamilies[$family][0]);
|
||||
}
|
||||
return sprintf($path, 'UNK');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the display name for a browser engine
|
||||
*
|
||||
* @param $engineName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getBrowserEngineName($engineName) {
|
||||
/*
|
||||
* Map leagcy types to engines
|
||||
*/
|
||||
$oldTypeMapping = array(
|
||||
'ie' => 'Trident',
|
||||
'gecko' => 'Gecko',
|
||||
'khtml' => 'KHTML',
|
||||
'webkit' => 'WebKit',
|
||||
'opera' => 'Presto',
|
||||
'unknown' => ''
|
||||
);
|
||||
if (array_key_exists($engineName, $oldTypeMapping)) {
|
||||
$engineName = $oldTypeMapping[$engineName];
|
||||
}
|
||||
|
||||
$displayNames = array(
|
||||
'Trident' => 'Trident (IE)',
|
||||
'Gecko' => 'Gecko (Firefox)',
|
||||
'KHTML' => 'KHTML (Konqueror)',
|
||||
'Presto' => 'Presto (Opera)',
|
||||
'WebKit' => 'WebKit (Safari, Chrome)',
|
||||
'Blink' => 'Blink (Chrome, Opera)'
|
||||
);
|
||||
|
||||
if (!empty($engineName)) {
|
||||
if (!empty($displayNames[$engineName])) {
|
||||
return $displayNames[$engineName];
|
||||
}
|
||||
return $engineName;
|
||||
}
|
||||
return Piwik::translate('General_Unknown');
|
||||
}
|
||||
|
|
|
|||
BIN
www/analytics/plugins/DevicesDetection/images/brand/3Q.ico
Normal file
|
After Width: | Height: | Size: 577 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/BBK.ico
Normal file
|
After Width: | Height: | Size: 263 B |
|
After Width: | Height: | Size: 799 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Celkon.ico
Normal file
|
After Width: | Height: | Size: 332 B |
|
After Width: | Height: | Size: 808 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Compaq.ico
Normal file
|
After Width: | Height: | Size: 453 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/ConCorde.ico
Normal file
|
After Width: | Height: | Size: 602 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Coolpad.ico
Normal file
|
After Width: | Height: | Size: 485 B |
|
After Width: | Height: | Size: 566 B |
|
After Width: | Height: | Size: 3.2 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Danew.ico
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Easypix.ico
Normal file
|
After Width: | Height: | Size: 881 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Evertek.ico
Normal file
|
After Width: | Height: | Size: 571 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Fujitsu.ico
Normal file
|
After Width: | Height: | Size: 298 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Gigabyte.ico
Normal file
|
After Width: | Height: | Size: 343 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Gigaset.ico
Normal file
|
After Width: | Height: | Size: 354 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Gionee.ico
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Hyundai.ico
Normal file
|
After Width: | Height: | Size: 407 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Le_Pan.ico
Normal file
|
After Width: | Height: | Size: 408 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/MSI.ico
Normal file
|
After Width: | Height: | Size: 377 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Nikon.ico
Normal file
|
After Width: | Height: | Size: 607 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/OnePlus.ico
Normal file
|
After Width: | Height: | Size: 181 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Quechua.ico
Normal file
|
After Width: | Height: | Size: 296 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/SFR.ico
Normal file
|
After Width: | Height: | Size: 686 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Sencor.ico
Normal file
|
After Width: | Height: | Size: 885 B |
|
After Width: | Height: | Size: 691 B |
|
After Width: | Height: | Size: 437 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Tolino.ico
Normal file
|
After Width: | Height: | Size: 321 B |
|
After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Wiko.ico
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Wolder.ico
Normal file
|
After Width: | Height: | Size: 513 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Woxter.ico
Normal file
|
After Width: | Height: | Size: 775 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Yarvik.ico
Normal file
|
After Width: | Height: | Size: 439 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/Zopo.ico
Normal file
|
After Width: | Height: | Size: 397 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/bq.ico
Normal file
|
After Width: | Height: | Size: 497 B |
BIN
www/analytics/plugins/DevicesDetection/images/brand/iBerry.ico
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/brand/teXet.ico
Normal file
|
After Width: | Height: | Size: 643 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/36.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AA.gif
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AB.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AG.gif
Normal file
|
After Width: | Height: | Size: 351 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AM.gif
Normal file
|
After Width: | Height: | Size: 198 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AN.gif
Normal file
|
After Width: | Height: | Size: 144 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AR.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AV.gif
Normal file
|
After Width: | Height: | Size: 151 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/AW.gif
Normal file
|
After Width: | Height: | Size: 574 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/B2.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BB.gif
Normal file
|
After Width: | Height: | Size: 576 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BD.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BE.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BJ.gif
Normal file
|
After Width: | Height: | Size: 949 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BP.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BS.gif
Normal file
|
After Width: | Height: | Size: 980 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/BX.gif
Normal file
|
After Width: | Height: | Size: 522 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CA.gif
Normal file
|
After Width: | Height: | Size: 573 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CC.gif
Normal file
|
After Width: | Height: | Size: 435 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CD.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CF.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CH.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CK.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CM.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CN.gif
Normal file
|
After Width: | Height: | Size: 998 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CO.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CP.gif
Normal file
|
After Width: | Height: | Size: 998 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CR.gif
Normal file
|
After Width: | Height: | Size: 1,007 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CS.gif
Normal file
|
After Width: | Height: | Size: 549 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/CX.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/DE.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/DF.gif
Normal file
|
After Width: | Height: | Size: 545 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/DI.gif
Normal file
|
After Width: | Height: | Size: 1 KiB |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/EL.gif
Normal file
|
After Width: | Height: | Size: 90 B |
BIN
www/analytics/plugins/DevicesDetection/images/browsers/EP.gif
Normal file
|
After Width: | Height: | Size: 316 B |