r66974 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66973‎ | r66974 | r66975 >
Date:16:56, 27 May 2010
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
(Bug 21278) Allow wiki markup to the sidebar
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Skin.php
@@ -2124,6 +2124,8 @@
21252125 */
21262126 function addToSidebar( &$bar, $text ) {
21272127 $lines = explode( "\n", $text );
 2128+ $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.
 2129+
21282130 $heading = '';
21292131 foreach( $lines as $line ) {
21302132 if( strpos( $line, '*' ) !== 0 ) {
@@ -2135,11 +2137,12 @@
21362138 $bar[$heading] = array();
21372139 }
21382140 } else {
 2141+ $line = trim( $line, '* ' );
21392142 if( strpos( $line, '|' ) !== false ) { // sanity check
21402143 global $wgMessageCache;
21412144 $line = $wgMessageCache->transform( $line );
21422145
2143 - $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
 2146+ $line = array_map( 'trim', explode( '|', explode( '|', $line, 2 ), 2 ) );
21442147 $link = wfMsgForContent( $line[0] );
21452148 if( $link == '-' ) {
21462149 continue;
@@ -2171,11 +2174,26 @@
21722175 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
21732176 'active' => false
21742177 );
 2178+ } else if ( (substr($line, 0, 2) == '{{') && (substr($line, -2) == '}}') ) {
 2179+ global $wgParser, $wgTitle;
 2180+
 2181+ $line = substr($line, 2, strlen($line) - 4 );
 2182+
 2183+ if (is_null($wgParser->mOptions))
 2184+ $wgParser->mOptions = new ParserOptions();
 2185+
 2186+ $wgParser->mOptions->setEditSection(false);
 2187+ $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $wgTitle, $wgParser->mOptions )->getText();
21752188 } else {
21762189 continue;
21772190 }
21782191 }
21792192 }
 2193+
 2194+ if ( count($wikiBar) > 0 )
 2195+ $bar = array_merge($bar, $wikiBar);
 2196+
 2197+ return $bar;
21802198 }
21812199
21822200 /**
Index: trunk/phase3/RELEASE-NOTES
@@ -75,7 +75,8 @@
7676 * (bug 22844) Added support for WinCache object caching
7777 * (bug 23580) Add two new events to LivePreview so that scripts can be
7878 notified about the beginning and finishing of LivePreview actions
79 -
 79+* (bug 21278) Now the sidebar allows inclusion of wiki markup.
 80+
8081 === Bug fixes in 1.17 ===
8182 * (bug 17560) Half-broken deletion moved image files to deletion archive
8283 without updating database

Follow-up revisions

RevisionCommit summaryAuthorDate
r66979Follow up r66974. Paste error.platonides19:38, 27 May 2010
r95166Remove the * {{msg}} syntax introduced to MediaWiki:Sidebar in r66974. This s...dantman18:23, 21 August 2011

Comments

#Comment by Raymond (talk | contribs)   18:17, 27 May 2010

Seen on translatewiki:

PHP Notice: Array to string conversion in /www/w/includes/Skin.php on line 2145

.php line 2151 calls wfMsgExt() /Skin.php on line 2152

#Comment by Brion VIBBER (talk | contribs)   20:15, 20 December 2010

(r66979 followup is said to fix this)

#Comment by Brion VIBBER (talk | contribs)   23:28, 16 October 2010

This syntax seems a bit off to me, as it's overriding familiar template syntax with something slightly different. Is this solidly in use yet?

#Comment by Platonides (talk | contribs)   14:13, 17 October 2010

The sidebar syntax is crazy. This is a syntax which didn't mean anything there previously and has the connotation of inclusion.

I'm open for alternatives, though. I doubt anyone is using it yet.

#Comment by Brion VIBBER (talk | contribs)   21:17, 20 December 2010

Yeah I'm not super hot for it, but it won't break anything existing. IMO the sidebar syntax is ultimately a dead-end and needs to be replaced with a user-friendly editing widget and a real data structure, so adding a few ugly things to the syntax now won't hurt much. :D

Marking the rev as resolved (for the other issue noted above).

Status & tagging log