Dear developers,
I wrote or edited the code attached below. I've also supplied working sample input and output files. I changed certain variables or names to "arbitrary" or "tag" in order to figure out how the thing works. Some variables like $wgParser or setHook can not be changed and appear to be predefined. That's fine, but when I hit "GO" after placing either one of these into the search box at mediawiki.org I get "*There is no page titled "setHook"*. I'm typically a Perl programmer and I understand how the following work:
1. htmlspecialchars 2. implode 3. return 4. function 5. foreach 6. array();
I just don't understand how this program knows the "$input" variable is inbetween the tags and the "$args" is embedded withing the html tag. It would be nice to read up on $wgParser and setHook as well but as I said earlier the mediawiki go button doesn't return any results and search returns too many.
Thanks for the support,
-Jon
*Code:*
<?php $wgExtensionFunctions[] = 'arbitraryFunctionName1';
function arbitraryFunctionName1() { global $wgParser; #important and breaks if changed, not found on PHP.net $wgParser->setHook( 'tag', 'arbitraryFunctionName2' ); }
function arbitraryFunctionName2( $input, $args, $parser ) { $attr = array(); // This time, make a list of attributes and their values, // and dump them, along with the user input foreach( $args as $ArbitraryName => $ArbitraryValue ) $attr[] = '<strong>' . htmlspecialchars( $ArbitraryName ) . '</strong> = ' . htmlspecialchars( $ArbitraryValue ); return implode( '<br />', $attr ) . "\n\n" . htmlspecialchars( $input ); }
*Input:*
<tag url="http://www.random.com" arg2="xxx" license="commercial">Company</tag>
*Output*
*url* = http://www.random.com *arg2* = xxx *license* = commercial
Company