Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php |
— | — | @@ -80,14 +80,14 @@ |
81 | 81 | 'articlefeedbackv5-form-header' => 'Feedback #$1, at $2', |
82 | 82 | 'articlefeedbackv5-form1-header-found' => '{{GENDER:$1|$1}} found what they were looking for:', |
83 | 83 | 'articlefeedbackv5-form1-header-not-found' => '{{GENDER:$1|$1}} did not find what they were looking for:', |
84 | | - 'articlefeedbackv5-form2-header-praise' => '{{GENDER:$1|$1}} had a comment:', |
85 | | - 'articlefeedbackv5-form2-header-problem' => '{{GENDER:$1|$1}} had a praise:', |
| 84 | + 'articlefeedbackv5-form2-header-praise' => '{{GENDER:$1|$1}} had a praise:', |
| 85 | + 'articlefeedbackv5-form2-header-problem' => '{{GENDER:$1|$1}} had a problem:', |
86 | 86 | 'articlefeedbackv5-form2-header-question' => '{{GENDER:$1|$1}} had a question:', |
87 | 87 | 'articlefeedbackv5-form2-header-suggestion' => '{{GENDER:$1|$1}} had a suggestion:', |
88 | | - 'articlefeedbackv5-form3-header' => '$1 rated this page $2/5', |
89 | | - 'articlefeedbackv5-form4-header' => 'User was presented with the CTA-only form.', |
90 | | - 'articlefeedbackv5-form5-header' => '$1 rated this page:', |
91 | | - 'articlefeedbackv5-form-not-shown' => 'User was not shown a feedback form.', |
| 88 | + 'articlefeedbackv5-form3-header' => '{{GENDER:$1|$1}} rated this page $2/5', |
| 89 | + 'articlefeedbackv5-form4-header' => '{{GENDER:$1|$1}} was presented with the CTA-only form.', |
| 90 | + 'articlefeedbackv5-form5-header' => '{{GENDER:$1|$1}} rated this page:', |
| 91 | + 'articlefeedbackv5-form-not-shown' => '{{GENDER:$1|$1}} was not shown a feedback form.', |
92 | 92 | 'articlefeedbackv5-form-invalid' => 'Invalid feedback form ID.', |
93 | 93 | 'articlefeedbackv5-delete-saved' => 'Feedback deleted', |
94 | 94 | 'articlefeedbackv5-abuse-saved' => 'Flagged as abuse', |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php |
— | — | @@ -276,6 +276,7 @@ |
277 | 277 | |
278 | 278 | # Update the overall number of records for this page. |
279 | 279 | ApiArticleFeedbackv5Utils::incrementFilterCount( $pageId, 'all' ); |
| 280 | + ApiArticleFeedbackv5Utils::incrementFilterCount( $pageId, 'visible' ); |
280 | 281 | # If the feedbackrecord had a comment, update that filter count. |
281 | 282 | if( $has_comment ) { |
282 | 283 | ApiArticleFeedbackv5Utils::incrementFilterCount( $pageId, 'comment' ); |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php |
— | — | @@ -387,9 +387,6 @@ |
388 | 388 | } |
389 | 389 | |
390 | 390 | private function renderBucket1( $record ) { |
391 | | - $name = htmlspecialchars( $record[0]->user_name ); |
392 | | - $link = $record[0]->af_user_id ? "User:$name" : "Special:Contributions/$name"; |
393 | | - |
394 | 391 | if ( $record['found']->aa_response_boolean ) { |
395 | 392 | $msg = 'articlefeedbackv5-form1-header-found'; |
396 | 393 | $class = 'positive'; |
— | — | @@ -397,31 +394,24 @@ |
398 | 395 | $msg = 'articlefeedbackv5-form1-header-not-found'; |
399 | 396 | $class = 'negative'; |
400 | 397 | } |
401 | | - $found = Html::openElement( 'h3' ) |
402 | | - . Html::element( 'span', array( 'class' => 'icon' ) ) |
403 | | - . Linker::link( Title::newFromText( $link ), $name ) |
404 | | - .Html::element( 'span', array( |
405 | | - 'class' => $class, |
406 | | - ), wfMessage( $msg, '')->escaped() ) |
407 | | - . Html::closeElement( 'h3' ); |
408 | 398 | |
| 399 | + $found = $this->feedbackHead( $msg, $class, $record[0] ); |
| 400 | + |
409 | 401 | return "$found |
410 | 402 | <blockquote>" . htmlspecialchars( $record['comment']->aa_response_text ) |
411 | 403 | . '</blockquote>'; |
412 | 404 | } |
413 | 405 | |
| 406 | + |
414 | 407 | private function renderBucket2( $record ) { |
415 | | - $name = htmlspecialchars( $record[0]->user_name ); |
416 | | - $type = htmlspecialchars( $record['tag']->afo_name ); |
| 408 | + $type = htmlspecialchars( $record['tag']->afo_name ); |
| 409 | + $class = $type == 'problem' ? 'negative' : 'positive'; |
417 | 410 | // Document for grepping. Uses any of the messages: |
418 | 411 | // * articlefeedbackv5-form2-header-praise |
419 | 412 | // * articlefeedbackv5-form2-header-problem |
420 | 413 | // * articlefeedbackv5-form2-header-question |
421 | 414 | // * articlefeedbackv5-form2-header-suggestion |
422 | | - return |
423 | | - Html::openElement( 'h3' ) |
424 | | - . wfMessage( 'articlefeedbackv5-form2-header-' . $type, $name )->escaped() |
425 | | - . Html::closeElement( 'h3' ) |
| 415 | + return $this->feedbackHead( "articlefeedbackv5-form2-header-$type", $class, $record[0], $type ) |
426 | 416 | . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text ) |
427 | 417 | . '</blockquote>'; |
428 | 418 | } |
— | — | @@ -431,37 +421,48 @@ |
432 | 422 | private function renderBucket3( $record ) { |
433 | 423 | $name = htmlspecialchars( $record[0]->user_name ); |
434 | 424 | $rating = htmlspecialchars( $record['rating']->aa_response_rating ); |
435 | | - return |
436 | | - Html::openElement( 'h3' ) |
437 | | - . wfMessage( 'articlefeedbackv5-form3-header', $name, $rating )->escaped() |
438 | | - . Html::closeElement( 'h3' ) |
| 425 | + $class = $record['rating']->aa_response_rating >= 3 ? 'positive' : 'negative'; |
| 426 | + |
| 427 | + return $this->feedbackHead( 'articlefeedbackv5-form3-header', $class, $record[0], $record['rating']->aa_response_rating ) |
439 | 428 | . '<blockquote>' . htmlspecialchars( $record['comment']->aa_response_text ) |
440 | 429 | . '</blockquote>'; |
441 | 430 | } |
442 | 431 | |
443 | 432 | private function renderBucket4( $record ) { |
444 | | - return wfMessage( 'articlefeedbackv5-form4-header' )->escaped(); |
| 433 | + return $this->feedbackHead( |
| 434 | + 'articlefeedbackv5-form4-header', |
| 435 | + 'positive', |
| 436 | + $record[0] |
| 437 | + ); |
445 | 438 | } |
446 | 439 | |
447 | 440 | private function renderBucket5( $record ) { |
448 | | - $name = htmlspecialchars( $record[0]->user_name ); |
449 | | - $rv = |
450 | | - Html::openElement( 'h3' ) |
451 | | - . wfMessage( 'articlefeedbackv5-form5-header', $name )->escaped() |
452 | | - . Html::closeElement( 'h3' ); |
453 | | - $rv .= '<ul>'; |
| 441 | + $name = htmlspecialchars( $record[0]->user_name ); |
| 442 | + $body = '<ul>'; |
| 443 | + $total = 0; |
| 444 | + $count = 0; |
454 | 445 | foreach ( $record as $key => $answer ) { |
455 | 446 | if ( $answer->afi_data_type == 'rating' && $key != '0' ) { |
456 | | - $rv .= "<li>" |
| 447 | + $body .= "<li>" |
457 | 448 | . htmlspecialchars( $answer->afi_name ) |
458 | 449 | . ': ' |
459 | 450 | . htmlspecialchars( $answer->aa_response_rating ) |
460 | 451 | . "</li>"; |
| 452 | + $total += $answer->aa_response_rating; |
| 453 | + $count++; |
461 | 454 | } |
462 | 455 | } |
463 | | - $rv .= "</ul>"; |
| 456 | + $body .= "</ul>"; |
| 457 | + |
| 458 | + $class = $total / $count >= 3 ? 'positive' : 'negative'; |
464 | 459 | |
465 | | - return $rv; |
| 460 | + $head = $this->feedbackHead( |
| 461 | + 'articlefeedbackv5-form5-header', |
| 462 | + $class, |
| 463 | + $record[0] |
| 464 | + ); |
| 465 | + |
| 466 | + return $head.$body; |
466 | 467 | } |
467 | 468 | |
468 | 469 | private function renderBucket0( $record ) { |
— | — | @@ -470,13 +471,37 @@ |
471 | 472 | } |
472 | 473 | |
473 | 474 | private function renderNoBucket( $record ) { |
474 | | - return wfMessage( 'articlefeedbackv5-form-invalid' )->escaped(); |
| 475 | + return $this->feedbackHead( |
| 476 | + 'articlefeedbackv5-form-invalid', |
| 477 | + 'negative', |
| 478 | + $record[0] |
| 479 | + ); |
475 | 480 | } |
476 | 481 | |
477 | 482 | private function renderBucket6( $record ) { |
478 | | - return wfMessage( 'articlefeedbackv5-form-not-shown' )->escaped(); |
| 483 | + return $this->feedbackHead( |
| 484 | + 'articlefeedbackv5-form-not-shown', |
| 485 | + 'positive', |
| 486 | + $record[0] |
| 487 | + ); |
479 | 488 | } |
480 | 489 | |
| 490 | + private function feedbackHead( $message, $class, $record, $extra = '' ) { |
| 491 | + $gender = ''; #? |
| 492 | + $name = htmlspecialchars( $record->user_name ); |
| 493 | + $link = $record->af_user_id ? "User:$name" : "Special:Contributions/$name"; |
| 494 | + $html = Html::openElement( 'h3' ) |
| 495 | + . Html::element( 'span', array( 'class' => 'icon' ) ) |
| 496 | + . Linker::link( Title::newFromText( $link ), $name ) |
| 497 | + . Html::element( 'span', |
| 498 | + array( 'class' => $class ), |
| 499 | + wfMessage( $message, $gender, $extra )->escaped() |
| 500 | + ) |
| 501 | + . Html::closeElement( 'h3' ); |
| 502 | + |
| 503 | + return $html; |
| 504 | + } |
| 505 | + |
481 | 506 | /** |
482 | 507 | * Gets the allowed parameters |
483 | 508 | * |
Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php |
— | — | @@ -193,15 +193,28 @@ |
194 | 194 | |
195 | 195 | public function initializeAccess() { |
196 | 196 | global $wgUser; |
197 | | - return array( |
| 197 | + $permissions = array( |
198 | 198 | 'blocked' => $wgUser->isBlocked(), |
199 | 199 | 'anon' => $wgUser->isAnon(), |
200 | 200 | 'registered' => !$wgUser->isAnon() && !$wgUser->isBlocked(), |
201 | 201 | 'autoconfirmed' => in_array('autoconfirmed', $wgUser->getEffectiveGroups()), |
202 | 202 | 'rollbackers' => in_array('rollbacker', $wgUser->getEffectiveGroups()), |
203 | | - 'admins' => in_array('sysop', $wgUser->getEffectiveGroups()), |
204 | | - 'oversight' => in_array('oversight', $wgUser->getEffectiveGroups()) |
| 203 | + 'admins' => false, |
| 204 | + 'oversight' => false |
205 | 205 | ); |
| 206 | + |
| 207 | + if( in_array('sysop', $wgUser->getEffectiveGroups() ) ) { |
| 208 | + $permissions['admins'] = true; |
| 209 | + $permissions['rollbackers'] = true; |
| 210 | + } |
| 211 | + |
| 212 | + if( in_array('oversight ', $wgUser->getEffectiveGroups() ) ) { |
| 213 | + $permissions['oversight'] = true; |
| 214 | + $permissions['rollbackers'] = true; |
| 215 | + $permissions['admins'] = true; |
| 216 | + } |
| 217 | + |
| 218 | + return $permissions; |
206 | 219 | } |
207 | 220 | } |
208 | 221 | |
Index: trunk/extensions/ArticleFeedbackv5/SpecialArticleFeedbackv5.php |
— | — | @@ -18,7 +18,6 @@ |
19 | 19 | private $access; |
20 | 20 | private $filters = array( |
21 | 21 | 'visible', |
22 | | - 'all', |
23 | 22 | 'comment' |
24 | 23 | ); |
25 | 24 | private $sorts = array( |
— | — | @@ -35,10 +34,11 @@ |
36 | 35 | $this->access = ApiArticleFeedbackv5Utils::initializeAccess(); |
37 | 36 | |
38 | 37 | if( $this->access[ 'rollbackers' ] ) { |
39 | | - $filter[] = 'invisible'; |
| 38 | + $this->filters[] = 'invisible'; |
| 39 | + $this->filters[] = 'all'; |
40 | 40 | } |
41 | 41 | if( $this->access[ 'oversight' ] ) { |
42 | | - $filter[] = 'deleted'; |
| 42 | + $this->filters[] = 'deleted'; |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |