From df9be6ec213b363353fcd8d06589d5fad423263b Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Sat, 31 Jul 2004 21:23:14 +0000 Subject: [PATCH] Article validation code (bug fixes) --- includes/Article.php | 12 ++++++++---- includes/SkinPHPTal.php | 2 +- includes/SpecialValidate.php | 17 +++++++++-------- languages/Language.php | 2 ++ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index c42f349459..c35e3ed056 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1055,11 +1055,15 @@ class Article { function validate () { global $wgOut ; - $v = new Validation ; - $html = $v->validate_form ( $this->mTitle->getDBkey() ) ; - $wgOut->setPagetitle( wfMsg( 'validate' ) . " : " . $this->mTitle->getText() ); + $wgOut->setPagetitle( wfMsg( 'validate' ) . " : " . $this->mTitle->getPrefixedText() ); $wgOut->setRobotpolicy( 'noindex,follow' ); - $wgOut->addHTML( $html ) ; + if ( $this->mTitle->getNamespace() != 0 ) + { + $wgOut->addHTML ( wfMsg ( 'val_validate_article_namespace_only' ) ) ; + return ; + } + $v = new Validation ; + $v->validate_form ( $this->mTitle->getDBkey() ) ; } # Add this page to my watchlist diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index 059afff9f1..3ea009c20f 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -435,7 +435,7 @@ } } - if ( $wgUseValidation && $wgUser->getID() != 0 && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) { + if ( $wgUseValidation && /*$wgUser->getID() != 0 && */ $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) { global $wgArticle ; $article_time = "×tamp=" . $wgArticle->mTimestamp ; $content_actions['validate'] = array('class' => ($action == 'validate') ? 'selected' : false , diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index 0c56b6fb66..e4c191038e 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -61,7 +61,13 @@ class Validation function validate_form ( $article_title = "" ) { global $wgOut, $wgLang, $wgUser; - if ( $wgUser->getID() == 0 ) return ; # Anon + + if ( $wgUser->getID() == 0 ) # Anon + { + $wgOut->addHTML ( wfMsg ( 'val_no_anon_validation' ) . $this->getPageStatistics ( $article_title ) ) ; + return ; + } + $validationtypes = $wgLang->getValidationTypes() ; if ( $article_title == "" ) { @@ -73,7 +79,7 @@ class Validation if ( isset ( $_GET['timestamp'] ) ) $article_time = $_GET['timestamp'] ; else $article_time = "" ; $article = Title::newFromText ( $article_title ) ; - + # Now we get all the "votes" for the different versions of this article for this user $val = $this->get_prev_data ( $wgUser->getID() , $article_title ) ; @@ -225,11 +231,6 @@ class Validation $html .= "

" . wfMsg ( 'preview' ) . "

" ; $wgOut->addHTML ( $html ) ; $wgOut->addWikiText ( $wgArticle->getContent( true ) ) ; - return "" ; - -# $html .= $wgArticle->getContent( true ) ; -# $html .= $wgArticle->view () ; -# return $html ; } function getData ( $user = -1 , $title = "" , $type = -1 ) @@ -252,7 +253,7 @@ class Validation { global $wgLang, $wgUser ; $validationtypes = $wgLang->getValidationTypes() ; - $article_title = $_GET['article_title'] ; + if ( $article_title == "" ) $article_title = $_GET['article_title'] ; $d = $this->getData ( -1 , $article_title , -1 ) ; if ( count ( $d ) ) $d = array_shift ( $d ) ; else $d = array () ; diff --git a/languages/Language.php b/languages/Language.php index 2a8085d896..bf0bfbd2e3 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -1281,6 +1281,8 @@ merging will fill in the other options with your previous settings.', 'val_view_version' => 'View this version', '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.', +'val_validate_article_namespace_only' => 'Only articles can be validated. This page is not in the article namespace.', # Move page # -- 2.20.1