simple fixes for DISPLAYTITLE
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Wed, 12 Apr 2006 10:59:21 +0000 (10:59 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Wed, 12 Apr 2006 10:59:21 +0000 (10:59 +0000)
includes/Parser.php

index 7a2c92c..1cdab61 100644 (file)
@@ -2441,7 +2441,7 @@ class Parser
         * @access private
         */
        function braceSubstitution( $piece ) {
-               global $wgContLang, $wgAllowDisplayTitle;
+               global $wgContLang, $wgAllowDisplayTitle, $action;
                $fname = 'Parser::braceSubstitution';
                wfProfileIn( $fname );
 
@@ -2613,27 +2613,30 @@ class Parser
                }
                
                # DISPLAYTITLE
-               if ( !$found && $argc == 1 && $wgAllowDisplayTitle ) {
-                       global $wgOut;
-                       
-                       # Only the first one counts...
-                       if ( $wgOut->mPageLinkTitle == "" ) {
-                               $param = $args[0];                      
-                               $parserOptions = new ParserOptions;
-                               $local_parser = new Parser ();
-                               $t2 = $local_parser->parse ( $param, $this->mTitle, $parserOptions, false );
-                               $wgOut->mPageLinkTitle = $wgOut->getPageTitle();
-                               $wgOut->mPagetitle = $t2->GetText();
-
-                               # Add subtitle
-                               $t = $this->mTitle->getPrefixedText();
-                               $st = trim ( $wgOut->getSubtitle () );
-                               if ( $st != "" ) $st .= " ";
-                               $st .= str_replace ( "$1", $t, wfMsg('displaytitle') );
-                               $wgOut->setSubtitle ( $st );
+               if ( !$found && $argc == 1 && $wgAllowDisplayTitle && $action == "view" ) {
+                       $mwDT =& MagicWord::get( MAG_DISPLAYTITLE );
+                       if ( $mwDT->matchStartAndRemove( $part1 ) ) {
+                               global $wgOut;
+                               
+                               # Only the first one counts...
+                               if ( $wgOut->mPageLinkTitle == "" ) {
+                                       $param = $args[0];                      
+                                       $parserOptions = new ParserOptions;
+                                       $local_parser = new Parser ();
+                                       $t2 = $local_parser->parse ( $param, $this->mTitle, $parserOptions, false );
+                                       $wgOut->mPageLinkTitle = $wgOut->getPageTitle();
+                                       $wgOut->mPagetitle = $t2->GetText();
+       
+                                       # Add subtitle
+                                       $t = $this->mTitle->getPrefixedText();
+                                       $st = trim ( $wgOut->getSubtitle () );
+                                       if ( $st != "" ) $st .= " ";
+                                       $st .= wfMsg('displaytitle', $t);
+                                       $wgOut->setSubtitle ( $st );
+                               }
+                               $text = "" ;
+                               $found = true ;
                        }
-                       $text = "" ;
-                       $found = true ;
                }               
 
                # Extensions