New DISPLAYTITLE magic template; decativated by default so not to scare Brion
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 11 Apr 2006 10:16:27 +0000 (10:16 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 11 Apr 2006 10:16:27 +0000 (10:16 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/MagicWord.php
includes/OutputPage.php
includes/Parser.php
includes/Skin.php
includes/SkinTemplate.php
languages/Language.php
languages/Messages.php
skins/MonoBook.php

index e4e1dd8..917c93e 100644 (file)
@@ -43,6 +43,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Minor grammatical improvements in English language files
 * Display the anon talk page info message on anon talk pages again
   (moved outside the parser cache)
+* Optional {{DISPLAYTITLE|title with markup}} magic word
+  Deactivated by default, set "$wgAllowDisplayTitle = true" in LocalSettings.php to activate
 
 
 == Compatibility ==
index 351543b..c344207 100644 (file)
@@ -1920,5 +1920,9 @@ $wgUseAjax = false;
  */
 $wgAjaxExportList = array( 'wfSajaxSearch' );
 
+/**
+ * Allow DISPLAYTITLE to change title display
+ */
+$wgAllowDisplayTitle = false ;
 
 ?>
index b48b574..7233af7 100644 (file)
@@ -72,6 +72,7 @@ $magicWords = array(
        'MAG_RAW',
        'MAG_SUBPAGENAME',
        'MAG_SUBPAGENAMEE',
+       'MAG_DISPLAYTITLE',
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
        wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
@@ -105,7 +106,8 @@ $wgVariableIDs = array(
        MAG_CURRENTDOW,
        MAG_REVISIONID,
        MAG_SUBPAGENAME,
-       MAG_SUBPAGENAMEE
+       MAG_SUBPAGENAMEE,
+       MAG_DISPLAYTITLE,
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
        wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
index a772717..ea979a8 100644 (file)
@@ -18,7 +18,7 @@ class OutputPage {
        var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
        var $mSubtitle, $mRedirect, $mStatusCode;
        var $mLastModified, $mETag, $mCategoryLinks;
-       var $mScripts, $mLinkColours;
+       var $mScripts, $mLinkColours, $mPageLinkTitle;
 
        var $mSuppressQuickbar;
        var $mOnloadHandler;
@@ -40,11 +40,11 @@ class OutputPage {
                $this->mHTMLtitle = $this->mPagetitle = $this->mBodytext =
                $this->mRedirect = $this->mLastModified =
                $this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy =
-               $this->mOnloadHandler = '';
+               $this->mOnloadHandler = $this->mPageLinkTitle = '';
                $this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true;
                $this->mSuppressQuickbar = $this->mPrintable = false;
                $this->mLanguageLinks = array();
-               $this->mCategoryLinks = array() ;
+               $this->mCategoryLinks = array();
                $this->mDoNothing = false;
                $this->mContainsOldMagic = $this->mContainsNewMagic = 0;
                $this->mParserOptions = ParserOptions::newFromUser( $temp = NULL );
@@ -54,7 +54,7 @@ class OutputPage {
                $this->mRevisionId = null;
        }
 
-       function addHeader( $name, $val ) { array_push( $this->mHeaders, $name.': '.$val ) ; }
+       function addHeader( $name, $val ) { array_push( $this->mHeaders, $name.': '.$val ); }
        function redirect( $url, $responsecode = '302' ) { $this->mRedirect = $url; $this->mRedirectCode = $responsecode; }
        function setStatusCode( $statusCode ) { $this->mStatusCode = $statusCode; }
 
@@ -821,9 +821,9 @@ class OutputPage {
 
                if( is_string( $source ) ) {
                        if( strcmp( $source, '' ) == 0 ) {
-                               global $wgTitle ;
+                               global $wgTitle;
                                if ( $wgTitle->getNamespace() == NS_MEDIAWIKI ) {
-                                       $source = wfMsgWeirdKey ( $wgTitle->getText() ) ;
+                                       $source = wfMsgWeirdKey ( $wgTitle->getText() );
                                } else {
                                        $source = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
                                }
index 3eaf38b..53f55d0 100644 (file)
@@ -2441,7 +2441,7 @@ class Parser
         * @access private
         */
        function braceSubstitution( $piece ) {
-               global $wgContLang;
+               global $wgContLang, $wgAllowDisplayTitle;
                $fname = 'Parser::braceSubstitution';
                wfProfileIn( $fname );
 
@@ -2611,6 +2611,30 @@ class Parser
                                $found = true;
                        }
                }
+               
+               # 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 );
+                       }
+                       $text = "" ;
+                       $found = true ;
+               }               
 
                # Extensions
                if ( !$found ) {
index 043ae38..5b2e56c 100644 (file)
@@ -686,7 +686,6 @@ END;
 
        function pageTitle() {
                global $wgOut;
-
                $s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
                return $s;
        }
index 297a99c..3c85c6d 100644 (file)
@@ -187,6 +187,7 @@ class SkinTemplate extends Skin {
                wfProfileIn( "$fname-stuff2" );
                $tpl->set( 'title', $wgOut->getPageTitle() );
                $tpl->set( 'pagetitle', $wgOut->getHTMLTitle() );
+               $tpl->set( 'displaytitle', $wgOut->mPageLinkTitle );
 
                $tpl->setRef( "thispage", $this->thispage );
                $subpagestr = $this->subPageSubtitle();
index 465de23..5256503 100644 (file)
@@ -265,6 +265,7 @@ $wgLanguageNamesEn =& $wgLanguageNames;
        MAG_LC                   => array( 0,    'LC:'                    ),
        MAG_UC                   => array( 0,    'UC:'                    ),
        MAG_RAW                  => array( 0,    'RAW:'                   ),
+       MAG_DISPLAYTITLE         => array( 1,    'DISPLAYTITLE'           ),
 );
 
 if (!$wgCachedMessageArrays) {
index 27c2674..5cbd732 100644 (file)
@@ -2000,6 +2000,9 @@ Please confirm that really want to recreate this article.',
 'articletitles' => "Articles starting with ''$1''",
 'hideresults' => 'Hide results',
 
+# DISPLAYTITLE
+'displaytitle' => '(Link to this page as [[$1]])',
+
 );
 
 
index 7939654..feef467 100644 (file)
@@ -93,7 +93,7 @@ class MonoBookTemplate extends QuickTemplate {
        <div id="content">
                <a name="top" id="top"></a>
                <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
-               <h1 class="firstHeading"><?php $this->text('title') ?></h1>
+               <h1 class="firstHeading"><?php $this->data['displaytitle']!=""?$this->text('title'):$this->html('title') ?></h1>
                <div id="bodyContent">
                        <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
                        <div id="contentSub"><?php $this->html('subtitle') ?></div>