Newer
Older
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik_Plugins
mattab
a validé
* @package DevicesDetection
*/
mattab
a validé
namespace Piwik\Plugins\DevicesDetection;
use Piwik\Piwik;
mattab
a validé
use UserAgentParserEnhanced;
function getBrandLogo($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';
}
}
mattab
a validé
function getBrowserFamilyFullNameExtended($label)
{
foreach (UserAgentParserEnhanced::$browserFamilies as $name => $family) {
if (in_array($label, $family)) {
return $name;
}
}
return Piwik::translate('General_Unknown');
}
mattab
a validé
function getBrowserFamilyLogoExtended($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$browserFamilies)) {
$path = 'plugins/UserSettings/images/browsers/' . UserAgentParserEnhanced::$browserFamilies[$label][0] . '.gif';
} else {
$path = 'plugins/UserSettings/images/browsers/UNK.gif';
}
return $path;
}
mattab
a validé
function getBrowserNameExtended($label)
{
$short = substr($label, 0, 2);
$ver = substr($label, 3, 10);
if (array_key_exists($short, UserAgentParserEnhanced::$browsers)) {
return trim(ucfirst(UserAgentParserEnhanced::$browsers[$short]) . ' ' . $ver);
} else {
return Piwik::translate('General_Unknown');
}
}
mattab
a validé
function getBrowserLogoExtended($label)
{
$short = substr($label, 0, 2);
mattab
a validé
$familyName = getBrowserFamilyFullNameExtended($short);
$path = getBrowserFamilyLogoExtended($familyName);
return $path;
}
mattab
a validé
function getDeviceBrandLabel($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$deviceBrands)) {
return ucfirst(UserAgentParserEnhanced::$deviceBrands[$label]);
} else {
return Piwik::translate('General_Unknown');
}
}
mattab
a validé
function getDeviceTypeLabel($label)
{
if (isset(UserAgentParserEnhanced::$deviceTypes[$label])) {
return UserAgentParserEnhanced::$deviceTypes[$label];
} else {
return Piwik::translate('General_Unknown');
}
}
mattab
a validé
function getDeviceTypeLogo($label)
{
$deviceTypeLogos = Array(
"Desktop" => "normal.gif",
"Smartphone" => "smartphone.png",
"Tablet" => "tablet.png",
"Tv" => "tv.png",
"Feature phone" => "mobile.gif",
if (!array_key_exists($label, $deviceTypeLogos) || $label == "Unknown") {
$label = 'unknown.gif';
} else {
$label = $deviceTypeLogos[$label];
}
$path = 'plugins/DevicesDetection/images/screens/' . $label;
return $path;
}
mattab
a validé
function getModelName($label)
{
return Piwik::translate('General_Unknown');
}
mattab
a validé
function getOSFamilyFullNameExtended($label)
{
foreach (UserAgentParserEnhanced::$osFamilies as $name => $family) {
if (in_array($label, $family)) {
return $name;
}
}
return Piwik::translate('General_Unknown');
}
mattab
a validé
function getOsFamilyLogoExtended($label)
{
if (array_key_exists($label, UserAgentParserEnhanced::$osFamilies)) {
$path = 'plugins/UserSettings/images/os/' . UserAgentParserEnhanced::$osFamilies[$label][0] . ".gif";
} else {
$path = 'plugins/UserSettings/images/os/UNK.gif';
}
return $path;
}
mattab
a validé
function getOsFullNameExtended($label)
{
$os = substr($label, 0, 3);
$ver = substr($label, 4, 15);
}
}
return Piwik::translate('General_Unknown');
}
mattab
a validé
function getOsLogoExtended($label)
{
$short = substr($label, 0, 3);
mattab
a validé
$familyName = getOsFamilyFullNameExtended($short);
$path = getOsFamilyLogoExtended($familyName);
return $path;
}