Semantic MediaWiki and related extensions
Static Public Member Functions | List of all members
SMWQueryProcessor Class Reference
Inheritance diagram for SMWQueryProcessor:
Inheritance graph
[legend]
Collaboration diagram for SMWQueryProcessor:
Collaboration graph
[legend]

Static Public Member Functions

static setRecursiveTextProcessor (RecursiveTextProcessor $recursiveTextProcessor=null)
 
static getProcessedParams (array $params, array $printRequests=[], $unknownInvalid=true, $context=null, $showMode=false)
 
static createQuery ( $queryString, array $params, $context=self::INLINE_QUERY, $format='', array $extraPrintouts=[], $contextPage=null)
 
static addThisPrintout (array &$printRequests, array $rawParams)
 
static processFunctionParams (array $rawParams, &$querystring, &$params, &$printouts, $showMode=false)
 
static getComponentsFromFunctionParams (array $rawParams, $showMode)
 
static getQueryAndParamsFromFunctionParams (array $rawParams, $outputMode, $context, $showMode, $contextPage=null)
 
static getResultFromFunctionParams (array $rawParams, $outputMode, $context=self::INLINE_QUERY, $showMode=false)
 
static getResultFromQueryString ( $queryString, array $params, $extraPrintouts, $outputMode, $context=self::INLINE_QUERY)
 
static getResultFromQuery (SMWQuery $query, array $params, $outputMode, $context)
 
static getResultPrinter ( $format, $context=self::SPECIAL_PAGE)
 
static getParameters ( $context=null, $resultPrinter=null)
 
static getFormatParameters ( $format)
 

Additional Inherited Members

- Public Attributes inherited from SMW\Query\QueryContext
const SPECIAL_PAGE = 1000
 
const INLINE_QUERY = 1001
 
const DEFERRED_QUERY = 1002
 
const CONCEPT_DESC = 1003
 
const CURTAILMENT_MODE = 1004
 
const MODE_INSTANCES = 1
 
const MODE_COUNT = 2
 
const MODE_DEBUG = 3
 
const MODE_NONE = 4
 

Detailed Description

This file contains a static class for accessing functions to generate and execute semantic queries and to serialise their results.

Author
Markus Krötzsch Static class for accessing functions to generate and execute semantic queries and to serialise their results.

Member Function Documentation

◆ addThisPrintout()

static SMWQueryProcessor::addThisPrintout ( array &  $printRequests,
array  $rawParams 
)
static

Add the subject print request, unless mainlabel is set to "-".

Since
1.7
Parameters
array$printRequests
array$rawParams

◆ createQuery()

static SMWQueryProcessor::createQuery (   $queryString,
array  $params,
  $context = self::INLINE_QUERY,
  $format = '',
array  $extraPrintouts = [],
  $contextPage = null 
)
static

Parse a query string given in SMW's query language to create an SMWQuery. Parameters are given as key-value-pairs in the given array. The parameter $context defines in what context the query is used, which affects ceretain general settings. An object of type SMWQuery is returned.

The format string is used to specify the output format if already known. Otherwise it will be determined from the parameters when needed. This parameter is just for optimisation in a common case.

Parameters
string$queryString
array$paramsThese need to be the result of a list fed to getProcessedParams
$context
string$format
array$extraPrintouts
Returns
SMWQuery

◆ getComponentsFromFunctionParams()

static SMWQueryProcessor::getComponentsFromFunctionParams ( array  $rawParams,
  $showMode 
)
static

Preprocess a query as given by an array of parameters as is typically produced by the #ask parser function or by Special:Ask. The parsing results in a querystring, an array of additional parameters, and an array of additional SMWPrintRequest objects, which are returned in an array with three components. If $showMode is true then the input will be processed as if for #show. This uses a slightly different way to get the query, and different default labels (empty) for additional print requests.

Parameters
array$rawParams
boolean$showMode
Returns
array( string, array( string => string ), array( SMWPrintRequest ) )

◆ getFormatParameters()

static SMWQueryProcessor::getFormatParameters (   $format)
static

Returns the definitions of all parameters supported by the specified format.

Since
1.8
Parameters
string$format
Returns
ParamDefinition[]

◆ getParameters()

static SMWQueryProcessor::getParameters (   $context = null,
  $resultPrinter = null 
)
static

Produces a list of default allowed parameters for a result printer. Most query printers should override this function.

Since
1.6.2, return element type changed in 1.8
Parameters
integer | null$context
ResultPrinter | null$resultPrinter
Returns
IParamDefinition[]

◆ getProcessedParams()

static SMWQueryProcessor::getProcessedParams ( array  $params,
array  $printRequests = [],
  $unknownInvalid = true,
  $context = null,
  $showMode = false 
)
static

Takes an array of unprocessed parameters, processes them using Validator, and returns them.

Both input and output arrays are param name (string) => param value (mixed)

Since
1.6.2 The return value changed in SMW 1.8 from an array with result values to an array with Param objects.
Parameters
array$params
array$printRequests
boolean$unknownInvalid
Returns
Param[]

◆ getQueryAndParamsFromFunctionParams()

static SMWQueryProcessor::getQueryAndParamsFromFunctionParams ( array  $rawParams,
  $outputMode,
  $context,
  $showMode,
  $contextPage = null 
)
static

Process and answer a query as given by an array of parameters as is typically produced by the #ask parser function. The parameter $context defines in what context the query is used, which affects certain general settings.

The main task of this function is to preprocess the raw parameters to obtain actual parameters, printout requests, and the query string for further processing.

Since
1.8
Parameters
array$rawParamsuser-provided list of unparsed parameters
integer$outputModeSMW_OUTPUT_WIKI, SMW_OUTPUT_HTML, ...
integer$contextINLINE_QUERY, SPECIAL_PAGE, CONCEPT_DESC
boolean$showModeprocess like #show parser function?
Returns
array( SMWQuery, array of IParam )

◆ getResultFromFunctionParams()

static SMWQueryProcessor::getResultFromFunctionParams ( array  $rawParams,
  $outputMode,
  $context = self::INLINE_QUERY,
  $showMode = false 
)
static

Process and answer a query as given by an array of parameters as is typically produced by the #ask parser function. The result is formatted according to the specified $outputformat. The parameter $context defines in what context the query is used, which affects ceretain general settings.

The main task of this function is to preprocess the raw parameters to obtain actual parameters, printout requests, and the query string for further processing.

Note
Consider using getQueryAndParamsFromFunctionParams() and getResultFromQuery() instead.
Deprecated:
Will vanish after release of SMW 1.8. See SMW_Ask.php for example code on how to get query results from #ask function parameters.

◆ getResultFromQuery()

static SMWQueryProcessor::getResultFromQuery ( SMWQuery  $query,
array  $params,
  $outputMode,
  $context 
)
static

Create a fully formatted result string from a query and its parameters. The method takes care of processing various types of query result. Most cases are handled by printers, but counting and debugging uses special code.

Parameters
SMWQuery$query
array$paramsThese need to be the result of a list fed to getProcessedParams
integer$outputMode
integer$context
Since
before 1.7, but public only since 1.8
Returns
string

◆ getResultFromQueryString()

static SMWQueryProcessor::getResultFromQueryString (   $queryString,
array  $params,
  $extraPrintouts,
  $outputMode,
  $context = self::INLINE_QUERY 
)
static

Process a query string in SMW's query language and return a formatted result set as specified by $outputmode. A parameter array of key-value-pairs constrains the query and determines the serialisation mode for results. The parameter $context defines in what context the query is used, which affects certain general settings. Finally, $extraprintouts supplies additional printout requests for the query results.

Parameters
string$queryString
array$paramsThese need to be the result of a list fed to getProcessedParams
$extraPrintouts
$outputMode
$context
Returns
string
Deprecated:
Will vanish after release of SMW 1.8. See SMW_Ask.php for example code on how to get query results from #ask function parameters.

◆ getResultPrinter()

static SMWQueryProcessor::getResultPrinter (   $format,
  $context = self::SPECIAL_PAGE 
)
static

Find suitable SMWResultPrinter for the given format. The context in which the query is to be used determines some basic settings of the returned printer object. Possible contexts are SMWQueryProcessor::SPECIAL_PAGE, SMWQueryProcessor::INLINE_QUERY, SMWQueryProcessor::CONCEPT_DESC.

Parameters
string$format
$context
Returns
SMWResultPrinter
Exceptions
MissingResultFormatException

◆ processFunctionParams()

static SMWQueryProcessor::processFunctionParams ( array  $rawParams,
$querystring,
$params,
$printouts,
  $showMode = false 
)
static

Preprocess a query as given by an array of parameters as is typically produced by the #ask parser function. The parsing results in a querystring, an array of additional parameters, and an array of additional SMWPrintRequest objects, which are filled into call-by-ref parameters. $showMode is true if the input should be treated as if given by #show

Parameters
array$rawParams
string$querystring
array$params
array$printoutsarray of SMWPrintRequest
boolean$showMode
Deprecated:
Will vanish after SMW 1.8 is released. Use getComponentsFromFunctionParams which has a cleaner interface.

◆ setRecursiveTextProcessor()

static SMWQueryProcessor::setRecursiveTextProcessor ( RecursiveTextProcessor  $recursiveTextProcessor = null)
static
Since
3.0
Parameters
RecursiveTextProcessor | null$recursiveTextProcessor

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

About | General disclaimer | Privacy policy