r60821 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60820‎ | r60821 | r60822 >
Date:01:31, 8 January 2010
Author:aaron
Status:ok
Tags:
Comment:
* Removed secondary form. Almost never comes up and makes things harder to maintain.
* Removed mergeTemplateParams(), unused since r60533
* Use session fail message when needed
Modified paths:
  • /trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/language/FlaggedRevs.i18n.php
@@ -167,8 +167,10 @@
168168 'revreview-text2' => '\'\'[[{{MediaWiki:Validationpage}}|Stable versions]] are checked revisions of pages and can be set as the default content for viewers.\'\'',
169169 'revreview-toggle' => '(+/-)',
170170 'revreview-toggle-title' => 'show/hide details',
171 - 'revreview-toolow' => 'You must at least rate each of the below attributes higher than "unapproved" in order for a revision to be considered reviewed.
172 -To deprecate a revision, set all fields to "unapproved".',
 171+ 'revreview-toolow' => '\'\'\'You must at least rate each of the below attributes higher than "unapproved" in order for a revision to be considered reviewed.\'\'\'
 172+To deprecate a revision, set all fields to "unapproved".
 173+
 174+Please hit the "back" button in your browser and try again.',
173175 'revreview-update' => 'Please [[{{MediaWiki:Validationpage}}|review]] any changes \'\'(shown below)\'\' made since the stable revision was [{{fullurl:{{#Special:Log}}|type=review&page={{FULLPAGENAMEE}}}} approved].<br />
174176 \'\'\'Some templates/files were updated:\'\'\'',
175177 'revreview-update-includes' => '\'\'\'Some templates/files were updated:\'\'\'',
Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php
@@ -117,14 +117,17 @@
118118 }
119119 # We must at least rate each category as 1, the minimum
120120 # Exception: we can rate ALL as unapproved to depreciate a revision
121 - $valid = true;
122121 if( $this->unapprovedTags && $this->unapprovedTags < count( FlaggedRevs::getDimensions() ) ) {
123 - $valid = false;
 122+ $wgOut->addWikiText( wfMsg( 'revreview-toolow' ) );
 123+ $wgOut->returnToMain( false, $this->page );
 124+ return;
124125 } elseif( !$wgUser->matchEditToken( $wgRequest->getVal('wpEditToken') ) ) {
125 - $valid = false;
 126+ $wgOut->addWikiText( wfMsg('sessionfailure') );
 127+ $wgOut->returnToMain( false, $this->page );
 128+ return;
126129 }
127130 # Submit or display info on failure
128 - if( $valid && $wgRequest->wasPosted() ) {
 131+ if( $wgRequest->wasPosted() ) {
129132 list($approved,$status) = $this->submit();
130133 // Success for either flagging or unflagging
131134 if( $status === true ) {
@@ -143,9 +146,6 @@
144147 $wgOut->showErrorPage( 'internalerror', 'revreview-revnotfound' );
145148 $wgOut->returnToMain( false, $this->page );
146149 }
147 - # Show revision and form
148 - } else {
149 - $this->showRevision();
150150 }
151151 }
152152
@@ -279,114 +279,6 @@
280280 }
281281 }
282282
283 - /**
284 - * Show revision review form
285 - */
286 - private function showRevision() {
287 - global $wgOut, $wgUser, $wgFlaggedRevComments;
288 -
289 - if( $this->unapprovedTags )
290 - $wgOut->addWikiText( '<strong>' . wfMsg( 'revreview-toolow' ) . '</strong>' );
291 -
292 - $wgOut->addWikiText( wfMsg( 'revreview-selected', $this->page->getPrefixedText() ) );
293 -
294 - $rev = Revision::newFromTitle( $this->page, $this->oldid );
295 - # Check if rev exists
296 - # Do not mess with deleted revisions
297 - if( !isset( $rev ) || $rev->mDeleted ) {
298 - $wgOut->showErrorPage( 'internalerror', 'notargettitle', 'notargettext' );
299 - return;
300 - }
301 -
302 - $wgOut->addHTML( "<ul>" );
303 - $wgOut->addHTML( $this->historyLine( $rev ) );
304 - $wgOut->addHTML( "</ul>" );
305 -
306 - if( FlaggedRevs::showStableByDefault() )
307 - $wgOut->addWikiText( wfMsg('revreview-text') );
308 -
309 - $action = $this->getTitle()->escapeLocalUrl( 'action=submit' );
310 - $form = "<form name='RevisionReview' action='$action' method='post'>";
311 - $form .= '<fieldset><legend>' . wfMsgHtml( 'revreview-legend' ) . '</legend><table><tr>';
312 -
313 - $formradios = array();
314 - # Dynamically contruct our radio options
315 - foreach( FlaggedRevs::getDimensions() as $tag => $levels ) {
316 - $formradios[$tag] = array();
317 - $x = count($levels); // number of levels AND zero
318 - for( $i=0; $i < $x; $i++ ) {
319 - $formradios[$tag][] = array( "revreview-$tag-$i", "wp$tag", $i );
320 - }
321 - $form .= '<td><strong>' . wfMsgHtml( "revreview-$tag" ) .
322 - '</strong></td><td width=\'20\'></td>';
323 - }
324 - $hidden = array(
325 - Xml::hidden( 'wpEditToken', $wgUser->editToken() ),
326 - Xml::hidden( 'target', $this->page->getPrefixedText() ),
327 - Xml::hidden( 'oldid', $this->oldid )
328 - );
329 -
330 - $form .= '</tr><tr>';
331 - foreach( $formradios as $set => $ratioset ) {
332 - $form .= '<td>';
333 - foreach( $ratioset as $item ) {
334 - list( $message, $name, $field ) = $item;
335 - # Don't give options the user can't set unless its the status quo
336 - $attribs = array('id' => $name.$field);
337 - if( !$this->userCan($set,$field) )
338 - $attribs['disabled'] = 'true';
339 - $form .= "<div>";
340 - $form .= Xml::radio( $name, $field, ($field==$this->dims[$set]), $attribs );
341 - $form .= Xml::label( wfMsg($message), $name.$field );
342 - $form .= "</div>\n";
343 - }
344 - $form .= '</td><td width=\'20\'></td>';
345 - }
346 - $form .= '</tr></table></fieldset>';
347 - # Add box to add live notes to a flagged revision
348 - if( $wgFlaggedRevComments && $wgUser->isAllowed( 'validate' ) ) {
349 - $form .= "<fieldset><legend>" . wfMsgHtml( 'revreview-notes' ) . "</legend>" .
350 - "<textarea tabindex='1' name='wpNotes' id='wpNotes' rows='3' cols='80' style='width:100%'>" .
351 - htmlspecialchars( $this->notes ) .
352 - "</textarea></fieldset>";
353 - }
354 -
355 - $form .= '<fieldset><legend>' . wfMsgHtml('revisionreview') . '</legend>';
356 - $form .= '<p>'.Xml::inputLabel( wfMsg( 'revreview-log' ), 'wpReason', 'wpReason', 60 ).'</p>';
357 - $form .= '<p>'.Xml::submitButton( wfMsg( 'revreview-submit' ) ).'</p>';
358 - foreach( $hidden as $item ) {
359 - $form .= $item;
360 - }
361 - # Hack, versioning params
362 - $form .= Xml::hidden( 'templateParams', $this->templateParams ) . "\n";
363 - $form .= Xml::hidden( 'imageParams', $this->imageParams ) . "\n";
364 - $form .= Xml::hidden( 'fileVersion', $this->fileVersion ) . "\n";
365 - $form .= Xml::hidden( 'wpApprove', $this->approve ) . "\n";
366 - $form .= Xml::hidden( 'rcid', $this->rcid ) . "\n";
367 - # Special token to discourage fiddling...
368 - $checkCode = self::validationKey( $this->templateParams, $this->imageParams,
369 - $this->fileVersion, $rev->getId() );
370 - $form .= Xml::hidden( 'validatedParams', $checkCode );
371 - $form .= '</fieldset>';
372 -
373 - $form .= '</form>';
374 - $wgOut->addHTML( $form );
375 - }
376 -
377 - /**
378 - * @param Revision $rev
379 - * @return string
380 - */
381 - private function historyLine( $rev ) {
382 - global $wgContLang;
383 - $date = $wgContLang->timeanddate( $rev->getTimestamp() );
384 - $difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'),
385 - '&diff=' . $rev->getId() . '&oldid=prev' ) . ')';
386 - $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() );
387 - return "<li>$difflink $revlink " . $this->skin->revUserLink($rev) . " " .
388 - $this->skin->revComment($rev) . "</li>";
389 - }
390 -
391283 public function isApproval() {
392284 # If all values are set to zero, this has been unapproved
393285 if( FlaggedRevs::dimensionsEmpty() && $this->approve ) {
@@ -870,27 +762,4 @@
871763 }
872764 wfProfileOut( __METHOD__ );
873765 }
874 -
875 - private function mergeTemplateParams( $pout, $tmps, $tmpIds, $maxID ) {
876 - foreach( $tmps as $ns => $dbkey_id ) {
877 - foreach( $dbkey_id as $dbkey => $pageid ) {
878 - if( !isset($pout->mTemplates[$ns]) )
879 - $pout->mTemplates[$ns] = array();
880 - # Add in this template; overrides
881 - $pout->mTemplates[$ns][$dbkey] = $pageid;
882 - }
883 - }
884 - # Merge in template params from first phase of parsing...
885 - foreach( $tmpIds as $ns => $dbkey_id ) {
886 - foreach( $dbkey_id as $dbkey => $revid ) {
887 - if( !isset($pout->mTemplateIds[$ns]) )
888 - $pout->mTemplateIds[$ns] = array();
889 - # Add in this template; overrides
890 - $pout->mTemplateIds[$ns][$dbkey] = $revid;
891 - }
892 - }
893 - if( $maxID > $pout->fr_newestTemplateID ) {
894 - $pout->fr_newestTemplateID = $maxID;
895 - }
896 - }
897766 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r60533* Changed 2-stage parsing to 1-state parsing for review. Expanded text isn't ...aaron01:35, 1 January 2010

Status & tagging log