From: Magnus Manske Date: Fri, 18 Mar 2005 21:59:13 +0000 (+0000) Subject: validation improvements X-Git-Tag: 1.5.0alpha1~579 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=477401882860a573b89473196e0a38ba58ea7cd7;p=lhc%2Fweb%2Fwiklou.git validation improvements --- diff --git a/includes/SpecialPage.php b/includes/SpecialPage.php index 9b4e2daa49..a77fe96657 100644 --- a/includes/SpecialPage.php +++ b/includes/SpecialPage.php @@ -51,6 +51,10 @@ $wgSpecialPages = array( 'Unusedimages' => new SpecialPage( 'Unusedimages' ) ); +global $wgUseValidation ; +if ( $wgUseValidation ) + $wgSpecialPages['Validate'] = new SpecialPage( 'Validate' ); + global $wgDisableCounters; if( !$wgDisableCounters ) { $wgSpecialPages['Popularpages'] = new SpecialPage( 'Popularpages' ); diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index 3441c306aa..d0a21010fe 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -711,7 +711,7 @@ class Validation { $ret = "" ; $title = $article->getTitle(); $title = $title->getPrefixedText() ; - $wgOut->setPageTitle ( "Revisions for " . $title ) ; + $wgOut->setPageTitle ( wfMsg ( 'val_rev_for' ) . $title ) ; foreach ( $this->voteCache AS $x => $y ) { $ret .= $this->getRevisionForm ( $article , $x , $y , $x == $revision ) ; @@ -719,6 +719,74 @@ class Validation { } 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 ; + $this->topicList = $this->getTopicList() ; + + $iamsure = $wgRequest->getVal ( "iamsure" , "0" ) == 1 ; + + if ( $iamsure && $wgRequest->getVal ( "m_add" , "--" ) != "--" ) { + $new_topic = $wgRequest->getVal ( "m_topic" ) ; + $new_limit = $wgRequest->getVal ( "m_limit" ) ; + if ( $new_topic != "" && $new_limit > 1 ) + $this->addTopic ( $new_topic , $new_limit ) ; + } + + $da = $wgRequest->getArray ( "m_del" ) ; + if ( $iamsure && isset ( $da ) && count ( $da ) > 0 ) { + $id = array_keys ( $da ) ; + $id = array_shift ( $id ) ; + $this->deleteTopic ( $id ) ; + } + + $r = "

" . wfMsg ( 'val_warning' ) . "

\n" ; + $r .= "
\n" ; + $r .= "\n" ; + $r .= "" . wfMsg ( 'val_list_header' ) . "\n" ; + foreach ( $this->topicList AS $x => $y ) { + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + } + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + $r .= "\n" ; + $r .= "
" . $y->val_type . "{$y->val_comment}1 .. {$y->val_value}
\n" ; + $r .= "
\n" ; + $r .= "" . wfMsg ( 'val_iamsure' ) . "\n" ; + $r .= "
\n" ; + return $r ; + } } @@ -726,22 +794,31 @@ class Validation { * constructor */ function wfSpecialValidate( $page = '' ) { - global $wgOut, $wgRequest, $wgUseValidation; + global $wgOut, $wgRequest, $wgUseValidation, $wgUser, $wgContLang; if( !$wgUseValidation ) { $wgOut->errorpage( "nosuchspecialpage", "nospecialpagetext" ); return; } + + $mode = $wgRequest->getVal ( "mode" ) ; + $skin = $wgUser->getSkin() ; + - $mode = $wgRequest->getVal( 'mode', 'form' ); - $v = new Validation; - $html = "" ; - if( $mode == "stat_page" ) { - $html = $v->getPageStatistics(); - } else if( $mode == "list_page" ) { - $html = $v->getArticleList(); + if ( $mode == "manage" ) { + $v = new Validation ; + $html = $v->manageTopics () ; + } else { + $t = Title::newFromText ( "Special:Validate" ) ; + $url = $t->getLocalURL ( "mode=manage" ) ; + $html = "$mode" ; + $html .= "\n" ; } - + $wgOut->addHTML( $html ); } diff --git a/languages/Language.php b/languages/Language.php index 06ab035574..56650ec458 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1460,6 +1460,12 @@ Type the name of the user in the box and press the button to make the user an ad # Validation 'val_yes' => 'Yes', 'val_no' => 'No', +'val_list_header' => '#TopicRangeAction', +'val_add' => 'Add', +'val_del' => 'Delete', +'val_warning' => 'Never, ever, change something here without explicit community consensus!', +'val_ref_for' => 'Revisions for ', +'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\'', 'val_form_note' => 'Hint: Merging your data means that for the article