Index: trunk/extensions/ArticleAssessmentPilot/ArticleAssessmentPilot.php |
— | — | @@ -4,8 +4,8 @@ |
5 | 5 | // then consider the last rating "stale" |
6 | 6 | $wgArticleAssessmentStaleCount = 5; |
7 | 7 | |
8 | | -// Number of "ratings" to store. Allows it to be a bit more dynamic |
9 | | -$wgArticleAssessmentRatingCount = 4; |
| 8 | +// Array of the "ratings" id's to store. Allows it to be a bit more dynamic |
| 9 | +$wgArticleAssessmentRatings = array( 1, 2, 3, 4 ); |
10 | 10 | |
11 | 11 | // Which category the pages must belong to have the rating widget added (with _ in text) |
12 | 12 | // Extension is "disabled" if this field is an empty string (as per default configuration) |
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiQueryArticleAssessment.php |
— | — | @@ -53,9 +53,9 @@ |
54 | 54 | $this->addOption( 'ORDER BY', 'aa_revision DESC' ); |
55 | 55 | } |
56 | 56 | |
57 | | - global $wgArticleAssessmentRatingCount; |
| 57 | + global $wgArticleAssessmentRatings; |
58 | 58 | |
59 | | - $this->addOption( 'LIMIT', $wgArticleAssessmentRatingCount ); |
| 59 | + $this->addOption( 'LIMIT', count( $wgArticleAssessmentRatings ) ); |
60 | 60 | |
61 | 61 | $res = $this->select( __METHOD__ ); |
62 | 62 | |
Index: trunk/extensions/ArticleAssessmentPilot/api/ApiArticleAssessment.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | } |
7 | 7 | |
8 | 8 | public function execute() { |
9 | | - global $wgUser, $wgArticleAssessmentRatingCount; |
| 9 | + global $wgUser, $wgArticleAssessmentRatings; |
10 | 10 | $params = $this->extractRequestParams(); |
11 | 11 | |
12 | 12 | $token = array(); |
— | — | @@ -50,22 +50,22 @@ |
51 | 51 | $revisionId = $params['revid']; |
52 | 52 | |
53 | 53 | // TODO: Fold for loop into foreach above? |
54 | | - for ( $i = 1; $i <= $wgArticleAssessmentRatingCount; $i++ ) { |
| 54 | + foreach( $wgArticleAssessmentRatings as $rating ) { |
55 | 55 | $lastRating = 0; |
56 | | - if ( isset( $lastRatings[$i] ) ) { |
57 | | - $lastRating = $lastRatings[$i]; |
| 56 | + if ( isset( $lastRatings[$rating] ) ) { |
| 57 | + $lastRating = $lastRatings[$rating]; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $thisRating = 0; |
61 | | - if ( isset( $params["r{$i}"] ) ) { |
62 | | - $thisRating = $params["r{$i}"]; |
| 61 | + if ( isset( $params["r{$rating}"] ) ) { |
| 62 | + $thisRating = $params["r{$rating}"]; |
63 | 63 | } |
64 | 64 | |
65 | 65 | $this->insertPageRating( $pageId, $i, ( $thisRating - $lastRating ), |
66 | 66 | ( $lastRating == 0 && $thisRating != 0 ) |
67 | 67 | ); |
68 | 68 | |
69 | | - $this->insertUserRatings( $pageId, $revisionId, $wgUser, $token, $i, $thisRating ); |
| 69 | + $this->insertUserRatings( $pageId, $revisionId, $wgUser, $token, $rating, $thisRating ); |
70 | 70 | } |
71 | 71 | |
72 | 72 | $r = array( 'result' => 'Success' ); |
— | — | @@ -164,7 +164,7 @@ |
165 | 165 | } |
166 | 166 | |
167 | 167 | public function getAllowedParams() { |
168 | | - global $wgArticleAssessmentRatingCount; |
| 168 | + global $wgArticleAssessmentRatings; |
169 | 169 | $ret = array( |
170 | 170 | 'pageid' => array( |
171 | 171 | ApiBase::PARAM_TYPE => 'integer', |
— | — | @@ -178,9 +178,9 @@ |
179 | 179 | ), |
180 | 180 | 'anontoken' => null, |
181 | 181 | ); |
182 | | - |
183 | | - for ( $i = 1; $i <= $wgArticleAssessmentRatingCount; $i++ ) { |
184 | | - $ret["r{$i}"] = array( |
| 182 | + |
| 183 | + foreach( $wgArticleAssessmentRatings as $rating ) { |
| 184 | + $ret["r{$rating}"] = array( |
185 | 185 | ApiBase::PARAM_TYPE => 'integer', |
186 | 186 | ApiBase::PARAM_DFLT => 0, |
187 | 187 | ApiBase::PARAM_MIN => 0, |
— | — | @@ -191,14 +191,14 @@ |
192 | 192 | } |
193 | 193 | |
194 | 194 | public function getParamDescription() { |
195 | | - global $wgArticleAssessmentRatingCount; |
| 195 | + global $wgArticleAssessmentRatings; |
196 | 196 | $ret = array( |
197 | 197 | 'pageid' => 'Page ID to submit assessment for', |
198 | 198 | 'revid' => 'Revision ID to submit assessment for', |
199 | 199 | 'anontoken' => 'Token for anonymous users', |
200 | 200 | ); |
201 | | - for ( $i = 1; $i <= $wgArticleAssessmentRatingCount; $i++ ) { |
202 | | - $ret["r{$i}"] = "Rating {$i}"; |
| 201 | + foreach( $wgArticleAssessmentRatings as $rating ) { |
| 202 | + $ret["r{$rating}"] = "Rating {$rating}"; |
203 | 203 | } |
204 | 204 | return $ret; |
205 | 205 | } |