How can I create, read, update and delete Mediawiki articles via scripts?

巧了我就是萌 提交于 2020-01-04 07:03:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!