Extension:QrCode

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

Release status: beta

Implementation Parser function, Media
Description Generates and adds QrCodes as PNG to wiki pages.
Author(s) David Raison (Kwisatztalk)
Latest version 0.11 (2011-11-29)
MediaWiki 1.12 - 1.17.x
License GNU Lesser General Public License
Download Template:WikimediaDownload/svn
Example QrCode generated for page URL

Translate the QrCode extension if possible

Check usage and version matrix; code metrics

Description[edit | edit source]

Generates qrcodes and adds them to your wiki pages.

Usage[edit | edit source]

This parser function has several options. The simplest use of the function is as follows:

{{#qrcode:}}

Not specifying any options generates a qrcode with the URL of the wiki page the function is used or transcluded in.

You can also specify options such as the error correction (ecc), size of the squares (size) and the margin to the code (boundary):

{{#qrcode: ecc=Q
 | size=4
 | boundary=5
 | label=URL replaced by this text
 | scheme=http
}}

Where ecc can be either of L,M,Q or H
You can force the url of your qrcodes to use another scheme than the one the author uses with the scheme parameter.

  • Note:* as the qrcodes are generated in the background, it can take a while for them to appear on your pages.

Setup[edit | edit source]

Requirements[edit | edit source]

  • libqrencode
  • PHP5
  • PHP GD2 extension with JPEG and PNG support
  • phpqrcode (included)
  • mkdir command is used, so does not work on Windows without some work

Download[edit | edit source]

You can download the code directly via SVN from the MediaWiki source code repository, at http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/QrCode/. From a command line, you can call the following:

svn checkout http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/QrCode/

Installation[edit | edit source]

Place the QrCode directory within the main MediaWiki 'extensions' directory.

Then, in the file LocalSettings.php in the main MediaWiki directory, add the following line:

include_once("$IP/extensions/QrCode/QrCode.php");

Settings[edit | edit source]

The following settings are optional and will be overwritten by specifying diverging settings in the function itself:

$wgQrCodeECC      = 'M';     // L,M,Q,H
$wgQrCodeSize     = 4;       // pixel size of black squares
$wgQrCodeBoundary = 0;       // margin around qrcode
$wgQrCodeForceScheme = 'http';  // force http links even for https pages

Release Notes[edit | edit source]

  • 0.11 - Add compatibility with 1.17, allow scheme forcing.
  • 0.09 - Remove option to rename bot, removed label sanitization.
  • 0.08 - Fix /Impersonation bug. QrCodes are now generated in the background.
  • 0.06 - Replaced filenames by hashes, changed handling of Mediawiki's title object.
  • 0.03 - Changed the way the MWQrCode class is instantiated, changed property handling.
  • 0.02 - Changed parser hook (Jeroen De Dauw), added phpqrcode libary.
  • 0.01 - Initial release.

Dev[edit | edit source]

Known Bugs[edit | edit source]

  • Get this error message applying QrCode:
Fatal error: require() [function.require]: Failed opening required '.../extensions/QrCode/phpqrcode/qrlib.php'
(include_path='.../includes:.../languages:.:/usr/share/php5:/usr/share/php') in .../includes/AutoLoader.php on line 1147
  • error when trying to svn co:
svn: warning: Error handling externals definition for 'QrCode/phpqrcode':
svn: warning: Repository moved permanently to 'https://svn.code.sf.net/p/phpqrcode/code/trunk'; please relocate

Todo[edit | edit source]

  • Review qrCode generation request (what happens when you hit the page and the file has not yet been generated?)
  • Update (i.e. replace) the image file when the QrCode arguments (ecc,size,boundary or scheme) change.
  • Ask whether qrcodes linked to a page should also be removed on the removal of the page.
  • Add an option to purge all qrcodes from the wiki.
  • Purge qrcodes from the filestore when they're not linked on any page anymore