2 # Copyright (C) 2004 Magnus Manske <magnus.manske@web.de>
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
23 * @subpackage SpecialPage
30 var $rev_fields = "rev_id,rev_page,rev_timestamp,rev_user_text,rev_user,rev_comment" ;
32 function getRevisionFromId( $rev_id ) {
33 if( isset( $this->id2rev
[$rev_id] ) ) return $this->id2rev
[$rev_id];
35 $db =& wfGetDB( DB_SLAVE
);
36 $fname = 'SpecialValidate::getRevisionFromId';
37 $res = $db->select( 'revision', $this->rev_fields
, array( 'rev_id' => $rev_id ), $fname, array( 'LIMIT' => 1 ) );
38 $rev = $db->fetchObject($res);
39 $db->freeResult($res);
41 $this->id2rev
[$rev->rev_id
] = $rev;
42 $this->ts2rev
[$rev->rev_timestamp
] = $rev;
47 function getRevisionFromTimestamp( $timestamp ) {
48 if( isset( $this->ts2rev
[$timestamp] ) ) return $this->ts2rev
[$timestamp];
50 $db =& wfGetDB( DB_SLAVE
);
51 $fname = 'SpecialValidate::getRevisionFromTimestamp';
52 $res = $db->select( 'revision', $this->rev_fields
,
53 array( 'rev_page' => $this->page_id
, 'rev_timestamp' => $timestamp ),
54 $fname, array( 'LIMIT' => 1 )
56 $rev = $db->fetchObject($res);
57 $db->freeResult($res);
59 $this->id2rev
[$rev->rev_id
] = $rev;
60 $this->ts2rev
[$rev->rev_timestamp
] = $rev;
65 # Returns a HTML link to the specified article revision
66 function getRevisionLink( &$article, $revision, $text = "" ) {
68 $sk = $wgUser->getSkin();
69 $t = $article->getTitle();
70 if( $text == "" ) $text = wfMsg("val_view_version");
71 return $sk->makeKnownLinkObj( $t, $this->getParsedWiki($text), 'oldid='.urlencode($revision) );
74 # Returns an array containing all topics you can vote on
75 function getTopicList() {
76 $db =& wfGetDB( DB_SLAVE
);
80 # NOTE : This query returns only the topics to vote on
81 $res = $db->select( 'validate', '*', array( 'val_page' => 0 ), 'SpecialValidate::getTopicList' );
82 while( $topic = $db->fetchObject($res) ) {
83 $topics[$topic->val_type
] = $topic;
85 $db->freeResult($res);
91 # Merges one dataset into another
92 function mergeInto( &$source, &$dest ) {
94 foreach( $source as $x => $y ) {
96 if( !isset( $dest[$x] ) ) {
98 } elseif( $dest[$x]->value
== 0 ) {
112 # Merges all votes prior to the given revision into it
113 function mergeOldRevisions( &$article, $revision ) {
114 $tmp = $this->voteCache
;
117 $ts = $this->getRevisionTimestamp( $revision );
118 $data = $this->voteCache
[$ts];
119 foreach( $tmp as $x => $y ) {
121 if( $this->mergeInto( $y, $data ) ) {
127 $this->setRevision( $article, $revision, $data );
131 # Clears all votes prior to the given revision
132 function clearOldRevisions( &$article, $revision ) {
133 $tmp = $this->voteCache
;
134 $ts = $this->getRevisionTimestamp( $revision );
135 foreach( $tmp as $x => $y ) {
137 $this->deleteRevisionVote ( $article, $this->getRevisionId( $x ) );
142 # Updates the votes for the given revision from the FORM data
143 function updateRevision( &$article, $revision ) {
146 if( isset( $this->voteCache
[$this->getRevisionTimestamp( $revision )] ) ) {
147 $data = $this->voteCache
[$this->getRevisionTimestamp( $revision )];
151 $nv = $wgRequest->getArray( "re_v_{$revision}", array() );
152 $nc = $wgRequest->getArray( "re_c_{$revision}", array() );
154 foreach( $nv as $x => $y ) {
155 $data[$x]->value
= $y;
156 $data[$x]->comment
= $nc[$x];
160 $this->setRevision( $article, $revision, $data );
163 # Sets a specific revision to both cache and database
164 function setRevision( &$article, $revision, &$data ) {
166 $this->deleteRevisionVote( $article, $revision );
167 $this->voteCache
[ $this->getRevisionTimestamp($revision) ] = $data;
168 foreach( $data as $x => $y ) {
169 if( $y->value
> 0 ) {
170 $ip = $wgUser->isAnon() ?
$wgUser->getName() : '';
171 $dbw =& wfGetDB( DB_MASTER
);
172 $dbw->insert( 'validate',
174 'val_user' => $wgUser->getId(),
175 'val_page' => $article->getId(),
176 'val_revision' => $revision,
178 'val_value' => $y->value
,
179 'val_comment' => $y->comment
,
181 'SpecialValidate::setRevision'
187 # Returns a map identifying the current user
188 function identifyUser( $user = "" ) {
190 if( $user == "" ) $user = $wgUser->getID();
191 return User
::isIP($user)
192 ?
array( 'val_user' => 0, 'val_ip' => $user )
193 : array( 'val_user' => $user );
196 # Deletes a specific vote set in both cache and database
197 function deleteRevisionVote( &$article, $revision ) {
198 $ts = $this->getRevisionTimestamp( $revision );
199 if( !isset ( $this->voteCache
[$ts] ) ) return;
201 $db =& wfGetDB( DB_MASTER
);
205 $this->identifyUser(),
207 'val_page' => $article->getID(),
208 'val_revision' => $revision
211 'SpecialValidate::deleteRevisionVote'
214 unset( $this->voteCache
[$ts] );
217 # Reads the entire vote list for this user for the given article
218 function getVoteList( $id, $user = "" ) {
219 $db =& wfGetDB( DB_SLAVE
);
221 # NOTE : This query gets the votes for a single user on a single page.
222 # Assuming most people will use the "merge" feature,
223 # this will be only a single entry.
224 $res = $db->select( 'validate', '*', array_merge( array( 'val_page' => $id ), $this->identifyUser($user) ) );
226 $revisions = array();
227 while( $vote = $db->fetchObject($res) ) {
228 $ts = $this->getRevisionTimestamp( $vote->val_revision
);
229 if( ! isset( $revisions[$ts] ) ) {
230 $revisions[$ts] = array();
232 $revisions[$ts][$vote->val_type
]->value
= $vote->val_value
;
233 $revisions[$ts][$vote->val_type
]->comment
= $vote->val_comment
;
235 $db->freeResult($res);
240 # Reads the entire vote list for this user for all articles
241 function getAllVoteLists( $user ) {
242 $db =& wfGetDB( DB_SLAVE
);
243 $this->allVoteDb
= $db ;
244 $a = $this->identifyUser($user) ;
245 $b = array ( "ORDER BY" => "val_page,val_revision" ) ;
246 $res = $db->select( 'validate', '*', $a , 'getAllVotesList' , $b );
250 # This functions adds a topic to the database
251 function addTopic( $topic, $limit ) {
252 $db =& wfGetDB( DB_MASTER
);
255 while( isset( $this->topicList
[$next_idx] ) ) {
265 'val_type' => $next_idx,
266 'val_value' => $limit,
267 'val_comment' => $topic,
270 'SpecialValidate::addTopic'
273 $t->val_user
= $t->val_page
= $t->val_revision
= 0;
274 $t->val_type
= $next_idx;
275 $t->val_value
= $limit;
276 $t->val_comment
= $topic;
278 $this->topicList
[$next_idx] = $t;
280 ksort( $this->topicList
);
283 function deleteTopic( $id ) {
284 $db =& wfGetDB( DB_MASTER
);
285 $db->delete( 'validate', array( 'val_type' => $id ), 'SpecialValidate::deleteTopic' );
286 unset( $this->topicList
[$id] );
289 # This function returns a link text to the page validation statistics
290 function getStatisticsLink( &$article ) {
292 $sk = $wgUser->getSkin();
293 $nt = $article->getTitle();
294 return $sk->makeKnownLinkObj( $nt, wfMsg( 'val_rev_stats', $nt->getPrefixedText() ), 'action=validate&mode=list' );
297 # This function returns a link text to the page validation statistics of a single revision
298 function getRevisionStatsLink( &$article, $revision ) {
300 $sk = $wgUser->getSkin();
301 $nt = $article->getTitle();
302 $text = $this->getParsedWiki( wfMsg('val_revision_stats_link') );
303 $query = "action=validate&mode=details&revision={$revision}";
304 return '(' . $sk->makeKnownLinkObj( $nt, $text, $query ) . ')';
307 # This function returns a link text to the user rating statistics page
308 function getUserRatingsLink( $user, $text ) {
310 $sk = $wgUser->getSkin();
311 if( $user == 0 ) $user = $wgUser->getName();
312 $nt = Title
::newFromText( 'Special:Validate' );
313 return $sk->makeKnownLinkObj( $nt, $text, 'mode=userstats&user='.urlencode($user) );
316 # Returns the timestamp of a revision based on the revision number
317 function getRevisionTimestamp( $rev_id ) {
318 $rev = $this->getRevisionFromId( $rev_id );
319 return $rev->rev_timestamp
;
322 # Returns the revision number of a revision based on the timestamp
323 function getRevisionId( $ts ) {
324 $rev = $this->getRevisionFromTimestamp( $ts );
329 # HTML generation functions from this point on
331 # Returns the metadata string for a revision
332 function getMetadata( $rev_id, &$article ) {
334 $sk = $wgUser->getSkin();
337 $x = $this->getRevisionFromId($rev_id);
338 $metadata .= wfTimestamp( TS_DB
, $x->rev_timestamp
);
340 if( $x->rev_user
== 0 ) {
341 $metadata .= $x->rev_user_text
;
344 $u->setId( $x->rev_user
);
345 $u->setName( $x->rev_user_text
);
346 $nt = $u->getUserPage();
347 $metadata .= $sk->makeKnownLinkObj( $nt, htmlspecialchars( $nt->getText() ) );
349 $metadata .= ': '. $sk->commentBlock( $x->rev_comment
, $article->getTitle() );
353 # Generates a link to the topic description
354 function getTopicLink($s) {
355 $t = Title
::newFromText ( wfMsg ( 'val_topic_desc_page' ) ) ;
356 # FIXME: Why doesn't this use standard linking code?
358 $r .= $t->escapeLocalURL () ;
359 $r .= "#" . urlencode ( $s ) ;
360 $r .= "\">{$s}</a>" ;
364 # Generates HTML from a wiki text, e.g., a wfMsg
365 function getParsedWiki ( $text ) {
366 global $wgOut, $wgTitle, $wgParser ;
367 $parserOutput = $wgParser->parse( $text , $wgTitle, $wgOut->mParserOptions
,false);
368 return $parserOutput->getText() ;
371 # Generates a form for a single revision
372 function getRevisionForm( &$article, $idx, &$data, $focus = false ) {
373 # Fill data with blank values
375 $revision = $this->getRevisionId( $ts );
376 foreach( $this->topicList
as $x => $y ) {
377 if( !isset( $data[$x] ) ) {
378 $data[$x]->value
= 0;
379 $data[$x]->comment
= "";
385 $table_class = $focus ?
'revisionform_focus' : 'revisionform_default';
386 $ret = "<form method='post'><table class='{$table_class}'>\n";
387 $head = "Revision #" . $revision;
388 $link = $this->getRevisionLink( $article, $revision );
389 $metadata = $this->getMetadata( $revision, $article );
390 $ret .= "<tr><th colspan='3'>" . $head . " ({$link}) {$metadata}</th></tr>\n";
392 foreach( $data as $x => $y ) {
394 $trclass = $line == 1 ?
"revision_tr_first" : "revision_tr_default";
395 $idx = "_{$revision}[{$x}]";
396 $ret .= "<tr class='{$trclass}'>\n";
398 $ret .= $this->getTopicLink ( $this->topicList
[$x]->val_comment
) ;
401 $tlx = $this->topicList
[$x];
403 $max = $tlx->val_value
;
404 for( $a = 0 ; $a <= $max ; $a++
) {
406 $vote .= wfMsg ( "val_noop" );
408 $vote .= "<input type='radio' name='re_v{$idx}' value='{$a}'";
409 if( $a == $y->value
) {
410 $vote .= " checked='checked'";
413 if( $max == 2 && $a == 1 ) {
414 $vote .= wfMsg( "val_no" ) . " ";
415 } elseif( $max == 2 && $a == 2 ) {
416 $vote .= wfMsg( "val_yes" );
417 } elseif( $a != 0 ) {
424 $ret .= "<td>{$vote}</td>\n";
426 $ret .= "<td><input size='50' style='width:98%' maxlength='250' type='text' name='re_c{$idx}' value='{$y->comment}'/>";
427 $ret .= "</td></tr>\n";
429 $checked = $focus ?
" checked='checked'" : "";
430 $ret .= "<tr><td colspan='3'>\n";
431 $ret .= "<input type='checkbox' name='re_merge_{$revision}' value='1'{$checked} />" . $this->getParsedWiki( wfMsg( 'val_merge_old' ) ) . " \n";
432 $ret .= "<input type='checkbox' name='re_clear_{$revision}' value='1'{$checked} />" . $this->getParsedWiki( wfMsg( 'val_clear_old' ) ) . " \n";
433 $ret .= "<input type='submit' name='re_submit[{$revision}]' value=\"" . wfMsgHtml( "ok" ) . "\" />\n";
435 if( $focus ) $ret .= "<br/>\n<small>" . $this->getParsedWiki ( wfMsg( "val_form_note" ) ) . "</small>";
436 $ret .= "</td></tr>\n";
437 $ret .= "</table></form>\n\n";
442 # Generates the page from the validation tab
443 function validatePageForm( &$article, $revision ) {
444 global $wgOut, $wgRequest, $wgUser;
447 $this->page_id
= $article->getID();
448 $this->topicList
= $this->getTopicList();
449 $this->voteCache
= $this->getVoteList( $article->getID() );
451 # Check for POST data
452 $re = $wgRequest->getArray( 're_submit' );
453 if ( isset( $re ) ) {
454 $id = array_keys( $re );
455 $id = $id[0] ; # $id is now the revision number the user clicked "OK" for
456 $clearOldRev = $wgRequest->getVal( "re_clear_{$id}", 0 );
457 $mergeOldRev = $wgRequest->getVal( "re_merge_{$id}", 0 );
458 $this->updateRevision( $article, $id );
460 $this->mergeOldRevisions( $article, $id );
463 $this->clearOldRevisions( $article, $id );
465 $ret .= '<p class="revision_saved">' . $this->getParsedWiki( wfMsg( 'val_revision_changes_ok' ) ) . "</p>";
467 $ret .= $this->getParsedWiki( wfMsg ('val_votepage_intro') );
470 # Make sure the requested revision exists
471 $rev = $this->getRevisionFromId($revision);
472 $ts = $rev->rev_timestamp
;
473 if( !isset( $this->voteCache
[$ts] ) ) {
474 $this->voteCache
[$ts] = array();
477 # Sort revisions list, newest first
478 krsort( $this->voteCache
);
481 $title = $article->getTitle();
482 $title = $title->getPrefixedText();
483 $wgOut->setPageTitle( wfMsg( 'val_rev_for', $title ) );
484 foreach( $this->voteCache
as $x => $y ) {
485 $ret .= $this->getRevisionForm( $article, $x, $y, $x == $ts );
488 $ret .= $this->getStatisticsLink( $article );
489 $ret .= "<p>" . $this->getUserRatingsLink( $wgUser->getID(), wfMsg( 'val_show_my_ratings' ) ) . "</p>";
493 # This function performs the "management" mode on Special:Validate
494 function manageTopics() {
496 $this->topicList
= $this->getTopicList();
498 $iamsure = true ; # Sure by default # $wgRequest->getVal( "iamsure", "0" ) == 1;
500 if( $iamsure && $wgRequest->getVal( "m_add", "--" ) != "--" ) {
501 $new_topic = $wgRequest->getVal( "m_topic" );
502 $new_limit = $wgRequest->getVal( "m_limit" );
503 if( $new_topic != "" && $new_limit > 1 ) {
504 $this->addTopic( $new_topic, $new_limit );
508 $da = $wgRequest->getArray( "m_del" );
509 if( $iamsure && isset( $da ) && count( $da ) > 0 ) {
510 $id = array_keys( $da );
511 $id = array_shift( $id );
512 $this->deleteTopic( $id );
515 # FIXME: Wikitext this
516 $r = "<p>" . $this->getParsedWiki( wfMsg( 'val_warning' ) ) . "</p>\n";
517 $r .= "<form method='post'>\n";
519 $r .= "<tr>" . wfMsg( 'val_list_header' ) . "</tr>\n";
520 foreach( $this->topicList
as $x => $y ) {
522 $r .= "<th>{$y->val_type}</th>\n";
523 $r .= "<td>" . $this->getTopicLink ( $y->val_comment
) . "</td>\n";
524 $r .= "<td>1 .. <b>" . intval( $y->val_value
) . "</b></td>\n";
525 $r .= "<td><input type='submit' name='m_del[" . intval( $x ) . "]' value='" . htmlspecialchars( wfMsg( 'val_del' ) ) . "'/></td>\n";
530 $r .= '<td><input type="text" name="m_topic" value=""/></td>' . "\n";
531 $r .= '<td>1 .. <input type="text" name="m_limit" value="" size="4"/></td>' . "\n";
532 $r .= '<td><input type="submit" name="m_add" value="' . htmlspecialchars( wfMsg( 'val_add' ) ) . '"/></td>' . "\n";
533 $r .= "</tr></table>\n";
534 # $r .= '<p><input type="checkbox" name="iamsure" id="iamsure" value="1"/>';
535 # $r .= '<label for="iamsure">' . $this->getParsedWiki( wfMsg( 'val_iamsure' ) ) . "</label></p>\n";
540 # Generates an ID for both logged-in users and anons; $res is an object from an SQL query
541 function make_user_id( &$res ) {
542 return $res->val_user
== 0 ?
$res->val_ip
: $res->val_user
;
545 function showDetails( &$article, $revision ) {
546 global $wgOut, $wgUser;
547 $this->page_id
= $article->getID();
548 $this->topicList
= $this->getTopicList();
550 $sk = $wgUser->getSkin();
551 $title = $article->getTitle();
552 $wgOut->setPageTitle( str_replace( '$1', $title->getPrefixedText(), wfMsg( 'val_validation_of' ) ) );
558 # Collecting statistic data
559 $db =& wfGetDB( DB_SLAVE
);
560 $res = $db->select( 'validate', '*', array( 'val_page' => $this->page_id
, 'val_revision' => $revision ), 'SpecialValidate::showDetails' );
561 while( $x = $db->fetchObject($res) ) {
562 $data[$this->make_user_id($x)][$x->val_type
] = $x;
563 $users[$this->make_user_id($x)] = true;
564 $topics[$x->val_type
] = true;
566 $db->freeResult($res);
568 # Sorting lists of topics and users
572 $ts = $this->getRevisionTimestamp( $revision );
573 $url = $this->getRevisionLink( $article, $revision, wfTimestamp( TS_DB
, $ts ) );
577 $ret .= "<p><b>" . str_replace( '$1', $url, wfMsg( 'val_revision_of' ) ) . "</b></p>\n";
579 $ret .= "<tr><th>" . $this->getParsedWiki ( wfMsg('val_details_th') ) . "</th>" ;
581 foreach( $topics as $t => $dummy ) {
582 $ret .= '<th>' . $sk->commentBlock( $this->topicList
[$t]->val_comment
, $article->getTitle() ) . '</th>';
587 foreach( $users as $u => $dummy ) { # Every row a user
590 if( !User
::IsIP( $u ) ) { # Logged-in user rating
591 $ret .= $this->getUserRatingsLink( $u, User
::whoIs( $u ) );
592 } else { # Anon rating
593 $ret .= $this->getUserRatingsLink( $u, $u );
596 foreach( $topics as $t => $dummy ) { # Every column a topic
597 if( !isset( $data[$u][$t] ) ) {
601 $ret .= $data[$u][$t]->val_value
;
602 if( $data[$u][$t]->val_comment
!= "" ) {
603 $ret .= ' ' . $sk->commentBlock( $data[$u][$t]->val_comment
, $article->getTitle() );
611 $ret .= "<p>" . $this->getStatisticsLink( $article ) . "</p>";
612 $ret .= "<p>" . $this->getUserRatingsLink( $wgUser->getID(), wfMsg( 'val_show_my_ratings' ) ) . "</p>";
617 # XXX This should be paged
618 function showList( &$article ) {
619 global $wgOut, $wgUser;
620 $this->page_id
= $article->getID();
621 $this->topicList
= $this->getTopicList();
623 $title = $article->getTitle();
624 $wgOut->setPageTitle( str_replace( '$1', $title->getPrefixedText(), wfMsg( 'val_validation_of' ) ) );
626 # Collecting statistic data
627 $db =& wfGetDB( DB_SLAVE
);
628 $res = $db->select( 'validate', '*', array( "val_page" => $this->page_id
), 'SpecialValidate::showList' );
630 $statistics = array();
631 while( $vote = $db->fetchObject($res) ) {
632 $ts = $this->getRevisionTimestamp($vote->val_revision
);
633 if ( !isset ( $statistics[$ts] ) ) $statistics[$ts] = array () ;
634 if ( !isset ( $statistics[$ts][$vote->val_type
]->count
) ) $statistics[$ts][$vote->val_type
]->count
= 0 ;
635 if ( !isset ( $statistics[$ts][$vote->val_type
]->sum
) ) $statistics[$ts][$vote->val_type
]->sum
= 0 ;
636 $statistics[$ts][$vote->val_type
]->count++
;
637 $statistics[$ts][$vote->val_type
]->sum +
= $vote->val_value
;
639 $db->freeResult($res);
641 krsort( $statistics );
643 $ret = "<table><tr>\n";
644 $ret .= "<th>" . $this->getParsedWiki( wfMsg( "val_revision" ) ) . "</th>\n";
645 foreach( $this->topicList
as $topic ) {
646 $ret .= "<th>" . $this->getTopicLink($topic->val_comment
) . "</th>";
650 foreach( $statistics as $ts => $data ) {
651 $rev_id = $this->getRevisionId( $ts );
652 $revision_link = $this->getRevisionLink( $article, $rev_id, wfTimestamp( TS_DB
, $ts ) );
653 $details_link = $this->getRevisionStatsLink( $article, $rev_id );
654 $ret .= "<tr><td>{$revision_link} {$details_link}</td>";
655 foreach( $this->topicList
as $topicType => $topic ) {
656 if( isset( $data[$topicType] ) ) {
657 $stats = $data[$topicType];
658 $average = $stats->count
== 0 ?
0 : $stats->sum
/ $stats->count
;
659 $ret .= sprintf( "<td><b>%1.1f</b> (%d)</td>", $average, $stats->count
);
666 $ret .= "</table>\n";
667 $ret .= "<p>" . $this->getUserRatingsLink( $wgUser->getID(), wfMsg( 'val_show_my_ratings' ) ) . "</p>";
671 function getRatingText( $value, $max ) {
672 if( $max == 2 && $value == 1 ) {
673 $ret = wfMsg ( "val_no" ) . " ";
674 } elseif( $max == 2 && $value == 2 ) {
675 $ret = wfMsg( "val_yes" );
676 } elseif( $value != 0 ) {
677 $ret = wfMsg( "val_of", $value, $max ) . " ";
689 # This function will get an SQL results handle on the first call
690 # and iterate through the results on each call, until
691 # it hits the end; after that, it will return an empty array
692 # to signal the calling function to stop
693 function iterateAllVotes ( $user ) {
694 if ( $this->allVotesCount
== -1 ) return array () ; # This is the end, my friend, the end
696 if ( $this->allVotesCount
== 0 ) {
697 $this->allVoteRes
= $this->getAllVoteLists( $user ) ;
698 $this->allVotesCount
= 1 ;
703 if( $vote = $this->allVoteDb
->fetchObject($this->allVoteRes
) ) {
704 $votes[$vote->val_page
][$vote->val_revision
][$vote->val_type
] = $vote;
706 $this->allVoteDb
->freeResult($this->allVoteRes
);
707 $this->allVotesCount
= -1 ; # Setting stop mark
712 if ( count ( $votes ) != 0 ) {
713 foreach ( $votes AS $k => $v ) {
715 break ; # Just once...
717 unset ( $this->allVotesCache
[$k] ) ;
722 function showUserStats( $user ) {
723 global $wgOut, $wgUser;
724 $this->topicList
= $this->getTopicList();
725 $sk = $wgUser->getSkin();
726 $this->allVotesCount
= 0 ; # Initialize
728 if( $user == $wgUser->getID() ) {
729 $wgOut->setPageTitle ( wfMsg ( 'val_my_stats_title' ) );
730 } elseif( !User
::IsIP( $user ) ) {
731 $wgOut->setPageTitle( wfMsg( 'val_user_stats_title', User
::whoIs( $user ) ) );
733 $wgOut->setPageTitle( wfMsg( 'val_user_stats_title', $user ) );
739 $temp = $this->iterateAllVotes ( $user ) ;
740 if ( count ( $temp ) == 0 ) break ; # All done
741 $articleid = array_shift ( array_keys ( $temp ) ) ;
742 $revisions = array_shift ( $temp ) ;
743 $title = Title
::newFromID( $articleid );
744 $ret .= "<tr><th colspan='4'>";
745 $ret .= $sk->makeKnownLinkObj( $title, $title->getEscapedText() );
746 $ret .= "</th></tr>";
747 krsort( $revisions );
748 foreach( $revisions as $revid => $revision ) {
749 $url = $title->getLocalURL( "oldid={$revid}" );
751 $ret .= $sk->makeKnownLinkObj( $title, wfMsg('val_revision_number', $revid ), "oldid={$revid}" );
755 foreach( $revision as $topic => $rating ) {
760 $ret .= "<td>" . $this->getTopicLink ( $this->topicList
[$topic]->val_comment
) . "</td>";
761 $ret .= "<td>" . $this->getRatingText( $rating->val_value
, $this->topicList
[$topic]->val_value
) . "</td>";
762 $ret .= "<td>" . $sk->commentBlock( $rating->val_comment
) . "</td>";
778 function wfSpecialValidate( $page = '' ) {
779 global $wgOut, $wgRequest, $wgUseValidation, $wgUser, $wgContLang;
781 if( !$wgUseValidation ) {
782 $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" );
788 if( ! $wgUser->isAllowed('change_validation') ) {
789 $wgOut->sysopRequired();
794 $mode = $wgRequest->getVal( "mode" );
795 $skin = $wgUser->getSkin();
798 if( $mode == "manage" ) {
799 $v = new Validation();
800 $html = $v->manageTopics();
801 } elseif( $mode == "userstats" ) {
802 $v = new Validation();
803 $user = $wgRequest->getVal( "user" );
804 $html = $v->showUserStats( $user );
809 $t = Title
::newFromText( "Special:Validate" );
810 $url = $t->escapeLocalURL( "mode=manage" );
811 $html .= "<li><a href=\"" . $url . "\">Manage</a></li>\n";
816 $wgOut->addHTML( $html );