Semantic MediaWiki and related extensions
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SMW\Query\ResultPrinters\ResultPrinter Class Reference
Inheritance diagram for SMW\Query\ResultPrinters\ResultPrinter:
Inheritance graph
[legend]
Collaboration diagram for SMW\Query\ResultPrinters\ResultPrinter:
Collaboration graph
[legend]

Public Member Functions

 __construct ( $format, $inline=true)
 
 setQueryContext ( $queryContext)
 
 msg ()
 
 setRecursiveTextProcessor (RecursiveTextProcessor $recursiveTextProcessor)
 
 isEnabledFeature ( $feature)
 
 copyParser ()
 
 registerResources (array $modules=[], array $styleModules=[])
 
 getQueryMode ( $context)
 
 getName ()
 
 setShowErrors ( $show)
 
 getParameters ()
 
 getParamDefinitions (array $definitions)
 
 isExportFormat ()
 
 isDeferrable ()
 
 supportsRecursiveAnnotation ()
 
 getDefaultSort ()
 
- Public Member Functions inherited from SMW\Query\ResultPrinter
 getResult (QueryResult $results, array $fullParams, $outputMode)
 

Public Attributes

const DEFERRED_DATA = 'deferred.data'
 

Static Public Attributes

static $maxRecursionDepth = 2
 

Protected Member Functions

 getResultText (QueryResult $res, $outputMode)
 
 buildResult (QueryResult $results)
 
 handleNonFileResult ( $result, QueryResult $results, $outputmode)
 
 handleParameters (array $params, $outputMode)
 
 postProcessParameters ()
 
 getLinker ( $firstcol=false)
 
 getLink (QueryResult $res, $outputMode, $classAffix='')
 
 getFurtherResultsLink (QueryResult $res, $outputMode)
 
 getErrorString (QueryResult $res)
 
 getResources ()
 
 escapeText ( $text, $outputmode)
 
 getSearchLabel ( $outputmode)
 
 linkFurtherResults (QueryResult $results)
 
 addError ( $errorMessage)
 

Protected Attributes

 $params
 
 $fullParams
 
 $outputMode
 
 $results
 
 $mIntro = ''
 
 $mOutro = ''
 
 $mSearchlabel = null
 
 $mDefault = ''
 
 $mFormat
 
 $mLinkFirst
 
 $mLinkOthers
 
 $mShowHeaders = SMW_HEADERS_SHOW
 
 $mShowErrors = true
 
 $mInline
 
 $mLinker
 
 $mErrors = []
 
 $isHTML = false
 
 $hasTemplates = false
 
 $recursiveTextProcessor
 
 $transcludeAnnotation = true
 

Detailed Description

Abstract base class for SMW's novel query printing mechanism. It implements part of the former functionality of SMWInlineQuery (everything related to output formatting and the corresponding parameters) and is subclassed by concrete printers that provide the main formatting functionality.

GNU GPL v2+

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

Constructor & Destructor Documentation

◆ __construct()

SMW\Query\ResultPrinters\ResultPrinter::__construct (   $format,
  $inline = true 
)

Constructor. The parameter $format is a format string that may influence the processing details.

Do not override in deriving classes.

Parameters
string$format
boolean$inlineOptional since 1.9

TODO: how can we get the default or user skin here (depending on context)?

Member Function Documentation

◆ addError()

SMW\Query\ResultPrinters\ResultPrinter::addError (   $errorMessage)
protected

Adds an error message for a parameter handling error so a list of errors can be created later on.

Since
1.6
Parameters
string$errorMessage

◆ buildResult()

SMW\Query\ResultPrinters\ResultPrinter::buildResult ( QueryResult  $results)
protected

Build and return the HTML result.

Since
1.8
Parameters
QueryResult$results
Returns
string

◆ copyParser()

SMW\Query\ResultPrinters\ResultPrinter::copyParser ( )
Since
3.1
Returns
Parser

◆ escapeText()

SMW\Query\ResultPrinters\ResultPrinter::escapeText (   $text,
  $outputmode 
)
protected

If $outputmode is SMW_OUTPUT_HTML, escape special characters occurring in the given text. Otherwise return text as is.

Parameters
string$text
$outputmode
Returns
string

◆ getDefaultSort()

SMW\Query\ResultPrinters\ResultPrinter::getDefaultSort ( )
Since
2.5
Returns
string

◆ getErrorString()

SMW\Query\ResultPrinters\ResultPrinter::getErrorString ( QueryResult  $res)
protected

Provides a simple formatted string of all the error messages that occurred. Can be used if not specific error formatting is desired. Compatible with HTML and Wiki.

Parameters
QueryResult$res
Returns
string

◆ getFurtherResultsLink()

SMW\Query\ResultPrinters\ResultPrinter::getFurtherResultsLink ( QueryResult  $res,
  $outputMode 
)
protected

Gets a SMWInfolink object that allows linking to further results for the query.

Since
1.8
Parameters
QueryResult$res
$outputMode
Returns
SMWInfolink

◆ getLink()

SMW\Query\ResultPrinters\ResultPrinter::getLink ( QueryResult  $res,
  $outputMode,
  $classAffix = '' 
)
protected

Gets a SMWInfolink object that allows linking to a display of the query result.

Since
1.8
Parameters
QueryResult$res
$outputMode
string$classAffix
Returns
SMWInfolink

◆ getLinker()

SMW\Query\ResultPrinters\ResultPrinter::getLinker (   $firstcol = false)
protected

Depending on current linking settings, returns a linker object for making hyperlinks or NULL if no links should be created.

Parameters
boolean$firstcolTrue of this is the first result column (having special linkage settings).
Returns
Linker|null

◆ getName()

SMW\Query\ResultPrinters\ResultPrinter::getName ( )
See also
IResultPrinter::getName
Returns
string

Implements SMW\Query\ResultPrinter.

◆ getParamDefinitions()

SMW\Query\ResultPrinters\ResultPrinter::getParamDefinitions ( array  $definitions)
See also
IResultPrinter::getParamDefinitions
Since
1.8
Parameters
ParamDefinition[]$definitions
Returns
array

Implements SMW\Query\ResultPrinter.

◆ getParameters()

SMW\Query\ResultPrinters\ResultPrinter::getParameters ( )

A function to describe the allowed parameters of a query using any specific format - most query printers should override this function.

Deprecated:
since 1.8, use getParamDefinitions instead.
Since
1.5
Returns
array

◆ getQueryMode()

SMW\Query\ResultPrinters\ResultPrinter::getQueryMode (   $context)
See also
IResultPrinter::getQueryMode
Parameters
$context
Returns
integer

Implements SMW\Query\ResultPrinter.

◆ getResources()

SMW\Query\ResultPrinters\ResultPrinter::getResources ( )
protected

Individual printer can override this method to allow for unified loading practice.

Styles are loaded first to avoid a possible FOUC (Flash of unstyled content).

Since
3.0
Returns
[]

◆ getResultText()

SMW\Query\ResultPrinters\ResultPrinter::getResultText ( QueryResult  $res,
  $outputMode 
)
abstractprotected

Return serialised results in specified format. Implemented by subclasses.

◆ getSearchLabel()

SMW\Query\ResultPrinters\ResultPrinter::getSearchLabel (   $outputmode)
protected

Get the string the user specified as a text for the "further results" link, properly escaped for the current output mode.

Parameters
$outputmode
Returns
string

◆ handleNonFileResult()

SMW\Query\ResultPrinters\ResultPrinter::handleNonFileResult (   $result,
QueryResult  $results,
  $outputmode 
)
protected

Continuation of getResult that only gets executed for non file outputs.

Since
1.6
Parameters
string$result
QueryResult$results
integer$outputmode
Returns
string

◆ handleParameters()

SMW\Query\ResultPrinters\ResultPrinter::handleParameters ( array  $params,
  $outputMode 
)
protected

Does any additional parameter handling that needs to be done before the actual result is build. This includes cleaning up parameter values and setting class fields.

Since 1.6 parameter handling should happen via validator based on the parameter definitions returned in getParameters. Therefore this method should likely not be used in any new code. It's mainly here for legacy reasons.

Since
1.6
Parameters
array$params
$outputMode

◆ isDeferrable()

SMW\Query\ResultPrinters\ResultPrinter::isDeferrable ( )
Since
3.0
Returns
boolean

◆ isEnabledFeature()

SMW\Query\ResultPrinters\ResultPrinter::isEnabledFeature (   $feature)
Since
2.5
Parameters
integer$feature
Returns
boolean

◆ isExportFormat()

SMW\Query\ResultPrinters\ResultPrinter::isExportFormat ( )
See also
IResultPrinter::isExportFormat
Since
1.8
Returns
boolean

Implements SMW\Query\ResultPrinter.

◆ linkFurtherResults()

SMW\Query\ResultPrinters\ResultPrinter::linkFurtherResults ( QueryResult  $results)
protected

Check whether a "further results" link would normally be generated for this result set with the given parameters. Individual result printers may decide to create or hide such a link independent of that, but this is the default.

Parameters
QueryResult$results
Returns
boolean

◆ msg()

SMW\Query\ResultPrinters\ResultPrinter::msg ( )

This method is added temporary measures to avoid breaking those that relied on the removed ContextSource interface.

Since
3.0
Returns

◆ postProcessParameters()

SMW\Query\ResultPrinters\ResultPrinter::postProcessParameters ( )
protected

Similar to handleParameters.

Since
1.8

◆ registerResources()

SMW\Query\ResultPrinters\ResultPrinter::registerResources ( array  $modules = [],
array  $styleModules = [] 
)
Since
3.0
Parameters
array$modules
array$styleModules

◆ setQueryContext()

SMW\Query\ResultPrinters\ResultPrinter::setQueryContext (   $queryContext)
Since
3.0
Parameters
integer$queryContext

◆ setRecursiveTextProcessor()

SMW\Query\ResultPrinters\ResultPrinter::setRecursiveTextProcessor ( RecursiveTextProcessor  $recursiveTextProcessor)
Since
3.0
Parameters
RecursiveTextProcessor$recursiveTextProcessor

◆ setShowErrors()

SMW\Query\ResultPrinters\ResultPrinter::setShowErrors (   $show)
See also
IResultPrinter::setShowErrors
Parameters
boolean$show

Implements SMW\Query\ResultPrinter.

◆ supportsRecursiveAnnotation()

SMW\Query\ResultPrinters\ResultPrinter::supportsRecursiveAnnotation ( )

Returns if the result printer supports using a "full parse" instead of a '[[SMW::off]]' . $wgParser->replaceVariables( $result ) . '[[SMW::on]]'

Since
3.0
Returns
boolean

Member Data Documentation

◆ $hasTemplates

SMW\Query\ResultPrinters\ResultPrinter::$hasTemplates = false
protected

If set, take the necessary steps to make sure that things like {{templatename| ...}} are properly processed if they occur in the result. Clearly, this is only relevant if the output is not HTML, i.e. it is ignored if SMWResultPrinter::$is_HTML is true. This setting is used only after the result text was generated.

Note
This requires extra processing and may make the result less useful for being used as a parameter for further parser functions. Use only if required.

◆ $isHTML

SMW\Query\ResultPrinters\ResultPrinter::$isHTML = false
protected

If set, treat result as plain HTML. Can be used by printer classes if wiki mark-up is not enough. This setting is used only after the result text was generated.

Note
HTML query results cannot be used as parameters for other templates or in any other way in combination with other wiki text. The result will be inserted on the page literally.

◆ $maxRecursionDepth

SMW\Query\ResultPrinters\ResultPrinter::$maxRecursionDepth = 2
static

This public variable can be set to higher values to allow more recursion; do this at your own risk! This can be set in LocalSettings.php, but only after enableSemantics().

◆ $mDefault

SMW\Query\ResultPrinters\ResultPrinter::$mDefault = ''
protected

Default return value for empty queries. Unescaped. Normally not used in sub-classes!

◆ $mIntro

SMW\Query\ResultPrinters\ResultPrinter::$mIntro = ''
protected

Text to print before the output in case it is not empty; assumed to be wikitext. Normally this is handled in SMWResultPrinter and can be ignored by subclasses.

◆ $mOutro

SMW\Query\ResultPrinters\ResultPrinter::$mOutro = ''
protected

Text to print after the output in case it is not empty; assumed to be wikitext. Normally this is handled in SMWResultPrinter and can be ignored by subclasses.

◆ $mSearchlabel

SMW\Query\ResultPrinters\ResultPrinter::$mSearchlabel = null
protected

Text to use for link to further results, or empty if link should not be shown. Unescaped! Use

See also
SMWResultPrinter::getSearchLabel() and
SMWResultPrinter::linkFurtherResults() instead of accessing this directly.

◆ DEFERRED_DATA

const SMW\Query\ResultPrinters\ResultPrinter::DEFERRED_DATA = 'deferred.data'

Individual printers can decide what sort of deferrable mode is used for the output. DEFERRED_DATA signals that the format expects only the data component to be loaded from the backend.


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

About | General disclaimer | Privacy policy