r35324 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r35323‎ | r35324 | r35325 >
Date:17:18, 25 May 2008
Author:leon
Status:old
Tags:
Comment:
Commiting Piwik extension for isb1009.
http://www.mediawiki.org/wiki/Extension:Piwik_Integration
Modified paths:
  • /trunk/extensions/piwik (added) (history)
  • /trunk/extensions/piwik/Piwik.php (added) (history)
  • /trunk/extensions/piwik/README (added) (history)

Diff [purge]

Index: trunk/extensions/piwik/Piwik.php
@@ -0,0 +1,85 @@
 2+<?php
 3+/**
 4+ * Parser hook extension to add a <randomimage> tag
 5+ *
 6+ * @addtogroup Extensions
 7+ * @author isb1009 <isb1009 at gmail dot com>
 8+ * @copyright © 2008 isb1009
 9+ * @licence GNU General Public Licence 2.0
 10+ */
 11+
 12+
 13+
 14+
 15+if ( !defined( 'MEDIAWIKI' ) ) {
 16+ die( 'This file is a MediaWiki extension, it is not a valid entry point' );
 17+}
 18+
 19+$wgExtensionCredits['other'][] = array(
 20+ 'name' => 'Piwik Integration',
 21+ 'version' => '0.2 Alpha',
 22+ 'author' => 'isb1009',
 23+ 'description' => 'Inserts Piwik script into MediaWiki pages for tracking. Based on Google Analytics Integration by Tim Laqua.',
 24+ 'descriptionurl' => 'piwik-desc',
 25+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Piwik_Integration',
 26+);
 27+
 28+
 29+
 30+$wgHooks['SkinAfterBottomScripts'][] = 'efPiwikHookText';
 31+
 32+$wgPiwikIDSite = "";
 33+$wgPiwikURLpiwikjs = "";
 34+$wgPiwikURLpiwikphp = "";
 35+$wgPiwikIgnoreSysops = true;
 36+$wgPiwikIgnoreBots = true;
 37+
 38+
 39+function efPiwikHookText(&$skin, &$text='') {
 40+ $text .= efAddPiwik();
 41+ return true;
 42+}
 43+
 44+function efAddPiwik() {
 45+ global $wgPiwikIDSite, $wgPiwikURLpiwikjs, $wgPiwikURLpiwikphp, $wgPiwikIgnoreSysops, $wgPiwikIgnoreBots, $wgUser;
 46+ if (!$wgUser->isAllowed('bot') || !$wgPiwikIgnoreBots) {
 47+ if (!$wgUser->isAllowed('protect') || !$wgPiwikIgnoreSysops) {
 48+ if ( !empty($wgPiwikIDSite) AND !empty($wgPiwikURLpiwikjs) AND !empty($wgPiwikURLpiwikphp)) {
 49+ $funcOutput = <<<PIWIK
 50+<!-- Piwik -->
 51+<a href="http://piwik.org" title="Web analytics" onclick="window.open(this.href);return(false);">
 52+<script language="javascript" src="{$wgPiwikURLpiwikjs}" type="text/javascript"></script>
 53+<script type="text/javascript">
 54+<!--
 55+piwik_action_name = '';
 56+piwik_idsite = {$wgPiwikIDSite};
 57+piwik_url = '{$wgPiwikURLpiwikphp}';
 58+piwik_log(piwik_action_name, piwik_idsite, piwik_url);
 59+ if( source.className == "image" ) {
 60+ _pk_link_type = 'link';
 61+ _pk_not_site_hostname = 0;
 62+ }
 63+//-->
 64+</script><object>
 65+<noscript><p>Web analytics <img src="{$wgPiwikURLpiwikphp}" style="border:0" alt="piwik"/></p>
 66+</noscript></object></a>
 67+<!-- /Piwik -->
 68+PIWIK;
 69+ } else {
 70+ $funcOutput = "\n<!-- You need to set the settings for Piwik -->";
 71+ }
 72+ } else {
 73+ $funcOutput = "\n<!-- Piwik tracking is disabled for users with 'protect' rights (i.e., sysops) -->";
 74+ }
 75+ } else {
 76+ $funcOutput = "\n<!-- Piwik tracking is disabled for bots -->";
 77+ }
 78+
 79+ return $funcOutput;
 80+}
 81+
 82+// Alias for efAddPiwik - backwards compatibility.
 83+function addPiwik() {
 84+ return efAddPiwik();
 85+}
 86+?>
Property changes on: trunk/extensions/piwik/Piwik.php
___________________________________________________________________
Added: svn:eol-style
187 + native
Index: trunk/extensions/piwik/README
@@ -0,0 +1,51 @@
 2+MediaWiki Piwik Integration extension
 3+
 4+version 0.2 Alpha
 5+25 May 2008
 6+
 7+This is the README file for the Piwik Integration extension for MediaWiki
 8+software. The extension is only useful if you've got a MediaWiki
 9+installation; it can only be installed by the administrator of the site.
 10+
 11+== Minimum requirements ==
 12+
 13+* MediaWiki 1.11+
 14+
 15+* A Piwik installation with the site configured
 16+
 17+== Installation instructions ==
 18+
 19+Please, read them carefully. They're not very difficult to understand,
 20+but ALL steps are necessary:
 21+
 22+* Create a folder called "piwik" in your extensions directory
 23+
 24+* Upload Piwik.php to the "piwik" folder you've just created
 25+
 26+* Edit your LocalSettings.php and, at the end of the file, add the
 27+ following:
 28+
 29+ require_once($IP.'/extensions/piwik/Piwik.php');
 30+
 31+
 32+* Then, you need to define where are piwik.php and piwik.js files in your
 33+ Piwik installation and the "idsite". To do it, just add after the
 34+ require_once:
 35+
 36+ $wgPiwikURLpiwikjs = "url/of/piwik.js";
 37+ $wgPiwikURLpiwikphp = "piwik.php_location";
 38+ $wgPiwikIDSite = "piwik_idsite";
 39+
 40+ Note: Change the value of $wgPiwikURLpiwikjs with the URL inside
 41+ "src". For example, in:
 42+
 43+ <script language="javascript" src="http://domain/path/piwik.js"
 44+ type="text/javascript"></script>
 45+ <script type="text/javascript">
 46+
 47+ the $wgPiwikURLpiwikjs is http://domain/path/piwik.js
 48+
 49+
 50+ Change the value of $wgPiwikURLpiwikphp with the URL inside
 51+ "piwik_url" and the value of $wgPiwikIDSite with the number inside
 52+ "piwik_idsite" in your Piwik code.

Status & tagging log