[Mediawiki-l] Creating wiki pages directly by program

Hugh Prior mediawiki at localpin.com
Thu Feb 2 14:55:54 UTC 2006


I would like to be able to create wiki pages by just calling a function to 
which I pass the name of the new page and the text which I want on the page. 
I have managed a solution where I just hack directly into the tables 
(bypassing all the mediawiki code), but started to hit code translation type 
problems, so I think it is best to do it building on all the wisdom already 
built into the mediawiki code.

The sort of "createPage()" function which I have so far got, but which does 
not work, is as follows:

/**
* Pass the name of the new page and the content and create the page
*/
function createPage($wikiPageName, $pageText) {
  $title = new Title();
  $title = $title->newFromText($wikiPageName);
  $article = new Article($title);
  $article->insertNewArticle($pageText, "No summary", false, false);
}

Anybody done this before?  Any ideas what I need to do specifically to get 
this working?

I have tried to trace through what the "index.php" file does when creating a 
page, but it's not easy to follow particularly because of the way in which 
the parameters are often implicit (e.g. via POST of form data).

Thanks for any help!



Hugh Prior 






More information about the MediaWiki-l mailing list