Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -1514,63 +1514,9 @@ |
1515 | 1515 | 'id' => 'fr-rating-controls') ); |
1516 | 1516 | $toggle = array(); |
1517 | 1517 | } |
1518 | | - $size = count(FlaggedRevs::getDimensions(),1) - count(FlaggedRevs::getDimensions()); |
1519 | | - |
| 1518 | + # Add main checkboxes/selects |
1520 | 1519 | $form .= Xml::openElement( 'span', array('id' => 'mw-ratingselects') ); |
1521 | | - # Loop through all different flag types |
1522 | | - foreach( FlaggedRevs::getDimensions() as $quality => $levels ) { |
1523 | | - $label = array(); |
1524 | | - $selected = ( isset($flags[$quality]) && $flags[$quality] > 0 ) ? |
1525 | | - $flags[$quality] : 1; |
1526 | | - # Disabled form? Set the selected item label |
1527 | | - if( $disabled ) { |
1528 | | - $label[$selected] = $levels[$selected]; |
1529 | | - # Collect all quality levels of a flag current user can set |
1530 | | - } else { |
1531 | | - foreach( $levels as $i => $name ) { |
1532 | | - if( !RevisionReview::userCan($quality,$i,$config) ) { |
1533 | | - if( $selected == $i ) $selected++; // bump default |
1534 | | - continue; // skip this level |
1535 | | - } |
1536 | | - $label[$i] = $name; |
1537 | | - } |
1538 | | - } |
1539 | | - $quantity = count( $label ); |
1540 | | - $form .= Xml::openElement( 'span', array('class' => 'fr-rating-options') ) . "\n"; |
1541 | | - $form .= "<b>" . Xml::tags( 'label', array( 'for' => "wp$quality" ), FlaggedRevs::getTagMsg( $quality ) ) . ":</b>\n"; |
1542 | | - # If the sum of qualities of all flags is above 6, use drop down boxes |
1543 | | - # 6 is an arbitrary value choosen according to screen space and usability |
1544 | | - if( $size > 6 ) { |
1545 | | - $attribs = array( 'name' => "wp$quality", 'id' => "wp$quality", 'onchange' => "updateRatingForm()" ) + $toggle; |
1546 | | - $form .= Xml::openElement( 'select', $attribs ); |
1547 | | - foreach( $label as $i => $name ) { |
1548 | | - $optionClass = array( 'class' => "fr-rating-option-$i" ); |
1549 | | - $form .= Xml::option( FlaggedRevs::getTagMsg($name), $i, ($i == $selected), $optionClass )."\n"; |
1550 | | - } |
1551 | | - $form .= Xml::closeElement('select')."\n"; |
1552 | | - # If there are more than two qualities (none, 1 and more) current user gets radio buttons |
1553 | | - } elseif( $quantity > 2 ) { |
1554 | | - foreach( $label as $i => $name ) { |
1555 | | - $attribs = array( 'class' => "fr-rating-option-$i", 'onchange' => "updateRatingForm()" ); |
1556 | | - $form .= Xml::radioLabel( FlaggedRevs::getTagMsg($name), "wp$quality", $i, "wp$quality".$i, |
1557 | | - ($i == $selected), $attribs ) . "\n"; |
1558 | | - } |
1559 | | - # Otherwise make checkboxes (two qualities available for current user |
1560 | | - # and disabled fields in case we are below the magic 6) |
1561 | | - } else { |
1562 | | - $i = $disabled ? $selected : 1; |
1563 | | - $attribs = array( 'class' => "fr-rating-option-$i", 'onchange' => "updateRatingForm()" ) + $toggle; |
1564 | | - $form .= Xml::checkLabel( wfMsg( "revreview-$label[$i]" ), "wp$quality", "wp$quality", |
1565 | | - ($selected == $i), $attribs ) . "\n"; |
1566 | | - } |
1567 | | - $form .= Xml::closeElement( 'span' ); |
1568 | | - } |
1569 | | - # If there were none, make one checkbox to approve/unapprove |
1570 | | - if( FlaggedRevs::dimensionsEmpty() ) { |
1571 | | - $form .= Xml::openElement( 'span', array('class' => 'fr-rating-options') ) . "\n"; |
1572 | | - $form .= Xml::checkLabel( wfMsg( "revreview-approved" ), "wpApprove", "wpApprove", 1 ) . "\n"; |
1573 | | - $form .= Xml::closeElement( 'span' ); |
1574 | | - } |
| 1520 | + $form .= FlaggedRevsXml::ratingInputs( $flags, $config, $disabled ); |
1575 | 1521 | $form .= Xml::closeElement( 'span' ); |
1576 | 1522 | |
1577 | 1523 | if( FlaggedRevs::allowComments() && $wgUser->isAllowed( 'validate' ) ) { |
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -57,6 +57,7 @@ |
58 | 58 | self::$minSL[$tag] = 1; |
59 | 59 | } |
60 | 60 | global $wgFlaggedRevsProtectLevels; |
| 61 | + $wgFlaggedRevsProtectLevels = (array)$wgFlaggedRevsProtectLevels; |
61 | 62 | foreach( $wgFlaggedRevsProtectLevels as $level => &$config ) { |
62 | 63 | # Sanity checks |
63 | 64 | if( !isset($config['select']) || !isset($config['override']) || !isset($config['autoreview']) ) { |
Index: branches/wmf-deployment/extensions/FlaggedRevs/specialpages/StablePages_body.php |
— | — | @@ -62,8 +62,13 @@ |
63 | 63 | $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
64 | 64 | |
65 | 65 | $stitle = SpecialPage::getTitleFor( 'Stabilization' ); |
66 | | - $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml('stablepages-config'), |
67 | | - 'page=' . $title->getPrefixedUrl() ); |
| 66 | + if( count( FlaggedRevs::getProtectionLevels() ) ) { |
| 67 | + $config = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('stablepages-config'), |
| 68 | + 'action=protect' ); |
| 69 | + } else { |
| 70 | + $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml('stablepages-config'), |
| 71 | + 'page=' . $title->getPrefixedUrl() ); |
| 72 | + } |
68 | 73 | $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml('stablepages-stable'), 'stable=1' ); |
69 | 74 | |
70 | 75 | if( intval($row->fpc_select) === FLAGGED_VIS_PRISTINE ) { |
Index: branches/wmf-deployment/extensions/FlaggedRevs/FlaggedRevsXML.php |
— | — | @@ -242,4 +242,79 @@ |
243 | 243 | " onclick='toggleRevRatings()' title='" . wfMsgHtml('revreview-toggle-title') . "' >" . |
244 | 244 | wfMsg( 'revreview-toggle' ) . "</a>"; |
245 | 245 | } |
| 246 | + |
| 247 | + /** |
| 248 | + * @param array $flags, selected flags |
| 249 | + * @param array $config, page config |
| 250 | + * @param bool $disabled, form disabled |
| 251 | + * @returns string |
| 252 | + * Generates a main tag inputs (checkboxes/radios/selects) for review form |
| 253 | + */ |
| 254 | + public static function ratingInputs( $flags, $config, $disabled ) { |
| 255 | + $form = ''; |
| 256 | + $toggle = $disabled ? array( 'disabled' => "disabled" ) : array(); |
| 257 | + $size = count(FlaggedRevs::getDimensions(),1) - count(FlaggedRevs::getDimensions()); |
| 258 | + # Loop through all different flag types |
| 259 | + foreach( FlaggedRevs::getDimensions() as $quality => $levels ) { |
| 260 | + $label = array(); // applicable tag levels |
| 261 | + $minLevel = 1; // first non-zero level number |
| 262 | + # Get current flag values or default if none |
| 263 | + $selected = ( isset($flags[$quality]) && $flags[$quality] > 0 ) ? |
| 264 | + $flags[$quality] : 1; |
| 265 | + # Disabled form? Set the selected item label |
| 266 | + if( $disabled ) { |
| 267 | + $label[$selected] = $levels[$selected]; |
| 268 | + # Collect all quality levels of a flag current user can set |
| 269 | + } else { |
| 270 | + foreach( $levels as $i => $name ) { |
| 271 | + # Some levels may be restricted or not applicable... |
| 272 | + if( !RevisionReview::userCan($quality,$i,$config) ) { |
| 273 | + if( $selected == $i ) $selected++; // bump default |
| 274 | + continue; // skip this level |
| 275 | + } else if( $i > 0 ) { |
| 276 | + $minLevel = $i; // first non-zero level number |
| 277 | + } |
| 278 | + $label[$i] = $name; |
| 279 | + } |
| 280 | + } |
| 281 | + $numLevels = count( $label ); |
| 282 | + $form .= Xml::openElement( 'span', array('class' => 'fr-rating-options') ) . "\n"; |
| 283 | + $form .= "<b>" . Xml::tags( 'label', array( 'for' => "wp$quality" ), |
| 284 | + FlaggedRevs::getTagMsg( $quality ) ) . ":</b>\n"; |
| 285 | + # If the sum of qualities of all flags is above 6, use drop down boxes |
| 286 | + # 6 is an arbitrary value choosen according to screen space and usability |
| 287 | + if( $size > 6 ) { |
| 288 | + $attribs = array( 'name' => "wp$quality", 'id' => "wp$quality", 'onchange' => "updateRatingForm()" ) + $toggle; |
| 289 | + $form .= Xml::openElement( 'select', $attribs ); |
| 290 | + foreach( $label as $i => $name ) { |
| 291 | + $optionClass = array( 'class' => "fr-rating-option-$i" ); |
| 292 | + $form .= Xml::option( FlaggedRevs::getTagMsg($name), $i, ($i == $selected), $optionClass )."\n"; |
| 293 | + } |
| 294 | + $form .= Xml::closeElement('select')."\n"; |
| 295 | + # If there are more than two levels, current user gets radio buttons |
| 296 | + } elseif( $numLevels > 2 ) { |
| 297 | + foreach( $label as $i => $name ) { |
| 298 | + $attribs = array( 'class' => "fr-rating-option-$i", 'onchange' => "updateRatingForm()" ); |
| 299 | + $form .= Xml::radioLabel( FlaggedRevs::getTagMsg($name), "wp$quality", $i, "wp$quality".$i, |
| 300 | + ($i == $selected), $attribs ) . "\n"; |
| 301 | + } |
| 302 | + # Otherwise make checkboxes (two levels available for current user) |
| 303 | + } else { |
| 304 | + # If disable, use the current flags; if none, then use the min flag. |
| 305 | + $i = $disabled ? $selected : $minLevel; |
| 306 | + $attribs = array( 'class' => "fr-rating-option-$i", 'onchange' => "updateRatingForm()" ); |
| 307 | + $attribs = $attribs + $toggle + array('value' => $minLevel); |
| 308 | + $form .= Xml::checkLabel( wfMsg( "revreview-{$label[$i]}" ), "wp$quality", "wp$quality", |
| 309 | + ($selected == $i), $attribs ) . "\n"; |
| 310 | + } |
| 311 | + $form .= Xml::closeElement( 'span' ); |
| 312 | + } |
| 313 | + # If there were none, make one checkbox to approve/unapprove |
| 314 | + if( FlaggedRevs::dimensionsEmpty() ) { |
| 315 | + $form .= Xml::openElement( 'span', array('class' => 'fr-rating-options') ) . "\n"; |
| 316 | + $form .= Xml::checkLabel( wfMsg( "revreview-approved" ), "wpApprove", "wpApprove", 1 ) . "\n"; |
| 317 | + $form .= Xml::closeElement( 'span' ); |
| 318 | + } |
| 319 | + return $form; |
| 320 | + } |
246 | 321 | } |
Property changes on: branches/wmf-deployment/extensions/FlaggedRevs |
___________________________________________________________________ |
Name: svn:mergeinfo |
247 | 322 | - /branches/REL1_15/phase3/extensions/FlaggedRevs:51646 |
/trunk/extensions/FlaggedRevs:56151-57450 |
/trunk/phase3/extensions/FlaggedRevs:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447 |
248 | 323 | + /branches/REL1_15/phase3/extensions/FlaggedRevs:51646 |
/trunk/extensions/FlaggedRevs:56151-57450,57735-57736 |
/trunk/phase3/extensions/FlaggedRevs:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447 |