r9121 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r9120‎ | r9121 | r9122 >
Date:14:09, 21 May 2005
Author:magnus_manske
Status:old
Tags:
Comment:
validation updates
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/SpecialValidate.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1284,6 +1284,8 @@
12851285 $v = new Validation ;
12861286 if ( $wgRequest->getVal ( "mode" , "" ) == "list" )
12871287 $t = $v->showList ( $this ) ;
 1288+ else if ( $wgRequest->getVal ( "mode" , "" ) == "details" )
 1289+ $t = $v->showDetails ( $this , $wgRequest->getVal( 'revision' ) ) ;
12881290 else
12891291 $t = $v->validatePageForm ( $this , $revision ) ;
12901292
Index: trunk/phase3/includes/SpecialValidate.php
@@ -201,10 +201,17 @@
202202 # This function returns a link text to the page validation statistics
203203 function link2statistics ( &$article ) {
204204 $nt = $article->getTitle();
205 - $url = htmlspecialchars( $nt->getLocalURL( 'action=validate&mode=list' ) );
 205+ $url = htmlspecialchars( $nt->getLocalURL( "action=validate&mode=list" ) );
206206 return wfMsg ( 'val_rev_stats_link', $nt->getPrefixedText(), $url );
207207 }
208208
 209+ # This function returns a link text to the page validation statistics of a single revision
 210+ function link2revisionstatistics ( &$article , $revision ) {
 211+ $nt = $article->getTitle();
 212+ $url = htmlspecialchars( $nt->getLocalURL( "action=validate&mode=details&revision={$revision}" ) );
 213+ return wfMsg ( 'val_revision_stats_link', $url );
 214+ }
 215+
209216 # Returns the timestamp of a revision based on the revision number
210217 function getTimestamp ( $revision ) {
211218 $ts = $this->rev2date[$revision] ;
@@ -308,6 +315,7 @@
309316 function validatePageForm ( &$article , $revision ) {
310317 global $wgOut, $wgRequest ;
311318
 319+ $ret = "" ;
312320 $this->prepareRevisions ( $article->getID() ) ;
313321 $this->topicList = $this->getTopicList() ;
314322 $this->voteCache = $this->getVoteList ( $article->getID() ) ;
@@ -323,6 +331,7 @@
324332 $this->updateRevision ( $article , $id ) ;
325333 if ( $mergeOldRev ) $this->mergeOldRevisions ( $article , $id ) ;
326334 if ( $clearOldRev ) $this->clearOldRevisions ( $article , $id ) ;
 335+ $ret .= "<p><font color='red'>" . wfMsg ( 'val_revision_changes_ok' ) . "</font></p>" ;
327336 }
328337
329338 # Make sure the requested revision exists
@@ -333,7 +342,6 @@
334343 krsort ( $this->voteCache ) ;
335344
336345 # Output
337 - $ret = "" ;
338346 $title = $article->getTitle();
339347 $title = $title->getPrefixedText() ;
340348 $wgOut->setPageTitle ( wfMsg ( 'val_rev_for' ) . $title ) ;
@@ -390,11 +398,75 @@
391399 $r .= "</form>\n" ;
392400 return $r ;
393401 }
 402+
 403+ function showDetails ( &$article , $revision ) {
 404+ global $wgDBprefix , $wgOut ;
 405+ $this->prepareRevisions ( $article->getID() ) ;
 406+ $this->topicList = $this->getTopicList() ;
 407+
 408+ $title = $article->getTitle() ;
 409+ $wgOut->setPageTitle ( str_replace ( '$1' , $title->getPrefixedText() , wfMsg ( 'val_validation_of' ) ) ) ;
 410+
 411+ # Collecting statistic data
 412+ $id = $article->getID() ;
 413+ $sql = "SELECT * FROM {$wgDBprefix}validate WHERE val_page='{$id}' AND val_revision='{$revision}'" ;
 414+ $res = wfQuery( $sql, DB_READ );
 415+ $data = array () ;
 416+ $users = array () ;
 417+ $topics = array () ;
 418+ while( $x = wfFetchObject( $res ) ) {
 419+ $data[$x->val_user][$x->val_type] = $x ;
 420+ $users[$x->val_user] = true ;
 421+ $topics[$x->val_type] = true ;
 422+ }
 423+
 424+ # Sorting lists of topics and users
 425+ ksort ( $users ) ;
 426+ ksort ( $topics ) ;
 427+
 428+ $ts = $this->getTimestamp ( $revision ) ;
 429+ $url = $this->getVersionLink ( $article , $revision , wfTimestamp ( TS_DB , $ts ) ) ;
 430+
 431+ # Table headers
 432+ $ret = "" ;
 433+ $ret .= "<p><b>" . str_replace ( '$1' , $url , wfMsg ( 'val_revision_of' ) ) . "</b></p>\n" ;
 434+ $ret .= "<table border='1' cellspacing='0' cellpadding='2'>\n" ;
 435+ $ret .= "<tr><th/>" ;
 436+
 437+ foreach ( $topics AS $t => $dummy ) {
 438+ $ret .= "<th>" . $this->topicList[$t]->val_comment . "</th>" ;
 439+ }
 440+ $ret .= "</tr>\n" ;
 441+
 442+ # Table data
 443+ foreach ( $users AS $u => $dummy ) { # Every row a user
 444+ $ret .= "<tr>" ;
 445+ $ret .= "<th>" . str_replace ( "$1" , $u , wfMsg ( 'val_details_th_user') ) . "</th>" ;
 446+ foreach ( $topics AS $t => $dummy ) { # Every column a topic
 447+ if ( !isset ( $data[$u][$t] ) ) $ret .= "<td/>" ;
 448+ else {
 449+ $ret .= "<td valign='center'>" ;
 450+ $ret .= $data[$u][$t]->val_value ;
 451+ if ( $data[$u][$t]->val_comment != "" )
 452+ $ret .= " <small>(" . $data[$u][$t]->val_comment . ")</small>" ;
 453+ $ret .= "</td>" ;
 454+ }
 455+ }
 456+ $ret .= "</tr>" ;
 457+ }
 458+ $ret .= "</table>" ;
 459+ $ret .= "<p>" . $this->link2statistics ( $article ) . "</p>" ;
 460+
 461+ return $ret ;
 462+ }
394463
395464 function showList ( &$article ) {
396 - global $wgDBprefix ;
 465+ global $wgDBprefix , $wgOut;
397466 $this->prepareRevisions ( $article->getID() ) ;
398467 $this->topicList = $this->getTopicList() ;
 468+
 469+ $title = $article->getTitle() ;
 470+ $wgOut->setPageTitle ( str_replace ( '$1' , $title->getPrefixedText() , wfMsg ( 'val_validation_of' ) ) ) ;
399471
400472 # Collecting statistic data
401473 $id = $article->getID() ;
@@ -402,7 +474,6 @@
403475 $res = wfQuery( $sql, DB_READ );
404476 $data = array () ;
405477 while( $x = wfFetchObject( $res ) ) {
406 - #$idx = $x->val_revision ;
407478 $idx = $this->getTimestamp ( $x->val_revision ) ;
408479 if ( !isset ( $data[$idx] ) )
409480 $data[$idx] = array () ;
@@ -419,16 +490,14 @@
420491 $ret = "" ;
421492 $ret .= "<table border='1' cellspacing='0' cellpadding='2'>\n" ;
422493 $ret .= "<tr><th>" . wfMsg("val_revision") . "</th>" ;
423 -# $ret .= "<th>" . wfMsg("val_time") . "</th>" ;
424494 foreach ( $this->topicList AS $x => $y )
425495 $ret .= "<th>{$y->val_comment}</th>" ;
426496 $ret .= "</tr>\n" ;
427497 foreach ( $data AS $ts => $y ) {
428498 $revision = $this->getRevisionNumber ( $ts ) ;
429 -# $url = $this->getVersionLink ( $article , $revision , $revision ) ;
430499 $url = $this->getVersionLink ( $article , $revision , wfTimestamp ( TS_DB , $ts ) ) ;
431 - $ret .= "<tr><th>{$url}</th>" ;
432 -# $ret .= "<td nowrap>" . wfTimestamp ( TS_DB , $ts ) . "</td>" ;
 500+ $detailsurl = $this->link2revisionstatistics ( $article , $revision ) ;
 501+ $ret .= "<tr><td>{$url} {$detailsurl}</td>" ;
433502 foreach ( $this->topicList AS $topicID => $dummy ) {
434503 if ( isset ( $y[$topicID] ) ) {
435504 $z = $y[$topicID] ;
Index: trunk/phase3/languages/Language.php
@@ -105,16 +105,6 @@
106106 'chick' => 'Chick'
107107 );
108108
109 -# Validation types
110 -$wgValidationTypesEn = array (
111 - '0' => "Style|Awful|Awesome|5",
112 - '1' => "Legal|Illegal|Legal|5",
113 - '2' => "Completeness|Stub|Extensive|5",
114 - '3' => "Facts|Wild guesses|Solid as a rock|5",
115 - '4' => "Suitable for 1.0 (paper)|No|Yes|2",
116 - '5' => "Suitable for 1.0 (CD)|No|Yes|2"
117 -);
118 -
119109 /* private */ $wgMathNamesEn = array(
120110 MW_MATH_PNG => 'mw_math_png',
121111 MW_MATH_SIMPLE => 'mw_math_simple',
@@ -1494,7 +1484,12 @@
14951485 'val_del' => 'Delete',
14961486 'val_warning' => '<b>Never, <i>ever</i>, change something here without <i>explicit</i> community consensus!</b>',
14971487 'val_rev_for' => 'Revisions for ',
 1488+'val_details_th_user' => 'User #$1',
 1489+'val_validation_of' => 'Validation of "$1"',
 1490+'val_revision_of' => 'Revision of $1',
 1491+'val_revision_changes_ok' => 'Your ratings have been stored!',
14981492 'val_rev_stats_link' => 'See the validation statistics for "$1" <a href="$2">here</a>',
 1493+'val_revision_stats_link' => '(<a href="$1">details</a>)',
14991494 'val_iamsure' => 'Check this box if you really mean it!',
15001495 'val_clear_old' => 'Clear my older validation data',
15011496 'val_merge_old' => 'Use my previous assessment where selected \'No opinion\'',

Status & tagging log