Extension:Comments

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Comments

Release status:Extension status stable

Comments.png
ImplementationTemplate:Extension#type Parser extension, Hook
DescriptionTemplate:Extension#description Adds <comments /> parser hook tag that allows commenting on articles
Author(s)Template:Extension#username David Pean
Misza
Jack Phoenix
Adam Carter
Latest versionTemplate:Extension#version 4.2.1 (2016-08-31; 6 months ago (2016-08-31))
MediaWikiTemplate:Extension#mediawiki 1.28+
Database changesTemplate:Extension#needs-updatephp Yes
TablesTemplate:Extension#table1 Comments
Comments_Vote
Comments_block
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
ExampleTemplate:Extension#example Social Tools Development Wiki
ParametersTemplate:Extension#parameters
  • $wgCommentsDefaultAvatar
  • $wgCommentsInRecentChanges
  • $wgCommentsSortDescending
TagsTemplate:Extension#tags
<comments />
Added rightsTemplate:Extension#rights
  • comment
  • commentadmin
  • commentlinks
Hooks usedTemplate:Extension#hook
MagicWordwgVariableIDsManual:Hooks/MagicWordwgVariableIDs
ParserFirstCallInitManual:Hooks/ParserFirstCallInit
ParserGetVariableValueSwitchManual:Hooks/ParserGetVariableValueSwitch
LoadExtensionSchemaUpdatesManual:Hooks/LoadExtensionSchemaUpdates
Hooks providedTemplate:Extension#newhook
Comment::add
Comment::delete
Comment::isSpam

Translate the Comments extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The Comments extension adds the parser hook tag to allow commenting on articles where the tag is present.

Comment actions are logged to Special:Log/comments, but by default they're hidden, just like patrol log entries. You can set $wgCommentsInRecentChanges = true; to show comments log entries in Special:RecentChanges (available in version 2.8+).

Majority of the code fixes were done by Misza and Jack Phoenix.

Installation[edit]

  • Download and place the file(s) in a directory called Comments in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    wfLoadExtension( 'Comments' );
    
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • YesY Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
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.

Usage[edit]

  • <comments /> — basic comment form, sufficient for most things
  • <comments allow="Derfel,Jack Phoenix,Misza" /> — only allows the users Derfel, Jack Phoenix and Misza to submit comments
  • <comments voting="Plus" /> — prevents users from rating comments negatively (thumb down), allowing only positive (thumb up) votes

Comments of the Day[edit]

The extension also comes with a "Comments of the Day" feature (<commentsoftheday />), which by default is not enabled. You can enable this feature in the wiki's LocalSettings.php, by adding the following after the require_once line:

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

If the nocache argument is passed to the parser hook (like this: <commentsoftheday nocache=true />), the parser hook will not use memcached and will just fetch the data from the database instead of cache. This is useful if you want to show the most up-to-date data, but it can be very server-intensive.

User rights[edit]

This extension adds three new user rights:

  • comment (which allows posting comments)
  • commentlinks (which allows posting external links in comments)
  • commentadmin (which allows deleting user-posted comments), e.g.
$wgGroupPermissions['sysop']['commentadmin'] = true;

By default, everyone, even anonymous users, can post comments, but posting comments that contain external links is limited to autoconfirmed users.

If you want anonymous users to be able to post external links, add this after the require_once:

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

By default only users in the commentadmin group can delete comments.

User points[edit]

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).

Parameters[edit]

  • $wgCommentsDefaultAvatar — path to an image which will be displayed instead of an avatar if social tools (SocialProfile extension) aren't installed. Should be 50x50px.
  • $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.

Magic words/Parser functions[edit]

Comments includes 2 magic words and a parser function:

  • {{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.

Hooks[edit]

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))

Internationalization[edit]

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 into your language.

TODO list[edit]

  1. HTML output is not valid XHTML - would be nice if it were but we can live without that
  2. Would be nice if there was a special page that gives a overview of all uses of the Comments extension on all pages (for an adminstrator to be able to moderate easier)


Social toolsSocial tools
SocialProfileExtension:SocialProfile OverviewExtension:SocialProfileDeveloper infoExtension:SocialProfile/For developersScreenshotsExtension:SocialProfile/ScreenshotsHistorySocial tools#History
Other social extensions Automatic Board WelcomeExtension:Automatic Board WelcomeBlogPageExtension:BlogPageChallengeExtension:ChallengeFanBoxesExtension:FanBoxesMiniInviteExtension:MiniInviteNewUsersListExtension:NewUsersListPictureGameExtension:PictureGamePollNYExtension:PollNYQuizGameExtension:QuizGameRandomFeaturedUserExtension:RandomFeaturedUserRandomGameUnitExtension:RandomGameUnitRandomUsersWithAvatarsExtension:RandomUsersWithAvatarsSiteMetricsExtension:SiteMetricsSiteScoutExtension:SiteScoutSportsTeamsExtension:SportsTeamsUserStatusExtension:UserStatusUserWelcomeExtension:UserWelcome
Other related extensions

(which do not depend on SocialProfile)

AnswersExtension:AnswersAJAXPollExtension:AJAXPollCommentsExtension:CommentsImageRatingExtension:ImageRatingLinkFilterExtension:LinkFilterMediaWikiChatExtension:MediaWikiChatNewSignupPageExtension:NewSignupPageTopListsExtension:TopListsVideoExtension:VideoVoteNYExtension:VoteNYWikiForumExtension:WikiForumWikiTextLoggedInOutExtension:WikiTextLoggedInOut