update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
9abe039dc8
commit
47263617c5
302 changed files with 418860 additions and 226988 deletions
|
|
@ -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
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
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
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
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
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
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
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"));
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue