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
Jonathan Nowacki wrote:
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"*.
[...]
In your MediaWiki installation, open Parser.php in the includes subdirectory. Search for "function setHook". Above that text, you will find the documentation for setHook(), in a comment. Generally, Parser.php is where you find documentation for $wgParser. Sometimes you will find documentation on a website, but it is often out of date and so not to be trusted.
-- Tim Starling
And don't be surprise to see some swear words there ;)
Tim Starling-2 wrote:
Jonathan Nowacki wrote:
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"*.
[...]
In your MediaWiki installation, open Parser.php in the includes subdirectory. Search for "function setHook". Above that text, you will find the documentation for setHook(), in a comment. Generally, Parser.php is where you find documentation for $wgParser. Sometimes you will find documentation on a website, but it is often out of date and so not to be trusted.
-- Tim Starling
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Tim Starling schreef:
Jonathan Nowacki wrote:
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"*.
Generally, Parser.php is where you find documentation for $wgParser. Sometimes you will find documentation on a website, but it is often out of date and so not to be trusted.
Documentation on www.mediawiki.org is generally out of date, agreed. But there's documentation at http://svn.wikimedia.org/doc/classParser.html which is generated based on those comments and never more than 24 hours out of date.
Roan Kattouw (Catrope)
I found setHook in Parser.php but $wgParser exists only once in an irrelevant comment. Doing a quick search showed that $wgParser is referenced up to 147 times on the standard media wiki distro. 56 of those lines show $wgParser preceded by a global declaration. It seems like it's locally defined yet in my script I'm unable to change the name. Any suggestions?
On Fri, May 16, 2008 at 1:11 AM, Tim Starling tstarling@wikimedia.org wrote:
Jonathan Nowacki wrote:
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"*.
[...]
In your MediaWiki installation, open Parser.php in the includes subdirectory. Search for "function setHook". Above that text, you will find the documentation for setHook(), in a comment. Generally, Parser.php is where you find documentation for $wgParser. Sometimes you will find documentation on a website, but it is often out of date and so not to be trusted.
-- Tim Starling
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
On Fri, May 16, 2008 at 2:54 PM, Jonathan Nowacki jnowacki@gmail.com wrote:
I found setHook in Parser.php but $wgParser exists only once in an irrelevant comment. Doing a quick search showed that $wgParser is referenced up to 147 times on the standard media wiki distro. 56 of those lines show $wgParser preceded by a global declaration. It seems like it's locally defined yet in my script I'm unable to change the name. Any suggestions?
$wgParser is a global that's initialized during MediaWiki startup. It's an object of the Parser class, which is why you were told to look in Parser.php: that's where its methods are defined. You may want to look at docs/globals.txt for more info on what globals MediaWiki uses.
"Simetrical" Simetrical+wikilist@gmail.com wrote in message news:7c2a12e20805161159k7195ba79ld6a887c4c60a1a56@mail.gmail.com...
On Fri, May 16, 2008 at 2:54 PM, Jonathan Nowacki
jnowacki@gmail.com wrote:
I found setHook in Parser.php but $wgParser exists only once in an irrelevant comment. Doing a quick search showed that $wgParser is referenced up to 147 times on the standard media wiki distro. 56 of
those
lines show $wgParser preceded by a global declaration. It seems like
it's
locally defined yet in my script I'm unable to change the name. Any suggestions?
$wgParser is a global that's initialized during MediaWiki startup. It's an object of the Parser class, which is why you were told to look in Parser.php: that's where its methods are defined. You may want to look at docs/globals.txt for more info on what globals MediaWiki uses.
Or perhaps http://www.php.net/manual/en/language.variables.scope.php for an introduction to PHP globals and how they work. There seem to be a few areas of the PHP language that you don't yet understand fully, so I would recommend looking in the PHP manual first rather than trying to figure it out from the MediaWiki code-base, which (let's be honest) is not necessarily the ideal introduction to PHP... :-)
- Mark Clements (HappyDog)
wikitech-l@lists.wikimedia.org