update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
37
www/analytics/core/DeviceDetectorFactory.php
Normal file
37
www/analytics/core/DeviceDetectorFactory.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
*/
|
||||
namespace Piwik;
|
||||
|
||||
use DeviceDetector\DeviceDetector;
|
||||
|
||||
class DeviceDetectorFactory
|
||||
{
|
||||
protected static $deviceDetectorInstances = array();
|
||||
|
||||
/**
|
||||
* Returns a Singleton instance of DeviceDetector for the given user agent
|
||||
* @param string $userAgent
|
||||
* @return DeviceDetector
|
||||
*/
|
||||
public static function getInstance($userAgent)
|
||||
{
|
||||
if (array_key_exists($userAgent, self::$deviceDetectorInstances)) {
|
||||
return self::$deviceDetectorInstances[$userAgent];
|
||||
}
|
||||
|
||||
$deviceDetector = new DeviceDetector($userAgent);
|
||||
$deviceDetector->discardBotInformation();
|
||||
$deviceDetector->setCache(new DeviceDetectorCache(86400));
|
||||
$deviceDetector->parse();
|
||||
|
||||
self::$deviceDetectorInstances[$userAgent] = $deviceDetector;
|
||||
|
||||
return $deviceDetector;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue