r65523 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65522‎ | r65523 | r65524 >
Date:16:15, 25 April 2010
Author:ialex
Status:deferred
Tags:
Comment:
Piwik Integration 1.5.2-piwik0.5.5:
* Fixes a long-time problem with trailing slashes
* New variable to choose Specialpage's report date ($wgPiwikSpecialPageDate)
* Removes some unused code and
* README improved

Patch by Isaac Sánchez Barrera - https://bugzilla.wikimedia.org/attachment.cgi?id=7328
Modified paths:
  • /trunk/extensions/Piwik/Piwik.php (modified) (history)
  • /trunk/extensions/Piwik/Piwik_specialpage.php (modified) (history)
  • /trunk/extensions/Piwik/README (modified) (history)

Diff [purge]

Index: trunk/extensions/Piwik/Piwik_specialpage.php
@@ -9,7 +9,7 @@
1010 }
1111
1212 function execute( $par ) {
13 - global $wgRequest, $wgOut, $wgPiwikURL, $wgScriptPath, $wgPiwikIDSite;
 13+ global $wgRequest, $wgOut, $wgPiwikURL, $wgScriptPath, $wgPiwikIDSite, $wgPiwikSpecialPageDate;
1414
1515 wfLoadExtensionMessages( 'Piwik' );
1616
@@ -18,24 +18,26 @@
1919 $wgOut->setPagetitle( 'Piwik' );
2020
2121 $selfTitle = $this->getTitle();
22 - $badCharsInURL = array( ":", "/" );
23 - $goodCharsInURL = array( "%3A", "%2F" );
24 - $specialcharsURL = str_replace( $badCharsInURL, $goodCharsInURL, $wgPiwikURL );
2522
2623 $lastvisits = wfMsg( 'piwik-lastvisits' );
2724 $countries = wfMsg( 'piwik-countries' );
2825 $browsers = wfMsg( 'piwik-browsers' );
2926
 27+ if ( $wgPiwikSpecialPageDate != 'today' && $wgPiwikSpecialPageDate != 'yesterday' ) {
 28+ $wgPiwikSpecialPageDate = 'yesterday';
 29+ }
 30+
 31+
3032 // checking
3133 $piwikpage = <<<PIWIK
3234 <h2>{$lastvisits}</h2>
33 - <iframe src="http://{$wgPiwikURL}/index.php?module=Widgetize&amp;action=iframe&amp;columns[]=nb_visits&amp;moduleToWidgetize=VisitsSummary&amp;actionToWidgetize=getEvolutionGraph&amp;idSite={$wgPiwikIDSite}&amp;period=day&amp;date=last30&amp;disableLink=1" marginheight="0" marginwidth="0" frameborder="0" height="250" scrolling="no" width="100%"></iframe>
 35+ <iframe src="http://{$wgPiwikURL}index.php?module=Widgetize&amp;action=iframe&amp;columns[]=nb_visits&amp;moduleToWidgetize=VisitsSummary&amp;actionToWidgetize=getEvolutionGraph&amp;idSite={$wgPiwikIDSite}&amp;period=day&amp;date=last30&amp;disableLink=1" marginheight="0" marginwidth="0" frameborder="0" height="250" scrolling="no" width="100%"></iframe>
3436
3537 <h2>{$countries}</h2>
36 - <iframe src="http://{$wgPiwikURL}/index.php?module=Widgetize&amp;action=iframe&amp;moduleToWidgetize=UserCountry&amp;actionToWidgetize=getCountry&amp;idSite={$wgPiwikIDSite}&amp;period=day&amp;date=yesterday&amp;disableLink=1" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" height="400" width="100%"></iframe>
 38+ <iframe src="http://{$wgPiwikURL}index.php?module=Widgetize&amp;action=iframe&amp;moduleToWidgetize=UserCountry&amp;actionToWidgetize=getCountry&amp;idSite={$wgPiwikIDSite}&amp;period=day&amp;date={$wgPiwikSpecialPageDate}&amp;disableLink=1" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" height="400" width="100%"></iframe>
3739
3840 <h2>{$browsers}</h2>
39 - <iframe src="http://{$wgPiwikURL}/index.php?module=Widgetize&amp;action=iframe&amp;moduleToWidgetize=UserSettings&amp;actionToWidgetize=getBrowser&amp;idSite={$wgPiwikIDSite}&amp;period=day&amp;date=yesterday&amp;disableLink=1" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" height="400" width="100%"></iframe>
 41+ <iframe src="http://{$wgPiwikURL}index.php?module=Widgetize&amp;action=iframe&amp;moduleToWidgetize=UserSettings&amp;actionToWidgetize=getBrowser&amp;idSite={$wgPiwikIDSite}&amp;period=day&amp;date={$wgPiwikSpecialPageDate}&amp;disableLink=1" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" height="400" width="100%"></iframe>
4042
4143 PIWIK;
4244
Index: trunk/extensions/Piwik/Piwik.php
@@ -4,7 +4,7 @@
55 *
66 * @addtogroup Extensions
77 * @author Isb1009 <isb1009 at gmail dot com>
8 - * @copyright © 2008 Isb1009
 8+ * @copyright © 2008-2010 Isb1009
99 * @licence GNU General Public Licence 2.0
1010 */
1111
@@ -15,7 +15,7 @@
1616 $wgExtensionCredits['specialpage'][] = array(
1717 'path' => __FILE__,
1818 'name' => 'Piwik Integration',
19 - 'version' => '1.5.1-piwik0.4.3',
 19+ 'version' => '1.5.2-piwik0.5.5',
2020 'author' => 'Isb1009',
2121 'descriptionmsg' => 'piwik-desc',
2222 'url' => 'http://www.mediawiki.org/wiki/Extension:Piwik_Integration',
@@ -30,6 +30,7 @@
3131 $wgPiwikCustomJS = "";
3232 $wgPiwikUsePageTitle = false;
3333 $wgPiwikActionName = "";
 34+$wgPiwikSpecialPageDate = 'yesterday';
3435
3536 function efPiwikHookText( $skin, &$text = '' ) {
3637 $text .= efAddPiwik();
Index: trunk/extensions/Piwik/README
@@ -1,7 +1,7 @@
22 MediaWiki Piwik Integration extension
33
4 -version 1.5-piwik0.4.2
5 -9 August 2009
 4+version 1.5.2-piwik0.5.5
 5+24 April 2010
66
77 This is the README file for the Piwik Integration extension for MediaWiki
88 software. The extension is only useful if you've got a MediaWiki
@@ -26,24 +26,25 @@
2727 * Edit your LocalSettings.php and, at the end of the file, add the
2828 following:
2929
30 - require_once($IP.'/extensions/piwik/Piwik.php');
 30+ require_once('/extensions/piwik/Piwik.php');
3131
3232
3333 * Then, you need to define where Piwik is installed and the "idsite".
3434 To do it, just add after the require_once:
3535
36 - $wgPiwikURL = "piwik/url/"; //Don't include the protocol
 36+ $wgPiwikURL = "piwik-host.tld/dir/"; //Don't include the protocol
3737 $wgPiwikIDSite = "piwik_idsite";
3838
39 - Note: Change the value of $wgPiwikURL with the URL, without the protocol,
40 - where you installed Piwik. Remember to add the trailing slash!
 39+ Note: Change the value of $wgPiwikURL with the URL, without the protocol
 40+ but including the domain name, where you installed Piwik.
 41+ Remember to add the trailing slash!
4142
4243 Change the value of $wgPiwikIDSite with your site ID.
4344 For example, in:
4445
4546 <!-- Piwik -->
4647 <script type="text/javascript">
47 - var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik/url/" : "http://piwik/url/");
 48+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik-host.tld/dir/" : "http://piwik-host.tld/dir/");
4849 document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
4950 </script><script type="text/javascript">
5051 try {
@@ -51,7 +52,7 @@
5253 piwikTracker.trackPageView();
5354 piwikTracker.enableLinkTracking();
5455 } catch( err ) {}
55 - </script><noscript><p><img src="http://piwik/url/piwik.php?idsite=3" style="border:0" alt=""/></p></noscript>
 56+ </script><noscript><p><img src="http://piwik-host.tld/dir/piwik.php?idsite=3" style="border:0" alt=""/></p></noscript>
5657 <!-- End Piwik Tag -->
5758
5859 the $wgPiwikIDSite is 3
@@ -83,3 +84,6 @@
8485 add that line with 'bureaucrat' where 'usergroup' is. The same is for
8586 normal users ('user') and anonymous users ('*').
8687
 88+* Since 1.5.2, you can set the date for the countries and browsers information in
 89+ the special page, setting $wgPiwikSpecialPageDate to either today or yesterday.
 90+

Status & tagging log