Index: trunk/extensions/ArticleFeedback/SpecialArticleFeedback.php |
— | — | @@ -119,6 +119,8 @@ |
120 | 120 | $ids[] = $page['page']; |
121 | 121 | } |
122 | 122 | self::populateTitleCache( $ids ); |
| 123 | + |
| 124 | + $categories = self::getCategories(); |
123 | 125 | |
124 | 126 | $rows = array(); |
125 | 127 | if ( $pages ) { |
— | — | @@ -129,12 +131,19 @@ |
130 | 132 | continue; |
131 | 133 | } |
132 | 134 | $row['page'] = $wgUser->getSkin()->link( $pageTitle, $pageTitle->getPrefixedText() ); |
133 | | - foreach ( $page['ratings'] as $value ) { |
| 135 | + foreach ( $categories as $catid => $catmsg ) { |
| 136 | + if ( isset( $page['ratings'][$catid] ) ) { |
| 137 | + $number = $this->formatNumber( $page['ratings'][$catid] ); |
| 138 | + $class = round( $page['ratings'][$catid] ); |
| 139 | + } else { |
| 140 | + $number = wfMsg( 'articlefeedback-table-noratings' ); |
| 141 | + $class = 'none'; |
| 142 | + } |
134 | 143 | $row[] = array( |
135 | | - 'text' => $this->formatNumber( $value ), |
| 144 | + 'text' => $number, |
136 | 145 | 'attr' => array( |
137 | 146 | 'class' => 'articleFeedback-table-column-rating ' . |
138 | | - 'articleFeedback-table-column-score-' . round( $value ) |
| 147 | + 'articleFeedback-table-column-score-' . $class |
139 | 148 | ) |
140 | 149 | ); |
141 | 150 | } |
— | — | @@ -153,7 +162,7 @@ |
154 | 163 | $caption, |
155 | 164 | array_merge( |
156 | 165 | array( wfMsg( 'articleFeedback-table-heading-page' ) ), |
157 | | - self::getCategories(), |
| 166 | + $categories, |
158 | 167 | array( wfMsg( 'articleFeedback-table-heading-average' ) ) |
159 | 168 | ), |
160 | 169 | $rows, |
— | — | @@ -168,15 +177,22 @@ |
169 | 178 | */ |
170 | 179 | protected function renderWeeklyMostChanged() { |
171 | 180 | global $wgUser; |
| 181 | + |
| 182 | + $categories = self::getCategories(); |
172 | 183 | |
173 | 184 | $rows = array(); |
174 | 185 | foreach ( $this->getWeeklyMostChanged() as $page ) { |
175 | 186 | $row = array(); |
176 | 187 | $pageTitle = Title::newFromText( $page['page'] ); |
177 | 188 | $row['page'] = $wgUser->getSkin()->link( $pageTitle, $pageTitle->getPrefixedText() ); |
178 | | - foreach ( $page['changes'] as $id => $value ) { |
| 189 | + foreach ( $categories as $catid => $catmsg ) { |
| 190 | + if ( isset( $page['changes'][$catid] ) ) { |
| 191 | + $number = $this->formatNumber( $page['changes'][$catid] ); |
| 192 | + } else { |
| 193 | + $number = wfMsg( 'articlefeedback-table-noratings' ); |
| 194 | + } |
179 | 195 | $row[] = array( |
180 | | - 'text' => $this->formatNumber( $value ), |
| 196 | + 'text' => $number, |
181 | 197 | 'attr' => array( |
182 | 198 | 'class' => 'articleFeedback-table-column-changes' |
183 | 199 | ) |
— | — | @@ -188,7 +204,7 @@ |
189 | 205 | wfMsg( 'articleFeedback-table-caption-weeklymostchanged' ), |
190 | 206 | array_merge( |
191 | 207 | array( wfMsg( 'articleFeedback-table-heading-page' ) ), |
192 | | - self::getCategories() |
| 208 | + $categories |
193 | 209 | ), |
194 | 210 | $rows, |
195 | 211 | 'articleFeedback-table-weeklymostchanged' |
— | — | @@ -204,6 +220,7 @@ |
205 | 221 | global $wgUser; |
206 | 222 | |
207 | 223 | $problems = $this->getProblems(); |
| 224 | + $categories = self::getCategories(); |
208 | 225 | |
209 | 226 | // Pre-fill page ID cache |
210 | 227 | $ids = array(); |
— | — | @@ -220,12 +237,19 @@ |
221 | 238 | continue; |
222 | 239 | } |
223 | 240 | $row['page'] = $wgUser->getSkin()->link( $pageTitle, $pageTitle->getPrefixedText() ); |
224 | | - foreach ( $page['ratings'] as $value ) { |
| 241 | + foreach ( $categories as $catid => $catmsg ) { |
| 242 | + if ( isset( $page['ratings'][$catid] ) ) { |
| 243 | + $number = $this->formatNumber( $page['ratings'][$catid] ); |
| 244 | + $class = round( $page['ratings'][$catid] ); |
| 245 | + } else { |
| 246 | + $number = wfMsg( 'articlefeedback-table-noratings' ); |
| 247 | + $class = 'none'; |
| 248 | + } |
225 | 249 | $row[] = array( |
226 | | - 'text' => $this->formatNumber( $value ), |
| 250 | + 'text' => $number, |
227 | 251 | 'attr' => array( |
228 | 252 | 'class' => 'articleFeedback-table-column-rating ' . |
229 | | - 'articleFeedback-table-column-score-' . round( $value ) |
| 253 | + 'articleFeedback-table-column-score-' . $class |
230 | 254 | ) |
231 | 255 | ); |
232 | 256 | } |
— | — | @@ -242,7 +266,7 @@ |
243 | 267 | wfMsg( 'articleFeedback-table-caption-recentlows' ), |
244 | 268 | array_merge( |
245 | 269 | array( wfMsg( 'articleFeedback-table-heading-page' ) ), |
246 | | - self::getCategories(), |
| 270 | + $categories, |
247 | 271 | array( wfMsg( 'articleFeedback-table-heading-average' ) ) |
248 | 272 | ), |
249 | 273 | $rows, |
— | — | @@ -414,7 +438,7 @@ |
415 | 439 | } |
416 | 440 | $highs_lows[] = array( |
417 | 441 | 'page' => $row->afs_page_id, |
418 | | - 'ratings' => FormatJson::decode( $row->afs_data ), |
| 442 | + 'ratings' => FormatJson::decode( $row->afs_data, true ), |
419 | 443 | 'average' => $row->afs_orderable_data |
420 | 444 | ); |
421 | 445 | } |
— | — | @@ -434,7 +458,7 @@ |
435 | 459 | } |
436 | 460 | $problems[] = array( |
437 | 461 | 'page' => $row->afs_page_id, |
438 | | - 'ratings' => FormatJson::decode( $row->afs_data ), |
| 462 | + 'ratings' => FormatJson::decode( $row->afs_data, true ), |
439 | 463 | 'average' => $row->afs_orderable_data |
440 | 464 | ); |
441 | 465 | } |
Index: trunk/extensions/ArticleFeedback/populateAFStatistics.php |
— | — | @@ -498,6 +498,11 @@ |
499 | 499 | * @param string $rating_set_hash |
500 | 500 | */ |
501 | 501 | public function addRating( $rating_id, $rating_value, $rating_set_hash = null ) { |
| 502 | + if ( intval( $rating_value ) == 0 ) { |
| 503 | + // Ignore zero ratings |
| 504 | + return; |
| 505 | + } |
| 506 | + |
502 | 507 | $this->ratings[ $rating_id ][] = $rating_value; |
503 | 508 | |
504 | 509 | if ( $rating_set_hash ) { |
Index: trunk/extensions/ArticleFeedback/ArticleFeedback.i18n.php |
— | — | @@ -106,6 +106,7 @@ |
107 | 107 | 'articleFeedback-table-caption-recentlows' => 'Recent lows', |
108 | 108 | 'articleFeedback-table-heading-page' => 'Page', |
109 | 109 | 'articleFeedback-table-heading-average' => 'Average', |
| 110 | + 'articlefeedback-table-noratings' => '-', |
110 | 111 | 'articleFeedback-copy-above-highlow-tables' => 'This is an experimental feature. Please provide feedback on the [$1 discussion page].', |
111 | 112 | 'articlefeedback-dashboard-bottom' => "'''Note''': We will continue to experiment with different ways of surfacing articles in these dashboards. At present, the dashboards include the following articles: |
112 | 113 | * Pages with highest/lowest ratings: articles that have received at least 10 ratings within the last 24 hours. Averages are calculated by taking the mean of all ratings submitted within the last 24 hours. |
— | — | @@ -180,6 +181,7 @@ |
181 | 182 | 'articlefeedback-pitch-join-login' => '{{Identical|Log in}}', |
182 | 183 | 'articleFeedback-table-heading-page' => '{{Identical|Page}}', |
183 | 184 | 'articleFeedback-table-heading-average' => '{{Identical|Average}}', |
| 185 | + 'articlefeedback-table-noratings' => 'Text to display in a table cell if there is no number to be shown', |
184 | 186 | 'articleFeedback-copy-above-highlow-tables' => 'The variable $1 will contain a full URL to a discussion page where the dashboard can be discussed - since the dashboard is powered by a special page, we can not rely on the built-in MediaWiki talk page.', |
185 | 187 | ); |
186 | 188 | |