r68827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68826‎ | r68827 | r68828 >
Date:11:04, 1 July 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Code cleanup, i18n fixes and fixmes
Modified paths:
  • /trunk/extensions/AuthorProtect/AuthorProtect.php (modified) (history)

Diff [purge]

Index: trunk/extensions/AuthorProtect/AuthorProtect.php
@@ -99,7 +99,6 @@
100100 function efAuthorProtectForm( $action, $article ) {
101101 global $wgTitle, $wgAuthorProtectDoProtect;
102102 if ( $action == 'authorprotect' ) {
103 - wfLoadExtensionMessages( 'AuthorProtect' );
104103 global $wgOut, $wgUser, $wgRequest, $wgRestrictionTypes;
105104 if ( $wgUser->isAllowed( 'authorprotect' ) ) {
106105 if ( userIsAuthor() ) {
@@ -109,7 +108,7 @@
110109 } else {
111110 if ( !$wgUser->matchEditToken( $wgRequest->getText( 'wpToken' ) ) ) {
112111 $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) );
113 - $wgOut->addWikiText( wfMsg( 'sessionfailure' ) );
 112+ $wgOut->addWikiMsg( 'sessionfailure' );
114113 return false;
115114 }
116115 $restrictions = array();
@@ -148,14 +147,14 @@
149148 );
150149 efAuthorProtectUnassignProtect();
151150 if ( $success ) {
152 - $wgOut->addWikiText( wfMsg( 'authorprotect-success' ) );
 151+ $wgOut->addWikiMsg( 'authorprotect-success' );
153152 } else {
154 - $wgOut->addWikiText( wfMsg( 'authorprotect-failure' ) );
 153+ $wgOut->addWikiMsg( 'authorprotect-failure' );
155154 }
156155 }
157156 } else {
158157 $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) );
159 - $wgOut->addWikiText( wfMsg( 'authorprotect-notauthor' ) );
 158+ $wgOut->addWikiMsg( 'authorprotect-notauthor' );
160159 }
161160 } else {
162161 $wgOut->permissionRequired( 'authorprotect' );
@@ -168,27 +167,30 @@
169168 function efAuthorProtectMakeProtectForm() {
170169 global $wgRestrictionTypes, $wgTitle, $wgUser;
171170 $token = $wgUser->editToken();
 171+ // FIXME: raw html messages
172172 $form = Xml::openElement( 'p' ) . wfMsg( 'authorprotect-intro' ) . Xml::closeElement( 'p' );
173173 $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $wgTitle->getLocalUrl( 'action=authorprotect' ) ) );
 174+
 175+ $br = Html::element( 'br' );
 176+
174177 foreach ( $wgRestrictionTypes as $type ) {
175178 $rest = $wgTitle->getRestrictions( $type );
176179 if ( $rest !== array() ) {
177180 if ( !$wgUser->isAllowed( $rest[0] ) && !in_array( 'author', $rest ) )
178181 continue; // it's protected at a level higher than them, so don't let them change it so they can now mess with stuff
179182 }
180 - $checked = in_array( 'author', $rest );
181 - $array = array( 'type' => 'checkbox', 'name' => 'check-' . $type, 'value' => $type );
182 - if ( $checked )
183 - $array = array_merge( $array, array( 'checked' => 'checked' ) );
184 - $form .= Xml::element( 'input', $array );
185 - $form .= ' ' . wfMsg( 'authorprotect-' . $type ) . Xml::element( 'br' );
 183+
 184+ $checked = in_array( 'author', $rest );
 185+ $form .= Xml::checkLabel( wfMsg( "authorprotect-$type" ), "check-$type", "check-$type", $checked ) . $br;
186186 }
187 - $form .= Xml::element( 'br' ) . Xml::element( 'label', array( 'for' => 'wpExpiryTime' ), wfMsg( 'authorprotect-expiry' ) ) . ' ';
188 - $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'wpExpiryTime' ) ) . Xml::element( 'br' );
189 - $form .= Xml::element( 'br' ) . Xml::element( 'label', array( 'for' => 'wpReason' ), wfMsg( 'authorprotect-reason' ) ) . ' ';
 187+
 188+ // FIXME: use Xml::inputLabel
 189+ $form .= $br . Xml::element( 'label', array( 'for' => 'wpExpiryTime' ), wfMsg( 'authorprotect-expiry' ) ) . ' ';
 190+ $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'wpExpiryTime' ) ) . $br;
 191+ $form .= $br . Xml::element( 'label', array( 'for' => 'wpReason' ), wfMsg( 'authorprotect-reason' ) ) . ' ';
190192 $form .= Xml::element( 'input', array( 'type' => 'text', 'name' => 'wpReason' ) );
191 - $form .= Xml::element( 'br' ) . Xml::element( 'input', array( 'type' => 'hidden', 'name' => 'wpToken', 'value' => $token ) );
192 - $form .= Xml::element( 'br' ) . Xml::element( 'input', array( 'type' => 'submit', 'name' => 'wpConfirm', 'value' => wfMsg( 'authorprotect-confirm' ) ) );
 193+ $form .= $br . Html::hidden( 'wpToken', $token );
 194+ $form .= $br . Xml::element( 'input', array( 'type' => 'submit', 'name' => 'wpConfirm', 'value' => wfMsg( 'authorprotect-confirm' ) ) );
193195 $form .= Xml::closeElement( 'form' );
194196 return $form;
195197 }
@@ -200,6 +202,7 @@
201203 $id = $wgTitle->getArticleId();
202204 $dbr = wfGetDB( DB_SLAVE ); // grab the slave for reading
203205 $aid = $dbr->selectField( 'revision', 'rev_user', array( 'rev_page' => $id ), __METHOD__ );
 206+ // FIXME: weak comparison
204207 return $wgUser->getID() == $aid;
205208 }
206209

Status & tagging log