+
+ # Clear all others
+ if( $wgRequest->getCheck( 'clear_other' ) ) {
+ $sql = "DELETE FROM validate WHERE val_title='" . wfStrencode( $article_title ) .
+ "' AND val_timestamp<>'" . wfStrencode( $oldtime ) . "' AND val_user='";
+ $sql .= wfStrencode( $wgUser->getID() ) . "'";
+ wfQuery( $sql, DB_WRITE );
+ $val2 = $val[$oldtime]; # Only version left
+ $val = array(); # So clear others
+ $val[$oldtime] = $val2;
+ }
+
+ # Delete old "votes" for this version
+ $sql = "DELETE FROM validate WHERE val_title='" . wfStrencode( $article_title ) .
+ "' AND val_timestamp='" . wfStrencode( $oldtime ) . "' AND val_user='";
+ $sql .= wfStrencode( $wgUser->getID() ) . "'";
+ wfQuery( $sql, DB_WRITE );
+
+ # Incorporate changes
+ for( $idx = 0; $idx < count( $validationtypes ); $idx++ ) {
+ $comment = $postcomment[$idx] ;
+ $rad = $postrad[$idx] ;
+ if ( !isset( $val[$oldtime][$idx] ) ) {
+ $val[$oldtime][$idx] = "";
+ }
+ $val[$oldtime][$idx]->val_value = $rad;
+ $val[$oldtime][$idx]->val_comment = $comment;
+ if( $rad != -1 ) {
+ # Store it in the database
+ $sql = "INSERT INTO validate (val_user,val_title,val_timestamp,val_type,val_value,val_comment) " .
+ "VALUES ( '" . wfStrencode( $wgUser->getID() ) . "','" .
+ wfStrencode( $article_title ) . "','" .
+ wfStrencode( $oldtime ) . "','" .
+ wfStrencode( $idx ) . "','" .
+ wfStrencode( $rad ) . "','" .
+ wfStrencode( $comment ) . "')";
+ wfQuery( $sql, DB_WRITE );
+ }
+ }
+ $wgArticle->showArticle( "Juhuu", wfMsg( 'val_validated' ) );
+ return; # Show article instead of validation page
+ }
+
+ # Generating HTML
+ $html = "";
+
+ $skin = $wgUser->getSkin();
+ $staturl = $skin->makeSpecialURL( "validate" , "mode=stat_page&article_title=" . urlencode( $article_title ) );
+ $listurl = $skin->makeSpecialURL( "validate" , "mode=list_page" );
+ $html .= "<a href=\"" . htmlspecialchars( $staturl ) . "\">" . wfMsg('val_stat_link_text') . "</a> \n";
+ $html .= "<a href=\"" . htmlspecialchars( $listurl ) . "\">" . wfMsg('val_article_lists') . "</a><br />\n";
+ $html .= "<small>" . wfMsg('val_form_note') . "</small><br />\n";
+
+ # Generating data tables
+ $tabsep = "<td width='0' style='border-left:2px solid black;'></td>";
+ $topstyle = "style='border-top:2px solid black'";
+ foreach( $val as $time => $stuff ) {
+ $tablestyle = "cellspacing='0' cellpadding='2'";
+ if ( $article_time == $time ) {
+ $tablestyle .=" style='border: 2px solid red'";
+ }
+ $html .= "<h2>" . wfMsg( 'val_version_of', gmdate( "F d, Y H:i:s", wfTimestamp2Unix( $time ) ) );
+ $this->find_this_version ( $article_title , $time , $table_id , $table_name );
+ if( $table_name == "cur" ) {
+ $html .= " (" . wfMsg( 'val_this_is_current_version' ) . ")";
+ }
+ $html .= "</h2>\n" ;
+ $html .= "<form method='post'>\n" ;
+ $html .= "<input type='hidden' name='oldtime' value=\"" . htmlspecialchars( $time ) . "\" />" ;
+ $html .= "<table {$tablestyle}>\n" ;
+ $html .= wfMsg( 'val_table_header', $tabsep );
+ for( $idx = 0; $idx < count( $validationtypes ); $idx++ ) {
+ $x = explode( "|" , $validationtypes[$idx] , 4 );
+ if( isset ( $stuff[$idx] ) ) {
+ $choice = $stuff[$idx]->val_value;
+ } else {
+ $choice = -1;
+ }
+ if( isset( $stuff[$idx] ) ) {
+ $comment = $stuff[$idx]->val_comment;
+ } else {
+ $comment = "";
+ }
+ $html .= "<tr><th align='left'>{$x[0]}</th>{$tabsep}<td align='right'>{$x[1]}</td>"
+ . "<td align='center'><span style='white-space: nowrap;'>" ;
+ for( $cnt = 0 ; $cnt < $x[3] ; $cnt++) {
+ $html .= "<input type='radio' name='rad{$idx}' value='{$cnt}'";
+ if ( $choice == $cnt ) $html .= " checked='checked'";
+ $html .= " /> ";
+ }
+ $html .= "</span></td><td>{$x[2]}</td>";
+ $html .= "<td><input type='radio' name='rad{$idx}' value='-1'";
+ if( $choice == -1 ) {
+ $html .= " checked='checked'";
+ }
+ $html .= " /> " . wfMsg ( "val_noop" ) . "</td>{$tabsep}";
+ $html .= "<td><input type='text' name='comment{$idx}' value=\"" . htmlspecialchars( $comment ) . "\" /></td>";
+ $html .= "</tr>\n";
+ }
+ $html .= "<tr><td {$topstyle} colspan='2'>";
+
+ # link to version
+ $title = Title::newFromDBkey( $article_title );
+ if ( $table_name == "cur" ) {
+ $link_version = $title->getLocalURL( "" );
+ } else {
+ $link_version = $title->getLocalURL( "oldid={$table_id}" );
+ }
+ $link_version = "<a href=\"" . htmlspecialchars( $link_version ) . "\">" . wfMsg ( 'val_view_version' ) . "</a>";
+ $html .= $link_version;
+ $html .= "</td><td {$topstyle} colspan='5'>";
+ $html .= "<input type='checkbox' name='merge_other' value='1' checked='checked' />";
+ $html .= wfMsg( 'val_merge_old' );
+ $html .= "<br /><input type='checkbox' name='clear_other' value='1' checked='checked' />";
+ $html .= wfMsg( 'val_clear_old', $skin->makeKnownLinkObj( $article ) );
+ $html .= "</td><td {$topstyle} align='right' valign='center'><input type='submit' name='doit' value=\"" . htmlspecialchars( wfMsg("ok") ) . "\" /></td>";
+ $html .= "</tr></table></form>\n";