From 8b73122a0d2c8121a6ad06acd5a90831ebfc0fdb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niklas=20Laxstr=C3=B6m?= Date: Fri, 14 Apr 2006 16:59:59 +0000 Subject: [PATCH] Yet another wfMsg, which includes hack to get inline wikitext blocks --- includes/GlobalFunctions.php | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 491a09afa9..c6e3313d82 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -540,6 +540,51 @@ function wfMsgWikiHtml( $key ) { return wfMsgReplaceArgs( $wgOut->parse( wfMsgGetKey( $key, true ), /* can't be set to false */ true ), $args ); } +/** + * Returns message in the requested format + * @param string $key Key of the message + * @param array $options Processing rules: + * parse: parses wikitext to html + * parseinline: parses wikitext to html and removes the surrounding p's added by parser or tidy + * escape: filters message trough htmlspecialchars + * replaceafter: parameters are substituted after parsing or escaping + */ +function wfMsgExt( $key, $options ) { + global $wgOut; + + $args = func_get_args(); + array_shift( $args ); + array_shift( $args ); + + if( !is_array($options) ) { + $options = array($options); + } + + $string = wfMsgGetKey( $key, true ); + + if( !in_array('replaceafter', $options) ) { + $string = wfMsgReplaceArgs( $string, $args ); + } + + if( in_array('parse', $options) ) { + $string = $wgOut->parse( $string, true ); + } elseif ( in_array('parseinline', $options) ) { + $string = $wgOut->parse( $string, true ); + if( preg_match( "~^

(.*)\n?

$~", $string, $m = null ) ) { + $string = $m[1]; + } + } elseif ( in_array('escape', $options) ) { + $string = htmlspecialchars ( $string ); + } + + if( in_array('replaceafter', $options) ) { + $string = wfMsgReplaceArgs( $string, $args ); + } + + return $string; +} + + /** * Just like exit() but makes a note of it. * Commits open transactions except if the error parameter is set -- 2.20.1