r46658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46657‎ | r46658 | r46659 >
Date:20:40, 31 January 2009
Author:aaron
Status:deferred
Tags:
Comment:
Remove $wgFlaggedRevValues (with b/c) and extend said functionality with 'levels' param to $wgFlaggedRevTags
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -127,15 +127,13 @@
128128
129129 # When setting up new dimensions or levels, you will need to add some
130130 # MediaWiki messages for the UI to show properly; any sysop can do this.
131 -# Define the tags we can use to rate an article, and set the minimum level
132 -# to have it become a "quality" or "pristine" version.
 131+# Define the tags we can use to rate an article, number of levels,
 132+# and set the minimum level to have it become a "quality" or "pristine" version.
133133 $wgFlaggedRevTags = array(
134 - 'accuracy' => array( 'quality' => 2, 'pristine' => 4 ),
135 - 'depth' => array( 'quality' => 1, 'pristine' => 4 ),
136 - 'style' => array( 'quality' => 1, 'pristine' => 4 ),
 134+ 'accuracy' => array( 'levels' => 3, 'quality' => 2, 'pristine' => 4 ),
 135+ 'depth' => array( 'levels' => 3, 'quality' => 1, 'pristine' => 4 ),
 136+ 'style' => array( 'levels' => 3, 'quality' => 1, 'pristine' => 4 ),
137137 );
138 -# How high can we rate these revisions?
139 -$wgFlaggedRevValues = 3;
140138 # Who can set what flags to what level? (use -1 or 0 for not at all)
141139 # This maps rights to the highest reviewable level for each tag.
142140 # Users cannot lower tags from a level they can't set
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -12,7 +12,7 @@
1313 protected static $includeVersionCache = array();
1414
1515 public static function load() {
16 - global $wgFlaggedRevTags, $wgFlaggedRevValues, $wgFlaggedRevsFeedbackTags;
 16+ global $wgFlaggedRevTags, $wgFlaggedRevsFeedbackTags;
1717 if( self::$loaded ) return true;
1818 # Assume true, then set to false if needed
1919 if( !empty($wgFlaggedRevTags) ) {
@@ -25,30 +25,32 @@
2626 if( !preg_match('/^[a-zA-Z]{1,20}$/',$tag) || $safeTag !== $tag ) {
2727 throw new MWException( 'FlaggedRevs given invalid tag name!' );
2828 }
29 - # Set FlaggedRevs tags
30 - self::$dimensions[$tag] = array();
31 - for( $i=0; $i <= $wgFlaggedRevValues; $i++ ) {
32 - self::$dimensions[$tag][$i] = "{$tag}-{$i}";
33 - }
3429 # Define "quality" and "pristine" reqs
3530 if( is_array($levels) ) {
3631 $minQL = $levels['quality'];
3732 $minPL = $levels['pristine'];
38 - # B/C, $levels is just an integer
 33+ $ratingLevels = $levels['levels'];
 34+ # B/C, $levels is just an integer (minQL)
3935 } else {
40 - global $wgFlaggedRevPristine;
 36+ global $wgFlaggedRevPristine, $wgFlaggedRevValues;
4137 $minQL = $levels;
4238 $minPL = isset($wgFlaggedRevPristine) ? $wgFlaggedRevPristine : $wgFlaggedRevValues+1;
 39+ $ratingLevels = isset($wgFlaggedRevValues) ? $wgFlaggedRevValues : 1;
4340 }
 41+ # Set FlaggedRevs tags
 42+ self::$dimensions[$tag] = array();
 43+ for( $i=0; $i <= $ratingLevels; $i++ ) {
 44+ self::$dimensions[$tag][$i] = "{$tag}-{$i}";
 45+ }
4446 # Sanity checks
4547 if( !is_integer($minQL) || !is_integer($minPL) ) {
4648 throw new MWException( 'FlaggedRevs given invalid tag value!' );
4749 }
48 - if( $minQL > $wgFlaggedRevValues ) {
 50+ if( $minQL > $ratingLevels ) {
4951 self::$qualityVersions = false;
5052 self::$pristineVersions = false;
5153 }
52 - if( $minPL > $wgFlaggedRevValues ) {
 54+ if( $minPL > $ratingLevels ) {
5355 self::$pristineVersions = false;
5456 }
5557 self::$minQL[$tag] = $minQL;

Status & tagging log