add icons for Character groups

This commit is contained in:
coderkun 2014-04-29 14:18:04 +02:00
commit 2d9a41a5fe
3461 changed files with 594457 additions and 0 deletions

View file

@ -0,0 +1,153 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\DevicesDetection;
use Piwik\Archive;
use Piwik\DataTable;
use Piwik\Metrics;
use Piwik\Piwik;
/**
* The DevicesDetection API lets you access reports on your visitors devices, brands, models, Operating system, Browsers.
* @method static \Piwik\Plugins\DevicesDetection\API getInstance()
*/
class API extends \Piwik\Plugin\API
{
/**
* @param string $name
* @param int $idSite
* @param string $period
* @param string $date
* @param string $segment
* @return DataTable
*/
protected function getDataTable($name, $idSite, $period, $date, $segment)
{
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;
}
/**
* Gets datatable displaying number of visits by device type (eg. desktop, smartphone, tablet)
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getType($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_types', $idSite, $period, $date, $segment);
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getDeviceTypeLogo'));
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceTypeLabel'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by device manufacturer name
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getBrand($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_brands', $idSite, $period, $date, $segment);
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getDeviceBrandLabel'));
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'logo', __NAMESPACE__ . '\getBrandLogo'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by device model
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getModel($idSite, $period, $date, $segment = false)
{
$dataTable = $this->getDataTable('DevicesDetection_models', $idSite, $period, $date, $segment);
$dataTable->filter('ColumnCallbackReplace', array('label', __NAMESPACE__ . '\getModelName'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by OS family (eg. Windows, Android, Linux)
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
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'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by OS version (eg. Android 4.0, Windows 7)
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
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'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by Browser family (eg. Firefox, InternetExplorer)
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getBrowserFamilies($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'));
return $dataTable;
}
/**
* Gets datatable displaying number of visits by Browser version (eg. Firefox 20, Safari 6.0)
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
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'));
return $dataTable;
}
}

View file

@ -0,0 +1,67 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\DevicesDetection;
use Piwik\Metrics;
class Archiver extends \Piwik\Plugin\Archiver
{
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_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 OS_FIELD = "config_os";
const OS_VERSION_FIELD = "CONCAT(log_visit.config_os, ';', log_visit.config_os_version)";
const BROWSER_FIELD = "config_browser_name";
const BROWSER_VERSION_DIMENSION = "CONCAT(log_visit.config_browser_name, ';', log_visit.config_browser_version)";
public function aggregateDayReport()
{
$this->aggregateByLabel(self::DEVICE_TYPE_FIELD, self::DEVICE_TYPE_RECORD_NAME);
$this->aggregateByLabel(self::DEVICE_BRAND_FIELD, self::DEVICE_BRAND_RECORD_NAME);
$this->aggregateByLabel(self::DEVICE_MODEL_FIELD, self::DEVICE_MODEL_RECORD_NAME);
$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_VERSION_DIMENSION, self::BROWSER_VERSION_RECORD_NAME);
}
public function aggregateMultipleReports()
{
$dataTablesToSum = array(
self::DEVICE_TYPE_RECORD_NAME,
self::DEVICE_BRAND_RECORD_NAME,
self::DEVICE_MODEL_RECORD_NAME,
self::OS_RECORD_NAME,
self::OS_VERSION_RECORD_NAME,
self::BROWSER_RECORD_NAME,
self::BROWSER_VERSION_RECORD_NAME
);
foreach ($dataTablesToSum as $dt) {
$this->getProcessor()->aggregateDataTableRecords(
$dt, $this->maximumRows, $this->maximumRows, $columnToSort = "nb_visits");
}
}
private function aggregateByLabel($labelSQL, $recordName)
{
$metrics = $this->getLogAggregator()->getMetricsFromVisitByDimension($labelSQL)->asDataTable();
$report = $metrics->getSerialized($this->maximumRows, null, Metrics::INDEX_NB_VISITS);
$this->getProcessor()->insertBlobRecord($recordName, $report);
}
}

View file

@ -0,0 +1,172 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\DevicesDetection;
use Piwik\Common;
use Piwik\Db;
use Piwik\Piwik;
use Piwik\Plugin\ControllerAdmin;
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 $view->render();
}
public function getType()
{
return $this->renderReport(__FUNCTION__);
}
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()
{
Piwik::checkUserHasSomeAdminAccess();
$view = new View('@DevicesDetection/detection');
$this->setBasicVariablesView($view);
ControllerAdmin::setBasicVariablesAdminView($view);
$userAgent = Common::getRequestVar('ua', $_SERVER['HTTP_USER_AGENT'], 'string');
$parsedUA = DeviceDetector::getInfoFromUserAgent($userAgent);
$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);
return $view->render();
}
public function showList()
{
Piwik::checkUserHasSomeAdminAccess();
$view = new View('@DevicesDetection/list');
$type = Common::getRequestVar('type', 'brands', 'string');
$list = array();
switch ($type) {
case 'brands':
$availableBrands = DeviceDetector::$deviceBrands;
foreach ($availableBrands AS $short => $name) {
if ($name != 'Unknown') {
$list[$name] = getBrandLogo($name);
}
}
break;
case 'browsers':
$availableBrowsers = DeviceDetector::$browsers;
foreach ($availableBrowsers AS $short => $name) {
$list[$name] = getBrowserLogoExtended($short);
}
break;
case 'browserfamilies':
$availableBrowserFamilies = DeviceDetector::$browserFamilies;
foreach ($availableBrowserFamilies AS $name => $browsers) {
$list[$name] = getBrowserFamilyLogoExtended($name);
}
break;
case 'os':
$availableOSs = DeviceDetector::$osShorts;
foreach ($availableOSs AS $name => $short) {
if ($name != 'Bot') {
$list[$name] = getOsLogoExtended($short);
}
}
break;
case 'osfamilies':
$osFamilies = DeviceDetector::$osFamilies;
foreach ($osFamilies AS $name => $oss) {
if ($name != 'Bot') {
$list[$name] = getOsFamilyLogoExtended($name);
}
}
break;
case 'devicetypes':
$deviceTypes = DeviceDetector::$deviceTypes;
foreach ($deviceTypes AS $name) {
$list[$name] = getDeviceTypeLogo($name);
}
break;
}
$view->itemList = $list;
return $view->render();
}
}

View file

@ -0,0 +1,380 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
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
*/
public function getInformation()
{
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'
);
}
/** The set of related reports displayed under the 'Operating Systems' header. */
private $osRelatedReports = null;
private $browserRelatedReports = null;
public function __construct()
{
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')
);
}
protected function getRawMetadataDeviceType()
{
$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
);
}
/**
* @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);
}
}
/**
* 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')
);
}
}

View file

@ -0,0 +1,37 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\DevicesDetection;
use Piwik\Common;
use Piwik\Updater;
use Piwik\Updates;
class Updates_1_14 extends Updates
{
static function getSql()
{
return array(
'ALTER TABLE `' . Common::prefixTable('log_visit') . '`
CHANGE `config_os_version` `config_os_version` VARCHAR( 100 ) DEFAULT NULL,
CHANGE `config_device_type` `config_device_type` VARCHAR( 100 ) DEFAULT NULL' => false,
);
}
static function isMajorUpdate()
{
return true;
}
static function update()
{
Updater::updateDatabase(__FILE__, self::getSql());
}
}

View file

@ -0,0 +1,220 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\DevicesDetection;
use Piwik\Piwik;
use DeviceDetector;
function getBrandLogo($label)
{
$label = str_replace(" ", "_", $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';
}
}
function getBrowserFamilyFullNameExtended($label)
{
foreach (DeviceDetector::$browserFamilies as $name => $family) {
if (in_array($label, $family)) {
return $name;
}
}
return Piwik::translate('General_Unknown');
}
function getBrowserFamilyLogoExtended($label)
{
if (array_key_exists($label, DeviceDetector::$browserFamilies)) {
return getBrowserLogoExtended(DeviceDetector::$browserFamilies[$label][0]);
}
return getBrowserLogoExtended($label);
}
function getBrowserNameExtended($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);
} else {
return Piwik::translate('General_Unknown');
}
}
/**
* Returns the path to the logo for the given browser
*
* First try to find a logo for the given short code
* If none can be found try to find a logo for the browser family
* Return unkown logo otherwise
*
* @param string $short Shortcode or name of browser
*
* @return string path to image
*/
function getBrowserLogoExtended($short)
{
$path = 'plugins/UserSettings/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);
$short = $flippedBrowsers[$short];
} else {
$short = substr($short, 0, 2);
}
}
$family = getBrowserFamilyFullNameExtended($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]);
}
return sprintf($path, 'UNK');
}
function getDeviceBrandLabel($label)
{
if (array_key_exists($label, DeviceDetector::$deviceBrands)) {
return ucfirst(DeviceDetector::$deviceBrands[$label]);
} else {
return Piwik::translate('General_Unknown');
}
}
function getDeviceTypeLabel($label)
{
$translations = array(
'desktop' => 'General_Desktop',
'smartphone' => 'DevicesDetection_Smartphone',
'tablet' => 'DevicesDetection_Tablet',
'feature phone' => 'DevicesDetection_FeaturePhone',
'console' => 'DevicesDetection_Console',
'tv' => 'DevicesDetection_TV',
'car browser' => 'DevicesDetection_CarBbrowser',
'smart display' => 'DevicesDetection_SmartDisplay',
'camera' => 'DevicesDetection_Camera'
);
if (isset(DeviceDetector::$deviceTypes[$label]) && isset($translations[DeviceDetector::$deviceTypes[$label]])) {
return Piwik::translate($translations[DeviceDetector::$deviceTypes[$label]]);
} else if (isset($translations[$label])) {
return Piwik::translate($translations[$label]);
} else {
return Piwik::translate('General_Unknown');
}
}
function getDeviceTypeLogo($label)
{
if (is_numeric($label) && isset(DeviceDetector::$deviceTypes[$label])) {
$label = DeviceDetector::$deviceTypes[$label];
}
$label = strtolower($label);
$deviceTypeLogos = Array(
"desktop" => "normal.gif",
"smartphone" => "smartphone.png",
"tablet" => "tablet.png",
"tv" => "tv.png",
"feature phone" => "mobile.gif",
"console" => "console.gif",
"car browser" => "carbrowser.png",
"camera" => "camera.png");
if (!array_key_exists($label, $deviceTypeLogos)) {
$label = 'unknown.gif';
} else {
$label = $deviceTypeLogos[$label];
}
$path = 'plugins/DevicesDetection/images/screens/' . $label;
return $path;
}
function getModelName($label)
{
if (!$label) {
return Piwik::translate('General_Unknown');
}
return $label;
}
function getOSFamilyFullNameExtended($label)
{
$label = DeviceDetector::getOsFamily($label);
if($label !== false) {
return $label;
}
return Piwik::translate('General_Unknown');
}
function getOsFamilyLogoExtended($label)
{
if (array_key_exists($label, DeviceDetector::$osFamilies)) {
return getOsLogoExtended(DeviceDetector::$osFamilies[$label][0]);
}
return getOsLogoExtended($label);
}
function getOsFullNameExtended($label)
{
if (!empty($label) && $label != ";") {
$os = substr($label, 0, 3);
$ver = substr($label, 4, 15);
$name = DeviceDetector::getOsNameFromId($os, $ver);
if (!empty($name)) {
return $name;
}
}
return Piwik::translate('General_Unknown');
}
/**
* 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
*
* @param string $short Shortcode or name of OS
*
* @return string path to image
*/
function getOsLogoExtended($short)
{
$path = 'plugins/UserSettings/images/os/%s.gif';
// 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];
} else {
$short = substr($short, 0, 3);
}
}
$family = getOsFamilyFullNameExtended($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]);
}
return sprintf($path, 'UNK');
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,016 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 964 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 809 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,012 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 694 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Some files were not shown because too many files have changed in this diff Show more