r112926 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112925‎ | r112926 | r112927 >
Date:22:59, 2 March 2012
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
[SpecialCentralAuth] Refactor awful hackish hand-made json-string
* Instead of going from nothing directly to JSON, just construct the complete thing into a multi-dimensional array and hand it off to OutputPage::addJsConfigVars
* Follow-up r112925
Modified paths:
  • /trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php
@@ -26,7 +26,7 @@
2727
2828 $this->getOutput()->addModules( 'ext.centralauth' );
2929 $this->getOutput()->addModuleStyles( 'ext.centralauth.noflash' );
30 - $this->addMergeMethodDescriptions();
 30+ $this->getOutput()->addJsConfigVars( 'wgMergeMethodDescriptions', $this->getMergeMethodDescriptions() );
3131
3232 $this->mUserName =
3333 trim(
@@ -701,15 +701,15 @@
702702 return $total;
703703 }
704704
705 - function addMergeMethodDescriptions() {
706 - $js = "wgMergeMethodDescriptions = {\n";
 705+ function getMergeMethodDescriptions() {
 706+ $mergeMethodDescriptions = array();
707707 foreach ( array( 'primary', 'new', 'empty', 'password', 'mail', 'admin', 'login' ) as $method ) {
708 - $short = Xml::encodeJsVar( $this->getLanguage()->ucfirst( wfMsgHtml( "centralauth-merge-method-{$method}" ) ) );
709 - $desc = Xml::encodeJsVar( wfMsgWikiHtml( "centralauth-merge-method-{$method}-desc" ) );
710 - $js .= "\t'{$method}' : { 'short' : {$short}, 'desc' : {$desc} }\n";
 708+ $mergeMethodDescriptions[$method] = array(
 709+ 'short' => $this->getLanguage()->ucfirst( wfMsgHtml( "centralauth-merge-method-{$method}" ) ),
 710+ 'desc' => wfMsgWikiHtml( "centralauth-merge-method-{$method}-desc" )
 711+ );
711712 }
712 - $js .= "}";
713 - $this->getOutput()->addInlineScript( $js );
 713+ return $mergeMethodDescriptions;
714714 }
715715
716716 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r112930[CentralAuth] Refactor JS...krinkle00:50, 3 March 2012
r1131831.19wmf1: MFT r112926catrope21:45, 6 March 2012
r114017MFT r112586, r112926, r112930, r113352reedy15:24, 16 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112925[SpecialCentralAuth] Fix trailing comma in object literal. This is too much f...krinkle22:37, 2 March 2012

Comments

#Comment by Catrope (talk | contribs)   21:43, 6 March 2012

This needs a 1.19 merge because it unbreaks r112925. Merging it to 1.19wmf1 now.

Status & tagging log