Index: trunk/extensions/AuthorProtect/AuthorProtect.php |
— | — | @@ -99,7 +99,6 @@ |
100 | 100 | function efAuthorProtectForm( $action, $article ) { |
101 | 101 | global $wgTitle, $wgAuthorProtectDoProtect; |
102 | 102 | if ( $action == 'authorprotect' ) { |
103 | | - wfLoadExtensionMessages( 'AuthorProtect' ); |
104 | 103 | global $wgOut, $wgUser, $wgRequest, $wgRestrictionTypes; |
105 | 104 | if ( $wgUser->isAllowed( 'authorprotect' ) ) { |
106 | 105 | if ( userIsAuthor() ) { |
— | — | @@ -109,7 +108,7 @@ |
110 | 109 | } else { |
111 | 110 | if ( !$wgUser->matchEditToken( $wgRequest->getText( 'wpToken' ) ) ) { |
112 | 111 | $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) ); |
113 | | - $wgOut->addWikiText( wfMsg( 'sessionfailure' ) ); |
| 112 | + $wgOut->addWikiMsg( 'sessionfailure' ); |
114 | 113 | return false; |
115 | 114 | } |
116 | 115 | $restrictions = array(); |
— | — | @@ -148,14 +147,14 @@ |
149 | 148 | ); |
150 | 149 | efAuthorProtectUnassignProtect(); |
151 | 150 | if ( $success ) { |
152 | | - $wgOut->addWikiText( wfMsg( 'authorprotect-success' ) ); |
| 151 | + $wgOut->addWikiMsg( 'authorprotect-success' ); |
153 | 152 | } else { |
154 | | - $wgOut->addWikiText( wfMsg( 'authorprotect-failure' ) ); |
| 153 | + $wgOut->addWikiMsg( 'authorprotect-failure' ); |
155 | 154 | } |
156 | 155 | } |
157 | 156 | } else { |
158 | 157 | $wgOut->setPageTitle( wfMsg( 'errorpagetitle' ) ); |
159 | | - $wgOut->addWikiText( wfMsg( 'authorprotect-notauthor' ) ); |
| 158 | + $wgOut->addWikiMsg( 'authorprotect-notauthor' ); |
160 | 159 | } |
161 | 160 | } else { |
162 | 161 | $wgOut->permissionRequired( 'authorprotect' ); |
— | — | @@ -168,27 +167,30 @@ |
169 | 168 | function efAuthorProtectMakeProtectForm() { |
170 | 169 | global $wgRestrictionTypes, $wgTitle, $wgUser; |
171 | 170 | $token = $wgUser->editToken(); |
| 171 | + // FIXME: raw html messages |
172 | 172 | $form = Xml::openElement( 'p' ) . wfMsg( 'authorprotect-intro' ) . Xml::closeElement( 'p' ); |
173 | 173 | $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $wgTitle->getLocalUrl( 'action=authorprotect' ) ) ); |
| 174 | + |
| 175 | + $br = Html::element( 'br' ); |
| 176 | + |
174 | 177 | foreach ( $wgRestrictionTypes as $type ) { |
175 | 178 | $rest = $wgTitle->getRestrictions( $type ); |
176 | 179 | if ( $rest !== array() ) { |
177 | 180 | if ( !$wgUser->isAllowed( $rest[0] ) && !in_array( 'author', $rest ) ) |
178 | 181 | continue; // it's protected at a level higher than them, so don't let them change it so they can now mess with stuff |
179 | 182 | } |
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; |
186 | 186 | } |
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' ) ) . ' '; |
190 | 192 | $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' ) ) ); |
193 | 195 | $form .= Xml::closeElement( 'form' ); |
194 | 196 | return $form; |
195 | 197 | } |
— | — | @@ -200,6 +202,7 @@ |
201 | 203 | $id = $wgTitle->getArticleId(); |
202 | 204 | $dbr = wfGetDB( DB_SLAVE ); // grab the slave for reading |
203 | 205 | $aid = $dbr->selectField( 'revision', 'rev_user', array( 'rev_page' => $id ), __METHOD__ ); |
| 206 | + // FIXME: weak comparison |
204 | 207 | return $wgUser->getID() == $aid; |
205 | 208 | } |
206 | 209 | |