From 789c5d8e7dfab442af8a6c463ff77bd9def0e452 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Sun, 25 Jul 2004 16:05:36 +0000 Subject: [PATCH] Article validation code --- includes/SpecialValidate.php | 26 ++++++++++++++++++++++---- languages/Language.php | 5 ++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index 4e9b0b4d47..5f2300efaf 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -199,13 +199,14 @@ class Validation if ( count ( $d ) ) $d = array_shift ( $d ) ; else $d = array () ; krsort ( $d ) ; - $html .= "\n" ; - $html .= "" ; + $html .= "
Version
\n" ; + $html .= "" ; foreach ( $validationtypes AS $idx => $title ) { $title = explode ( "|" , $title ) ; $html .= "" ; } + $html .= "" ; $html .= "\n" ; foreach ( $d AS $version => $data ) { @@ -217,35 +218,52 @@ class Validation $vmax = array() ; $vcur = array() ; + $users = array() ; foreach ( $data AS $type => $x2 ) { if ( !isset ( $vcur[$type] ) ) $vcur[$type] = 0 ; if ( !isset ( $vmax[$type] ) ) $vmax[$type] = 0 ; + if ( !isset ( $users[$type] ) ) $users[$type] = 0 ; foreach ( $x2 AS $user => $x ) { $vcur[$type] += $x->val_value ; $temp = explode ( "|" , $validationtypes[$type]) ; $vmax[$type] += $temp[3] - 1 ; + $users[$type] += 1 ; } } + $total_count = 0 ; + $total_percent = 0 ; foreach ( $validationtypes AS $idx => $title ) { - $html .= "" ; } + if ( $total_count > 0 ) + { + $total = $total_percent / $total_count ; + $total = "{$total} %" ; + } + else $total = "" ; + $html .= "" ; + $html .= "" ; } $html .= "
" . wfMsg('val_version') . "{$title[0]}" . wfMsg('val_total') . "
" ; + $html .= "" ; if ( isset ( $vcur[$idx] ) ) { $average = 100 * $vcur[$idx] / $vmax[$idx] ; - $h = wfMsg ( "val_percent" ) ; + $total_count += 1 ; + $total_percent += $average ; + if ( $users[$idx] > 1 ) $h = wfMsg ( "val_percent" ) ; + else $h = wfMsg ( "val_percent_single" ) ; $h = str_replace ( "$1" , $average , $h ) ; $h = str_replace ( "$2" , $vcur[$idx] , $h ) ; $h = str_replace ( "$3" , $vmax[$idx] , $h ) ; + $h = str_replace ( "$4" , $users[$idx] , $h ) ; $html .= $h ; } else $html .= "(" . wfMsg ( "val_noop" ) . ")" ; $html .= "{$total}
\n" ; diff --git a/languages/Language.php b/languages/Language.php index e1ef1b2309..d0258f30f8 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1260,7 +1260,10 @@ Type the name of the user in the box and press the button to make the user an ad # Validation 'val_clear_old' => 'Clear my other validation data for this article', 'val_noop' => 'No opinion', -'val_percent' => '$1% ($2 of $3 points)', +'val_percent' => '$1%
($2 of $3 points by $4 users)', +'val_percent_single' => '$1%
($2 of $3 points by one user)', +'val_total' => 'Total', +'val_version' => 'Version', 'val_tab' => 'Validate', 'val_this_version' => "

This version

\n", 'val_version_of' => "

Version of $1

\n" , -- 2.20.1