For getting data from external sources, I've been writing PHP scripts
to generate XML for import via maintenance/importDump.php. I have a
bunch of general use scripts that can pull the old content out of a
page, extract parts of the content for reuse in a template for that
page type. I also use my experimental TableEdit extension to hold
data I'm importing from the external sources. A typical example
would be something like
Old page:
==Overview==
Infobox table
===Notes===
Stuff users have written
===References===
<references/>
Template (Note that this is not being used in the Mediawiki sense of
a template for transclusion):
==Overview==
{{{Infobox table}}}
===Notes===
{{{NOTES}}}
===References===
<references/>
The update script
1) grabs the content of the old page
2) extracts the "Stuff users have written" using preg_match() and
store it as $notes
3) makes a draft of the new page with $new_page = get_latest_text
($template);
4) queries the external data source to generate an updated Infobox
table and stores it as $infobox_table
5) puts in the new infobox with str_replace('{{{Infobox table}}},
$infobox_table, $new_page)
6) puts back the old user notes with str_replace('{{{NOTES}}},
$notes, $new_page)
7) saves $new_table into an XML file compatible with importDump.php
8) loads the XML file.
Hope that makes sense. This is being used to build a wiki about the
biology of E. coli as a model organism. I'm going to eventually make
the utility functions for doing this available, but they need more
testing.
You should probably look at semanitic mediawiki for how to get data
back out of the wiki. Data can also be extracted from the TableEdit
tables, which have content stored in an external mysql database.
Hope this helps.
Jim
On Jul 13, 2007, at 3:49 AM, Flip Mozart wrote:
Hello!
I am new to MediaWiki though I know some PHP programming.
I have a variety of data sources (e.g. relational databases, excel
files, text files, Java beans, PHP classes, web services). I want
to set up a Wiki that will read from and write to these data sources.
One idea I have is to write a custom tag (let's call it an XData
tag or external data source tag), used like in this sample article:
The city of Manila has <xdata source="http://
some.almanac.or.uri">8,500,000</xdata> inhabitants.
My first question: What do you folks think about this idea? Are
there other (possibly more elegant) ways of accomplishing the same
objective? Some existing extension perhaps? InputBox?
Let's pursue the XData idea a little further. Suppose there is
already an article on Manila (City) where the population is
<xdata ...>8,500,000</xdata>. Suppose I edit the article and
changed this to 10,000,000. I would then like to update the
underlying (external) data source.
My questions:
1) How do I do this? Exactly which event (hook) do I use?
ArticleSave?
2) Is there an MWiki function that checks if an article has been
changed or not?
3) How do I know if the text changed was between <xdata> tags or
not (short of writing my own article text parser)?
Serge
Send instant messages to your online friends http://
uk.messenger.yahoo.com
_______________________________________________
MediaWiki-l mailing list
MediaWiki-l(a)lists.wikimedia.org
http://lists.wikimedia.org/mailman/listinfo/mediawiki-l
=====================================
Jim Hu
Associate Professor
Dept. of Biochemistry and Biophysics
2128 TAMU
Texas A&M Univ.
College Station, TX 77843-2128
979-862-4054