https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112926

Revision: 112926
Author:   krinkle
Date:     2012-03-02 22:59:11 +0000 (Fri, 02 Mar 2012)
Log Message:
-----------
[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: trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php
===================================================================
--- trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php        
2012-03-02 22:37:34 UTC (rev 112925)
+++ trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php        
2012-03-02 22:59:11 UTC (rev 112926)
@@ -26,7 +26,7 @@
 
                $this->getOutput()->addModules( 'ext.centralauth' );
                $this->getOutput()->addModuleStyles( 'ext.centralauth.noflash' 
);
-               $this->addMergeMethodDescriptions();
+               $this->getOutput()->addJsConfigVars( 
'wgMergeMethodDescriptions', $this->getMergeMethodDescriptions() );
 
                $this->mUserName =
                        trim(
@@ -701,15 +701,15 @@
                return $total;
        }
 
-       function addMergeMethodDescriptions() {
-               $js = "wgMergeMethodDescriptions = {\n";
+       function getMergeMethodDescriptions() {
+               $mergeMethodDescriptions = array();
                foreach ( array( 'primary', 'new', 'empty', 'password', 'mail', 
'admin', 'login' ) as $method ) {
-                       $short = Xml::encodeJsVar( 
$this->getLanguage()->ucfirst( wfMsgHtml( "centralauth-merge-method-{$method}" 
) ) );
-                       $desc = Xml::encodeJsVar( wfMsgWikiHtml( 
"centralauth-merge-method-{$method}-desc" ) );
-                       $js .= "\t'{$method}' : { 'short' : {$short}, 'desc' : 
{$desc} }\n";
+                       $mergeMethodDescriptions[$method] = array(
+                               'short' => $this->getLanguage()->ucfirst( 
wfMsgHtml( "centralauth-merge-method-{$method}" ) ),
+                               'desc' => wfMsgWikiHtml( 
"centralauth-merge-method-{$method}-desc" )
+                       );
                }
-               $js .= "}";
-               $this->getOutput()->addInlineScript( $js );
+               return $mergeMethodDescriptions;
        }
 
        /**


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to