Index: trunk/extensions/Review/language/en.php |
— | — | @@ -23,7 +23,8 @@ |
24 | 24 | 'review_sidebar_you_have_other_reviews_for_this_article' => "You have already reviewed other versions of this article. Your other ratings will be merged into this one where you selected 'no opinion'.", |
25 | 25 | 'review_page_link' => "review statistics", |
26 | 26 | 'review_sidebar_final' => "For review data of this page view, see its $1", |
27 | | - 'review_for_page' => "Review for \"$1\"", |
| 27 | + 'review_for_page' => "Review for page \"$1\"", |
| 28 | + 'review_for_user' => "Review for user \"$1\"", |
28 | 29 | 'review_error' => "Something's wrong!", |
29 | 30 | 'review_no_reviews_for_page' => "There are currently no reviews for \"$1\".", |
30 | 31 | 'review_total_statistics' => "Total", |
— | — | @@ -32,6 +33,11 @@ |
33 | 34 | 'review_statistic_cell' => "Average: $1 of $2<br/>($4 users, $5 anons)", |
34 | 35 | 'review_version_statistic_cell' => "$1 of $2", |
35 | 36 | 'review_version_reviews_link' => "<small>(version reviews)</small>", |
| 37 | + 'review_concerns_page' => "This review is about the page \"$1\".", |
| 38 | + 'review_concerns_user' => "This is about reviews by user \"$1\".", |
| 39 | + 'review_user_reviews' => "<small>(reviews by this user)</small>", |
| 40 | + 'review_user_page_list' => "The user reviewed the following pages:", |
| 41 | + 'review_user_details_link' => "(details)", |
36 | 42 | ) |
37 | 43 | ); |
38 | 44 | ?> |
Index: trunk/extensions/Review/Review.php |
— | — | @@ -168,7 +168,6 @@ |
169 | 169 | # Create the revision array, if necessary |
170 | 170 | if ( !isset ( $ret[$line->val_revision] ) ) |
171 | 171 | $ret[$line->val_revision] = array () ; |
172 | | - |
173 | 172 | # Store the data |
174 | 173 | $ret[$line->val_revision][$line->val_type] = $line ; |
175 | 174 | } |
— | — | @@ -349,7 +348,7 @@ |
350 | 349 | <?php |
351 | 350 | } |
352 | 351 | print "<input type='hidden' name='review_oldid' value='{$revision}'/>" ; |
353 | | - print "<div style='text-align:right'><input type='submit' name='save_review' value='" . wfMsgForContent('review_save') . "'/></div>" ; |
| 352 | + print "<input style='width:100%' type='submit' name='save_review' value='" . wfMsgForContent('review_save') . "'/>" ; |
354 | 353 | print "<div id='review_sidebar_note'>" ; |
355 | 354 | print wfMsgForContent ( 'review_sidebar_explanation' ) ; |
356 | 355 | if ( count ( $ratings ) > 1 ) { |
— | — | @@ -482,7 +481,7 @@ |
483 | 482 | } |
484 | 483 | |
485 | 484 | /** |
486 | | - * Returns a HTML table row for the statistics of a revision |
| 485 | + * Returns a HTML table row for the statistics of a revision. Output heavy! |
487 | 486 | * @param $title The page |
488 | 487 | * @param $revision The revision ID (or -1 for table header, 0 for total statistics) |
489 | 488 | * @param $data The data for this revision |
— | — | @@ -496,7 +495,7 @@ |
497 | 496 | # Row header |
498 | 497 | $ret = "<tr><th id='review_statistics_table_header' align='left' nowrap>" ; |
499 | 498 | if ( $revision < 0 ) { |
500 | | - # Table headers |
| 499 | + # Table headersconcerns |
501 | 500 | if ( $revision == -1 ) { |
502 | 501 | $ret .= wfMsgForContent ( 'review_statistics_left_corner' ) ; |
503 | 502 | } else { |
— | — | @@ -513,15 +512,20 @@ |
514 | 513 | $ak = array_keys ( $data ) ; |
515 | 514 | $k = array_shift ( $ak ) ; |
516 | 515 | if ( $data[$k]->val_user == 0 ) { |
517 | | - #$user = User::newFromName ( $data[$k]->val_ip ) ; |
518 | 516 | $user = new User ; |
519 | 517 | $user->setName ( $data[$k]->val_ip ) ; |
| 518 | + $user_reviews = "user_ip=" . $data[$k]->val_ip ; |
520 | 519 | } else { |
521 | 520 | $user = new User ; |
522 | 521 | $user->setID ( $data[$k]->val_user ) ; |
523 | 522 | $user->loadFromDatabase() ; |
| 523 | + $user_reviews = "user_id=" . $data[$k]->val_user ; |
524 | 524 | } |
525 | 525 | $ret .= $skin->makeLinkObj ( $user->getUserPage() , $user->getName() ) ; |
| 526 | + $ret .= "<br/>" ; |
| 527 | + $ret .= $skin->makeLinkObj ( $wgTitle , |
| 528 | + wfMsgForContent('review_user_reviews') , |
| 529 | + "mode=view_user_reviews&{$user_reviews}" ) ; |
526 | 530 | } else { |
527 | 531 | # Individual revision |
528 | 532 | $page_id = $title->getArticleID() ; |
— | — | @@ -535,7 +539,7 @@ |
536 | 540 | foreach ( $wgReviewExtensionTopics AS $type => $topic ) { |
537 | 541 | if ( $revision < 0 ) { |
538 | 542 | # Table header row |
539 | | - $ret .= "<th id='review_statistics_table_header' nowrap>" ; |
| 543 | + $ret .= "<th id='review_statistics_table_header'>" ; |
540 | 544 | $ret .= $topic->name ; |
541 | 545 | $ret .= "</th>" ; |
542 | 546 | } else if ( $revision_mode ) { |
— | — | @@ -594,10 +598,30 @@ |
595 | 599 | } |
596 | 600 | |
597 | 601 | /** |
| 602 | + */ |
| 603 | + function get_list_of_pages_reviewed_by_user ( $user ) { |
| 604 | + $conds = array () ; |
| 605 | + wfReviewExtensionSetUserCondition ( $user , $conds ) ; |
| 606 | + $dbr =& wfGetDB( DB_SLAVE ); |
| 607 | + $res = $dbr->select( |
| 608 | + /* FROM */ 'validate', |
| 609 | + /* SELECT */ 'DISTINCT val_page', |
| 610 | + /* WHERE */ $conds, |
| 611 | + $fname |
| 612 | + ); |
| 613 | + |
| 614 | + $ret = array() ; |
| 615 | + while ( $line = $dbr->fetchObject( $res ) ) { |
| 616 | + $ret[] = $line->val_page ; |
| 617 | + } |
| 618 | + return $ret ; |
| 619 | + } |
| 620 | + |
| 621 | + /** |
598 | 622 | * Special page main function |
599 | 623 | */ |
600 | 624 | function execute( $par = null ) { |
601 | | - global $wgRequest , $wgOut , $wgUser ; |
| 625 | + global $wgRequest , $wgOut , $wgUser , $wgTitle ; |
602 | 626 | wfReviewExtensionInitMessages () ; |
603 | 627 | |
604 | 628 | $out = "" ; |
— | — | @@ -605,18 +629,43 @@ |
606 | 630 | $mode = $wgRequest->getText ( 'mode' , "" ) ; |
607 | 631 | $page_id = $wgRequest->getInt ( 'page_id' , 0 ) ; |
608 | 632 | $rev_id = $wgRequest->getInt ( 'rev_id' , 0 ) ; |
| 633 | + $user_id = $wgRequest->getInt ( 'user_id' , 0 ) ; |
| 634 | + $user_ip = $wgRequest->getText ( 'user_ip' , "" ) ; |
609 | 635 | $error = false ; |
| 636 | + |
| 637 | + if ( $user_id != 0 OR $user_ip != "" ) { |
| 638 | + $theuser = new User ; |
| 639 | + if ( $user_id == 0 ) { |
| 640 | + $theuser->setName ( $user_ip ) ; |
| 641 | + } else { |
| 642 | + $theuser->setID ( $user_id ) ; |
| 643 | + $theuser->loadFromDatabase() ; |
| 644 | + } |
| 645 | + } |
610 | 646 | |
611 | 647 | if ( $page_id == 0 ) { |
612 | | - $title = new Title ; |
613 | | - $error = true ; |
| 648 | + $title = NULL ; |
614 | 649 | } else { |
615 | 650 | $title = Title::newFromID ( $page_id ) ; |
616 | 651 | } |
617 | 652 | |
618 | | - if ( $error ) { |
619 | | - # Do nothing |
620 | | - } else if ( $mode == 'view_page_statistics' ) { |
| 653 | + # Info ahead |
| 654 | + $o = array () ; |
| 655 | + if ( $page_id != 0 ) { |
| 656 | + $link = $skin->makeLinkObj( $title ) ; |
| 657 | + $o[] = wfMsgForContent ( 'review_concerns_page' , $link ) ; |
| 658 | + } |
| 659 | + if ( isset ( $theuser ) ) { |
| 660 | + $link = $skin->makeLinkObj ( $theuser->getUserPage() , $theuser->getName() ) ; |
| 661 | + $o[] = wfMsgForContent ( 'review_concerns_user' , $link ) ; |
| 662 | + } |
| 663 | + if ( count ( $o ) > 0 ) { |
| 664 | + $out .= "<ul><li>" . implode ( "</li>\n<li>" , $o ) . "</li></ul>" ; |
| 665 | + } |
| 666 | + |
| 667 | + # Modes |
| 668 | + if ( $mode == 'view_page_statistics' ) { |
| 669 | + # View statistics for one page |
621 | 670 | $revisions = $this->get_reviewed_revisions ( $title ) ; |
622 | 671 | arsort ( $revisions ) ; # Newest first |
623 | 672 | if ( count ( $revisions ) == 0 ) { |
— | — | @@ -636,18 +685,63 @@ |
637 | 686 | $out .= $out2 ; |
638 | 687 | $out .= "</table>\n" ; |
639 | 688 | } |
| 689 | + $page_title = wfMsgForContent ( 'review_for_page' , $title->getPrefixedText() ) ; |
640 | 690 | } else if ( $mode == 'view_version_statistics' ) { |
641 | | - $data = array () ; |
| 691 | + # View statistics for a specific version of a page |
| 692 | + $data = array () ; |
| 693 | + $out .= "<table id='review_statistics_table'>\n" ; |
| 694 | + $out .= $this->get_revision_statistics_row ( $title , -2 , $data ) ; |
| 695 | + $reviews = $this->get_reviews_for_revision ( $title , $rev_id ) ; |
| 696 | + $this->analyze_review_data ( $title , $rev_id , $reviews , $data ) ; |
| 697 | + $out .= $this->get_revision_statistics_row ( $title , 0 , $data ) ; # Statistics for the revision |
| 698 | + $data = $this->group_data_by_user ( $reviews ) ; |
| 699 | + foreach ( $data AS $entry ) { |
| 700 | + $out .= $this->get_revision_statistics_row ( $title , 1 , $entry , true ) ; |
| 701 | + } |
| 702 | + $out .= "</table>\n" ; |
| 703 | + $page_title = wfMsgForContent ( 'review_for_page' , $title->getPrefixedText() ) ; |
| 704 | + } else if ( $mode == 'view_user_reviews' AND isset ( $theuser ) ) { |
| 705 | + if ( $page_id != 0 ) { |
| 706 | + # View the reviews of a user for a specific page |
| 707 | + $revisions = wfReviewExtensionGetUserRatingsForPage ( $title , $theuser ) ; |
| 708 | + print count ( $revisions ) ; |
| 709 | + |
| 710 | + $statistics = array() ; |
642 | 711 | $out .= "<table id='review_statistics_table'>\n" ; |
643 | | - $out .= $this->get_revision_statistics_row ( $title , -2 , $data ) ; |
644 | | - $reviews = $this->get_reviews_for_revision ( $title , $rev_id ) ; |
645 | | - $this->analyze_review_data ( $title , $rev_id , $reviews , $data ) ; |
646 | | - $out .= $this->get_revision_statistics_row ( $title , 0 , $data ) ; # Statistics for the revision |
647 | | - $data = $this->group_data_by_user ( $reviews ) ; |
648 | | - foreach ( $data AS $entry ) { |
649 | | - $out .= $this->get_revision_statistics_row ( $title , 1 , $entry , true ) ; |
| 712 | + $out .= $this->get_revision_statistics_row ( $title , -1 , $statistics ) ; |
| 713 | + $out2 = "" ; |
| 714 | + foreach ( $revisions AS $revision => $reviews ) { |
| 715 | + $data = $this->analyze_review_data ( $title , $revision , $reviews , $statistics ) ; |
| 716 | + $out2 .= $this->get_revision_statistics_row ( $title , $revision , $data ) ; |
650 | 717 | } |
| 718 | + $out .= $this->get_revision_statistics_row ( $title , 0 , $statistics ) ; |
| 719 | + $out .= $out2 ; |
651 | 720 | $out .= "</table>\n" ; |
| 721 | + |
| 722 | + |
| 723 | + } else { |
| 724 | + # View the pages reviewed by a user |
| 725 | + $data = $this->get_list_of_pages_reviewed_by_user ( $theuser ) ; |
| 726 | + $out .= "<h2>" . wfMsgForContent ( 'review_user_page_list' ) . "</h2>\n" ; |
| 727 | + $data2 = array () ; |
| 728 | + if ( $user_id == 0 ) |
| 729 | + $user_link = "user_ip=".$user_ip ; |
| 730 | + else |
| 731 | + $user_link = "user_id=".$user_id ; |
| 732 | + foreach ( $data AS $pid ) { |
| 733 | + $t = Title::newFromID ( $pid ) ; |
| 734 | + $link1 = $skin->makeLinkObj ( $t ) ; |
| 735 | + $link2 = $skin->makeLinkObj ( $wgTitle , |
| 736 | + wfMsgForContent('review_user_details_link') , |
| 737 | + "mode=view_user_reviews&" . $user_link . "&page_id={$pid}" |
| 738 | + ) ; |
| 739 | + $data2[] = $link1 . " " . $link2 ; |
| 740 | + } |
| 741 | + asort ( $data2 ) ; |
| 742 | + if ( count ( $data2 ) > 0 ) |
| 743 | + $out .= "<ol><li>" . implode ( "</li>\n<li>" , $data2 ) . "</li></ul>" ; |
| 744 | + } |
| 745 | + $page_title = wfMsgForContent ( 'review_for_user' , $theuser->getName() ) ; |
652 | 746 | } else { |
653 | 747 | $error = true ; |
654 | 748 | } |
— | — | @@ -656,7 +750,7 @@ |
657 | 751 | if ( $error ) { |
658 | 752 | $wgOut->addHtml( wfMsgForContent ( 'review_error' ) ); |
659 | 753 | } else { |
660 | | - $wgOut->setPageTitle ( wfMsgForContent ( 'review_for_page' , $title->getPrefixedText() ) ) ; |
| 754 | + $wgOut->setPageTitle ( $page_title ) ; |
661 | 755 | $wgOut->addHtml( $out ); |
662 | 756 | } |
663 | 757 | } |
Index: trunk/extensions/Review/review.css |
— | — | @@ -1,4 +1,3 @@ |
2 | | - |
3 | 2 | #review_sidebar_range { |
4 | 3 | font-size:80%; |
5 | 4 | } |