Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Coding my first extension!!! a few questions if you don't mind

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


jnowacki at gmail

May 15, 2008, 6:57 PM

Post #1 of 6 (162 views)
Permalink
Coding my first extension!!! a few questions if you don't mind

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
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


tstarling at wikimedia

May 15, 2008, 10:11 PM

Post #2 of 6 (149 views)
Permalink
Re: Coding my first extension!!! a few questions if you don't mind [In reply to]

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[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


jschulz_4587 at msn

May 15, 2008, 10:32 PM

Post #3 of 6 (149 views)
Permalink
Re: Coding my first extension!!! a few questions if you don't mind [In reply to]

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[at]lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>

--
View this message in context: http://www.nabble.com/Coding-my-first-extension%21%21%21-a-few-questions-if-you-don%27t-mind-tp17266302p17267960.html
Sent from the Wikipedia Developers mailing list archive at Nabble.com.


_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


roan.kattouw at home

May 16, 2008, 1:25 AM

Post #4 of 6 (149 views)
Permalink
Re: Coding my first extension!!! a few questions if you don't mind [In reply to]

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)

_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


jnowacki at gmail

May 16, 2008, 11:54 AM

Post #5 of 6 (137 views)
Permalink
Re: Coding my first extension!!! a few questions if you don't mind [In reply to]

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[at]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[at]lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>



--
IU Medical School
410 West 10th Street, Suite 5000 Indianapolis, IN 46202-5122
United States of America
_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Simetrical+wikilist at gmail

May 16, 2008, 11:59 AM

Post #6 of 6 (139 views)
Permalink
Re: Coding my first extension!!! a few questions if you don't mind [In reply to]

On Fri, May 16, 2008 at 2:54 PM, Jonathan Nowacki <jnowacki[at]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.

_______________________________________________
Wikitech-l mailing list
Wikitech-l[at]lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.