r84631 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84630‎ | r84631 | r84632 >
Date:21:14, 23 March 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Changed extension functions registering parser hooks and tags to use ParserFirstCallInit hook
* Removed some useless extension functions
* ParserFistCallInit hook has a parameter, so use it
Modified paths:
  • /trunk/extensions/EmbedVideo/EmbedVideo.hooks.php (modified) (history)
  • /trunk/extensions/SkinPerPage/SkinPerPage.php (modified) (history)
  • /trunk/extensions/SpecialFileList/SpecialFilelist.php (modified) (history)
  • /trunk/extensions/SpecialTalk/SpecialTalk.php (modified) (history)
  • /trunk/extensions/StockCharts/StockCharts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SpecialFileList/SpecialFilelist.php
@@ -11,7 +11,6 @@
1212 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1313 */
1414
15 -$wgExtensionFunctions[] = 'wfSpecialFilelist';
1615 $wgExtensionCredits['specialpage'][] = array(
1716 'path' => __FILE__,
1817 'name' => 'File list',
Index: trunk/extensions/SpecialTalk/SpecialTalk.php
@@ -12,7 +12,7 @@
1313 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
1414 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1515 */
16 -$wgExtensionFunctions[] = 'wfSpecialTalk';
 16+
1717 $wgExtensionCredits['other'][] = array(
1818 'path' => __FILE__,
1919 'name' => 'SpecialTalk',
@@ -28,33 +28,22 @@
2929 // Extension messages.
3030 $wgExtensionMessagesFiles['SpecialTalk'] = $dir . 'SpecialTalk.i18n.php';
3131
32 -function wfSpecialTalk() {
33 - class SpecialTalk {
34 - public function __construct() {
35 - global $wgHooks;
 32+$wgHooks['SkinTemplateBuildContentActionUrlsAfterSpecialPage'][] = 'wfSpecialTalkHook';
3633
37 - $wgHooks['SkinTemplateBuildContentActionUrlsAfterSpecialPage'][] = array( &$this, 'SpecialTalkHook' );
38 - }
 34+function wfSpecialTalkHook( SkinTemplate &$skin_template, array &$content_actions ) {
 35+ $title = Title::makeTitle( NS_PROJECT_TALK, $skin_template->mTitle->getText() );
3936
40 - public function SpecialTalkHook( SkinTemplate &$skin_template, array &$content_actions ) {
41 - $title = Title::makeTitle( NS_PROJECT_TALK, $skin_template->mTitle->getText() );
 37+ $content_actions['talk'] = $skin_template->tabAction(
 38+ $title,
 39+ // msg
 40+ 'talk',
 41+ // selected
 42+ false,
 43+ // &query=
 44+ '',
 45+ // check existance
 46+ true
 47+ );
4248
43 - $content_actions['talk'] = $skin_template->tabAction(
44 - $title,
45 - // msg
46 - 'talk',
47 - // selected
48 - false,
49 - // &query=
50 - '',
51 - // check existance
52 - true
53 - );
54 -
55 - return true;
56 - }
57 - }
58 -
59 - // Establish a singleton.
60 - new SpecialTalk;
 49+ return true;
6150 }
Index: trunk/extensions/SkinPerPage/SkinPerPage.php
@@ -17,13 +17,13 @@
1818
1919 $wgExtensionMessagesFiles['SkinPerPage'] = dirname( __FILE__ ) . "/SkinPerPage.i18n.php";
2020
21 -$wgExtensionFunctions[] = array( 'SkinPerPage', 'setup' );
 21+$wgHooks['ParserFirstCallInit'][] = 'SkinPerPage::setup';
2222 $wgHooks['OutputPageParserOutput'][] = 'SkinPerPage::outputHook';
2323
2424 class SkinPerPage {
25 - static function setup() {
26 - global $wgParser;
27 - $wgParser->setHook( 'skin', array( __CLASS__, 'parserHook' ) );
 25+ static function setup( $parser ) {
 26+ $parser->setHook( 'skin', array( __CLASS__, 'parserHook' ) );
 27+ return true;
2828 }
2929
3030 static function parserHook( $text, $attribs, $parser ) {
Index: trunk/extensions/StockCharts/StockCharts.php
@@ -17,7 +17,7 @@
1818 *
1919 */
2020
21 -$wgExtensionFunctions[] = 'efStockCharts';
 21+$wgHooks['ParserFirstCallInit'][] = 'efStockChartsSetHooks';
2222 $wgHooks['LanguageGetMagic'][] = 'efStockChartsMagic';
2323
2424 $wgExtensionCredits['parserhook'][] = array(
@@ -34,11 +34,10 @@
3535
3636 $wgAutoloadClasses['StockCharts'] = dirname( __FILE__ ) . '/StockCharts_body.php';
3737
38 -// CHECKME: use $wgHooks['ParserFirstCallInit'] here?
39 -function efStockCharts() {
40 - global $wgParser;
41 - $wgParser->setHook( 'stockchart', array( 'StockCharts', 'renderTagExtension' ) ); // hook for <stockchart ../>
42 - $wgParser->setFunctionHook( 'stockchart', array( 'StockCharts', 'renderParserFunction' ) ); // hook for {{#stockchart ..}}
 38+function efStockChartsSetHooks( $parser ) {
 39+ $parser->setHook( 'stockchart', array( 'StockCharts', 'renderTagExtension' ) ); // hook for <stockchart ../>
 40+ $parser->setFunctionHook( 'stockchart', array( 'StockCharts', 'renderParserFunction' ) ); // hook for {{#stockchart ..}}
 41+ return true;
4342 }
4443
4544 function efStockChartsMagic( &$magicWords, $langCode ) {
Index: trunk/extensions/EmbedVideo/EmbedVideo.hooks.php
@@ -12,21 +12,15 @@
1313 /**
1414 * Sets up parser functions.
1515 */
16 - public static function setup() {
 16+ public static function setup( $parser ) {
1717 # Setup parser hooks. ev is the primary hook, evp is supported for
1818 # legacy purposes
19 - $prefix = '';
20 - EmbedVideo::addMagicWord( $prefix, "ev", "EmbedVideo::parserFunction_ev" );
21 - EmbedVideo::addMagicWord( $prefix, "evp", "EmbedVideo::parserFunction_evp" );
 19+ $parser->setFunctionHook( 'ev', 'EmbedVideo::parserFunction_ev' );
 20+ $parser->setFunctionHook( 'evp', 'EmbedVideo::parserFunction_evp' );
2221
2322 return true;
2423 }
2524
26 - private static function addMagicWord( $prefix, $word, $function ) {
27 - global $wgParser;
28 - $wgParser->setFunctionHook( $prefix . $word, $function );
29 - }
30 -
3125 /**
3226 ** Adds magic words for parser functions.
3327 * @param Array $magicWords

Follow-up revisions

RevisionCommit summaryAuthorDate
r84644And I forgot to commit this in r84631ialex22:35, 23 March 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   23:05, 16 June 2011

wtf on SpecialTalk.php? :)

Status & tagging log