Extension:AJAXPoll

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual
Crystal Clear action run.png
AJAX Poll

Release status: stable

Implementation Parser extension
Description Allows AJAX-based polls with <poll> tag
Author(s) Dariusz Siedlecki, Jack Phoenix, Thomas Gries
Latest version 1.87 (2013-10-12)
MediaWiki 1.16+
trunk version works with mw trunk
Database changes php update.php
License GFDL
Download
Example Any ShoutWiki site
Hooks used
ParserFirstCallInit

LoadExtensionSchemaUpdates

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

Check usage and version matrix; code metrics
Bugs: list open list all report

AJAX Poll extension allows one or more AJAX-based polls on MediaWiki pages with <poll> tag.

Installation[edit | edit source]

You can download the extension directly from the MediaWiki source code repository (browse code). You can get:

One of the extension's tags

Not all extensions have tags. Some extensions have tags for each release, in which case those tags have the same stability as the release. To download a tag

  • Go to the tags list
  • Click the name of the tag you want to download
  • Click "snapshot"
The latest version of one of the extension's branches

Each extension has a master branch containing the latest code (might be unstable). Extensions may have further branches as well.

  • Go to the branches list
  • Click the branch name
  • Click "snapshot"
A snapshot made during the release of a MediaWiki version.

This might be unstable and is not guaranteed to work with the associated MediaWiki version.

After you've got the code, save it into the extensions/AJAXPoll directory of your wiki.

If you are familiar with git and have shell access to your server, you can obtain the extension, with all its tags and branches, as follows:

cd extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/AJAXPoll.git
  • Download and extract the file(s) in a directory called AJAXPoll in your extensions/ folder. If you're a developer and this extension is in a Git repository, then instead you should clone the repository.
  • Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/AJAXPoll/AJAXPoll.php";
  • Run the update script which will automatically create the necessary database tables that this extension needs.
  • Done! Navigate to "Special:Version" on your wiki to verify that the extension is successfully installed.
# if you want to restrict the poll
# use the following code lines after calling the AJAXPoll extension
# to restrict to user group (example)

# The 'ajaxpoll-view-results-before-vote' group permission allows the specified
# group members to view poll results even without having voted
# but only if the high-level group permission 'ajaxpoll-vote' allows to view
# results in general.
#
# This 'ajaxpoll-view-results-before-vote' can be overwritten with the specific
# per-poll setting "show-results-before-voting" which takes precedence over the
# group permission.
#
# permission 'ajaxpoll-view-results' >>
# >> per-poll setting "show-results-before-voting" (if present)
# >> permission 'ajaxpoll-view-results-before-vote'

# anons
# default: anons cannot vote and will never see results
$wgGroupPermissions['*']['ajaxpoll-vote'] = false;
$wgGroupPermissions['*']['ajaxpoll-view-results'] = false;
$wgGroupPermissions['*']['ajaxpoll-view-results-before-vote'] = false;
 
# users
# default: users can vote and can see poll results - when they have voted
$wgGroupPermissions['user']['ajaxpoll-vote'] = true;
$wgGroupPermissions['user']['ajaxpoll-view-results'] = true;

If you want to disable the automatic tracking category then set the text MediaWiki:ajaxpoll-tracking-category in your wiki to "-" (minus).

Usage[edit | edit source]

<poll>
Do you like this poll ?
Yes, it is awesome.
Yes.
No, I do not like polls.
</poll>

20120216 AJAX Poll screenshot.png

If you want this, you can allow or deny the result-viewing before voting per-poll by adding the show-results-before-voting parameter in the opening tag:

<poll show-results-before-voting>
<poll show-results-before-voting=1>
<poll show-results-before-voting=0>

If the first line after <poll> is "STATS", then some statistics about the wiki and its polls will be displayed. These statistics are not localizable and this whole feature will probably be removed (or at least refactored, but probably removed) in the future.