BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
SMWQuery Class Reference

Public Member Functions

 __construct ($description=null, $inline=false, $concept=false)
 
 setContextPage (DIWikiPage $contextPage=null)
 
 getContextPage ()
 
 setQuerySource ($querySource)
 
 getQuerySource ()
 
 setMainLabel ($mainlabel)
 
 getMainLabel ()
 
 setDescription (SMWDescription $description)
 
 getDescription ()
 
 setExtraPrintouts ($extraprintouts)
 
 getExtraPrintouts ()
 
 getErrors ()
 
 addErrors ($errors)
 
 setQueryString ($querystring)
 
 getQueryString ($fresh=false)
 
 getOffset ()
 
 setOffset ($offset)
 
 getLimit ()
 
 setLimit ($limit, $restrictinline=true)
 
 setUnboundLimit ($limit)
 
 setSortKeys (array $sortKeys)
 
 getSortKeys ()
 
 applyRestrictions ()
 
 toArray ()
 
 getHash ()
 
 getQueryId ()
 

Public Attributes

const MODE_INSTANCES = 1
 
const MODE_COUNT = 2
 
const MODE_DEBUG = 3
 
const MODE_NONE = 4
 
 $sort = false
 
 $sortkeys = array()
 
 $querymode = self::MODE_INSTANCES
 

Detailed Description

Representation of queries in SMW, each consisting of a query description and various parameters. Some settings might also lead to changes in the query description.

Most additional query parameters (limit, sort, ascending, ...) are interpreted as in SMWRequestOptions (though the latter contains some additional settings).

Constructor & Destructor Documentation

SMWQuery::__construct (   $description = null,
  $inline = false,
  $concept = false 
)

Constructor.

Parameters
$descriptionSMWDescription object describing the query conditions
$inlinebool stating whether this query runs in an inline context; used to determine proper default parameters (e.g. the default limit)
$conceptbool stating whether this query belongs to a concept; used to determine proper default parameters (concepts usually have less restrictions)

Member Function Documentation

SMWQuery::applyRestrictions ( )

Apply structural restrictions to the current description.

SMWQuery::getContextPage ( )
Since
2.3
Returns
DIWikiPage|null
SMWQuery::getExtraPrintouts ( )
Returns
PrintRequest[]
SMWQuery::getHash ( )
Since
2.1
Returns
string
SMWQuery::getMainLabel ( )

Gets the mainlabel.

Since
1.6.
Returns
string
SMWQuery::getQueryId ( )
Since
2.3
Returns
string
SMWQuery::getQuerySource ( )
Since
2.4
Returns
string
SMWQuery::getQueryString (   $fresh = false)
Since
1.7
Parameters
boolean$fresh
Returns
string
SMWQuery::getSortKeys ( )
Since
2.2
Returns
array
SMWQuery::setContextPage ( DIWikiPage  $contextPage = null)
Since
2.3
Parameters
DIWikiPage | null$contextPage
SMWQuery::setLimit (   $limit,
  $restrictinline = true 
)

Set a limit for number of query results. The set limit might be restricted by the current offset so as to ensure that the number of the last considered result does not exceed the maximum amount of supported results. The function returns the chosen limit.

Note
It makes sense to have limit==0, e.g. to only show a link to the search special
SMWQuery::setMainLabel (   $mainlabel)

Sets the mainlabel.

Since
1.6.
Parameters
string$mainlabel
SMWQuery::setOffset (   $offset)

Set an offset for the returned query results. No offset beyond the maximal query limit will be set, and the current query limit might be reduced in order to ensure that no results beyond the maximal limit are returned. The function returns the chosen offset.

Todo:
The function should be extended to take into account whether or not we are in inline mode (not critical, since offsets are usually not applicable inline).
SMWQuery::setQuerySource (   $querySource)
Since
2.4
Parameters
string
SMWQuery::setSortKeys ( array  $sortKeys)
Note
format: "Property key" => "ASC" / "DESC" (note: order of entries also matters)
Since
2.2
Parameters
array$sortKeys
SMWQuery::setUnboundLimit (   $limit)
Note
Sets an unbound limit that is independent from GLOBAL settings
Since
2.0
Parameters
integer$limit
Returns
Query
SMWQuery::toArray ( )

Returns serialized query details

The output is following the askargs api module convention

conditions The query conditions (requirements for a subject to be included) printouts The query printouts (which properties to show per subject) parameters The query parameters (non-condition and non-printout arguments)

Since
1.9
Returns
array

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