Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | /** |
12 | | - * This class pulls the individual ratings/comments for the feedback page. |
| 12 | + * This class pulls the individual ratings/comments for the feedback page. |
13 | 13 | * |
14 | 14 | * @package ArticleFeedback |
15 | 15 | * @subpackage Api |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | $result = $this->getResult(); |
33 | 33 | $pageId = $params['pageid']; |
34 | 34 | $length = 0; |
35 | | - $count = $this->fetchFeedbackCount( |
| 35 | + $count = $this->fetchFeedbackCount( |
36 | 36 | $params['pageid'], $params['filter'] ); |
37 | 37 | $feedback = $this->fetchFeedback( |
38 | 38 | $params['pageid'], |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | ); |
93 | 93 | } |
94 | 94 | |
95 | | - public function fetchFeedback( $pageId, |
| 95 | + public function fetchFeedback( $pageId, |
96 | 96 | $filter = 'visible', $order = 'newest', $limit = 25, $offset = 0 ) { |
97 | 97 | $dbr = wfGetDB( DB_SLAVE ); |
98 | 98 | $ids = array(); |
— | — | @@ -100,10 +100,9 @@ |
101 | 101 | $where = $this->getFilterCriteria( $filter ); |
102 | 102 | $order; |
103 | 103 | |
| 104 | + # Newest first is the only option right now. |
104 | 105 | switch($order) { |
105 | 106 | case 'newest': |
106 | | - $order = 'af_id DESC'; |
107 | | - break; |
108 | 107 | default: |
109 | 108 | $order = 'af_id DESC'; |
110 | 109 | break; |
— | — | @@ -112,16 +111,16 @@ |
113 | 112 | $where['af_page_id'] = $pageId; |
114 | 113 | |
115 | 114 | /* I'd really love to do this in one big query, but MySQL |
116 | | - doesn't support LIMIT inside IN() subselects, and since |
| 115 | + doesn't support LIMIT inside IN() subselects, and since |
117 | 116 | we don't know the number of answers for each feedback |
118 | 117 | record until we fetch them, this is the only way to make |
119 | 118 | sure we get all answers for the exact IDs we want. */ |
120 | 119 | $id_query = $dbr->select( |
121 | 120 | 'aft_article_feedback', 'af_id', $where, __METHOD__, |
122 | | - array( |
123 | | - 'LIMIT' => $limit, |
| 121 | + array( |
| 122 | + 'LIMIT' => $limit, |
124 | 123 | 'OFFSET' => $offset, |
125 | | - 'ORDER BY' => $order |
| 124 | + 'ORDER BY' => $order |
126 | 125 | ) |
127 | 126 | ); |
128 | 127 | foreach($id_query as $id) { |
— | — | @@ -129,11 +128,11 @@ |
130 | 129 | } |
131 | 130 | |
132 | 131 | $rows = $dbr->select( |
133 | | - array( 'aft_article_feedback', 'aft_article_answer', |
| 132 | + array( 'aft_article_feedback', 'aft_article_answer', |
134 | 133 | 'aft_article_field', 'aft_article_field_option' |
135 | 134 | ), |
136 | 135 | array( 'af_id', 'af_bucket_id', 'afi_name', 'afo_name', |
137 | | - 'aa_response_text', 'aa_response_boolean', |
| 136 | + 'aa_response_text', 'aa_response_boolean', |
138 | 137 | 'aa_response_rating', 'aa_response_option_id', |
139 | 138 | 'afi_data_type', 'af_created', 'af_user_text', |
140 | 139 | 'af_hide_count', 'af_abuse_count' |
— | — | @@ -149,7 +148,7 @@ |
150 | 149 | 'LEFT JOIN', 'af_id = aa_feedback_id' |
151 | 150 | ), |
152 | 151 | 'aft_article_field_option' => array( |
153 | | - 'LEFT JOIN', |
| 152 | + 'LEFT JOIN', |
154 | 153 | 'aa_response_option_id = afo_option_id' |
155 | 154 | ) |
156 | 155 | ) |
— | — | @@ -208,26 +207,26 @@ |
209 | 208 | return $rv; |
210 | 209 | } |
211 | 210 | |
212 | | - private function renderBucket1( $record ) { |
| 211 | + private function renderBucket1( $record ) { |
213 | 212 | $name = $record[0]->af_user_text; |
214 | 213 | if( $record['found']->aa_response_boolean ) { |
215 | | - $found = wfMsg( |
| 214 | + $found = wfMsg( |
216 | 215 | 'articlefeedbackv5-form1-header-found', |
217 | 216 | $name |
218 | 217 | ); |
219 | 218 | } else { |
220 | | - $found = wfMsg( |
| 219 | + $found = wfMsg( |
221 | 220 | 'articlefeedbackv5-form1-header-not-found', |
222 | 221 | $name |
223 | 222 | ); |
224 | 223 | |
225 | 224 | } |
226 | | - return "$found |
| 225 | + return "$found |
227 | 226 | <blockquote>".$record['comment']->aa_response_text |
228 | 227 | .'</blockquote>'; |
229 | 228 | } |
230 | 229 | |
231 | | - private function renderBucket2( $record ) { |
| 230 | + private function renderBucket2( $record ) { |
232 | 231 | $name = $record[0]->af_user_text; |
233 | 232 | $type = $record['tag']->afo_name; |
234 | 233 | return wfMsg( 'articlefeedbackv5-form2-header', $name, $type ) |
— | — | @@ -235,7 +234,7 @@ |
236 | 235 | .'</blockquote>'; |
237 | 236 | } |
238 | 237 | |
239 | | - private function renderBucket3( $record ) { |
| 238 | + private function renderBucket3( $record ) { |
240 | 239 | $name = $record[0]->af_user_text; |
241 | 240 | $rating = $record['rating']->aa_response_rating; |
242 | 241 | return wfMsg( 'articlefeedbackv5-form3-header', $name, $rating ) |
— | — | @@ -243,11 +242,11 @@ |
244 | 243 | .'</blockquote>'; |
245 | 244 | } |
246 | 245 | |
247 | | - private function renderBucket4( $record ) { |
| 246 | + private function renderBucket4( $record ) { |
248 | 247 | return wfMsg( 'articlefeedbackv5-form4-header' ); |
249 | 248 | } |
250 | 249 | |
251 | | - private function renderBucket5( $record ) { |
| 250 | + private function renderBucket5( $record ) { |
252 | 251 | $name = $record[0]->af_user_text; |
253 | 252 | $rv = wfMsg( 'articlefeedbackv5-form5-header', $name ); |
254 | 253 | $rv .= '<ul>'; |
— | — | @@ -261,16 +260,16 @@ |
262 | 261 | return $rv; |
263 | 262 | } |
264 | 263 | |
265 | | - private function renderBucket0( $record ) { |
| 264 | + private function renderBucket0( $record ) { |
266 | 265 | # Future-proof this for when the bucket ID changes to 0. |
267 | 266 | return $this->renderBucket6( $record ); |
268 | 267 | } |
269 | 268 | |
270 | | - private function renderNoBucket( $record ) { |
| 269 | + private function renderNoBucket( $record ) { |
271 | 270 | return wfMsg( 'articlefeedbackv5-form-invalid' ); |
272 | 271 | } |
273 | 272 | |
274 | | - private function renderBucket6( $record ) { |
| 273 | + private function renderBucket6( $record ) { |
275 | 274 | return wfMsg( 'articlefeedbackv5-form-not-shown' ); |
276 | 275 | } |
277 | 276 | |
— | — | @@ -289,13 +288,13 @@ |
290 | 289 | 'sort' => array( |
291 | 290 | ApiBase::PARAM_REQUIRED => false, |
292 | 291 | ApiBase::PARAM_ISMULTI => false, |
293 | | - ApiBase::PARAM_TYPE => array( |
| 292 | + ApiBase::PARAM_TYPE => array( |
294 | 293 | 'oldest', 'newest', 'etc' ) |
295 | 294 | ), |
296 | 295 | 'filter' => array( |
297 | 296 | ApiBase::PARAM_REQUIRED => false, |
298 | 297 | ApiBase::PARAM_ISMULTI => false, |
299 | | - ApiBase::PARAM_TYPE => array( |
| 298 | + ApiBase::PARAM_TYPE => array( |
300 | 299 | 'all', 'hidden', 'visible' ) |
301 | 300 | ), |
302 | 301 | 'limit' => array( |