http://www.mediawiki.org/wiki/Special:Code/MediaWiki/58459
Revision: 58459 Author: sergeychernyshev Date: 2009-11-03 03:36:24 +0000 (Tue, 03 Nov 2009) Log Message: ----------- HTML is inserted as is now, thanks to Joshua C. Lerner. Modified Paths: -------------- trunk/extensions/Widgets/Widgets.php Modified: trunk/extensions/Widgets/Widgets.php =================================================================== --- trunk/extensions/Widgets/Widgets.php 2009-11-03 03:30:30 UTC (rev 58458) +++ trunk/extensions/Widgets/Widgets.php 2009-11-03 03:36:24 UTC (rev 58459) @@ -64,6 +64,7 @@ // Parser function registration $wgExtensionFunctions[] = 'widgetNamespacesInit'; $wgHooks['ParserFirstCallInit'][] = 'widgetParserFunctions'; +$wgHooks['ParserAfterTidy'][] = 'processEncodedWidgetOutput'; function widgetParserFunctions( &$parser ) { $parser->setFunctionHook( 'widget', 'renderWidget' ); @@ -179,9 +180,22 @@ return '<div class=\"error\">' . wfMsgExt( 'widgets-desc', array( 'parsemag' ), $widgetName ) . '</div>'; } + // Hide the widget from the parser + $output = '<!-- ENCODED_CONTENT '.base64_encode($output).' -->'; return $parser->insertStripItem( $output, $parser->mStripState ); } +function processEncodedWidgetOutput( &$out, &$text ) { + // Find all hidden content and restore to normal + $text = preg_replace( + '/<!-- ENCODED_CONTENT ([0-9a-zA-Z\\+]+=*) -->/esm', + 'base64_decode("$1")', + $text + ); + + return true; +} + function widgetNamespacesInit() { global $wgGroupPermissions, $wgNamespaceProtection; _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs