r48745 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48744‎ | r48745 | r48746 >
Date:15:44, 24 March 2009
Author:raymond
Status:deferred
Tags:
Comment:
* Some UI tweaks:
** Use Xml::functions and classes to fix input form for RTL wikis
** Add the needed right (but commented out to avoid enabling by accident)
** Add documention for enabling in a install.settings file
** Make input form consistent with similar input forms.
Modified paths:
  • /trunk/extensions/UserMerge/UserMerge.i18n.php (modified) (history)
  • /trunk/extensions/UserMerge/UserMerge.php (modified) (history)
  • /trunk/extensions/UserMerge/UserMerge_body.php (modified) (history)
  • /trunk/extensions/UserMerge/install.settings (added) (history)

Diff [purge]

Index: trunk/extensions/UserMerge/UserMerge_body.php
@@ -32,7 +32,7 @@
3333 // init variables
3434 $olduser_text = '';
3535 $newuser_text = '';
36 - $deleteUserCheck = '';
 36+ $deleteUserCheck = false;
3737 $validNewUser = false;
3838
3939 if ( strlen( $wgRequest->getText( 'olduser' ).$wgRequest->getText( 'newuser' ) ) > 0 || $wgRequest->getText( 'deleteuser' ) ) {
@@ -44,7 +44,7 @@
4545 $newuser_text = is_object( $newuser ) ? $newuser->getText() : '';
4646
4747 if ( $wgRequest->getText( 'deleteuser' ) ) {
48 - $deleteUserCheck = 'checked="checked" ';
 48+ $deleteUserCheck = true;
4949 }
5050
5151 if ( strlen( $olduser_text ) > 0 ) {
@@ -55,10 +55,10 @@
5656
5757 if ( !is_object( $objOldUser ) ) {
5858 $validOldUser = false;
59 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg('usermerge-badolduser') . "</span><br />\n" );
 59+ $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>", 'usermerge-badolduser' );
6060 } elseif ( $olduserID == $wgUser->getID() ) {
6161 $validOldUser = false;
62 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg('usermerge-noselfdelete') . "</span><br />\n" );
 62+ $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>", 'usermerge-noselfdelete' );
6363 } else {
6464 global $wgUserMergeProtectedGroups;
6565
@@ -71,7 +71,7 @@
7272
7373 if ( $boolProtected ) {
7474 $validOldUser = false;
75 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg('usermerge-protectedgroup') . "</span><br />\n" );
 75+ $wgOut->wrapWikiMsg( "<div class='error'>\n$1</div>", 'usermerge-protectedgroup' );
7676 } else {
7777 $validOldUser = true;
7878
@@ -88,7 +88,7 @@
8989 } else {
9090 //invalid newuser entered
9191 $validNewUser = false;
92 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg('usermerge-badnewuser') . "</span><br />\n" );
 92+ $wgOut->wrapWikiMsg( "<div class='error'>$1</div>", 'usermerge-badnewuser' );
9393 }
9494 } else {
9595 //newuser looks good
@@ -98,7 +98,7 @@
9999 //empty newuser string
100100 $validNewUser = false;
101101 $newuser_text = "Anonymous";
102 - $wgOut->addHTML( "<span style=\"color: red;\">" . wfMsg('usermerge-nonewuser', $newuser_text) . "</span><br />\n" );
 102+ $wgOut->wrapWikiMsg( "<div class='error'>$1</div>", array( 'usermerge-nonewuser', $newuser_text ) );
103103 }
104104 }
105105 }
@@ -110,32 +110,46 @@
111111 //NO POST data found
112112 }
113113
114 - $action = $wgTitle->escapeLocalUrl();
115 - $token = $wgUser->editToken();
 114+ $wgOut->addHTML(
 115+ Xml::openElement( 'form', array( 'method' => 'post', 'action' => $wgTitle->getLocalUrl(), 'id' => 'usermergeform' ) ) .
 116+ Xml::fieldset( wfMsg( 'usermerge-fieldset' ) ) .
 117+ Xml::openElement( 'table', array( 'id' => 'mw-usermerge-table' ) ) .
 118+ "<tr>
 119+ <td class='mw-label'>" .
 120+ Xml::label( wfMsg( 'usermerge-olduser' ), 'olduser' ) .
 121+ "</td>
 122+ <td class='mw-input'>" .
 123+ Xml::input( 'olduser', 20, $olduser_text, array( 'type' => 'text', 'tabindex' => '1', 'onFocus' => "document.getElementById('olduser').select;" ) ) . ' ' .
 124+ "</td>
 125+ </tr>
 126+ <tr>
 127+ <td class='mw-label'>" .
 128+ Xml::label( wfMsg( 'usermerge-newuser' ), 'newuser' ) .
 129+ "</td>
 130+ <td class='mw-input'>" .
 131+ Xml::input( 'newuser', 20, $newuser_text, array( 'type' => 'text', 'tabindex' => '2', 'onFocus' => "document.getElementById('newuser').select;" ) ) .
 132+ "</td>
 133+ </tr>
 134+ <tr>
 135+ <td>&nbsp;" .
 136+ "</td>
 137+ <td class='mw-input'>" .
 138+ Xml::checkLabel( wfMsg( 'usermerge-deleteolduser' ), 'deleteuser', 'deleteuser', $deleteUserCheck, array( 'tabindex' => '3' ) ) .
 139+ "</td>
 140+ </tr>
 141+ <tr>
 142+ <td>&nbsp;
 143+ </td>
 144+ <td class='mw-submit'>" .
 145+ Xml::submitButton( wfMsg( 'usermerge-submit' ), array( 'tabindex' => '4' ) ) .
 146+ "</td>
 147+ </tr>" .
 148+ Xml::closeElement( 'table' ) .
 149+ Xml::closeElement( 'fieldset' ) .
 150+ Xml::hidden( 'token', $wgUser->editToken() ) .
 151+ Xml::closeElement( 'form' ) . "\n"
 152+ );
116153
117 - $wgOut->addHTML( "
118 -<form id='usermergeform' method='post' action=\"$action\">
119 -<table>
120 - <tr>
121 - <td align='right'>" . wfMsg( 'usermerge-olduser' ) . "</td>
122 - <td align='left'><input tabindex='1' type='text' size='20' name='olduser' id='olduser' value=\"$olduser_text\" onFocus=\"document.getElementById('olduser').select;\" /></td>
123 - </tr>
124 - <tr>
125 - <td align='right'>" . wfMsg( 'usermerge-newuser' ) . "</td>
126 - <td align='left'><input tabindex='2' type='text' size='20' name='newuser' id='newuser' value=\"$newuser_text\" onFocus=\"document.getElementById('newuser').select;\" /></td>
127 - </tr>
128 - <tr>
129 - <td align='right'>" . wfMsg( 'usermerge-deleteolduser' ) . "</td>
130 - <td align='left'><input tabindex='3' type='checkbox' name='deleteuser' id='deleteuser' $deleteUserCheck/></td>
131 - </tr>
132 - <tr>
133 - <td>&nbsp;</td>
134 - <td align='right'><input type='submit' name='submit' value=\"" . wfMsg( 'usermerge-submit' ) . "\" /></td>
135 - </tr>
136 -</table>
137 -<input type='hidden' name='token' value='$token' />
138 -</form>");
139 -
140154 if ( $validNewUser && $validOldUser ) {
141155 //go time, baby
142156 if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
Index: trunk/extensions/UserMerge/UserMerge.i18n.php
@@ -1,8 +1,9 @@
22 <?php
3 -#coding: utf-8
4 -/** \file
5 -* \brief Internationalization file for the User Merge and Delete Extension.
6 -*/
 3+/**
 4+ * Internationalisation file for the User Merge and Delete Extension.
 5+ *
 6+ * @addtogroup Extensions
 7+ */
78
89 $messages = array();
910
@@ -11,12 +12,13 @@
1213 'usermerge-desc' => "[[Special:UserMerge|Merges references from one user to another user]] in the wiki database - will also delete old users following merge. Requires ''usermerge'' privileges",
1314 'usermerge-badolduser' => 'Invalid old username',
1415 'usermerge-badnewuser' => 'Invalid new username',
15 - 'usermerge-nonewuser' => 'Empty new username - assuming merge to $1.<br />
16 -Click <u>Merge User</u> to accept.',
 16+ 'usermerge-nonewuser' => 'Empty new username - assuming merge to "$1".<br />
 17+Click "{{int:usermerge-submit}}" to accept.',
1718 'usermerge-noolduser' => 'Empty old username',
18 - 'usermerge-olduser' => 'Old user (merge from)',
19 - 'usermerge-newuser' => 'New user (merge to)',
20 - 'usermerge-deleteolduser' => 'Delete old user?',
 19+ 'usermerge-fieldset' => 'Usernames to merge',
 20+ 'usermerge-olduser' => 'Old user (merge from):',
 21+ 'usermerge-newuser' => 'New user (merge to):',
 22+ 'usermerge-deleteolduser' => 'Delete old user',
2123 'usermerge-submit' => 'Merge user',
2224 'usermerge-badtoken' => 'Invalid edit token',
2325 'usermerge-userdeleted' => '$1 ($2) has been deleted.',
Index: trunk/extensions/UserMerge/UserMerge.php
@@ -15,9 +15,12 @@
1616 'author' => 'Tim Laqua',
1717 'description' => "Merges references from one user to another user in the Wiki database - will also delete old users following merge. Requires 'usermerge' privileges.",
1818 'descriptionmsg' => 'usermerge-desc',
19 - 'version' => '1.6'
 19+ 'version' => '1.6.1'
2020 );
2121
 22+$wgAvailableRights[] = 'usermerge';
 23+# $wgGroupPermissions['bureaucrat']['usermerge'] = true;
 24+
2225 $dir = dirname(__FILE__) . '/';
2326 $wgAutoloadClasses['UserMerge'] = $dir . 'UserMerge_body.php';
2427
@@ -29,8 +32,8 @@
3033 $wgUserMergeProtectedGroups = array( "sysop" );
3134
3235 # Add a new log type
33 -$wgLogTypes[] = 'usermerge';
34 -$wgLogNames['usermerge'] = 'usermerge-logpage';
35 -$wgLogHeaders['usermerge'] = 'usermerge-logpagetext';
36 -$wgLogActions['usermerge/mergeuser'] = 'usermerge-success-log';
37 -$wgLogActions['usermerge/deleteuser'] = 'usermerge-userdeleted-log';
 36+$wgLogTypes[] = 'usermerge';
 37+$wgLogNames['usermerge'] = 'usermerge-logpage';
 38+$wgLogHeaders['usermerge'] = 'usermerge-logpagetext';
 39+$wgLogActions['usermerge/mergeuser'] = 'usermerge-success-log';
 40+$wgLogActions['usermerge/deleteuser'] = 'usermerge-userdeleted-log';
Index: trunk/extensions/UserMerge/install.settings
@@ -0,0 +1,4 @@
 2+require_once( "$IP/extensions/UserMerge/UserMerge.php" );
 3+# Assign the usermerge right to a usergroup, i.e. to the bureaucrats:
 4+$wgGroupPermissions['bureaucrat']['usermerge'] = true;
 5+
Property changes on: trunk/extensions/UserMerge/install.settings
___________________________________________________________________
Name: svn:eol-style
16 + native

Status & tagging log