如何通过脚本创建、阅读、更新和删除 Mediawiki 文章?

发布于 2024-12-19 06:31:19 字数 172 浏览 4 评论 0原文

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

我构建了一个媒体维基扩展,可以上传文件并解析其内容。根据内容,有必要创建或更新相应的 wiki 文章。

问题是是否已经有一些我可以使用的不错的实现(或最佳实践),或者我是否必须从头开始使用 wiki api。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你列表最软的妹 2024-12-26 06:31:19

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

$newArticle = new Article("Title")
$articleCreated = $newArticle->doEdit('content', 'summary', 'mode')

if ($articleCreated) {
  $wgOut->addHTML("success");
}

$mode 为 EDIT_NEWEDIT_UPDATE

很抱歉迟到的答复,但是我不能在 8 小时内回答我自己的问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文