Jump to content

Extension:评论

本頁使用了標題或全文手工轉換
From mediawiki.org
This page is a translated version of the page Extension:Comments and the translation is 100% complete.
MediaWiki扩展手册
Comments
发行状态: 稳定版
实现 解析器扩展 , 函数钩
描述
添加‎<comments />解析器钩子标签,允许对文章评论
作者
最新版本 5.0
MediaWiki 1.43+
数据库更改
Comments
Comments_Vote
Comments_block
许可协议 GNU通用公眾授權條款2.0或更新版本
下載
  • $wgCommentsDefaultAvatar
  • $wgCommentsInRecentChanges
  • $wgCommentsAbuseFilterGroup
  • $wgCommentsSortDescending
‎<comments />
  • comment
  • commentadmin
  • commentlinks
  • comment-delete-own
季度下載量 46 (Ranked 84th)
前往translatewiki.net翻譯Comments扩展
問題 开启的任务 · 报告错误

评论扩展添加了‎<comments />解析器钩子标记,允许对存在该标记的文章发表评论。

评论操作会记录在Special:Log/comments,但是默认情况下它们会像在巡查 日志中一样隐藏。 你可以设置$wgCommentsInRecentChanges = true;以展示Special:RecentChanges中的评论日志项目(在2.8+版本可用)。

大部分的代码修复工作由MiszaJack Phoenix完成。

安裝

  • 下载文件,并将解压后的Comments文件夹移动到extensions/目录中。
    开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Comments
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'Comments' );
    
  • 运行更新脚本,它将自动创建此扩展必须依赖的数据库表。
  • Yes 完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
You will need to download the master version for the extension to work properly, as there is an issue with the branched versions.

用法

  • ‎<comments /> — 基本的评论格式,已足夠應付大多数的事情。
  • <comments allow="Derfel,Jack Phoenix,Misza" /> — 仅允许用户 Derfel、Jack Phoenix、以及Misza提交评论。
  • <comments voting="Plus" /> — 防止用户对评论进行负面评价(好評),只允许进行正面评价(差評)。

每日评论

该扩展还自带「每日评论」功能(‎<commentsoftheday />),默认情况下「未」启用。你可以在维基的LocalSettings.php中启用该功能,方法是在require_once行后添加以下内容:

require_once "$IP/extensions/Comments/CommentsOfTheDay.php";

如果将nocache参数传递给解析器钩子(比如:<commentsoftheday nocache=true />),解析器钩子将不会使用memcached,而是直接从数据库而不是缓存中获取数据。 如果你想显示最新数据,这很有用,但可能会非常耗费服务器资源。

用户权限

这个扩展添加下列新的用户权限

  • comment - 它允许发布评论
  • commentlinks - 它允许在评论中发布外部链接
  • commentadmin - 它允许删除用户发布的评论
  • comment-delete-own - 它允许删除自己的评论,例如
$wgGroupPermissions['sysop']['commentadmin'] = true;

默认情况下,每个人都可以发表评论,即使是匿名用户也可以,但要发表包含外部链接的评论則仅限于自动确认用户

如果希望匿名用户也能发布外部链接,请在require_once后添加此项:

$wgGroupPermissions['*']['commentlinks'] = true;

默认情况下,只有commentadmin组的用户可以删除评论。

用户积分

This is relevant only if the SocialProfile extension is installed and $wgUserLevels is properly configured.
  • $wgUserStatsPointValues['comment_plus'] — the number of points to give out when another user gives a "thumbs up" to your comment.
  • $wgUserStatsPointValues['comment_ignored'] — the number of points to give out when another user adds your comments to their ignore list (Special:CommentIgnoreList).

参数

  • $wgCommentsDefaultAvatar — the path to an image which will be displayed instead of an avatar if social tools (SocialProfile extension) aren't installed. It should be 50x50px. Note that there is no default avatar image shipped with this extension. The default is defined in extension.json and links to an external image on shoutwiki.com server, an ad-driven wiki farm. You may prefer to set this parameter to point to a local file.
  • $wgCommentsInRecentChanges — by default, this variable is set to false. Set it to true to display comments log entries in Special:RecentChanges, too, in addition to the comments log at Special:Log/comments.
  • $wgCommentsSortDescending — by default, this variable is set to false. Set it to true to sort comments by date descending, with the new comment box and most recent comments at the top.
  • $wgCommentsAbuseFilterGroup — This is the custom group name for AbuseFilter for when the AbuseFilter extension is enabled. It ensures that AbuseFilter only pulls the filters related to Comments. If you want AbuseFilter to pull all the filters, enter 'default' here. The default value for this is 'comment', which ensures that AbuseFilter will only look for filters specifically written to target comments.

魔法词/解析器功能

评论包括2个魔法词和一个解析器函数:

  • {{NUMBEROFCOMMENTS}} gives the entire number of comments on the wiki.
  • {{NUMBEROFCOMMENTSPAGE}} gives number of comments on the current page.
  • {{NUMBEROFCOMMENTSPAGE:<pagename>}} gives number of comments on the given page.

钩子

Comments extension adds three hooks, Comment::add, Comment::delete and Comment::isSpam.

Hook name When it is called Parameters
Comment::add After a comment has been added to the database, at the bottom of Comment::add function
  • $comment (instance of Comment class)
  • $commentID
  • $pageID
Comment::delete After a comment has been deleted and the caches have been purged (function delete on class Comment)
  • &$comment (instance of Comment class)
  • $commentID
  • $pageID
Comment::isSpam Called in Comment::isSpam before performing other spam checks.
  • &$text (user-supplied comment text to check against spam)
  • &$retVal (boolean; function return value, i.e. does the supplied text contain spam (true) or not (false))

Anti-spam

Though (as of Q3/2023) Comments does not (yet) support ConfirmEdit, MediaWiki's de facto CAPTCHA extension, there are plenty of other anti-spam measures built in, including:

  • restricting who can add comments and/or comments that contain hyperlinks (see the #User rights section above)
  • support for $wgSpamRegex and $wgSummarySpamRegex
  • possibility for extension developers to implement custom spam checks via the Comment::isSpam hook point (see the #Hooks section above)
  • AbuseFilter interoperability — AbuseFilter can be made to check if the action variable's value is comment to write filters that apply only to comments made via the Comments extension; the new_wikitext variable contains the actual comment text, and the new_size variable is calculated on-demand based on the value of the new_wikitext variable. Refer to AbuseFilter's documentation for more details on how those variables and filters work.
    • The new configuration variable $wgCommentsAbuseFilterGroup can be set to 'default' to make existing AbuseFilter filters apply to comments as well. By default, it is set to 'comment', so only filters specifically designed to target comments will be executed against comments made via the Comments extension.

国际化

The Comments extension currently has (partial or full) support for 68 different languages, including English. Please visit translatewiki.net if you want to translate Comments or other extensions of the social tools family of extensions into your language or modify existing translations.

參見