Index: trunk/extensions/DateDiff/DateDiff.php |
— | — | @@ -13,38 +13,44 @@ |
14 | 14 | die( 'Not an entry point.' ); |
15 | 15 | } |
16 | 16 | |
17 | | -define( 'Datediff_VERSION', '0.1' ); |
| 17 | +define( 'Datediff_VERSION', '0.1.1' ); |
18 | 18 | |
19 | 19 | $wgExtensionMessagesFiles['DateDiff'] = dirname( __FILE__ ) . '/DateDiff.i18n.php'; |
20 | | -$wgExtensionFunctions[] = "efDateDiff"; |
21 | | -$wgHooks['LanguageGetMagic'][] = 'efDatesFunctionMagic'; |
22 | 20 | |
23 | 21 | // Extension credits that show up on Special:Version |
24 | 22 | $wgExtensionCredits['parserhook'][] = array( |
25 | 23 | 'path' => __FILE__, |
26 | 24 | '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 | + ), |
28 | 29 | 'url' => 'http://www.mediawiki.org/wiki/Extension:DateDiff', |
29 | 30 | 'descriptionmsg' => 'datediff-desc', |
30 | 31 | 'version' => Datediff_VERSION, |
31 | 32 | ); |
32 | 33 | |
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; |
36 | 40 | } |
37 | 41 | |
38 | 42 | /** |
39 | | - * Adds the magic words for the parser functions |
| 43 | + * Adds the magic words for the parser functions. |
40 | 44 | */ |
41 | | -function efDatesFunctionMagic( &$magicWords, $langCode ) { |
| 45 | +function efDDDatesFunctionMagic( &$magicWords, $langCode ) { |
42 | 46 | $magicWords['dates'] = array( 0, 'dates' ); |
43 | 47 | return true; |
44 | 48 | } |
45 | 49 | |
46 | | -function calcdates( &$parser ) { |
| 50 | +function efDDCalcDates( &$parser ) { |
47 | 51 | $params = func_get_args(); |
48 | | - array_shift( $params ); // We already know the $parser ... |
| 52 | + |
| 53 | + // We already know the $parser ... |
| 54 | + array_shift( $params ); |
49 | 55 | |
50 | 56 | while ( empty( $params[0] ) ) { |
51 | 57 | array_shift( $params ); |
— | — | @@ -56,7 +62,6 @@ |
57 | 63 | // We currently ignore the label of the date. |
58 | 64 | $dates[] = substr( $pair, strpos( $pair, '=' ) + 1 ); |
59 | 65 | } |
60 | | - |
61 | 66 | |
62 | 67 | $time1 = strtotime( $dates[0] ); |
63 | 68 | $time2 = strtotime( $dates[1] ); |