问题
Currently I'm trying to figure out what's the easiest way to perform CRUD operations on wiki pages (using PHP).
I've built an media wiki extension where it's possible to upload a file and parse its content. Depending on the content it is necessary to either create or update the respective wiki articles.
The question is if there are already some nice implementations (or best practices) which I might use or if I have to start from scratch with the wiki api.
回答1:
Ok, this was a lot easier than expected. Just create an Article object and use the doEdit
function to create or edit a page:
$newArticle = new Article("Title")
$articleCreated = $newArticle->doEdit('content', 'summary', 'mode')
if ($articleCreated) {
$wgOut->addHTML("success");
}
And $mode is either EDIT_NEW
or EDIT_UPDATE
.
Sorry for the delayed answer, however I wasn't allowed to answer my own questions within 8 hours.
来源:https://stackoverflow.com/questions/8368583/how-can-i-create-read-update-and-delete-mediawiki-articles-via-scripts