From ed733183366a2bcf5cc7b99e6aef2f2f945df741 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Fri, 18 Mar 2005 23:08:25 +0000 Subject: [PATCH] validation improvements --- includes/Article.php | 5 +- includes/SkinTemplate.php | 37 +++++----- includes/SpecialValidate.php | 127 +++++++++++++++++++++++++++-------- languages/Language.php | 5 +- 4 files changed, 125 insertions(+), 49 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 527a2d5587..b89c3c2a9d 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1251,7 +1251,10 @@ class Article { include_once ( "SpecialValidate.php" ) ; # The "Validation" class $v = new Validation ; - $t = $v->validatePageForm ( $this , $revision ) ; + if ( $wgRequest->getVal ( "mode" , "" ) == "list" ) + $t = $v->showList ( $this ) ; + else + $t = $v->validatePageForm ( $this , $revision ) ; $wgOut->addHTML ( $t ) ; } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 252450ddb8..5c0ceb5c9a 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -616,25 +616,24 @@ class SkinTemplate extends Skin { # Validate tab. TODO: add validation to logged-in user rights if($wgUseValidation){ # && $wgUser->isAllowed('validate')){ - #$oid = $oldid ? '&revision='.IntVal( $oldid ) : "" ; - if ( $oldid ) $oid = IntVal( $oldid ) ; # Use the oldid - else - {# Trying to get the current article revision through this weird stunt - $tid = $this->mTitle->getArticleID(); - $tns = $this->mTitle->getNamespace(); - $sql = "SELECT page_latest FROM page WHERE page_id={$tid} AND page_namespace={$tns}" ; - $res = wfQuery( $sql, DB_READ ); - if( $s = wfFetchObject( $res ) ) - $oid = $s->page_latest ; - else $oid = "" ; # Something's wrong, like the article has been deleted in the last 10 ns - } - if ( $oid != "" ) { - $oid = "&revision={$oid}" ; - $content_actions['validate'] = array( - 'class' => ($action == 'validate') ? 'selected' : false, - 'text' => wfMsg('val_tab'), - 'href' => $this->mTitle->getLocalUrl( "action=validate{$oid}" ) - ); + if ( $oldid ) $oid = IntVal( $oldid ) ; # Use the oldid + else + {# Trying to get the current article revision through this weird stunt + $tid = $this->mTitle->getArticleID(); + $tns = $this->mTitle->getNamespace(); + $sql = "SELECT page_latest FROM page WHERE page_id={$tid} AND page_namespace={$tns}" ; + $res = wfQuery( $sql, DB_READ ); + if( $s = wfFetchObject( $res ) ) + $oid = $s->page_latest ; + else $oid = "" ; # Something's wrong, like the article has been deleted in the last 10 ns + } + if ( $oid != "" ) { + $oid = "&revision={$oid}" ; + $content_actions['validate'] = array( + 'class' => ($action == 'validate') ? 'selected' : false, + 'text' => wfMsg('val_tab'), + 'href' => $this->mTitle->getLocalUrl( "action=validate{$oid}" ) + ); } } } diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index d0a21010fe..3030f281c9 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -681,6 +681,48 @@ class Validation { return $r ; } + # This functions adds a topic to the database + function addTopic ( $topic , $limit ) { + $a = 1 ; + while ( isset ( $this->topicList[$a] ) ) $a++ ; + $sql = "INSERT INTO validate (val_user,val_page,val_revision,val_type,val_value,val_comment) VALUES (" ; + $sql .= "'0','0','0','{$a}','{$limit}','" ; + $sql .= Database::strencode ( $topic ) . "')" ; + $res = wfQuery( $sql, DB_WRITE ); + $x->val_user = $x->val_page = $x->val_revision = 0 ; + $x->val_type = $a ; + $x->val_value = $limit ; + $x->val_comment = $topic ; + $this->topicList[$a] = $x ; + ksort ( $this->topicList ) ; + } + + # This functions adds a topic to the database + function deleteTopic ( $id ) { + $sql = "DELETE FROM validate WHERE val_type='{$id}'" ; + $res = wfQuery( $sql, DB_WRITE ); + unset ( $this->topicList[$id] ) ; + } + + # This function returns a link text to the page validation statistics + function link2statistics ( &$article ) { + $ret = wfMsg ( 'val_rev_stats_link' ) ; + $nt = $article->getTitle() ; + $ret = str_replace ( "$1" , $nt->getPrefixedText() , $ret ) ; + +# $t = Title::newFromText ( "Special:Validate" ) ; +# $url = $t->getLocalURL ( "mode=list&id=" . $article->getID() ) ; + $url = $nt->getLocalURL ( "action=validate&mode=list" ) ; + $ret = str_replace ( "$2" , $url , $ret ) ; + + return $ret ; + } + + + + # HTML generation functions from this point on + + # Generates the page from the validation tab function validatePageForm ( &$article , $revision ) { global $wgOut, $wgRequest ; @@ -717,32 +759,10 @@ class Validation { $ret .= $this->getRevisionForm ( $article , $x , $y , $x == $revision ) ; $ret .= "
\n" ; } + $ret .= $this->link2statistics ( $article ) ; return $ret ; } - # This functions adds a topic to the database - function addTopic ( $topic , $limit ) { - $a = 1 ; - while ( isset ( $this->topicList[$a] ) ) $a++ ; - $sql = "INSERT INTO validate (val_user,val_page,val_revision,val_type,val_value,val_comment) VALUES (" ; - $sql .= "'0','0','0','{$a}','{$limit}','" ; - $sql .= Database::strencode ( $topic ) . "')" ; - $res = wfQuery( $sql, DB_WRITE ); - $x->val_user = $x->val_page = $x->val_revision = 0 ; - $x->val_type = $a ; - $x->val_value = $limit ; - $x->val_comment = $topic ; - $this->topicList[$a] = $x ; - ksort ( $this->topicList ) ; - } - - # This functions adds a topic to the database - function deleteTopic ( $id ) { - $sql = "DELETE FROM validate WHERE val_type='{$id}'" ; - $res = wfQuery( $sql, DB_WRITE ); - unset ( $this->topicList[$id] ) ; - } - # This function performs the "management" mode on Special:Validate function manageTopics () { global $wgRequest ; @@ -787,6 +807,48 @@ class Validation { $r .= "\n" ; return $r ; } + + function showList ( &$article ) { + $this->topicList = $this->getTopicList() ; + + # Collecting statistic data + $id = $article->getID() ; + $sql = "SELECT * FROM validate WHERE val_page='{$id}'" ; + $res = wfQuery( $sql, DB_READ ); + $data = array () ; + while( $x = wfFetchObject( $res ) ) { + if ( !isset ( $data[$x->val_revision] ) ) + $data[$x->val_revision] = array () ; + if ( !isset ( $data[$x->val_revision][$x->val_type] ) ) { + $data[$x->val_revision][$x->val_type]->count = 0 ; + $data[$x->val_revision][$x->val_type]->sum = 0 ; + } + $data[$x->val_revision][$x->val_type]->count++ ; + $data[$x->val_revision][$x->val_type]->sum += $x->val_value ; + } + + $ret = "" ; + $ret .= "\n" ; + $ret .= "" ; + foreach ( $this->topicList AS $x => $y ) + $ret .= "" ; + $ret .= "\n" ; + foreach ( $data AS $revision => $y ) { + $url = $this->getVersionLink ( $article , $revision , $revision ) ; + $ret .= "" ; + foreach ( $this->topicList AS $topicID => $dummy ) { + if ( isset ( $y[$topicID] ) ) { + $z = $y[$topicID] ; + if ( $z->count == 0 ) $a = 0 ; + else $a = $z->sum / $z->count ; + $ret .= sprintf ( "" , $a , $z->count ) ; + } else $ret .= "\n" ; + } + $ret .= "
Revision{$y->val_comment}
{$url}%1.1f (%d)" ; + } + $ret .= "
\n" ; + return $ret ; + } } @@ -801,6 +863,14 @@ function wfSpecialValidate( $page = '' ) { return; } +/* + # Can do? + if ( ! $wgUser->isAllowed('change_validation') ) { + $wgOut->sysopRequired(); + return; + } +*/ + $mode = $wgRequest->getVal ( "mode" ) ; $skin = $wgUser->getSkin() ; @@ -808,14 +878,17 @@ function wfSpecialValidate( $page = '' ) { if ( $mode == "manage" ) { $v = new Validation ; $html = $v->manageTopics () ; +# } else if ( $mode == "list" ) { +# $v = new Validation ; +# $html = $v->showList ( $wgRequest->getVal ( "id" ) ) ; } else { - $t = Title::newFromText ( "Special:Validate" ) ; - $url = $t->getLocalURL ( "mode=manage" ) ; $html = "$mode" ; $html .= "\n" ; } diff --git a/languages/Language.php b/languages/Language.php index 56650ec458..0f0cae0741 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1464,7 +1464,8 @@ Type the name of the user in the box and press the button to make the user an ad 'val_add' => 'Add', 'val_del' => 'Delete', 'val_warning' => 'Never, ever, change something here without explicit community consensus!', -'val_ref_for' => 'Revisions for ', +'val_rev_for' => 'Revisions for ', +'val_rev_stats_link' => 'See the validation statistics for "$1" here', 'val_iamsure' => 'Check this box if you really mean it!', 'val_clear_old' => 'Clear my older validation data', 'val_merge_old' => 'Use my previous assessment where selected \'No opinion\'', @@ -1485,7 +1486,7 @@ merging will fill in the other options with your previous settings.', 'val_version_of' => "Version of $1" , 'val_table_header' => "Class$1Opinion$1Comment\n", 'val_stat_link_text' => 'Validation statistics for this article', -'val_view_version' => 'View this version', +'val_view_version' => 'View this revision', 'val_validate_version' => 'Validate this version', 'val_user_validations' => 'This user has validated $1 pages.', 'val_no_anon_validation' => 'You have to be logged in to validate an article.', -- 2.20.1