Extension:Comments

This page is a translated version of the page Extension:Comments and the translation is 94% complete.
MediaWiki 拡張機能マニュアル
Comments
リリースの状態: 安定
実装 パーサー拡張機能 , フック
説明 記事にコメントできるようにする ‎<comments /> パーサー フック タグを追加する
作者
最新バージョン 5.0
MediaWiki 1.39+
データベースの変更 はい
テーブル Comments
Comments_Vote
Comments_block
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
  • $wgCommentsDefaultAvatar
  • $wgCommentsInRecentChanges
  • $wgCommentsAbuseFilterGroup
  • $wgCommentsSortDescending
‎<comments />
  • comment
  • commentadmin
  • commentlinks
  • comment-delete-own
Quarterly downloads 74 (Ranked 80th)
translatewiki.net で翻訳を利用できる場合は、Comments 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

Extension:Commentsは、‎<comments />パーサーフックタグを追加して、タグが存在する記事にコメントできるようにします。

Comment actions are logged to Special:Log/comments, but by default they're hidden, just like patrol log entries. $wgCommentsInRecentChanges = true; を設定して、コメントの記録項目をを Special:RecentChanges で表示できます (バージョン 2.8 以降で利用可能)。

コード修正の大部分はMiszaJack Phoenixで行われました。

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のCommentsという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Comments
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'Comments' );
    
  • 更新スクリプトを実行します。このスクリプトは、この拡張機能が必要とするデータベーステーブルを自動的に作成します。
  •   完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
You will need to download the master version in order 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" /> — 利用者がコメントを否定的 (反対) に評価するのを防ぎ、肯定的 (賛成) 投票のみを許可します。

今日のコメント

この拡張機能には、「Comments of the Day」(訳:今日のコメント)機能(‎<commentsoftheday />)が付属しており、デフォルトでは「無効」になっています。 require_once行の後に以下を追加することにより、WikiのLocalSettings.phpでこの機能を有効にできます。

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

nocache引数がパーサーフック(<commentsoftheday nocache=true />のように)に渡される場合、 パーサーフックはmemcachedを使用せず、キャッシュではなくデータベースからデータをフェッチするだけです。 最新のデータを表示する場合に役立ちますが、サーバーに非常に負荷がかかる可能性があります。

利用者権限

この拡張機能は、以下の新しい利用者権限を追加します:

  • comment - (コメントを投稿できます)
  • commentlinks - (コメントに外部リンクを投稿できます)
  • commentadmin - 利用者が投稿したコメントを削除できます
  • comment-delete-own - which allows deleting one's own comments, e.g.
$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'] — amount of points to give out when another user gives "thumbs up" to your comment.
  • $wgUserStatsPointValues['comment_ignored'] — amount of points to give out when another user adds your comments to their ignore list (Special:CommentIgnoreList).

パラメーター

  • $wgCommentsDefaultAvatar — path to an image which will be displayed instead of an avatar if social tools (SocialProfile extension) aren't installed. 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 would like AbuseFilter to pull all of 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 into the database, on 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 in general 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.

関連項目