r13572 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r13571 | r13572 (on ViewVC) | r13573 >
Date:10:16, 11 April 2006
Author:magnusmanske
Status:new
Tags:
Comment:New DISPLAYTITLE magic template; decativated by default so not to scare Brion
Modified paths:

Diff [purge]

Index: trunk/phase3/skins/MonoBook.php
===================================================================
--- trunk/phase3/skins/MonoBook.php	(revision 13571)
+++ trunk/phase3/skins/MonoBook.php	(revision 13572)
@@ -93,7 +93,7 @@
 	<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>
Index: trunk/phase3/includes/Parser.php
===================================================================
--- trunk/phase3/includes/Parser.php	(revision 13571)
+++ trunk/phase3/includes/Parser.php	(revision 13572)
@@ -2441,7 +2441,7 @@
 	 * @access private
 	 */
 	function braceSubstitution( $piece ) {
-		global $wgContLang;
+		global $wgContLang, $wgAllowDisplayTitle;
 		$fname = 'Parser::braceSubstitution';
 		wfProfileIn( $fname );
 
@@ -2611,7 +2611,31 @@
 				$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 ) {
 			$colonPos = strpos( $part1, ':' );
Index: trunk/phase3/includes/OutputPage.php
===================================================================
--- trunk/phase3/includes/OutputPage.php	(revision 13571)
+++ trunk/phase3/includes/OutputPage.php	(revision 13572)
@@ -18,7 +18,7 @@
 	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 @@
 		$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 @@
 		$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 @@
 
 		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: trunk/phase3/includes/MagicWord.php
===================================================================
--- trunk/phase3/includes/MagicWord.php	(revision 13571)
+++ trunk/phase3/includes/MagicWord.php	(revision 13572)
@@ -72,6 +72,7 @@
 	'MAG_RAW',
 	'MAG_SUBPAGENAME',
 	'MAG_SUBPAGENAMEE',
+	'MAG_DISPLAYTITLE',
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
 	wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
@@ -105,7 +106,8 @@
 	MAG_CURRENTDOW,
 	MAG_REVISIONID,
 	MAG_SUBPAGENAME,
-	MAG_SUBPAGENAMEE
+	MAG_SUBPAGENAMEE,
+	MAG_DISPLAYTITLE,
 );
 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
 	wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
Index: trunk/phase3/includes/SkinTemplate.php
===================================================================
--- trunk/phase3/includes/SkinTemplate.php	(revision 13571)
+++ trunk/phase3/includes/SkinTemplate.php	(revision 13572)
@@ -187,6 +187,7 @@
 		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: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 13571)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 13572)
@@ -1920,5 +1920,9 @@
  */
 $wgAjaxExportList = array( 'wfSajaxSearch' );
 
+/**
+ * Allow DISPLAYTITLE to change title display
+ */
+$wgAllowDisplayTitle = false ;
 
 ?>
Index: trunk/phase3/includes/Skin.php
===================================================================
--- trunk/phase3/includes/Skin.php	(revision 13571)
+++ trunk/phase3/includes/Skin.php	(revision 13572)
@@ -686,7 +686,6 @@
 
 	function pageTitle() {
 		global $wgOut;
-
 		$s = '<h1 class="pagetitle">' . htmlspecialchars( $wgOut->getPageTitle() ) . '</h1>';
 		return $s;
 	}
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 13571)
+++ trunk/phase3/RELEASE-NOTES	(revision 13572)
@@ -43,6 +43,8 @@
 * 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: trunk/phase3/languages/Messages.php
===================================================================
--- trunk/phase3/languages/Messages.php	(revision 13571)
+++ trunk/phase3/languages/Messages.php	(revision 13572)
@@ -2000,6 +2000,9 @@
 'articletitles' => "Articles starting with ''$1''",
 'hideresults' => 'Hide results',
 
+# DISPLAYTITLE
+'displaytitle' => '(Link to this page as [[$1]])',
+
 );
 
 
Index: trunk/phase3/languages/Language.php
===================================================================
--- trunk/phase3/languages/Language.php	(revision 13571)
+++ trunk/phase3/languages/Language.php	(revision 13572)
@@ -265,6 +265,7 @@
 	MAG_LC                   => array( 0,    'LC:'                    ),
 	MAG_UC                   => array( 0,    'UC:'                    ),
 	MAG_RAW                  => array( 0,    'RAW:'                   ),
+	MAG_DISPLAYTITLE         => array( 1,    'DISPLAYTITLE'           ),
 );
 
 if (!$wgCachedMessageArrays) {
Views
Toolbox