SMWQueryUIHelper Class Reference

This class captures the core activities of what a semantic search page should do: take parameters, validate them and generate results, or errors, if any. More...

List of all members.

Public Member Functions

 __construct ($context=SMWQueryUIHelper::SPECIAL_PAGE)
 Although this constructor is publicly accessible, its use is discouraged.
 hasError ()
 Returns true if any errors have occured.
 getLimit ()
 Returns the limit of results defined.
 getOffset ()
 Returns the offset of results.
 hasFurtherResults ()
 Would there be more query results that were not shown due to a limit?
 getResultObject ()
 Returns a handle to the underlying Result object.
 getErrors ()
 Returns an array of errors, if any have occured.
 setQueryString ($queryString="", $enableValidation=false)
 Sets up a query.
 setPrintOuts (array $printOuts=array(), $enableValidation=false)
 Sets up any extra properties which need to be displayed with results.
 setParams (array $params=array(), $enableValidation=false)
 Sets the parameters for the query.
 extractParameters ($p)
 Processes the QueryString, Params, and PrintOuts.
 execute ()
 Executes the query.
 getHTMLResult ()
 Returns the results in HTML, or in case of exports, a link to the result.
 getAsk ()
 Returns the query in the ask format.
 getQueryString ()
 Returns the query.
 getResultCount ()
 Returns number of available results.
 getParameters ()
 Returns the parameter array.
 getPrintOuts ()
 Returns additional prinouts as an array of SMWPrintRequests.

Static Public Member Functions

static addUI (SpecialPage &$page)
 Register a Semantic Search Special Page.
static getUiList ()
 Returns an array of Semantic Search Special Pages.
static makeForInfoLink ($p, $enableValidation=false)
 Constructs a new SMWQueryUIHelper object when the query is passed to the UI in the Info-link format.
static makeForUI ($query, array $params, array $printouts, $enableValidation=false)
 Constructs a new SMWQueryUIHelper when the query is passed to the UI from a web form.

Public Attributes

const SPECIAL_PAGE = 0
 Constants define whether the parameters was passed from the ui form (SPECIAL_PAGE) or from the further results infolink (WIKI_LINK).
const WIKI_LINK = 1
 Has the query come from a special page, or from an InfoLink?

Static Protected Member Functions

static validateProperty ($property)
 Checks if $property exists in the wiki or not.

Protected Attributes

 $queryString = ''
 $parameters = array()
 $printOuts = array()
 $printOutStrings = array()

Static Protected Attributes

static $uiPages = array()

Private Attributes

 $errorsOccured = false
 $context
 $errors = array()
 $defaultResultPrinter = 'broadtable'
 The default result printer if no format is set at the higher level.
 $queryResult = null


Detailed Description

This class captures the core activities of what a semantic search page should do: take parameters, validate them and generate results, or errors, if any.

Query UIs may use this class to create a customised UI interface. In most cases, one is likely to extend the SMWQueryUI class to build a Search Special page. However in order to access some core featues, one may directly access the methods of this class.

This class does not define the format in which data should be passed through the web, except those already defined by SMWInfolink.

Author:
Devayon Das

Definition at line 18 of file SMW_QueryUIHelper.php.


Constructor & Destructor Documentation

SMWQueryUIHelper::__construct ( context = SMWQueryUIHelper::SPECIAL_PAGE  ) 

Although this constructor is publicly accessible, its use is discouraged.

Instantiation can instead be done by the makeForInfoLink() to handle infolink requests or makeForUI() to handle requests from a Query form.

Parameters:
mixed $context SMWQueryUIHelper::SPECIAL_PAGE | SMWQueryUIHelper::WIKI_LINK

Definition at line 100 of file SMW_QueryUIHelper.php.

References $context.


Member Function Documentation

SMWQueryUIHelper::hasError (  ) 

Returns true if any errors have occured.

Returns:
boolean

Definition at line 109 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getLimit (  ) 

Returns the limit of results defined.

If not set, it returns 0.

Returns:
integer

Definition at line 118 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getOffset (  ) 

Returns the offset of results.

If it isnt defined, returns a default value of 20.

Returns:
integer

Definition at line 132 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::hasFurtherResults (  ) 

Would there be more query results that were not shown due to a limit?

Returns:
boolean

Definition at line 145 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getResultObject (  ) 

Returns a handle to the underlying Result object.

Returns:
SMWQueryResult

Definition at line 158 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getErrors (  ) 

Returns an array of errors, if any have occured.

Returns:
array of strings

Definition at line 167 of file SMW_QueryUIHelper.php.

Referenced by execute().

static SMWQueryUIHelper::addUI ( SpecialPage &$  page  )  [static]

Register a Semantic Search Special Page.

This method can be used by any new Query UI to register itself. The corresponding method getUiList() would return the names of all lists Query UIs.

See also:
getUiList()
Parameters:
SpecialPage $page

Definition at line 181 of file SMW_QueryUIHelper.php.

static SMWQueryUIHelper::getUiList (  )  [static]

Returns an array of Semantic Search Special Pages.

See also:
addUI()
Returns:
array of SpecialPage

Definition at line 195 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::setQueryString ( queryString = "",
enableValidation = false 
)

Sets up a query.

If validation is enabled, then the query string is checked for errors.

Parameters:
string $queryString The query
Returns:
array array of errors, if any.

Definition at line 206 of file SMW_QueryUIHelper.php.

References $errors, $queryString, and SMWQueryProcessor::createQuery().

SMWQueryUIHelper::setPrintOuts ( array $  printOuts = array(),
enableValidation = false 
)

Sets up any extra properties which need to be displayed with results.

Each string in printouts should be of the form "?property" or "property".

When validation is enabled, the values in $printOuts are checked against properties which exist in the wiki, and a warning string (for each property) is returned. Returns an empty array otherwise.

Parameters:
array $printOuts Array of strings
boolean $enableValidation
Returns:
array Array of errors messages (strings), if any.

Definition at line 240 of file SMW_QueryUIHelper.php.

References $errors, $printOuts, and validateProperty().

SMWQueryUIHelper::setParams ( array $  params = array(),
enableValidation = false 
)

Sets the parameters for the query.

The structure of $params is defined partly by ask and also by the Result Printer used. When validation is enabled, $params are checked for conformance, and error messages, if any, are returned.

Although it is not mandatory for any params to be set while calling this method, this method must be called so that default parameters are used.

int $smwgQMaxInlineLimit array $smwgResultFormats

Parameters:
array $params
boolean $enableValidation
Returns:
array of strings

Definition at line 279 of file SMW_QueryUIHelper.php.

References $errors, $smwgQMaxInlineLimit, $smwgResultFormats, and SMWQueryProcessor::getResultPrinter().

Referenced by extractParameters().

SMWQueryUIHelper::extractParameters ( p  ) 

Processes the QueryString, Params, and PrintOuts.

Todo:
Combine this method with execute() or remove it altogether.

Definition at line 324 of file SMW_QueryUIHelper.php.

References SMWInfolink::decodeParameters(), SMWQueryProcessor::processFunctionParams(), and setParams().

SMWQueryUIHelper::execute (  ) 

Executes the query.

This method can be called once $queryString, $parameters, $printOuts are set either by using the setQueryString(), setParams() and setPrintOuts() followed by extractParameters(), or one of the static factory methods such as makeForInfoLink() or makeForUI().

Errors, if any can be accessed from hasError() and getErrors().

Definition at line 348 of file SMW_QueryUIHelper.php.

References $errors, SMWQueryProcessor::addThisPrintout(), SMWQueryProcessor::createQuery(), getErrors(), SMWQueryProcessor::getProcessedParams(), SMWQueryProcessor::getResultPrinter(), SMWWikiPageValue::makePageFromTitle(), smwfGetStore(), and SMWQueryProcessor::SPECIAL_PAGE.

SMWQueryUIHelper::getHTMLResult (  ) 

Returns the results in HTML, or in case of exports, a link to the result.

This method can only be called after execute() has been called.

Returns:
string of all the HTML generated

Definition at line 436 of file SMW_QueryUIHelper.php.

References $queryResult, SMWQueryProcessor::getResultPrinter(), and SMWQueryProcessor::SPECIAL_PAGE.

SMWQueryUIHelper::getAsk (  ) 

Returns the query in the ask format.

Returns:
string

Definition at line 463 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getQueryString (  ) 

Returns the query.

Returns:
string

Definition at line 481 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getResultCount (  ) 

Returns number of available results.

Returns:
int

Definition at line 490 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getParameters (  ) 

Returns the parameter array.

Returns:
array

Definition at line 503 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::getPrintOuts (  ) 

Returns additional prinouts as an array of SMWPrintRequests.

Returns:
array SMWPrintRequest or an empty array

Definition at line 512 of file SMW_QueryUIHelper.php.

static SMWQueryUIHelper::makeForInfoLink ( p,
enableValidation = false 
) [static]

Constructs a new SMWQueryUIHelper object when the query is passed to the UI in the Info-link format.

This constructor should be used for handling the "further results" links in wiki-pages that use ask. If your search UI handles form parameters only, then consider using makeForUI().

If any errors do occur while parsing parameters, they may be accessed from hasError() and getErrors().

Parameters:
string $p parameters of the query.
boolean $enableValidation
Returns:
SMWQueryUIHelper
Todo:
Handle validation for infolink parameters

Definition at line 536 of file SMW_QueryUIHelper.php.

Referenced by SMWQueryUI::execute().

static SMWQueryUIHelper::makeForUI ( query,
array $  params,
array $  printouts,
enableValidation = false 
) [static]

Constructs a new SMWQueryUIHelper when the query is passed to the UI from a web form.

This constructor should be used to handle form parameters sent from the UI itself. If your search UI must also handle "further results" links from a wiki page, consider using makeForInfoLink().

If any errors do occur while parsing parameters, they may be accessed from hasError() and getErrors().

Parameters:
string $query
array $params of key=>value pairs
array $printouts array of '?property' strings
boolean $enableValidation
Returns:
SMWQueryUIHelper

Definition at line 560 of file SMW_QueryUIHelper.php.

Referenced by SMWQueryUI::execute().

static SMWQueryUIHelper::validateProperty ( property  )  [static, protected]

Checks if $property exists in the wiki or not.

Parameters:
string $property a property name in "?property" format
Returns:
boolean

Definition at line 575 of file SMW_QueryUIHelper.php.

Referenced by setPrintOuts().


Member Data Documentation

SMWQueryUIHelper::$queryString = '' [protected]

Definition at line 24 of file SMW_QueryUIHelper.php.

Referenced by setQueryString().

SMWQueryUIHelper::$parameters = array() [protected]

Definition at line 31 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::$printOuts = array() [protected]

Definition at line 37 of file SMW_QueryUIHelper.php.

Referenced by setPrintOuts().

SMWQueryUIHelper::$printOutStrings = array() [protected]

Definition at line 45 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::$errorsOccured = false [private]

Definition at line 51 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::$context [private]

Definition at line 58 of file SMW_QueryUIHelper.php.

Referenced by __construct().

SMWQueryUIHelper::$errors = array() [private]

Definition at line 65 of file SMW_QueryUIHelper.php.

Referenced by execute(), setParams(), setPrintOuts(), and setQueryString().

SMWQueryUIHelper::$defaultResultPrinter = 'broadtable' [private]

The default result printer if no format is set at the higher level.

Definition at line 70 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::$queryResult = null [private]

Definition at line 77 of file SMW_QueryUIHelper.php.

Referenced by getHTMLResult().

Constants define whether the parameters was passed from the ui form (SPECIAL_PAGE) or from the further results infolink (WIKI_LINK).

Definition at line 83 of file SMW_QueryUIHelper.php.

Has the query come from a special page, or from an InfoLink?

Definition at line 84 of file SMW_QueryUIHelper.php.

SMWQueryUIHelper::$uiPages = array() [static, protected]

Definition at line 91 of file SMW_QueryUIHelper.php.


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

Generated on Sun Mar 18 07:15:43 2012 for Semantic MediaWiki by  doxygen 1.5.6