如何创建,读取,更新,并通过脚本删除Mediawiki的文章? [英] How can I create, read, update and delete Mediawiki articles via scripts?

查看:119
本文介绍了如何创建,读取,更新,并通过脚本删除Mediawiki的文章?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图找出什么对(使用PHP)在wiki页面上进行CRUD操作最简单的方法。

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.

现在的问题是,如果已经有一些不错的实现(或最佳实践)的,如果我必须从与维基API从头开始我可能会使用或

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.

推荐答案

好吧,这是比较容易比预期很多。只需创建一个Article对象,并使用的doEdit 函数来创建或编辑一个页面:

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");
}

和$模式可以是 EDIT_NEW EDIT_UPDATE

抱歉延迟答案,但是我没有被允许在8小时内回答我自己的问题。

Sorry for the delayed answer, however I wasn't allowed to answer my own questions within 8 hours.

这篇关于如何创建,读取,更新,并通过脚本删除Mediawiki的文章?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆