SMWQueryProcessor Class Reference
[SMWQuery]

Static class for accessing functions to generate and execute semantic queries and to serialise their results. More...

List of all members.

Static Public Member Functions

static getProcessedParams (array $params, array $printRequests=null, $unknownInvalid=true)
 Takes an array of unprocessed parameters, processes them using Validator, and returns them.
static createQuery ($querystring, array $params, $context=self::INLINE_QUERY, $format= '', array $extraprintouts=array())
 Parse a query string given in SMW's query language to create an SMWQuery.
static addThisPrintout (array &$printRequests, array $rawParams)
 Add the subject print request, unless mainlabel is set to "-".
static processFunctionParams (array $rawparams, &$querystring, &$params, &$printouts, $showmode=false)
 Preprocess a query as given by an array of parameters as is typically produced by the ask parser function.
static getResultFromFunctionParams (array $rawparams, $outputmode, $context=self::INLINE_QUERY, $showmode=false)
 Process and answer a query as given by an array of parameters as is typically produced by the ask parser function.
static getResultFromQueryString ($querystring, array $params, $extraprintouts, $outputmode, $context=self::INLINE_QUERY)
 Process a query string in SMW's query language and return a formatted result set as specified by $outputmode.
static getResultFromQuery (SMWQuery $query, array $params, $extraprintouts, $outputmode, $context=self::INLINE_QUERY, $format= '')
 TODO: document.
static getResultPrinter ($format, $context=self::SPECIAL_PAGE)
 Find suitable SMWResultPrinter for the given format.
static getParameters ()
 A function to describe the allowed parameters of a query using any specific format - most query printers should override this function.

Public Attributes

const SPECIAL_PAGE = 0
const INLINE_QUERY = 1
const CONCEPT_DESC = 2

Static Protected Member Functions

static getSortKeys (array $sortParam, array $orderParam, $defaultSort)
 Takes the sort and order parameters and returns a list of sort keys and a list of errors.
static getResultFormat (array $params)
 Determines the format from an array of parameters, and returns it.


Detailed Description

Static class for accessing functions to generate and execute semantic queries and to serialise their results.

Definition at line 15 of file SMW_QueryProcessor.php.


Member Function Documentation

static SMWQueryProcessor::getProcessedParams ( array $  params,
array $  printRequests = null,
unknownInvalid = true 
) [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
Parameters:
array $params
array $printRequests
boolean $unknownInvalid
Returns:
array

Definition at line 39 of file SMW_QueryProcessor.php.

Referenced by SMWQueryUIHelper::execute(), SMWSearchByProperty::getNearbyResults(), ApiSMWQuery::getQuery(), SDBrowseDataPage::outputResults(), and SMWConcept::render().

static SMWQueryProcessor::createQuery ( querystring,
array $  params,
context = self::INLINE_QUERY,
format = '',
array $  extraprintouts = array() 
) [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 $params These need to be the result of a list fed to getProcessedParams
$context 
string $format
array $extraprintouts
Returns:
SMWQuery

Definition at line 76 of file SMW_QueryProcessor.php.

References $smwgQConceptFeatures, $smwgQDefaultLimit, $smwgQDefaultNamespaces, $smwgQFeatures, $smwgQMaxLimit, SMWQuery::MODE_COUNT, SMWQuery::MODE_DEBUG, and SMWQuery::MODE_NONE.

Referenced by SMWQueryUIHelper::execute(), SMWSearchByProperty::getNearbyResults(), ApiSMWQuery::getQuery(), SDBrowseDataPage::outputResults(), SMWConcept::render(), and SMWQueryUIHelper::setQueryString().

static SMWQueryProcessor::getSortKeys ( array $  sortParam,
array $  orderParam,
defaultSort 
) [static, protected]

Takes the sort and order parameters and returns a list of sort keys and a list of errors.

Since:
1.7
Parameters:
array $sortParam
array $orders
string $defaultSort
Returns:
array ( keys => array(), errors => array() )

Definition at line 147 of file SMW_QueryProcessor.php.

References SMWPropertyValue::makeUserProperty().

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

Definition at line 204 of file SMW_QueryProcessor.php.

References SMWPrintRequest::PRINT_THIS.

Referenced by SMWQueryUIHelper::execute(), SMWSearchByProperty::getNearbyResults(), ApiSMWQuery::getQuery(), and SDBrowseDataPage::outputResults().

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 $printouts array of SMWPrintRequest
$showmode 

Definition at line 230 of file SMW_QueryProcessor.php.

References SMWPropertyValue::makeUserProperty(), SMWPrintRequest::PRINT_CATS, SMWPrintRequest::PRINT_CCAT, SMWPrintRequest::PRINT_PROP, and SMWPrintRequest::PRINT_THIS.

Referenced by ApiAsk::execute(), SMWQueryUIHelper::extractParameters(), SMWAskPage::extractQueryParameters(), and SDBrowseDataPage::outputResults().

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.

Definition at line 330 of file SMW_QueryProcessor.php.

Referenced by SMWShow::render(), and SMWAsk::render().

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 $params These need to be the result of a list fed to getProcessedParams
$extraprintouts 
$outputmode 
$context 

Definition at line 356 of file SMW_QueryProcessor.php.

static SMWQueryProcessor::getResultFromQuery ( SMWQuery query,
array $  params,
extraprintouts,
outputmode,
context = self::INLINE_QUERY,
format = '' 
) [static]

TODO: document.

Parameters:
SMWQuery $query
array $params These need to be the result of a list fed to getProcessedParams
$extraprintouts 
$outputmode 
$context 
$format 
Returns:
string

Definition at line 380 of file SMW_QueryProcessor.php.

References $smwgQuerySources, $store, SMWQuery::MODE_INSTANCES, SMWQuery::MODE_NONE, smwfEncodeMessages(), and smwfGetStore().

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

Definition at line 443 of file SMW_QueryProcessor.php.

References $smwgResultFormats.

Referenced by SMWParamFormat::doManipulation(), SMWQueryUIHelper::execute(), SMWSMWDoc::getFormatParameters(), SMWQueryUI::getFormatSelectBoxSep(), SMWQueryUIHelper::getHTMLResult(), SDBrowseDataPage::outputResults(), SMWQueryUIHelper::setParams(), and SMWAskPage::showFormatOptions().

static SMWQueryProcessor::getResultFormat ( array $  params  )  [static, protected]

Determines the format from an array of parameters, and returns it.

Deprecated:
since 1.6.2, removal in 1.8
Parameters:
array $params
Returns:
string

Definition at line 464 of file SMW_QueryProcessor.php.

References $smwgResultFormats, and SMWParamFormat::resolveFormatAliases().

static SMWQueryProcessor::getParameters (  )  [static]

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

TODO: refactor non-printer params up to the query processor and do all param handling there.

Since:
1.6.2
Returns:
array

Definition at line 495 of file SMW_QueryProcessor.php.

Referenced by SRFArray::getParameters(), and SMWAskPage::showFormatOptions().


Member Data Documentation

Definition at line 21 of file SMW_QueryProcessor.php.

Referenced by SMWShow::render().

Definition at line 22 of file SMW_QueryProcessor.php.

Referenced by SMWConcept::render().


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

Generated on Fri Feb 10 07:15:46 2012 for Semantic MediaWiki by  doxygen 1.5.6