Article validation code (bug fixes)
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Sat, 31 Jul 2004 21:23:14 +0000 (21:23 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Sat, 31 Jul 2004 21:23:14 +0000 (21:23 +0000)
includes/Article.php
includes/SkinPHPTal.php
includes/SpecialValidate.php
languages/Language.php

index c42f349..c35e3ed 100644 (file)
@@ -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
index 059afff..3ea009c 100644 (file)
                                        }
                                }
 
-                               if ( $wgUseValidation && $wgUser->getID() != 0 && $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
+                               if ( $wgUseValidation && /*$wgUser->getID() != 0 && */ $wgTitle->getArticleId() && $wgTitle->getNamespace() == 0 ) {
                                        global $wgArticle ;
                                        $article_time = "&timestamp=" . $wgArticle->mTimestamp ;
                                        $content_actions['validate'] = array('class' => ($action == 'validate') ? 'selected' : false ,
index 0c56b6f..e4c1910 100644 (file)
@@ -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 .= "<h2>" . wfMsg ( 'preview' ) . "</h2>" ;
                $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 () ;
index 2a8085d..bf0bfbd 100644 (file)
@@ -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 <i>not</i> in the article namespace.',
 
 # Move page
 #