Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -60,8 +60,8 @@ |
61 | 61 | 'articlefeedbackv5-special-filter-label-before' => 'Show only:', |
62 | 62 | 'articlefeedbackv5-special-filter-label-after' => '', |
63 | 63 | 'articlefeedbackv5-special-showing' => '$1 feedback posts on this page', // FIXME: Needs plural support on $1. |
64 | | - 'articleFeedbackv5-link' => 'Permalink', |
65 | | - 'articleFeedbackv5-updates-since' => '$1 Edits since post', |
| 64 | + 'articlefeedbackv5-comment-link' => 'Permalink', |
| 65 | + 'articlefeedbackv5-updates-since' => '{{PLURAL:$1|1 edit|$1 edits}} since post', |
66 | 66 | 'articlefeedbackv5-special-more' => 'More', |
67 | 67 | 'articlefeedbackv5-special-pagetitle' => 'Feedback: $1', |
68 | 68 | |
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -43,6 +43,11 @@ |
44 | 44 | $.articleFeedbackv5special.filter = 'visible'; |
45 | 45 | |
46 | 46 | /** |
| 47 | + * Some fitlers have values they need tobe passed (eg, permalinks) |
| 48 | + */ |
| 49 | + $.articleFeedbackv5special.filterValue = undefined; |
| 50 | + |
| 51 | + /** |
47 | 52 | * The name of the sorting method used |
48 | 53 | */ |
49 | 54 | $.articleFeedbackv5special.sort = 'newest'; |
— | — | @@ -50,7 +55,7 @@ |
51 | 56 | /** |
52 | 57 | * The number of responses to display per data pull |
53 | 58 | */ |
54 | | - $.articleFeedbackv5special.limit = 5; |
| 59 | + $.articleFeedbackv5special.limit = 25; |
55 | 60 | |
56 | 61 | /** |
57 | 62 | * The index at which to start the pull |
— | — | @@ -225,11 +230,12 @@ |
226 | 231 | 'type' : 'GET', |
227 | 232 | 'dataType': 'json', |
228 | 233 | 'data' : { |
229 | | - 'afvfpageid' : $.articleFeedbackv5special.page, |
230 | | - 'afvffilter' : $.articleFeedbackv5special.filter, |
231 | | - 'afvfsort' : $.articleFeedbackv5special.sort, |
232 | | - 'afvflimit' : $.articleFeedbackv5special.limit, |
233 | | - 'afvfcontinue': $.articleFeedbackv5special.continue, |
| 234 | + 'afvfpageid' : $.articleFeedbackv5special.page, |
| 235 | + 'afvffilter' : $.articleFeedbackv5special.filter, |
| 236 | + 'afvffiltervalue' : $.articleFeedbackv5special.filterValue, |
| 237 | + 'afvfsort' : $.articleFeedbackv5special.sort, |
| 238 | + 'afvflimit' : $.articleFeedbackv5special.limit, |
| 239 | + 'afvfcontinue' : $.articleFeedbackv5special.continue, |
234 | 240 | 'action' : 'query', |
235 | 241 | 'format' : 'json', |
236 | 242 | 'list' : 'articlefeedbackv5-view-feedback', |
— | — | @@ -278,6 +284,16 @@ |
279 | 285 | $.articleFeedbackv5special.apiUrl = mw.util.wikiScript('api'); |
280 | 286 | $.articleFeedbackv5special.page = mw.config.get( 'afPageId' ); |
281 | 287 | $.articleFeedbackv5special.setBinds(); |
| 288 | + |
| 289 | + // Process anything we found in the URL hash |
| 290 | + // Permalinks. |
| 291 | + var id = window.location.hash.match(/id=(\d+)/) |
| 292 | + if( id ) { |
| 293 | + $.articleFeedbackv5special.filter = 'id'; |
| 294 | + $.articleFeedbackv5special.filterValue = id[1]; |
| 295 | + } |
| 296 | + |
| 297 | + // Initial load |
282 | 298 | $.articleFeedbackv5special.loadFeedback( true ); |
283 | 299 | |
284 | 300 | // }}} |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -31,10 +31,11 @@ |
32 | 32 | $pageId = $params['pageid']; |
33 | 33 | $html = ''; |
34 | 34 | $length = 0; |
35 | | - $count = $this->fetchFeedbackCount( $params['pageid'], $params['filter'] ); |
| 35 | + $count = $this->fetchFeedbackCount( $params['pageid'], $params['filter'], $params['filtervalue'] ); |
36 | 36 | $feedback = $this->fetchFeedback( |
37 | 37 | $params['pageid'], |
38 | 38 | $params['filter'], |
| 39 | + $params['filtervalue'], |
39 | 40 | $params['sort'], |
40 | 41 | $params['limit'], |
41 | 42 | ( $params['continue'] !== 'null' ? $params['continue'] : null ) |
— | — | @@ -57,7 +58,7 @@ |
58 | 59 | } |
59 | 60 | } |
60 | 61 | |
61 | | - public function fetchFeedbackCount( $pageId, $filter ) { |
| 62 | + public function fetchFeedbackCount( $pageId, $filter, $filterValue ) { |
62 | 63 | $dbr = wfGetDB( DB_SLAVE ); |
63 | 64 | $count = $dbr->selectField( |
64 | 65 | array( 'aft_article_filter_count' ), |
— | — | @@ -73,12 +74,12 @@ |
74 | 75 | } |
75 | 76 | |
76 | 77 | public function fetchFeedback( $pageId, |
77 | | - $filter = 'visible', $order = 'newest', $limit = 25, $continue = null ) { |
| 78 | + $filter = 'visible', $filterValue = null, $order = 'newest', $limit = 25, $continue = null ) { |
78 | 79 | $dbr = wfGetDB( DB_SLAVE ); |
79 | 80 | $ids = array(); |
80 | 81 | $rows = array(); |
81 | 82 | $rv = array(); |
82 | | - $where = $this->getFilterCriteria( $filter ); |
| 83 | + $where = $this->getFilterCriteria( $filter, $filterValue ); |
83 | 84 | $order; |
84 | 85 | |
85 | 86 | # TODO: The SQL needs to handle all sorts of weird cases. |
— | — | @@ -118,6 +119,7 @@ |
119 | 120 | 'ORDER BY' => $order |
120 | 121 | ) |
121 | 122 | ); |
| 123 | + |
122 | 124 | foreach ( $id_query as $id ) { |
123 | 125 | $ids[] = $id->af_id; |
124 | 126 | } |
— | — | @@ -136,7 +138,7 @@ |
137 | 139 | 'aa_response_rating', 'aa_response_option_id', |
138 | 140 | 'afi_data_type', 'af_created', 'user_name', |
139 | 141 | 'af_user_ip', 'af_hide_count', 'af_abuse_count', |
140 | | - 'af_helpful_count', 'af_delete_count' |
| 142 | + 'af_helpful_count', 'af_delete_count', '(SELECT COUNT(*) FROM revision WHERE rev_id > af_revision_id AND rev_page = '.( integer ) $pageId.') AS age' |
141 | 143 | ), |
142 | 144 | array( 'af_id' => $ids ), |
143 | 145 | __METHOD__, |
— | — | @@ -170,7 +172,7 @@ |
171 | 173 | return $rv; |
172 | 174 | } |
173 | 175 | |
174 | | - private function getFilterCriteria( $filter ) { |
| 176 | + private function getFilterCriteria( $filter, $filterValue = null ) { |
175 | 177 | $where = array(); |
176 | 178 | switch( $filter ) { |
177 | 179 | case 'all': |
— | — | @@ -182,6 +184,9 @@ |
183 | 185 | case 'comment': |
184 | 186 | $where = array( 'aa_response_text IS NOT NULL'); |
185 | 187 | break; |
| 188 | + case 'id': |
| 189 | + $where = array( 'af_id' => $filterValue ); |
| 190 | + break; |
186 | 191 | case 'visible': |
187 | 192 | default: |
188 | 193 | $where = array( 'af_hide_count' => 0 ); |
— | — | @@ -224,12 +229,12 @@ |
225 | 230 | 'class' => 'articleFeedbackv5-comment-details-permalink' |
226 | 231 | ) ) |
227 | 232 | .Html::element( 'a', array( |
228 | | - 'href' => '#' |
| 233 | + 'href' => "#id=$id" |
229 | 234 | ), wfMessage( 'articlefeedbackv5-comment-link' ) ) |
230 | 235 | . Html::closeElement( 'div' ) |
231 | 236 | . Html::element( 'div', array( |
232 | 237 | 'class' => 'articleFeedbackv5-comment-details-updates' |
233 | | - ), wfMessage( 'articleFeedbackv5-updates-since', 0 ) ) |
| 238 | + ), wfMessage( 'articlefeedbackv5-updates-since', $record[0]->age ) ) |
234 | 239 | . Html::closeElement( 'div' ); |
235 | 240 | ; |
236 | 241 | |
— | — | @@ -272,9 +277,7 @@ |
273 | 278 | . Html::closeElement( 'ul' ) |
274 | 279 | . Html::closeElement( 'div' ); |
275 | 280 | |
276 | | - # TODO: permalinks |
277 | 281 | return Html::openElement( 'div', array( 'class' => 'articleFeedbackv5-feedback' ) ) |
278 | | - . $header_links |
279 | 282 | . $content |
280 | 283 | . $details |
281 | 284 | . $tools |
— | — | @@ -369,29 +372,34 @@ |
370 | 373 | */ |
371 | 374 | public function getAllowedParams() { |
372 | 375 | return array( |
373 | | - 'pageid' => array( |
| 376 | + 'pageid' => array( |
374 | 377 | ApiBase::PARAM_REQUIRED => true, |
375 | 378 | ApiBase::PARAM_ISMULTI => false, |
376 | 379 | ApiBase::PARAM_TYPE => 'integer' |
377 | 380 | ), |
378 | | - 'sort' => array( |
| 381 | + 'sort' => array( |
379 | 382 | ApiBase::PARAM_REQUIRED => false, |
380 | 383 | ApiBase::PARAM_ISMULTI => false, |
381 | 384 | ApiBase::PARAM_TYPE => array( |
382 | 385 | 'oldest', 'newest' ) |
383 | 386 | ), |
384 | | - 'filter' => array( |
| 387 | + 'filter' => array( |
385 | 388 | ApiBase::PARAM_REQUIRED => false, |
386 | 389 | ApiBase::PARAM_ISMULTI => false, |
387 | 390 | ApiBase::PARAM_TYPE => array( |
388 | | - 'all', 'invisible', 'visible', 'comment' ) |
| 391 | + 'all', 'invisible', 'visible', 'comment', 'id' ) |
389 | 392 | ), |
390 | | - 'limit' => array( |
| 393 | + 'filtervalue' => array( |
391 | 394 | ApiBase::PARAM_REQUIRED => false, |
392 | 395 | ApiBase::PARAM_ISMULTI => false, |
| 396 | + ApiBase::PARAM_TYPE => 'string' |
| 397 | + ), |
| 398 | + 'limit' => array( |
| 399 | + ApiBase::PARAM_REQUIRED => false, |
| 400 | + ApiBase::PARAM_ISMULTI => false, |
393 | 401 | ApiBase::PARAM_TYPE => 'integer' |
394 | 402 | ), |
395 | | - 'continue' => array( |
| 403 | + 'continue' => array( |
396 | 404 | ApiBase::PARAM_REQUIRED => false, |
397 | 405 | ApiBase::PARAM_ISMULTI => false, |
398 | 406 | ApiBase::PARAM_TYPE => 'string' |
— | — | @@ -406,11 +414,12 @@ |
407 | 415 | */ |
408 | 416 | public function getParamDescription() { |
409 | 417 | return array( |
410 | | - 'pageid' => 'Page ID to get feedback ratings for', |
411 | | - 'sort' => 'Key to sort records by', |
412 | | - 'filter' => 'What filtering to apply to list', |
413 | | - 'limit' => 'Number of records to show', |
414 | | - 'continue' => 'Offset from which to continue', |
| 418 | + 'pageid' => 'Page ID to get feedback ratings for', |
| 419 | + 'sort' => 'Key to sort records by', |
| 420 | + 'filter' => 'What filtering to apply to list', |
| 421 | + 'filtervalue' => 'Optional param to pass to filter', |
| 422 | + 'limit' => 'Number of records to show', |
| 423 | + 'continue' => 'Offset from which to continue', |
415 | 424 | ); |
416 | 425 | } |
417 | 426 | |
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php |
— | — | @@ -161,7 +161,6 @@ |
162 | 162 | 'articlefeedbackv5-delete-saved', |
163 | 163 | 'articlefeedbackv5-helpful-saved', |
164 | 164 | 'articlefeedbackv5-comment-link' |
165 | | - |
166 | 165 | ), |
167 | 166 | ), |
168 | 167 | ); |