r84240 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84239‎ | r84240 | r84241 >
Date:13:54, 18 March 2011
Author:ialex
Status:resolved (Comments)
Tags:
Comment:
extension function -> ParserFirstCallInit hook to register parser hooks and functions
Modified paths:
  • /trunk/extensions/EmailAddressImage/EmailAddressImage.php (modified) (history)
  • /trunk/extensions/FolkTagCloud/FolkTagCloud.php (modified) (history)
  • /trunk/extensions/FootNote/Footnote.php (modified) (history)
  • /trunk/extensions/FormatDates/FormatDates.php (modified) (history)
  • /trunk/extensions/FramedVideo/FramedVideo.php (modified) (history)
  • /trunk/extensions/Gnuplot/Gnuplot.php (modified) (history)
  • /trunk/extensions/geoserver/geoserver.php (modified) (history)
  • /trunk/extensions/gis/geo.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FramedVideo/FramedVideo.php
@@ -24,7 +24,7 @@
2525
2626 $dir = dirname(__FILE__) . '/';
2727 $wgExtensionMessagesFiles['FramedVideo'] = $dir . 'FramedVideo.i18n.php';
28 -$wgExtensionFunctions[] = 'wfFramedVideo';
 28+$wgHooks['ParserFirstCallInit'][] = 'wfFramedVideoSetHook';
2929
3030 $wgExtensionCredits['parserhook'][] = array(
3131 'path' => __FILE__,
@@ -35,10 +35,9 @@
3636 'version' => '1.2.1',
3737 );
3838
39 -function wfFramedVideo() {
40 - global $wgParser;
41 -
42 - $wgParser->setHook( 'video', 'renderFramedVideo' );
 39+function wfFramedVideoSetHook( $parser ) {
 40+ $parser->setHook( 'video', 'renderFramedVideo' );
 41+ return true;
4342 }
4443
4544 function renderFramedVideo( $input, $args, $parser ) {
Index: trunk/extensions/FormatDates/FormatDates.php
@@ -17,7 +17,7 @@
1818
1919 $wgAutoloadClasses['DateParser'] = dirname( __FILE__ ) . '/DateParser.php';
2020 $wgAutoloadClasses['FormattableDate'] = dirname( __FILE__ ) . '/FormattableDate.php';
21 -$wgExtensionFunctions[] = 'efFormatDates';
 21+$wgHooks['ParserFirstCallInit'][] = 'efFormatDatesSetHook';
2222
2323 $wgExtensionCredits['parserhook'][] = array(
2424 'path' => __FILE__,
@@ -26,9 +26,9 @@
2727 'description' => 'Supports refactoring of unlinked dates through the <code><nowiki><date></nowiki></code> tag',
2828 );
2929
30 -function efFormatDates() {
31 - global $wgParser;
32 - $wgParser->setHook( 'date', 'efFormatDate' );
 30+function efFormatDatesSetHook( $parser ) {
 31+ $parser->setHook( 'date', 'efFormatDate' );
 32+ return true;
3333 }
3434
3535 function efFormatDate( $text, $args, &$parser ) {
Index: trunk/extensions/FolkTagCloud/FolkTagCloud.php
@@ -32,13 +32,13 @@
3333
3434 $wgExtensionMessagesFiles['FolkTagCloud'] = dirname( __FILE__ ) . '/FolkTagCloud.i18n.php';
3535
36 -$wgExtensionFunctions[] = 'registerFolkTagCloudExtension';
 36+$wgHooks['ParserFirstCallInit'][] = 'registerFolkTagCloudExtension';
3737 $wgHooks['smwInitProperties'][] = 'initFolkTagProperty';
3838
3939 # registering extension
40 -function registerFolkTagCloudExtension() {
41 - global $wgParser;
42 - $wgParser->setHook( 'folktagcloud', 'renderFolkTagCloud' );
 40+function registerFolkTagCloudExtension( $parser ) {
 41+ $parser->setHook( 'folktagcloud', 'renderFolkTagCloud' );
 42+ return true;
4343 }
4444
4545 # initialising predefined property 'FolkTag'
Index: trunk/extensions/gis/geo.php
@@ -41,16 +41,16 @@
4242 exit( 1 ) ;
4343 }
4444
45 -$wgExtensionFunctions[] = "wfGeoExtension";
 45+$wgHooks['ArticleSaveComplete'][] = 'articleSaveGeo';
 46+$wgHooks['ArticleDelete'][] = 'articleDeleteGeo';
 47+$wgHooks['ParserFirstCallInit'][] = 'wfGeoSetHook';
4648
4749 /**
4850 * Installer
4951 */
50 -function wfGeoExtension () {
51 - global $wgParser, $wgHooks ;
52 - $wgParser->setHook ( 'geo' , 'parseGeo' ) ;
53 - $wgHooks['ArticleSaveComplete'][] = 'articleSaveGeo';
54 - $wgHooks['ArticleDelete'][] = 'articleDeleteGeo';
 52+function wfGeoSetHook( $parser ) {
 53+ $parser->setHook( 'geo', 'parseGeo' );
 54+ return true;
5555 }
5656
5757 $wgExtensionCredits['specialpage'][] = array(
Index: trunk/extensions/EmailAddressImage/EmailAddressImage.php
@@ -22,15 +22,10 @@
2323 );
2424
2525 $wgExtensionMessagesFiles['AdvancedRandom'] = dirname(__FILE__) . '/EmailAddressImage.i18n.php';
26 -$wgExtensionFunctions[] = 'emailAddressImage';
 26+$wgHooks['ParserFirstCallInit'][] = 'emailAddressImage';
2727
28 -# Sets the hook to be executed once the parser has stripped HTML tags.
29 -$wgHooks['ParserAfterStrip'][] = 'emailAddressImage';
30 -
31 -function emailAddressImage() {
32 - global $wgParser;
33 -
34 - $wgParser->setHook( 'email', 'doAddressImage' );
 28+function emailAddressImage( $parser ) {
 29+ $parser->setHook( 'email', 'doAddressImage' );
3530 return true;
3631 }
3732
Index: trunk/extensions/Gnuplot/Gnuplot.php
@@ -32,11 +32,11 @@
3333 $wgGnuplotDefaultTerminal = 'set terminal png';
3434 $wgGnuplotDefaultSize = 'set size 0.5,0.5';
3535
36 -$wgExtensionFunctions[] = "wfGnuplotExtension";
 36+$wgHooks['ParserFirstCallInit'][] = 'wfGnuplotSetHook';
3737
38 -function wfGnuplotExtension() {
39 - global $wgParser;
40 - $wgParser->setHook( "gnuplot", "renderGnuplot" );
 38+function wfGnuplotSetHook( $parser ) {
 39+ $parser->setHook( "gnuplot", "renderGnuplot" );
 40+ return true;
4141 }
4242
4343 function renderGnuplot( $gnuplotsrc ) {
Index: trunk/extensions/geoserver/geoserver.php
@@ -13,17 +13,17 @@
1414 'description' => 'Allows geotagging using the <nowiki><geo></nowiki> tag. Saves geodata in a WFS-T server, e.g. geoserver.',
1515 );
1616
17 -$wgExtensionFunctions[] = "wfGeoserverExtension";
 17+$wgHooks['ParserFirstCallInit'][] = 'wfGeoserverSetHook';
 18+$wgHooks['ArticleSaveComplete'][] = 'articleDeleteGeo';
 19+$wgHooks['ArticleDelete'][] = 'articleDeleteGeo';
 20+$wgHooks['ArticleEditUpdatesDeleteFromRecentchanges'][] = 'articleSaveGeo';
1821
1922 /**
2023 * Installer
2124 */
22 -function wfGeoServerExtension () {
23 - global $wgParser, $wgHooks ;
24 - $wgParser->setTransparentTagHook ( 'geo' , 'parseGeo' ) ;
25 -# $wgHooks['ArticleSaveComplete'][] = 'articleDeleteGeo';
26 - $wgHooks['ArticleDelete'][] = 'articleDeleteGeo';
27 - $wgHooks['ArticleEditUpdatesDeleteFromRecentchanges'][] = 'articleSaveGeo';
 25+function wfGeoserverSetHook( $parser ) {
 26+ $parser->setTransparentTagHook( 'geo', 'parseGeo' );
 27+ return true;
2828 }
2929
3030 global $wgAutoloadClasses;
Index: trunk/extensions/FootNote/Footnote.php
@@ -41,12 +41,12 @@
4242 'url' => 'http://www.mediawiki.org/wiki/Extension:Footnote',
4343 );
4444
45 -$wgExtensionFunctions[] = "wfFootnote";
 45+$wgHooks['ParserBeforeTidy'][] = 'insert_endnotes';
 46+$wgHooks['ParserFirstCallInit'][] = "wfFootnoteSetHook";
4647
47 -function wfFootnote() {
48 - global $wgParser, $wgHooks ;
49 - $wgParser->setHook( "footnote" , 'parse_footnote' ) ;
50 - $wgHooks['ParserBeforeTidy'][] = 'insert_endnotes' ;
 48+function wfFootnoteSetHook( $parser ) {
 49+ $parser->setHook( 'footnote', 'parse_footnote' );
 50+ return true;
5151 }
5252
5353 $footnoteNotes = array() ;

Follow-up revisions

RevisionCommit summaryAuthorDate
r84242And I forgot to commit these ones in r84240ialex13:56, 18 March 2011
r90300Fix for r84240: comment back ArticleSaveComplete hookialex17:17, 17 June 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   22:40, 16 June 2011

articleDeleteGeo hook was commented out...now it isn't.

Status & tagging log