Junliano,
Thanks for the help. The suggested approach is excellent, but limited to
usage for particular class of hooks and versions of MW, in this case
$wgExtParserFunctions.
For all function hooks, the following syntax works without having to worry
about different versions and classes of MW (at least I think it does - it
does on the ones I've tested). This example (parser function 'replace_e')
extends the parser function 'replace' by interpreting escaped characters.
<source lang=php>
function runReplace_e( $parser, $inStr = '', $inReplaceFrom = '',
$inReplaceTo = '' ) {
global $wgParser;
list($callback,$flags) = $wgParser->mFunctionHooks['replace'];
return @call_user_func_array( $callback,
array_merge(array($parser),array($inStr,
stripcslashes($inReplaceFrom), stripcslashes($inReplaceTo)) ));
}
</source>
If someone knows a cleaner/more efficient way, I'd love to hear it!
Jack D. Pond
"Believe those who are seeking the truth. Doubt those who find it." -- Andre
Gide(1869-1951)
-----Original Message-----
From: mediawiki-l-bounces(a)lists.wikimedia.org
[mailto:mediawiki-l-bounces@lists.wikimedia.org] On Behalf Of
Juliano F. Ravasi
Sent: Tuesday, September 08, 2009 3:14 PM
To: MediaWiki announcements and site admin list
Subject: Re: [Mediawiki-l] Extending an existing
ParserFunction extension
Jack D. Pond wrote:
function runReplace_e( &$parser, $inStr =
'', $inReplaceFrom = '',
$inReplaceTo = '' ) {
return (runReplace( &$parser, $inStr,
stripcslashes($inReplaceFrom)
, stripcslashes($inReplaceFrom))); }
Recheck your parameters, $inReplaceFrom is used twice.
What you want is probably this:
{
global $wgExtParserFunctions;
return $wgExtParserFunctions->runReplace( ...etc... );
}
--
Juliano F. Ravasi ..
http://juliano.info/
5105 46CC B2B7 F0CD 5F47 E740 72CA 54F4 DF37 9E96
"A candle loses nothing by lighting another candle." -- Erin Majors
* NOTE: Don't try to reach me through this address, use
"contact@" instead.
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l