Query printer boilerplate guideline

From semantic-mediawiki.org

The result printer boilerplate should enable inexperienced as well as experienced developers quickly to become acquainted with the specifics of a SRF result printer implementation. The aim is to make it easier to gain access in how to write a result printer without having to worry to much about a starting point. The current boilerplate implementation has been tested with SRF 1.7/SRF 1.8.

Where to start with ?[edit]

File Task / Comment
[1] Write your result printer


PHP module implementation

For details, please read available inline comments. For SRF specific class references, please have a look at this section.

ext.srf.boilerplate.simple.js JS module implementation

.../boilerplate/resources/... JS module which represents a simple implementation on how to communicate with your PHP printer module. For information about plug-ins and JavaScript, please have a look at this section.

ext.srf.boilerplate.namespace.js JS module implementation

.../boilerplate/resources/... JS module using class instances that is more coherent with Semantic Result Formats coding convention to avoid pollution of the "global($)" namespace and at the same time enabling to make functions reusable with the SRF extension family.

SRF_Resources.php Resource module registration

Register modules used for this format. For details, please read available inline comments.

// Simple implementation
$wgResourceModules['ext.srf.boilerplate.simple'] ...
[2] Register your result printer
SemanticResultFormats.php Register your class
// Boilerplate
// Uncomment the line below and adopt the class name
// $wgAutoloadClasses['SRFBoilerplate'] = $formatDir . 'boilerplate/SRF_Boilerplate.php';
Assign a format identifier
// Assign the Boilerplate class to a format identifier
// 'boilerplate' => 'SRFBoilerplate',
SRF_Settings.php Enable access
// Boilerplate
// Enable access to the format identifier
// 'boilerplate',
[3] Register your result printer test
SRF_Hooks.php Register a test class

For information about tests, please have a look at this section.

// Boilerplate
// Register your testclass
// 'formats/Boilerplate',
BoilerplateTest.php Create a test file

See .../tests/phpunit/formats/BoilerplateTest.php

[4] Register new messages
SRF_Messages.php Add additional messages that are introduced with the new result printer such as:
  • Printer name srf-printername-...
  • Parameters srf-paramdesc-...
  • Labels used in JavaScript
  • etc.