123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class PiwikAnalyticsPlugin extends Plugin
- {
-
- public $piwikroot = null;
-
- public $piwikId = null;
-
- function __construct($root=null, $id=null)
- {
- $this->piwikroot = $root;
- $this->piwikId = $id;
- parent::__construct();
- }
-
- function onEndShowScripts($action)
- {
-
-
-
-
-
-
-
-
-
- $piwikUrl = '//' . $this->piwikroot . 'piwik.js';
- $piwikCode = <<<ENDOFPIWIK
- try {
- var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$this->piwikroot}" : "http://{$this->piwikroot}");
- var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
- piwikTracker.trackPageView();
- piwikTracker.enableLinkTracking();
- } catch( err ) {}
- ENDOFPIWIK;
-
- $action->element('script', array('type' => 'text/javascript', 'src' => $piwikUrl), ' ');
- $action->inlineScript($piwikCode);
- return true;
- }
- function onPluginVersion(&$versions)
- {
- $versions[] = array('name' => 'PiwikAnalytics',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Tobias Diekershoff, Evan Prodromou',
- 'homepage' => 'http://status.net/wiki/Plugin:Piwik',
- 'rawdescription' =>
-
- _m('Use <a href="http://piwik.org/">Piwik</a> Open Source web analytics software.'));
- return true;
- }
- }
|