From 26b770cf32eb65f0116f1bef732dc5e31cd18f60 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Sat, 29 Oct 2005 17:08:01 +0000 Subject: [PATCH] Fixes requested by Alfio Puglisi --- includes/DefaultSettings.php | 1 + includes/SpecialValidate.php | 59 ++++++++++++++++++++++++++++-------- languages/Language.php | 3 ++ 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e395f987bc..a59903637d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -599,6 +599,7 @@ $wgDisableLangConversion = false; # Use article validation feature; turned off by default $wgUseValidation = false; +$wgValidationMaxTopics = 25; # Maximum number of topics $wgValidationForAnons = true ; # Whether to use zhdaemon to perform Chinese text processing diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index f58bf5e4a1..061307175c 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -454,6 +454,7 @@ class Validation { $ret = ""; $this->page_id = $article->getID(); $this->topicList = $this->getTopicList(); + if ( $this->getNoTopicsWarning() ) return "" ; $this->voteCache = $this->getVoteList( $article->getID() ); # Check for POST data @@ -500,16 +501,21 @@ class Validation { # This function performs the "management" mode on Special:Validate function manageTopics() { - global $wgRequest; + global $wgRequest, $wgValidationMaxTopics; $this->topicList = $this->getTopicList(); - $iamsure = true ; # Sure by default # $wgRequest->getVal( "iamsure", "0" ) == 1; + $r = "" ; # Return value + $iamsure = true ; # Sure by default, see checkbox below # $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 ); + if ( count ( $this->topicList ) >= $wgValidationMaxTopics ) { # Catching this in case someone tries a manually edited URL... + $ret .= "

" . wfMsg ( 'val_max_topics' , $wgValidationMaxTopics ) . "

" ; + } else { + $new_topic = $wgRequest->getVal( "m_topic" ); + $new_limit = $wgRequest->getVal( "m_limit" ); + if( $new_topic != "" && $new_limit > 1 ) { + $this->addTopic( $new_topic, $new_limit ); + } } } @@ -521,7 +527,7 @@ class Validation { } # FIXME: Wikitext this - $r = "

" . $this->getParsedWiki( wfMsg( 'val_warning' ) ) . "

\n"; + $r .= "

" . $this->getParsedWiki( wfMsg( 'val_warning' ) ) . "

\n"; $r .= "
\n"; $r .= "\n"; $r .= "" . wfMsg( 'val_list_header' ) . "\n"; @@ -533,14 +539,29 @@ class Validation { $r .= "\n"; $r .= "\n"; } - $r .= "\n"; - $r .= "\n"; - $r .= '' . "\n"; - $r .= '' . "\n"; - $r .= '' . "\n"; - $r .= "
1 ..
\n"; + + # Add topic, or too-many-topics warning + if ( count ( $this->topicList ) >= $wgValidationMaxTopics ) { + $r .= "" ; + $r .= wfMsg ( 'val_max_topics' , $wgValidationMaxTopics ) ; + $r .= "" ; + } else { + $r .= "\n"; + $r .= "\n"; + $r .= '' . "\n"; + $r .= '1 .. ' . "\n"; + $r .= '' ; + $r .= '' ; + $r .= '' . "\n"; + $r .= "" ; + } + + $r .= "\n"; + +# This is fot the checkbox "I am sure" for actions, which was found to be unituitive # $r .= '

'; # $r .= '

\n"; + $r .= "
\n"; return $r; } @@ -554,6 +575,7 @@ class Validation { global $wgOut, $wgUser; $this->page_id = $article->getID(); $this->topicList = $this->getTopicList(); + if ( $this->getNoTopicsWarning() ) return "" ; $sk = $wgUser->getSkin(); $title = $article->getTitle(); @@ -626,6 +648,7 @@ class Validation { global $wgOut, $wgUser , $wgRequest; $this->page_id = $article->getID(); $this->topicList = $this->getTopicList(); + if ( $this->getNoTopicsWarning() ) return "" ; $title = $article->getTitle(); $wgOut->setPageTitle( wfMsg( 'val_validation_of', $title->getPrefixedText() ) ); @@ -740,6 +763,7 @@ class Validation { function showUserStats( $user ) { global $wgOut, $wgUser, $wgRequest; $this->topicList = $this->getTopicList(); + if ( $this->getNoTopicsWarning() ) return "" ; $sk = $wgUser->getSkin(); $offset = $wgRequest->getVal( "offset" , 0 ); @@ -807,6 +831,15 @@ class Validation { return $ret; } + + function getNoTopicsWarning () { + global $wgOut ; + if ( !isset ( $this->topicList ) ) # Just making sure, shouldn't be necessary... + $this->topicList = $this->getTopicList(); + if ( count ( $this->topicList ) > 0 ) return false ; # Topics set, all right + $wgOut->errorpage( "val_no_topics_defined", "val_no_topics_defined_text" ); + return true ; + } } diff --git a/languages/Language.php b/languages/Language.php index 295f6638b6..74e24b5415 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1560,6 +1560,9 @@ Type the name of the user in the box and press the button to make the user an ad 'val_validated' => 'Validation done.', 'val_article_lists' => 'List of validated articles', 'val_page_validation_statistics' => 'Page validation statistics for $1', +'val_max_topics' => 'Maximum number of $1 topics reached', +'val_no_topics_defined' => 'No topics defined', +'val_no_topics_defined_text' => 'You have no topics defined which can be rated. Go to [[Special:Validate]], and have an administrator run the "Manage" function to add at least one topic and point range.', # Move page # -- 2.20.1