r72924 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72923‎ | r72924 | r72925 >
Date:19:18, 13 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed small things, version number incremented to 0.1.1
Modified paths:
  • /trunk/extensions/DateDiff/DateDiff.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DateDiff/DateDiff.php
@@ -13,38 +13,44 @@
1414 die( 'Not an entry point.' );
1515 }
1616
17 -define( 'Datediff_VERSION', '0.1' );
 17+define( 'Datediff_VERSION', '0.1.1' );
1818
1919 $wgExtensionMessagesFiles['DateDiff'] = dirname( __FILE__ ) . '/DateDiff.i18n.php';
20 -$wgExtensionFunctions[] = "efDateDiff";
21 -$wgHooks['LanguageGetMagic'][] = 'efDatesFunctionMagic';
2220
2321 // Extension credits that show up on Special:Version
2422 $wgExtensionCredits['parserhook'][] = array(
2523 'path' => __FILE__,
2624 'name' => 'DateDiff',
27 - 'author' => 'David Raison',
 25+ 'author' => array(
 26+ '[http://david.raison.lu David Raison]',
 27+ '[http://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]'
 28+ ),
2829 'url' => 'http://www.mediawiki.org/wiki/Extension:DateDiff',
2930 'descriptionmsg' => 'datediff-desc',
3031 'version' => Datediff_VERSION,
3132 );
3233
33 -function efDateDiff() {
34 - global $wgParser;
35 - $wgParser->setFunctionHook( 'dates', 'calcdates' );
 34+$wgHooks['ParserFirstCallInit'][] = 'efDDDateDiff';
 35+$wgHooks['LanguageGetMagic'][] = 'efDDDatesFunctionMagic';
 36+
 37+function efDDDateDiff( Parser &$parser ) {
 38+ $parser->setFunctionHook( 'dates', 'efDDCalcDates' );
 39+ return true;
3640 }
3741
3842 /**
39 - * Adds the magic words for the parser functions
 43+ * Adds the magic words for the parser functions.
4044 */
41 -function efDatesFunctionMagic( &$magicWords, $langCode ) {
 45+function efDDDatesFunctionMagic( &$magicWords, $langCode ) {
4246 $magicWords['dates'] = array( 0, 'dates' );
4347 return true;
4448 }
4549
46 -function calcdates( &$parser ) {
 50+function efDDCalcDates( &$parser ) {
4751 $params = func_get_args();
48 - array_shift( $params ); // We already know the $parser ...
 52+
 53+ // We already know the $parser ...
 54+ array_shift( $params );
4955
5056 while ( empty( $params[0] ) ) {
5157 array_shift( $params );
@@ -56,7 +62,6 @@
5763 // We currently ignore the label of the date.
5864 $dates[] = substr( $pair, strpos( $pair, '=' ) + 1 );
5965 }
60 -
6166
6267 $time1 = strtotime( $dates[0] );
6368 $time2 = strtotime( $dates[1] );

Status & tagging log