1 |
45059
|
argiro.kok
|
<?php
|
2 |
|
|
|
3 |
|
|
defined('_JEXEC') or die('Access denied');
|
4 |
|
|
|
5 |
|
|
jimport('joomla.application.component.model');
|
6 |
|
|
|
7 |
|
|
require_once(dirname(__FILE__) . DS . 'piwik' . DS . 'PiwikTracker.php');
|
8 |
|
|
|
9 |
|
|
// This model is used for Piwik logging when no frontend is available.
|
10 |
|
|
class OpenAireModelPiwik extends JModelItem {
|
11 |
|
|
const MAX_DATA = 200;
|
12 |
|
|
const PAGE = 'page';
|
13 |
|
|
|
14 |
|
|
private $tracker;
|
15 |
|
|
|
16 |
|
|
// Construct a new OpenAireModelClaim.
|
17 |
|
|
// $configuration the configuration to use
|
18 |
|
|
public function __construct($configuration) {
|
19 |
|
|
parent :: __construct($configuration);
|
20 |
|
|
$parameters = JComponentHelper :: getParams('com_openaire');
|
21 |
|
|
$this -> tracker = new PiwikTracker($parameters -> get('piwikSiteId'), $parameters -> get('piwikUrl'));
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
// Track a page view using Piwik.
|
25 |
|
|
// $title the page title to track
|
26 |
|
|
// $data the data to track
|
27 |
|
|
public function track($title, $data) {
|
28 |
|
|
$this -> tracker -> setCustomVariable(1, 'user', JFactory :: getUser() -> email, self :: PAGE);
|
29 |
|
|
$this -> tracker -> setCustomVariable(2, 'session', JFactory :: getSession() -> getId(), self :: PAGE);
|
30 |
|
|
$this -> tracker -> setCustomVariable(3, 'data', substr($data, 0, self :: MAX_DATA), self :: PAGE);
|
31 |
|
|
$this -> tracker -> setCustomVariable(4, 'data', substr($data, self :: MAX_DATA, 2 * self :: MAX_DATA), self :: PAGE);
|
32 |
|
|
$this -> tracker -> setCustomVariable(5, 'data', substr($data, 2 * self :: MAX_DATA, 3 * self :: MAX_DATA), self :: PAGE);
|
33 |
|
|
$this -> tracker -> doTrackPageView($title);
|
34 |
|
|
}
|
35 |
|
|
}
|