Index: trunk/phase3/includes/SpecialValidate.php |
— | — | @@ -173,6 +173,22 @@ |
174 | 174 | return $r ; |
175 | 175 | } |
176 | 176 | |
| 177 | + # Reads the entire vote list for this user for all articles |
| 178 | + function getAllVoteLists ( $user ) { |
| 179 | + global $wgDBprefix ; |
| 180 | + $r = array () ; # Revisions |
| 181 | + $sql = "SELECT * FROM {$wgDBprefix}validate WHERE val_user=" . $user ; |
| 182 | + $res = wfQuery( $sql, DB_READ ); |
| 183 | + while( $x = wfFetchObject( $res ) ) { |
| 184 | + $a = $x->val_page ; |
| 185 | + $y = $x->val_revision ; |
| 186 | + if ( !isset ( $r[$a] ) ) $r[$a] = array () ; |
| 187 | + if ( !isset($r[$a][$y]) ) $r[$a][$y] = array () ; |
| 188 | + $r[$a][$y][$x->val_type] = $x ; |
| 189 | + } |
| 190 | + return $r ; |
| 191 | + } |
| 192 | + |
177 | 193 | # This functions adds a topic to the database |
178 | 194 | function addTopic ( $topic , $limit ) { |
179 | 195 | global $wgDBprefix ; |
— | — | @@ -212,6 +228,13 @@ |
213 | 229 | return wfMsg ( 'val_revision_stats_link', $url ); |
214 | 230 | } |
215 | 231 | |
| 232 | + # This function returns a link text to the user rating statistics page |
| 233 | + function link2userratings ( $user , $text ) { |
| 234 | + $nt = Title::newFromText ( "Special:Validate" ) ; |
| 235 | + $url = htmlspecialchars( $nt->getLocalURL( "mode=userstats&user={$user}" ) ); |
| 236 | + return "<a href=\"{$url}\">{$text}</a>" ; |
| 237 | + } |
| 238 | + |
216 | 239 | # Returns the timestamp of a revision based on the revision number |
217 | 240 | function getTimestamp ( $revision ) { |
218 | 241 | $ts = $this->rev2date[$revision] ; |
— | — | @@ -313,7 +336,7 @@ |
314 | 337 | |
315 | 338 | # Generates the page from the validation tab |
316 | 339 | function validatePageForm ( &$article , $revision ) { |
317 | | - global $wgOut, $wgRequest ; |
| 340 | + global $wgOut, $wgRequest, $wgUser ; |
318 | 341 | |
319 | 342 | $ret = "" ; |
320 | 343 | $this->prepareRevisions ( $article->getID() ) ; |
— | — | @@ -351,6 +374,7 @@ |
352 | 375 | $ret .= "<br/>\n" ; |
353 | 376 | } |
354 | 377 | $ret .= $this->link2statistics ( $article ) ; |
| 378 | + $ret .= "<p>" . $this->link2userratings ( $wgUser->GetID() , wfMsg('val_show_my_ratings') ) . "</p>" ; |
355 | 379 | return $ret ; |
356 | 380 | } |
357 | 381 | |
— | — | @@ -400,7 +424,7 @@ |
401 | 425 | } |
402 | 426 | |
403 | 427 | function showDetails ( &$article , $revision ) { |
404 | | - global $wgDBprefix , $wgOut ; |
| 428 | + global $wgDBprefix , $wgOut, $wgUser ; |
405 | 429 | $this->prepareRevisions ( $article->getID() ) ; |
406 | 430 | $this->topicList = $this->getTopicList() ; |
407 | 431 | |
— | — | @@ -456,6 +480,7 @@ |
457 | 481 | } |
458 | 482 | $ret .= "</table>" ; |
459 | 483 | $ret .= "<p>" . $this->link2statistics ( $article ) . "</p>" ; |
| 484 | + $ret .= "<p>" . $this->link2userratings ( $wgUser->GetID() , wfMsg('val_show_my_ratings') ) . "</p>" ; |
460 | 485 | |
461 | 486 | return $ret ; |
462 | 487 | } |
— | — | @@ -509,9 +534,54 @@ |
510 | 535 | $ret .= "</tr>\n" ; |
511 | 536 | } |
512 | 537 | $ret .= "</table>\n" ; |
| 538 | + $ret .= "<p>" . $this->link2userratings ( $wgUser->GetID() , wfMsg('val_show_my_ratings') ) . "</p>" ; |
513 | 539 | return $ret ; |
514 | 540 | } |
| 541 | + |
| 542 | + function getRatingText ( $value , $max ) { |
| 543 | + if ( $max == 2 && $value == 1 ) $ret = wfMsg ( "val_no" ) . " " ; |
| 544 | + else if ( $max == 2 && $value == 2 ) $ret = wfMsg ( "val_yes" ) ; |
| 545 | + else if ( $value != 0 ) $ret = wfMsg ( "val_of" , $value , $max ) . " " ; |
| 546 | + else $ret = "" ; |
| 547 | + return $ret ; |
| 548 | + } |
515 | 549 | |
| 550 | + function showUserStats ( $user ) { |
| 551 | + global $wgDBprefix , $wgOut, $wgUser ; |
| 552 | + $this->topicList = $this->getTopicList() ; |
| 553 | + $data = $this->getAllVoteLists ( $user ) ; |
| 554 | + |
| 555 | + if ( $user == $wgUser->getID() ) $wgOut->setPageTitle ( wfMsg ( 'val_my_stats_title' ) ) ; |
| 556 | + else $wgOut->setPageTitle ( wfMsg ( 'val_user_stats_title' , $user ) ) ; |
| 557 | + |
| 558 | + $ret = "" ; |
| 559 | + $ret .= "<table border='1' cellspacing='0' cellpadding='2'>\n" ; |
| 560 | + |
| 561 | + foreach ( $data AS $articleid => $revisions ) { |
| 562 | + $title = Title::newFromID ( $articleid ) ; |
| 563 | + $ret .= "<tr><th align='left' colspan='4'><a href=\"" . $title->getLocalURL() . "\">" . $title->getPrefixedText() . "</a></th></tr>" ; |
| 564 | + krsort ( $revisions ) ; |
| 565 | + foreach ( $revisions AS $revid => $revision ) { |
| 566 | + $url = $title->getLocalURL ( "oldid={$revid}" ) ; |
| 567 | + $ret .= "<tr><th align='left'><a href=\"{$url}\">" . wfMsg ( 'val_revision_number' , $revid ) . "</a></th>" ; |
| 568 | + ksort ( $revision ) ; |
| 569 | + $initial = true ; |
| 570 | + foreach ( $revision AS $topic => $rating ) { |
| 571 | + if ( !$initial ) $ret .= "<tr><td/>" ; |
| 572 | + $initial = false ; |
| 573 | + $ret .= "<td>" . $this->topicList[$topic]->val_comment . "</td>" ; |
| 574 | + $ret .= "<td>" . $this->getRatingText ( $rating->val_value , $this->topicList[$topic]->val_value ) . "</td>" ; |
| 575 | + $ret .= "<td>" . htmlentities ( $rating->val_comment ) . "</td>" ; |
| 576 | + $ret .= "</tr>" ; |
| 577 | + } |
| 578 | + } |
| 579 | + $ret .= "</tr>" ; |
| 580 | + } |
| 581 | + $ret .= "</table>" ; |
| 582 | + |
| 583 | + return $ret ; |
| 584 | + } |
| 585 | + |
516 | 586 | } |
517 | 587 | |
518 | 588 | /** |
— | — | @@ -540,9 +610,11 @@ |
541 | 611 | if ( $mode == "manage" ) { |
542 | 612 | $v = new Validation ; |
543 | 613 | $html = $v->manageTopics () ; |
544 | | -# } else if ( $mode == "list" ) { |
545 | | -# $v = new Validation ; |
546 | | -# $html = $v->showList ( $wgRequest->getVal ( "id" ) ) ; |
| 614 | + } else if ( $mode == "userstats" ) { |
| 615 | + $v = new Validation ; |
| 616 | + $user = $wgUser->GetID() ; |
| 617 | + #$user = $wgRequest->getVal ( "user" ) ; # Uncomment this to allow all user statistics to be public |
| 618 | + $html = $v->showUserStats ( $user ) ; |
547 | 619 | } else { |
548 | 620 | $html = "$mode" ; |
549 | 621 | $html .= "<ul>\n" ; |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -1477,11 +1477,16 @@ |
1478 | 1478 | # Validation |
1479 | 1479 | 'val_yes' => 'Yes', |
1480 | 1480 | 'val_no' => 'No', |
| 1481 | +'val_of' => '$1 of $2', |
1481 | 1482 | 'val_revision' => 'Revision', |
1482 | 1483 | 'val_time' => 'Time', |
| 1484 | +'val_user_stats_title' => 'Validation overview of user #$1', |
| 1485 | +'val_my_stats_title' => 'My validation overview', |
1483 | 1486 | 'val_list_header' => '<th>#</th><th>Topic</th><th>Range</th><th>Action</th>', |
1484 | 1487 | 'val_add' => 'Add', |
1485 | 1488 | 'val_del' => 'Delete', |
| 1489 | +'val_show_my_ratings' => 'Show my validations', |
| 1490 | +'val_revision_number' => 'Revision #$1', |
1486 | 1491 | 'val_warning' => '<b>Never, <i>ever</i>, change something here without <i>explicit</i> community consensus!</b>', |
1487 | 1492 | 'val_rev_for' => 'Revisions for ', |
1488 | 1493 | 'val_details_th_user' => 'User #$1', |