* Parser can now know that it is parsing an interface message
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sat, 29 Apr 2006 13:15:19 +0000 (13:15 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sat, 29 Apr 2006 13:15:19 +0000 (13:15 +0000)
* (bug 4737) MediaWiki:Viewcount supports {{PLURAL}} now

RELEASE-NOTES
includes/GlobalFunctions.php
includes/OutputPage.php
includes/Parser.php
includes/Skin.php
includes/SkinTemplate.php
includes/SpecialUserlogout.php
languages/Messages.php
languages/MessagesFi.php

index 6497f62..53ab7ee 100644 (file)
@@ -138,6 +138,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 5741) Introduce {{NUMBEROFUSERS}} magic word
 * (bug 93) <nowiki> tags and tildes in templates
 * The returnto parameter is now actually used by SpecialUserlogin.php
+* Parser can now know that it is parsing an interface message
+* (bug 4737) MediaWiki:Viewcount supports {{PLURAL}} now
 
 == Compatibility ==
 
index 97f9638..53a7bdb 100644 (file)
@@ -564,16 +564,16 @@ function wfMsgExt( $key, $options ) {
                $options = array($options);
        }
 
-       $string = wfMsgGetKey( $key, true );
+       $string = wfMsgGetKey( $key, true, false, false );
 
        if( !in_array('replaceafter', $options) ) {
                $string = wfMsgReplaceArgs( $string, $args );
        }
 
        if( in_array('parse', $options) ) {
-               $string = $wgOut->parse( $string, true );
+               $string = $wgOut->parse( $string, true, true );
        } elseif ( in_array('parseinline', $options) ) {
-               $string = $wgOut->parse( $string, true );
+               $string = $wgOut->parse( $string, true, true );
                if( preg_match( "~^<p>(.*)\n?</p>$~", $string, $m = null ) ) {
                        $string = $m[1];
                }
index d6e653a..3062e1f 100644 (file)
@@ -352,12 +352,14 @@ class OutputPage {
        }
 
        /**
-        * Parse wikitext and return the HTML. This is for special pages that add the text later
+        * Parse wikitext and return the HTML.
         */
-       function parse( $text, $linestart = true ) {
+       function parse( $text, $linestart = true, $interface = false ) {
                global $wgParser, $wgTitle;
+               if ( $interface) { $this->mParserOptions->setInterfaceMessage(true); }
                $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions,
                        $linestart, true, $this->mRevisionId );
+               if ( $interface) { $this->mParserOptions->setInterfaceMessage(false); }
                return $parserOutput->getText();
        }
 
index fcbb603..83ee8ec 100644 (file)
@@ -2472,7 +2472,7 @@ class Parser
         * @private
         */
        function braceSubstitution( $piece ) {
-               global $wgContLang, $wgAllowDisplayTitle, $action;
+               global $wgContLang, $wgLang, $wgAllowDisplayTitle, $action;
                $fname = 'Parser::braceSubstitution';
                wfProfileIn( $fname );
 
@@ -2624,11 +2624,12 @@ class Parser
                        }
                }
 
+               $lang = $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang;
                # GRAMMAR
                if ( !$found && $argc == 1 ) {
                        $mwGrammar =& MagicWord::get( MAG_GRAMMAR );
                        if ( $mwGrammar->matchStartAndRemove( $part1 ) ) {
-                               $text = $linestart . $wgContLang->convertGrammar( $args[0], $part1 );
+                               $text = $linestart . $lang->convertGrammar( $args[0], $part1 );
                                $found = true;
                        }
                }
@@ -2638,7 +2639,7 @@ class Parser
                        $mwPluralForm =& MagicWord::get( MAG_PLURAL );
                        if ( $mwPluralForm->matchStartAndRemove( $part1 ) ) {
                                if ($argc==2) {$args[2]=$args[1];}
-                               $text = $linestart . $wgContLang->convertPlural( $part1, $args[0], $args[1], $args[2]);
+                               $text = $linestart . $lang->convertPlural( $part1, $args[0], $args[1], $args[2]);
                                $found = true;
                        }
                }
@@ -4154,7 +4155,8 @@ class ParserOptions
        var $mEditSection;               # Create "edit section" links
        var $mNumberHeadings;            # Automatically number headings
        var $mAllowSpecialInclusion;     # Allow inclusion of special pages
-       var $mTidy;                      # Ask for tidy cleanup
+       var $mTidy;                      # Ask for tidy cleanup
+       var $mInterfaceMessage;          # Which lang to call for PLURAL and GRAMMAR
 
        function getUseTeX()                        { return $this->mUseTeX; }
        function getUseDynamicDates()               { return $this->mUseDynamicDates; }
@@ -4166,7 +4168,8 @@ class ParserOptions
        function getEditSection()                   { return $this->mEditSection; }
        function getNumberHeadings()                { return $this->mNumberHeadings; }
        function getAllowSpecialInclusion()         { return $this->mAllowSpecialInclusion; }
-       function getTidy()                          { return $this->mTidy; }
+       function getTidy()                          { return $this->mTidy; }
+       function getInterfaceMessage()              { return $this->mInterfaceMessage; }
 
        function setUseTeX( $x )                    { return wfSetVar( $this->mUseTeX, $x ); }
        function setUseDynamicDates( $x )           { return wfSetVar( $this->mUseDynamicDates, $x ); }
@@ -4177,8 +4180,9 @@ class ParserOptions
        function setEditSection( $x )               { return wfSetVar( $this->mEditSection, $x ); }
        function setNumberHeadings( $x )            { return wfSetVar( $this->mNumberHeadings, $x ); }
        function setAllowSpecialInclusion( $x )     { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
-       function setTidy( $x )                      { return wfSetVar( $this->mTidy, $x); }
+       function setTidy( $x )                      { return wfSetVar( $this->mTidy, $x); }
        function setSkin( &$x ) { $this->mSkin =& $x; }
+       function setInterfaceMessage( $x )          { return wfSetVar( $this->mInterfaceMessage, $x); }
 
        function ParserOptions() {
                global $wgUser;
@@ -4221,6 +4225,7 @@ class ParserOptions
                $this->mNumberHeadings = $user->getOption( 'numberheadings' );
                $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
                $this->mTidy = false;
+               $this->mInterfaceMessage = false;
                wfProfileOut( $fname );
        }
 }
index 6bc2935..0e60b9f 100644 (file)
@@ -893,7 +893,7 @@ END;
                if ( !$wgDisableCounters ) {
                        $count = $wgLang->formatNum( $wgArticle->getCount() );
                        if ( $count ) {
-                               $s = wfMsg( 'viewcount', $count );
+                               $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
                        }
                }
 
index 25c4319..24f0d2a 100644 (file)
@@ -308,7 +308,7 @@ class SkinTemplate extends Skin {
                        if ( !$wgDisableCounters ) {
                                $viewcount = $wgLang->formatNum( $wgArticle->getCount() );
                                if ( $viewcount ) {
-                                       $tpl->set('viewcount', wfMsg( "viewcount", $viewcount ));
+                                       $tpl->set('viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) );
                                } else {
                                        $tpl->set('viewcount', false);
                                }
index 4b89278..f3fcbc4 100644 (file)
@@ -18,7 +18,7 @@ function wfSpecialUserlogout() {
                wfRunHooks('UserLogoutComplete', array(&$wgUser));
 
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
-               $wgOut->addWikiText( wfMsg( 'logouttext' ) );
+               $wgOut->addHTML( wfMsgExt( 'logouttext', array( 'parse' ) ) );
                $wgOut->returnToMain();
 
        }
index eddfbf7..0c44f21 100644 (file)
@@ -211,7 +211,7 @@ parent class in order maintain consistency across languages.
 'redirectedfrom' => '(Redirected from $1)',
 'redirectpagesub' => 'Redirect page',
 'lastmodified' => 'This page was last modified $1.',
-'viewcount'            => 'This page has been accessed $1 times.',
+'viewcount'            => 'This page has been accessed {{plural:$1|one time|$1 times}}.',
 'copyright'    => 'Content is available under $1.',
 'protectedpage' => 'Protected page',
 'administrators' => 'Project:Administrators',
index 95bc7f5..3642a02 100644 (file)
 'redirectedfrom'      => 'Uudelleenohjattu sivulta $1',
 'redirectpagesub'     => 'Uudelleenohjaussivu',
 'lastmodified'        => 'Sivua on viimeksi muutettu  $1.',
-'viewcount'           => 'Tämä sivu on näytetty $1 kertaa.',
+'viewcount'           => 'Tämä sivu on näytetty {{PLURAL:$1|yhden kerran|$1 kertaa}}.',
 'copyright'           => 'Sisältö on käytettävissä lisenssillä $1.',
 'poweredby'           => '{{GRAMMAR:genitive|{{SITENAME}}}} tarjoaa [http://www.mediawiki.org/ MediaWiki], avoimen lähdekoodin ohjelmisto.',
 'printsubtitle'       => '(Lähde: {{SERVER}})',