Sorry for repeating the post. I got a little confused initially.
I have used the YourExtensionName.php to render the information between <ref>example</ref>. These tags just identify that the text is a reference and show them in a particualr format in the article.
I want to add this 'example' value to a referencelinks table which is same as the imagelinks table. For this i need to do this as mentioned by Jama
# This method will be called before an article is saved $wgHooks['ArticleSaveComplete'][] = 'myFunction';
# This method will be called before an article is displayed or previewed. $wgHooks['ParserAfterStrip'][] = 'myOtherFunction';
But where in my extension do i put this code? Will it come outside of the 2 functions in the extension file or should it be inside the renderExample function?
Thanks
-- Amruta
On 27/11/05, Amruta Lonkar gtg808u@mail.gatech.edu wrote:
# This method will be called before an article is saved $wgHooks['ArticleSaveComplete'][] = 'myFunction';
# This method will be called before an article is displayed or previewed. $wgHooks['ParserAfterStrip'][] = 'myOtherFunction';
But where in my extension do i put this code? Will it come outside of the 2 functions in the extension file or should it be inside the renderExample function?
The idea according to docs/hooks.txt is that they be added in a "setup function" for the extension - i.e. the same one referenced in $wgExtensionFunctions[] which calls $wgParser->setHook() to setup the <ref>...</ref> bit.
As far as I can see, though, it ought to be just as possible to do this in "global" scope, outside of any class or function but inside the same file as the extension so it can be activated and deactivated with a single include() line.
I certainly *wouldn't* recommend putting it in the function that actually gets called to parse a <ref> tag, as that will lead to odd things like it hasn't been called [yet], or has been called more than once (in which case your other functions would be called more than once) and so forth.
-- Rowan Collins BSc [IMSoP]
That makes sense. What is happening though is that an article can have any number of references in it and every reference has a unique id associated with it. So my purpsoe in using wgHooks is to save this reference id for every reference in the article in the database and this id can be obtained only once the user parses the string between the <ref>..</ref> tags i.e in the renderReference function in the extension file. In that case do you think this will work?.
Thanks
Quoting Rowan Collins rowan.collins@gmail.com:
On 27/11/05, Amruta Lonkar gtg808u@mail.gatech.edu wrote:
# This method will be called before an article is saved $wgHooks['ArticleSaveComplete'][] = 'myFunction';
# This method will be called before an article is displayed or previewed. $wgHooks['ParserAfterStrip'][] = 'myOtherFunction';
But where in my extension do i put this code? Will it come outside of the 2 functions in the extension file or should it be inside the renderExample function?
The idea according to docs/hooks.txt is that they be added in a "setup function" for the extension - i.e. the same one referenced in $wgExtensionFunctions[] which calls $wgParser->setHook() to setup the <ref>...</ref> bit.
As far as I can see, though, it ought to be just as possible to do this in "global" scope, outside of any class or function but inside the same file as the extension so it can be activated and deactivated with a single include() line.
I certainly *wouldn't* recommend putting it in the function that actually gets called to parse a <ref> tag, as that will lead to odd things like it hasn't been called [yet], or has been called more than once (in which case your other functions would be called more than once) and so forth.
-- Rowan Collins BSc [IMSoP] _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
-- Amruta
On 28/11/05, Amruta Lonkar gtg808u@mail.gatech.edu wrote:
That makes sense. What is happening though is that an article can have any number of references in it and every reference has a unique id associated with it. So my purpsoe in using wgHooks is to save this reference id for every reference in the article in the database and this id can be obtained only once the user parses the string between the <ref>..</ref> tags i.e in the renderReference function in the extension file. In that case do you think this will work?.
Hm... I'm not sure - I can't see a reason why extension tags would necessarily get parsed at all during the pre-save transform (as opposed to when *viewing* the article), but then I don't know that they won't.
Even so, I would suggest storing the IDs somewhere (e.g. create a global variable called something like $wgReferenceIDs[]) rather than just calling hooked functions multiple times - not that the other way won't work, but it just seems like "nicer" coding to do them all in one go. So, assuming renderReference() is getting called when you want it to, you can just have it add to $wgReferenceIDs[] (or whatever) and the other two functions can run exactly once and process everything from that list.
-- Rowan Collins BSc [IMSoP]
I had a question regarding creating a referencelinks table similar to the imagelinks table. I have created a namespace for references and as i understand the pages in the image namespace are formed using the name stored in the imagelinks table and two images cannot have the same name. However in case of references there can be many references of the same author but different publications, so i cant just store the rl_from and rl_to in this table. I need some way to identify the reference in this table also. Can anyone give me any suggestions on what would be the best way to create this table.
The current format of the table is +---------+-----------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+-----------------+------+-----+---------+----------------+ | rl_from | int(8) unsigned | | MUL | 0 | | | rl_to | varchar(255) | | MUL | | | |---------+-----------------+------+-----+---------+----------------+
Thanks
Quoting Rowan Collins rowan.collins@gmail.com:
On 28/11/05, Amruta Lonkar gtg808u@mail.gatech.edu wrote:
That makes sense. What is happening though is that an article can have any number of references in it and every reference has a unique id associated
with
it. So my purpsoe in using wgHooks is to save this reference id for every reference in the article in the database and this id can be obtained only once the user parses the string between the <ref>..</ref> tags i.e in the renderReference function in the extension file. In that case do you think
this
will work?.
Hm... I'm not sure - I can't see a reason why extension tags would necessarily get parsed at all during the pre-save transform (as opposed to when *viewing* the article), but then I don't know that they won't.
Even so, I would suggest storing the IDs somewhere (e.g. create a global variable called something like $wgReferenceIDs[]) rather than just calling hooked functions multiple times - not that the other way won't work, but it just seems like "nicer" coding to do them all in one go. So, assuming renderReference() is getting called when you want it to, you can just have it add to $wgReferenceIDs[] (or whatever) and the other two functions can run exactly once and process everything from that list.
-- Rowan Collins BSc [IMSoP] _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
-- Amruta
Hi,
I note that wanted pages http://wiki.nuestrasoficinas.com.ar/index.php?title=Especial:Wantedpages does not work as I hope.
For example: Here http://wiki.nuestrasoficinas.com.ar/index.php?title=Computadora I have [[máquina de Turing]] not defined and in wantedpages it does not appear.
That I can watch? I want see all pages not even defined
By default, pages don't appear in Special:Wantedpages until there are at least two redlinks to them somewhere. Chances are, this is your only link to that page.
Rob Church
On 28/11/05, wikiWIS wikiwis@gmail.com wrote:
Hi,
I note that wanted pages http://wiki.nuestrasoficinas.com.ar/index.php?title=Especial:Wantedpages does not work as I hope.
For example: Here http://wiki.nuestrasoficinas.com.ar/index.php?title=Computadora I have [[máquina de Turing]] not defined and in wantedpages it does not appear.
That I can watch? I want see all pages not even defined
-- Tks Cris
MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org