Skip to content
Extraits de code Groupes Projets
functions.php 4 ko
Newer Older
  • Learn to ignore specific revisions
  • <?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
    
    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';
        }
    }
    
    
    function getBrowserFamilyFullNameExtended($label)
    
    {
        foreach (UserAgentParserEnhanced::$browserFamilies as $name => $family) {
            if (in_array($label, $family)) {
                return $name;
            }
        }
    
        return Piwik::translate('General_Unknown');
    
    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;
    }
    
    
    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');
    
    function getBrowserLogoExtended($label)
    
        $familyName = getBrowserFamilyFullNameExtended($short);
        $path = getBrowserFamilyLogoExtended($familyName);
    
    {
        if (array_key_exists($label, UserAgentParserEnhanced::$deviceBrands)) {
            return ucfirst(UserAgentParserEnhanced::$deviceBrands[$label]);
        } else {
    
            return Piwik::translate('General_Unknown');
    
    {
        if (isset(UserAgentParserEnhanced::$deviceTypes[$label])) {
    
            return UserAgentParserEnhanced::$deviceTypes[$label];
    
            return Piwik::translate('General_Unknown');
    
            "Desktop"       => "normal.gif",
            "Smartphone"    => "smartphone.png",
            "Tablet"        => "tablet.png",
            "Tv"            => "tv.png",
    
            "Console"       => "console.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's avatar
    mattab a validé
        if (!$label) {
    
            return Piwik::translate('General_Unknown');
    
    mattab's avatar
    mattab a validé
        }
        return $label;
    
    function getOSFamilyFullNameExtended($label)
    
    {
        foreach (UserAgentParserEnhanced::$osFamilies as $name => $family) {
            if (in_array($label, $family)) {
                return $name;
            }
        }
    
        return Piwik::translate('General_Unknown');
    
    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's avatar
    mattab a validé
        if (!empty($label) && $label != ";") {
    
            $os = substr($label, 0, 3);
            $ver = substr($label, 4, 15);
    
    mattab's avatar
    mattab a validé
            $name = UserAgentParserEnhanced::getOsNameFromId($os, $ver);
    
            if (!empty($name)) {
    
    mattab's avatar
    mattab a validé
                return $name;
    
        return Piwik::translate('General_Unknown');
    
    mattab's avatar
    mattab a validé
    
    
        $familyName = getOsFamilyFullNameExtended($short);
        $path = getOsFamilyLogoExtended($familyName);