r33540 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r33539‎ | r33540 | r33541 >
Date:06:31, 18 April 2008
Author:nikerabbit
Status:old
Tags:
Comment:
* Parse messages in correct language, so plurals and grammar might even work correctly
* Deprecated one unneeded parameter in one message
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.i18n.php (modified) (history)
  • /trunk/extensions/CentralAuth/SpecialCentralAuth.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -1544,6 +1544,8 @@
15451545 * The special named parameter 'options' in a message specification array is passed
15461546 * through to the $options parameter of wfMsgExt().
15471547 *
 1548+ * Don't use this for messages that are not in users interface language.
 1549+ *
15481550 * For example:
15491551 *
15501552 * $wgOut->wrapWikiMsg( '<div class="error">$1</div>', 'some-error' );
@@ -1572,6 +1574,6 @@
15731575 }
15741576 $s = str_replace( '$' . ($n+1), wfMsgExt( $name, $options, $args ), $s );
15751577 }
1576 - $this->addHTML( $this->parse( $s ) );
 1578+ $this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
15771579 }
15781580 }
Index: trunk/extensions/CentralAuth/SpecialCentralAuth.php
@@ -61,7 +61,7 @@
6262 $globalUser = new CentralAuthUser( $this->mUserName );
6363
6464 if ( !$globalUser->exists() ) {
65 - $this->showError( wfMsgNoTrans( 'centralauth-admin-nonexistent', $this->mUserName ) );
 65+ $this->showError( 'centralauth-admin-nonexistent', $this->mUserName );
6666 $this->showUsernameForm();
6767 return;
6868 }
@@ -70,49 +70,49 @@
7171
7272 if( $this->mPosted ) {
7373 if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
74 - $this->showError( wfMsg( 'centralauth-token-mismatch' ) );
 74+ $this->showError( 'centralauth-token-mismatch' );
7575 } elseif( $this->mMethod == 'unmerge' ) {
7676 $status = $globalUser->adminUnattach( $this->mDatabases );
7777 if ( !$status->isGood() ) {
78 - $this->showError( $status->getWikiText() );
 78+ $this->showStatusError( $status->getWikiText() );
7979 } else {
8080 global $wgLang;
81 - $this->showSuccess( wfMsgNoTrans( 'centralauth-admin-unmerge-success',
 81+ $this->showSuccess( 'centralauth-admin-unmerge-success',
8282 $wgLang->formatNum( $status->successCount ),
83 - $status->successCount ) );
 83+ /* deprecated */ $status->successCount );
8484 }
8585 } elseif ( $this->mMethod == 'delete' ) {
8686 $status = $globalUser->adminDelete();
8787 if ( !$status->isGood() ) {
88 - $this->showError( $status->getWikiText() );
 88+ $this->showStatusError( $status->getWikiText() );
8989 } else {
9090 global $wgLang;
91 - $this->showSuccess( wfMsgNoTrans( 'centralauth-admin-delete-success', $this->mUserName ) );
 91+ $this->showSuccess( 'centralauth-admin-delete-success', $this->mUserName );
9292 $deleted = true;
9393 $this->logAction( 'delete', $this->mUserName, $wgRequest->getVal( 'reason' ) );
9494 }
9595 } elseif( $this->mMethod == 'lock' ) {
9696 $status = $globalUser->adminLock();
9797 if ( !$status->isGood() ) {
98 - $this->showError( $status->getWikiText() );
 98+ $this->showStatusError( $status->getWikiText() );
9999 } else {
100100 global $wgLang;
101 - $this->showSuccess( wfMsgNoTrans( 'centralauth-admin-lock-success', $this->mUserName ) );
 101+ $this->showSuccess( 'centralauth-admin-lock-success', $this->mUserName );
102102 $locked = true;
103103 $this->logAction( 'lock', $this->mUserName, $wgRequest->getVal( 'reason' ) );
104104 }
105105 } elseif( $this->mMethod == 'unlock' ) {
106106 $status = $globalUser->adminUnlock();
107107 if ( !$status->isGood() ) {
108 - $this->showError( $status->getWikiText() );
 108+ $this->showStatusError( $status->getWikiText() );
109109 } else {
110110 global $wgLang;
111 - $this->showSuccess( wfMsgNoTrans( 'centralauth-admin-unlock-success', $this->mUserName ) );
 111+ $this->showSuccess( 'centralauth-admin-unlock-success', $this->mUserName );
112112 $unlocked = true;
113113 $this->logAction( 'unlock', $this->mUserName, $wgRequest->getVal( 'reason' ) );
114114 }
115115 } else {
116 - $this->showError( wfMsg( 'centralauth-admin-bad-input' ) );
 116+ $this->showError( 'centralauth-admin-bad-input' );
117117 }
118118
119119 }
@@ -128,16 +128,31 @@
129129 }
130130 }
131131
132 - function showError( $message ) {
 132+ function showStatusError( $wikitext ) {
133133 global $wgOut;
134 - $wgOut->addWikiText( "<div class='error'>\n$message</div>" );
 134+ $wrap = Xml::tags( 'div', array( 'class' => 'error' ), $s );
 135+ $wgOut->addHTML( $wgOut->parse( $wrap, /*linestart*/true, /*uilang*/true ) );
135136 }
136137
137 - function showSuccess( $message ) {
 138+ function showError( $message /* varargs */ ) {
 139+ $args = func_get_args();
 140+ array_shift( $args ); // remove first
 141+ $args = array_values( $args );
 142+
138143 global $wgOut;
139 - $wgOut->addWikiText( "<div class='success'>\n$message</div>" );
 144+ $wgOut->wrapWikiMsg( '<div class="error">$1</div>', $message, $args );
140145 }
141146
 147+
 148+ function showSuccess( $message /* varargs */ ) {
 149+ $args = func_get_args();
 150+ array_shift( $args ); // remove first
 151+ $args = array_values( $args );
 152+
 153+ global $wgOut;
 154+ $wgOut->wrapWikiMsg( '<div class="success">$1</div>', $message, $args );
 155+ }
 156+
142157 function showUsernameForm() {
143158 global $wgOut, $wgScript;
144159 $wgOut->addHtml(
Index: trunk/extensions/CentralAuth/CentralAuth.i18n.php
@@ -138,7 +138,7 @@
139139 'centralauth-admin-bad-input' => 'Invalid merge selection',
140140 'centralauth-admin-none-selected' => 'No accounts selected to modify.',
141141 'centralauth-admin-already-unmerged' => 'Skipping $1, already unmerged',
142 - 'centralauth-admin-unmerge-success' => 'Successfully unmerged $1 {{PLURAL:$2|account|accounts}}',
 142+ 'centralauth-admin-unmerge-success' => 'Successfully unmerged $1 {{PLURAL:$1|account|accounts}}',
143143 'centralauth-admin-delete-title' => 'Delete account',
144144 'centralauth-admin-delete-description' => 'Deleting the global account will delete any global preferences, unattach all local accounts, and leave the global name free for another user to take.
145145 All local accounts will continue to exist.

Status & tagging log