r45072 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45071‎ | r45072 | r45073 >
Date:08:14, 27 December 2008
Author:mrzman
Status:deferred
Tags:
Comment:
cleanup of Special:Interwiki:
* Use Xml functions for most of it
* Conform ids/names to coding conventions
Modified paths:
  • /trunk/phase3/includes/specials/SpecialInterwiki.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialInterwiki.php
@@ -7,17 +7,15 @@
88 class SpecialInterwiki extends SpecialPage {
99
1010 function __construct() {
11 - parent::__construct( 'Interwiki' );
 11+ parent::__construct( 'Interwiki', 'interwiki' );
1212 }
13 -
1413
15 - function execute( $par = null ) {
 14+ function execute( $par ) {
1615 global $wgRequest, $wgOut, $wgUser;
1716
18 - $admin = $wgUser->isAllowed( 'interwiki' );
19 -
2017 $this->setHeaders();
21 - if( $admin ){
 18+ $admin = $this->userCanExecute( $wgUser );
 19+ if ( $admin ) {
2220 $wgOut->setPagetitle( wfMsg( 'interwiki' ) );
2321 } else {
2422 $wgOut->setPagetitle( wfMsg( 'interwiki-title-norights' ) );
@@ -39,31 +37,32 @@
4038 }
4139
4240 $prefix = $wgRequest->getVal( 'prefix' );
43 - $encPrefix = htmlspecialchars( $prefix );
44 - $actionUrl = $selfTitle->escapeLocalURL( "action=submit" );
45 - $button = wfMsgHtml( 'delete' );
46 - $topmessage = wfMsgHtml( 'interwiki_delquestion', $encPrefix );
 41+ $actionUrl = $selfTitle->getLocalURL( "action=submit" );
 42+ $button = wfMsg( 'delete' );
 43+ $topmessage = wfMsg( 'interwiki_delquestion', $encPrefix );
4744 $deletingmessage = wfMsgHtml( 'interwiki_deleting', $encPrefix );
48 - $reasonmessage = wfMsgHtml( 'deletecomment' );
 45+ $reasonmessage = wfMsg( 'deletecomment' );
4946 $defaultreason = wfMsgForContent( 'interwiki_defaultreason' );
50 - $token = htmlspecialchars( $wgUser->editToken() );
 47+ $token = $wgUser->editToken();
5148
5249 $wgOut->addHTML(
53 - "<fieldset>
54 - <legend>$topmessage</legend>
55 - <form id=\"delete\" method=\"post\" action=\"{$actionUrl}\">
56 - <table><tr>
57 - <td>$deletingmessage</td>
58 - </tr><tr>
59 - <td>$reasonmessage &nbsp; <input tabindex='1' type='text' name=\"reason\" maxlength='200' size='60' value='$defaultreason' /></td>
60 - </tr><tr><td>
61 - <input type='submit' name='delete' id=\"interwikideletebutton\" value='{$button}' />
62 - <input type='hidden' name='prefix' value='{$encPrefix}' />
63 - <input type='hidden' name='do' value='delete' />
64 - <input type='hidden' name='wpEditToken' value='{$token}' />
65 - </td></tr></table>
66 - </form>
67 - </fieldset>\n"
 50+ Xml::openElement( 'fieldset' ) .
 51+ Xml::element( 'legend', null, $topmessage ) .
 52+ Xml::openElement( 'form', array('id'=> 'mw-interwiki-deleteform', 'method'=> 'post', 'action'=>$actionUrl) ) .
 53+ Xml::openElement( 'table' ) .
 54+ "<tr><td>$deletingmessage</td></tr>".
 55+ '<tr><td class="mw-label">' . Xml::label( $reasonmessage, 'mw-interwiki-deletereason') . '</td>' .
 56+ '<td class="mw-input">' .
 57+ Xml::input( 'wpInterwikiReason', 60, $defaultreason, array('tabindex'=>'1', 'id'=>'mw-interwiki-deletereason', 'maxlength'=>'200') ) .
 58+ '</td></tr>' .
 59+ '<tr><td class="mw-submit">' . Xml::submitButton( $button, array('id'=>'mw-interwiki-submit') ) .
 60+ Xml::hidden( 'wpInterwikiPrefix', $prefix ) .
 61+ Xml::hidden( 'wpInterwikiAction', $action ) .
 62+ Xml::hidden( 'wpEditToken', $token ) .
 63+ '</td></tr>' .
 64+ Xml::closeElement( 'table' ) .
 65+ Xml::closeElement( 'form' ) .
 66+ Xml::closeElement( 'fieldset' )
6867 );
6968 break;
7069 case "edit" :
@@ -80,61 +79,57 @@
8180 $wgOut->wrapWikiMsg( '<div class="errorbox">$1</div>', array( 'interwiki_editerror', $prefix ) );
8281 return;
8382 }
84 - $prefix = htmlspecialchars( $row->iw_prefix );
85 - $defaulturl = htmlspecialchars( $row->iw_url );
86 - $trans = $row->iw_trans ? " checked='checked'" : '' ;
87 - $local = $row->iw_local ? " checked='checked'" : '';
88 - $old = "<input type='hidden' name='prefix' value='" . htmlspecialchars( $row->iw_prefix ) . "' />";
89 - $topmessage = wfMsgHtml( 'interwiki_edittext' );
90 - $intromessage = wfMsgHtml( 'interwiki_editintro' );
91 - $button = wfMsgHtml( 'edit' );
 83+ $prefix = '<tt>' . htmlspecialchars( $row->iw_prefix ) . '</tt>';
 84+ $defaulturl = $row->iw_url;
 85+ $trans = $row->iw_trans;
 86+ $local = $row->iw_local;
 87+ $old = Xml::hidden( 'wpInterwikiPrefix', $row->iw_prefix );
 88+ $topmessage = wfMsgExt( 'interwiki_edittext', array('parseinline') );
 89+ $intromessage = wfMsgExt( 'interwiki_editintro', array('parseinline') );
 90+ $button = wfMsg( 'edit' );
9291 } else {
93 - $prefix = "<input tabindex='1' type='text' name='prefix' maxlength='20' size='20' />";
94 - $local = '';
95 - $trans = '';
 92+ $prefix = Xml::input( 'wpInterwikiPrefix', 20, false, array( 'tabindex'=>'1', 'id'=>'mw-interwiki-prefix', 'maxlength'=>'20') );
 93+ $local = false;
 94+ $trans = false;
9695 $old = '';
97 - $defaulturl = wfMsgHtml( 'interwiki_defaulturl' );
98 - $topmessage = wfMsgHtml( 'interwiki_addtext' );
99 - $intromessage = wfMsgHtml( 'interwiki_addintro' );
100 - $button = wfMsgHtml( 'interwiki_addbutton' );
 96+ $defaulturl = wfMsg( 'interwiki_defaulturl' );
 97+ $topmessage = wfMsgExt( 'interwiki_addtext', array('parseinline') );
 98+ $intromessage = wfMsgExt( 'interwiki_addintro', array('parseinline') );
 99+ $button = wfMsg( 'interwiki_addbutton' );
101100 }
102101
103 - $actionUrl = $selfTitle->escapeLocalURL( 'action=submit' );
 102+ $actionUrl = $selfTitle->getLocalURL( 'action=submit' );
104103 $prefixmessage = wfMsgHtml( 'interwiki_prefix' );
105 - $localmessage = wfMsgHtml( 'interwiki_local' );
106 - $transmessage = wfMsgHtml( 'interwiki_trans' );
107 - $reasonmessage = wfMsgHtml( 'interwiki_reasonfield' );
108 - $urlmessage = wfMsgHtml( 'interwiki_url' );
109 - $token = htmlspecialchars( $wgUser->editToken() );
110 - $defaultreason = htmlspecialchars( wfMsgForContent( 'interwiki_defaultreason' ) );
 104+ $localmessage = wfMsg( 'interwiki_local' );
 105+ $transmessage = wfMsg( 'interwiki_trans' );
 106+ $reasonmessage = wfMsg( 'interwiki_reasonfield' );
 107+ $urlmessage = wfMsg( 'interwiki_url' );
 108+ $token = $wgUser->editToken();
 109+ $defaultreason = wfMsgForContent( 'interwiki_defaultreason' );
111110
112111 $wgOut->addHTML(
113 - "<fieldset>
114 - <legend>$topmessage</legend>
115 - $intromessage
116 - <form id='{$action}' method='post' action='{$actionUrl}'>
117 - <table id='interwikitable-{$action}'><tr>
118 - <td>$prefixmessage</td>
119 - <td>$prefix</td>
120 - </tr><tr>
121 - <td>$localmessage</td>
122 - <td><input type='checkbox' id='local' name='local' {$local}/></td>
123 - </tr><tr>
124 - <td>$transmessage</td>
125 - <td><input type='checkbox' id='trans' name='trans' {$trans}/></td>
126 - </tr><tr>
127 - <td>$urlmessage</td>
128 - <td><input tabindex='1' type='text' name='theurl' maxlength='200' size='60' value='$defaulturl' /></td>
129 - </tr><tr>
130 - <td>$reasonmessage</td>
131 - <td><input tabindex='1' type='text' name='reason' maxlength='200' size='60' value='$defaultreason' /></td>
132 - </tr></table>
133 - <input type='submit' name='{$action}' id='interwiki{$action}button' value='{$button}' />
134 - <input type='hidden' name='do' value='{$action}' />
135 - $old
136 - <input type='hidden' name='wpEditToken' value='{$token}' />
137 - </form>
138 - </fieldset>\n"
 112+ Xml::openElement( 'fieldset' ) .
 113+ Xml::element( 'legend', null, $topmessage ) .
 114+ $intromessage .
 115+ Xml::openElement( 'form', array('id'=> 'mw-interwiki-editform', 'method'=> 'post', 'action'=>$actionUrl) ) .
 116+ Xml::openElement( 'table', array('id'=>"mw-interwiki-$action") ) .
 117+ "<tr><td class='mw-label'>$prefixmessage</td><td><tt>$prefix</tt></td></tr>" .
 118+ "<tr><td class='mw-label'>" . Xml::label( $localmessage, 'mw-interwiki-local' ) . '</td>' .
 119+ "<td class='mw-input'>" . Xml::check( 'wpInterwikiLocal', $local, array('id'=>'mw-interwiki-local') ) . '</td></tr>' .
 120+ '<tr><td class="mw-label">' . Xml::label( $transmessage, 'mw-interwiki-trans' ) . '</td>' .
 121+ '<td class="mw-input">' . Xml::check( 'wpInterwikiTrans', $trans, array('id'=>'mw-interwiki-trans') ) . '</td></tr>' .
 122+ '<tr><td class="mw-label">' . Xml::label( $urlmessage, 'mw-interwiki-url' ) . '</td>' .
 123+ '<td class="mw-input">' . Xml::input( 'wpInterwikiURL', 60, $defaulturl, array('tabindex'=>'1', 'maxlength'=>'200', 'id'=>'mw-interwiki-url') ) . '</td></tr>' .
 124+ '<tr><td class="mw-label">' . Xml::label( $reasonmessage, 'mw-interwiki-editreason' ) . '</td>' .
 125+ '<td class="mw-input">' . Xml::input( 'wpInterwikiReason', 60, $defaultreason, array( 'tabindex'=>'1', 'id'=>'mw-interwiki-editreason', 'maxlength'=>'200') ) .
 126+ Xml::hidden( 'wpInterwikiAction', $action ) .
 127+ $old .
 128+ Xml::hidden( 'wpEditToken', $token ) .
 129+ '</td></tr>' .
 130+ '<tr><td class="mw-submit">' . Xml::submitButton( $button, array('id'=>'mw-interwiki-submit') ) . '</td></tr>' .
 131+ Xml::closeElement( 'table' ) .
 132+ Xml::closeElement( 'form' ) .
 133+ Xml::closeElement( 'fieldset' )
139134 );
140135 break;
141136 case "submit":
@@ -147,9 +142,9 @@
148143 return;
149144 }
150145
151 - $prefix = $wgRequest->getVal('prefix');
152 - $reason = $wgRequest->getText('reason');
153 - $do = $wgRequest->getVal('do');
 146+ $prefix = $wgRequest->getVal( 'wpInterwikiPrefix' );
 147+ $reason = $wgRequest->getText( 'wpInterwikiReason' );
 148+ $do = $wgRequest->getVal( 'wpInterwikiAction' );
154149 $dbw = wfGetDB( DB_MASTER );
155150 switch( $do ){
156151 case "delete":
@@ -166,9 +161,9 @@
167162 break;
168163 case "edit":
169164 case "add":
170 - $theurl = $wgRequest->getVal('theurl');
171 - $local = $wgRequest->getCheck('local') ? 1 : 0;
172 - $trans = $wgRequest->getCheck('trans') ? 1 : 0;
 165+ $theurl = $wgRequest->getVal( 'wpInterwikiURL' );
 166+ $local = $wgRequest->getCheck( 'wpInterwikiLocal' ) ? 1 : 0;
 167+ $trans = $wgRequest->getCheck( 'wpInterwikiTrans' ) ? 1 : 0;
173168 $data = array( 'iw_prefix' => $prefix, 'iw_url' => $theurl,
174169 'iw_local' => $local, 'iw_trans' => $trans );
175170
@@ -195,7 +190,7 @@
196191 $localmessage = wfMsgHtml( 'interwiki_local' );
197192 $transmessage = wfMsgHtml( 'interwiki_trans' );
198193
199 - $wgOut->addWikiText( wfMsg( 'interwiki_intro', '[http://www.mediawiki.org/wiki/Interwiki_table MediaWiki.org]' ) );
 194+ $wgOut->addWikiText( wfMsg( 'interwiki_intro' ) );
200195
201196 if ($admin) {
202197 $skin = $wgUser->getSkin();
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2212,7 +2212,7 @@
22132213 Remember that this can break existing links.',
22142214 'interwiki_edittext' => 'Editing an interwiki prefix',
22152215 'interwiki_error' => 'Error: The interwiki table is empty, or something else went wrong.',
2216 -'interwiki_intro' => 'See $1 for more information about the interwiki table.
 2216+'interwiki_intro' => 'See [http://www.mediawiki.org/wiki/Interwiki_table MediaWiki.org] for more information about the interwiki table.
22172217 There is a [[Special:Log/interwiki|log of changes]] to the interwiki table.',
22182218 'interwiki_local' => 'Define this as a local wiki',
22192219 'interwiki_log_added' => 'added prefix "$2" ($3) (trans: $4) (local: $5) to the interwiki table',

Status & tagging log