From 32fa648dc9fcfaae9dcae71f50941d888773e707 Mon Sep 17 00:00:00 2001 From: Platonides Date: Thu, 27 May 2010 16:56:34 +0000 Subject: [PATCH] (Bug 21278) Allow wiki markup to the sidebar --- RELEASE-NOTES | 3 ++- includes/Skin.php | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b234b56f74..a14d8a9d3d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -75,7 +75,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 22844) Added support for WinCache object caching * (bug 23580) Add two new events to LivePreview so that scripts can be notified about the beginning and finishing of LivePreview actions - +* (bug 21278) Now the sidebar allows inclusion of wiki markup. + === Bug fixes in 1.17 === * (bug 17560) Half-broken deletion moved image files to deletion archive without updating database diff --git a/includes/Skin.php b/includes/Skin.php index afb0fabcc2..de80f131a2 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -2124,6 +2124,8 @@ CSS; */ function addToSidebar( &$bar, $text ) { $lines = explode( "\n", $text ); + $wikiBar = array(); # We need to handle the wikitext on a different variable, to avoid trying to do an array operation on text, which would be a fatal error. + $heading = ''; foreach( $lines as $line ) { if( strpos( $line, '*' ) !== 0 ) { @@ -2135,11 +2137,12 @@ CSS; $bar[$heading] = array(); } } else { + $line = trim( $line, '* ' ); if( strpos( $line, '|' ) !== false ) { // sanity check global $wgMessageCache; $line = $wgMessageCache->transform( $line ); - $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) ); + $line = array_map( 'trim', explode( '|', explode( '|', $line, 2 ), 2 ) ); $link = wfMsgForContent( $line[0] ); if( $link == '-' ) { continue; @@ -2171,11 +2174,26 @@ CSS; 'id' => 'n-' . strtr( $line[1], ' ', '-' ), 'active' => false ); + } else if ( (substr($line, 0, 2) == '{{') && (substr($line, -2) == '}}') ) { + global $wgParser, $wgTitle; + + $line = substr($line, 2, strlen($line) - 4 ); + + if (is_null($wgParser->mOptions)) + $wgParser->mOptions = new ParserOptions(); + + $wgParser->mOptions->setEditSection(false); + $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText(); } else { continue; } } } + + if ( count($wikiBar) > 0 ) + $bar = array_merge($bar, $wikiBar); + + return $bar; } /** -- 2.20.1