Semantic MediaWiki and related extensions
Public Member Functions | List of all members
SMW\Query\ResultPrinter Interface Reference
Inheritance diagram for SMW\Query\ResultPrinter:
Inheritance graph
[legend]

Public Member Functions

 getResult (QueryResult $results, array $fullParams, $outputMode)
 
 getQueryMode ( $context)
 
 getName ()
 
 setShowErrors ( $show)
 
 getParamDefinitions (array $definitions)
 
 isExportFormat ()
 

Detailed Description

Interface for SMW result printers.

GNU GPL v2+

Since
1.8
Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
Markus Krötzsch

Member Function Documentation

◆ getName()

SMW\Query\ResultPrinter::getName ( )

◆ getParamDefinitions()

SMW\Query\ResultPrinter::getParamDefinitions ( array  $definitions)

◆ getQueryMode()

SMW\Query\ResultPrinter::getQueryMode (   $context)

This function determines the query mode that is to be used for this printer in various contexts. The query mode influences how queries to that printer should be processed to obtain a result. Possible values are SMWQuery::MODE_INSTANCES (retrieve instances), SMWQuery::MODE_NONE (do nothing), SMWQuery::MODE_COUNT (get number of results), SMWQuery::MODE_DEBUG (return debugging text). Possible values for context are SMWQueryProcessor::SPECIAL_PAGE, SMWQueryProcessor::INLINE_QUERY, SMWQueryProcessor::CONCEPT_DESC.

The default implementation always returns SMWQuery::MODE_INSTANCES. File exports like RSS will use MODE_INSTANCES on special pages (so that instances are retrieved for the export) and MODE_NONE otherwise (displaying just a download link).

Parameters
$context
Returns
integer

Implemented in SMW\Query\ResultPrinters\ResultPrinter, SMW\Query\ResultPrinters\FeedExportPrinter, ModernTimeline\ModernTimelinePrinter, and SMW\Query\ResultPrinters\FileExportPrinter.

◆ getResult()

SMW\Query\ResultPrinters\ResultPrinter::getResult ( QueryResult  $results,
array  $fullParams,
  $outputMode 
)
final

Main entry point: takes an QueryResult and parameters given as key-value-pairs in an array, and returns the serialised version of the results, formatted as HTML or Wiki or whatever is specified. Normally this is not overwritten by subclasses.

If the outputmode is SMW_OUTPUT_WIKI, then the function will return something that is suitable for being used in a MediaWiki parser function, i.e. a wikitext strong or an array with flags and the string as entry 0. See Parser::setFunctionHook() for documentation on this. In all other cases, the function returns just a string.

For outputs SMW_OUTPUT_WIKI and SMW_OUTPUT_HTML, error messages or standard "further results" links are directly generated and appended. For SMW_OUTPUT_FILE, only the plain generated text is returned.

Note
A note on recursion: some query printers may return wiki code that comes from other pages, e.g. from templates that are used in formatting or from embedded result pages. Both kinds of pages may contain #ask queries that do again use new pages, so we must care about recursion. We do so by simply counting how often this method starts a subparse and stopping at depth 2. There is one special case: if this method is called outside parsing, and the concrete printer returns wiki text, and wiki text is requested, then we may return wiki text with sub-queries to the caller. If the caller parses this (which is likely) then this will again call us in parse-context and all recursion checks catch. Only the first level of parsing is done outside and thus not counted. Thus you effectively can get down to level 3. The basic maximal depth of 2 can be changed by setting the variable SMWResultPrinter::$maxRecursionDepth (in LocalSettings.php, after enableSemantics()). Do this at your own risk.
Parameters
$resultsQueryResult
$fullParamsarray
$outputModeinteger
Returns
string
See also
IResultPrinter::getResult
Note
: since 1.8 this method is final, since it's the entry point. Most logic has been moved out to buildResult, which you can override.
Parameters
$resultsQueryResult
$fullParamsarray
$outputModeinteger
Returns
string

◆ isExportFormat()

SMW\Query\ResultPrinter::isExportFormat ( )

◆ setShowErrors()

SMW\Query\ResultPrinter::setShowErrors (   $show)

Set whether errors should be shown. By default they are.

Parameters
boolean$show

Implemented in SMW\Query\ResultPrinters\ResultPrinter, and ModernTimeline\ModernTimelinePrinter.


The documentation for this interface was generated from the following file:

About | General disclaimer | Privacy policy