(Bug 21278) Allow wiki markup to the sidebar
authorPlatonides <platonides@users.mediawiki.org>
Thu, 27 May 2010 16:56:34 +0000 (16:56 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Thu, 27 May 2010 16:56:34 +0000 (16:56 +0000)
RELEASE-NOTES
includes/Skin.php

index b234b56..a14d8a9 100644 (file)
@@ -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
index afb0fab..de80f13 100644 (file)
@@ -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;
        }
 
        /**