From e2106c40360fcd59b4b5bdc69d8c23e025ed2797 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 11 Apr 2006 10:16:27 +0000 Subject: [PATCH] New DISPLAYTITLE magic template; decativated by default so not to scare Brion --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 4 ++++ includes/MagicWord.php | 4 +++- includes/OutputPage.php | 12 ++++++------ includes/Parser.php | 26 +++++++++++++++++++++++++- includes/Skin.php | 1 - includes/SkinTemplate.php | 1 + languages/Language.php | 1 + languages/Messages.php | 3 +++ skins/MonoBook.php | 2 +- 10 files changed, 46 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e4e1dd887f..917c93e592 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 351543b802..c344207d4a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1920,5 +1920,9 @@ $wgUseAjax = false; */ $wgAjaxExportList = array( 'wfSajaxSearch' ); +/** + * Allow DISPLAYTITLE to change title display + */ +$wgAllowDisplayTitle = false ; ?> diff --git a/includes/MagicWord.php b/includes/MagicWord.php index b48b5747c1..7233af751b 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -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 ) ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a772717562..ea979a8a30 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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' ); } diff --git a/includes/Parser.php b/includes/Parser.php index 3eaf38bd9a..53f55d0919 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -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 ) { diff --git a/includes/Skin.php b/includes/Skin.php index 043ae38695..5b2e56c734 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -686,7 +686,6 @@ END; function pageTitle() { global $wgOut; - $s = '

' . htmlspecialchars( $wgOut->getPageTitle() ) . '

'; return $s; } diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 297a99c81c..3c85c6d3f8 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -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(); diff --git a/languages/Language.php b/languages/Language.php index 465de238d8..5256503c46 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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) { diff --git a/languages/Messages.php b/languages/Messages.php index 27c2674cbf..5cbd732d86 100644 --- a/languages/Messages.php +++ b/languages/Messages.php @@ -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]])', + ); diff --git a/skins/MonoBook.php b/skins/MonoBook.php index 79396541ff..feef467499 100644 --- a/skins/MonoBook.php +++ b/skins/MonoBook.php @@ -93,7 +93,7 @@ class MonoBookTemplate extends QuickTemplate {
data['sitenotice']) { ?>
html('sitenotice') ?>
-

text('title') ?>

+

data['displaytitle']!=""?$this->text('title'):$this->html('title') ?>

msg('tagline') ?>

html('subtitle') ?>
-- 2.20.1