r82126 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82125‎ | r82126 | r82127 >
Date:19:22, 14 February 2011
Author:ialex
Status:deferred
Tags:
Comment:
* Pass the title to SpecialContributorsAddon::getContributorsText() instead of using $wgTitle
* Don't use an extension function to register the hook, do it while including the file
Modified paths:
  • /trunk/extensions/ContributorsAddon/ContributorsAddon.php (modified) (history)
  • /trunk/extensions/ContributorsAddon/ContributorsAddonClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributorsAddon/ContributorsAddonClass.php
@@ -1,17 +1,17 @@
22 <?php
33
44 class SpecialContributorsAddon extends SpecialContributors {
5 - public function getContributorsText() {
6 - global $wgUser, $wgLang, $wgTitle;
7 - $this->target = $wgTitle;
 5+ public function getContributorsText( $title ) {
 6+ global $wgUser, $wgLang;
 7+ $this->target = $title;
88 $contribText = '';
99
1010 if( $this->target->exists() ) {
1111 $total = 0;
12 - $skin =& $wgUser->getSkin();
 12+ $skin = $wgUser->getSkin();
1313 $link = $skin->makeKnownLinkObj( $this->target );
1414 $contribText .= '<h2>' . wfMsgHtml( 'contributors-subtitle', $link ) . '</h2>';
15 - list( $contributors, $others ) = $this->getMainContributors($wgTitle);
 15+ list( $contributors, $others ) = $this->getMainContributors( $title );
1616 $contribText .= '<ul>';
1717 foreach( $contributors as $username => $info ) {
1818 list( $id, $count ) = $info;
Index: trunk/extensions/ContributorsAddon/ContributorsAddon.php
@@ -17,7 +17,6 @@
1818 exit( 1 );
1919 }
2020
21 -$wgExtensionFunctions[] = 'efContributorsAddon';
2221 $wgExtensionCredits['other'][] = array(
2322 'path' => __FILE__,
2423 'name' => 'ContributorsAddon',
@@ -30,18 +29,14 @@
3130 $wgExtensionMessagesFiles['ContributorsAddon'] = $dir . 'ContributorsAddon.i18n.php';
3231 $wgAutoloadClasses['SpecialContributorsAddon'] = $dir . 'ContributorsAddonClass.php';
3332
34 -function efContributorsAddon() {
35 - global $wgHooks;
36 - $wgHooks['OutputPageParserOutput'][] = 'efContributorsAddonSetup';
37 - return true;
38 -}
 33+$wgHooks['OutputPageParserOutput'][] = 'efContributorsAddonSetup';
3934
40 -function efContributorsAddonSetup(&$out, $parseroutput) {
 35+function efContributorsAddonSetup( &$out, $parseroutput ) {
4136 global $wgScriptPath;
4237 $out->addScript( '<link rel="stylesheet" type="text/css" href="' . $wgScriptPath . '/extensions/ContributorsAddon/ContributorsAddon.css" />' );
4338 $out->addScript( '<script type="text/javascript" src="' . $wgScriptPath . '/extensions/ContributorsAddon/ContributorsAddon.js"><!-- ContributorsAddon js --></script>' );
4439 $spContribAddon = new SpecialContributorsAddon;
45 - $out->addScript( "\n<script type=\"text/javascript\">\nvar contributorsText = \"". $spContribAddon->getContributorsText() . "\";\n</script>\n" );
 40+ $out->addScript( "\n<script type=\"text/javascript\">\nvar contributorsText = \"". $spContribAddon->getContributorsText( $out->getTitle() ) . "\";\n</script>\n" );
4641 return true;
4742 }
4843

Sign-offs

UserFlagDate
MarkAHershbergerinspected19:59, 14 February 2011

Status & tagging log