diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-06-11 07:04:53 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-06-11 07:04:53 +0400 |
commit | 4f2e01d20a8027cf545613d883e4ef22267c1cc1 (patch) | |
tree | f065435c1eed3716d834f30886ceb95140214116 /plugins/DevicesDetection/Columns/Base.php | |
parent | fca3bf825184cf0ddc3b9edcac0d90c95802afbf (diff) |
starting to refactor reports into classes, also refactored some more dimensions which is still not 100% working and needs more work
Diffstat (limited to 'plugins/DevicesDetection/Columns/Base.php')
-rw-r--r-- | plugins/DevicesDetection/Columns/Base.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/plugins/DevicesDetection/Columns/Base.php b/plugins/DevicesDetection/Columns/Base.php new file mode 100644 index 0000000000..ffe9d45bdb --- /dev/null +++ b/plugins/DevicesDetection/Columns/Base.php @@ -0,0 +1,38 @@ +<?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\Columns; + +use \DeviceDetector; +use Piwik\CacheFile; +use Piwik\Plugin\VisitDimension; + +abstract class Base extends VisitDimension +{ + private static $uaParser = array(); + + /** + * @param string $userAgent + * @return DeviceDetector + */ + public function getUAParser($userAgent) + { + $key = md5($userAgent); + + if (!array_key_exists($key, self::$uaParser)) { + + $UAParser = new \DeviceDetector($userAgent); + $UAParser->setCache(new CacheFile('tracker', 86400)); + $UAParser->parse(); + + self::$uaParser[$key] = $UAParser; + } + + return self::$uaParser[$key]; + } +} |