BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
ApiQueryBase Class Reference
Inheritance diagram for ApiQueryBase:
Collaboration diagram for ApiQueryBase:

Public Member Functions

 __construct (ApiQuery $queryModule, $moduleName, $paramPrefix= '')
 
Methods to implement
 getCacheMode ($params)
 
 requestExtraData ($pageSet)
 
- Public Member Functions inherited from ApiBase
 __construct (ApiMain $mainModule, $moduleName, $modulePrefix= '')
 
 execute ()
 
 getModuleManager ()
 
 getCustomPrinter ()
 
 getHelpUrls ()
 
 shouldCheckMaxlag ()
 
 isReadMode ()
 
 isWriteMode ()
 
 mustBePosted ()
 
 isDeprecated ()
 
 isInternal ()
 
 needsToken ()
 
 getConditionalRequestData ($condition)
 
 getModuleName ()
 
 getModulePrefix ()
 
 getMain ()
 
 isMain ()
 
 getParent ()
 
 lacksSameOriginSecurity ()
 
 getModulePath ()
 
 getModuleFromPath ($path)
 
 getResult ()
 
 getErrorFormatter ()
 
 getContinuationManager ()
 
 setContinuationManager ($manager)
 
 dynamicParameterDocumentation ()
 
 encodeParamName ($paramName)
 
 extractRequestParams ($parseLimit=true)
 
 requireOnlyOneParameter ($params, $required)
 
 requireMaxOneParameter ($params, $required)
 
 requireAtLeastOneParameter ($params, $required)
 
 requirePostedParameters ($params, $prefix= 'prefix')
 
 getTitleOrPageId ($params, $load=false)
 
 validateToken ($token, array $params)
 
 getWatchlistUser ($params)
 
 setWarning ($warning)
 
 dieUsage ($description, $errorCode, $httpRespCode=0, $extradata=null)
 
 dieBlocked (Block $block)
 
 getErrorFromStatus ($status, &$extraData=null)
 
 dieStatus ($status)
 
static dieReadOnly ()
 
 dieUsageMsg ($error)
 
 dieUsageMsgOrDebug ($error)
 
 parseMsg ($error)
 
 logFeatureUsage ($feature)
 
 getFinalDescription ()
 
 getFinalParams ($flags=0)
 
 getFinalParamDescription ()
 
 modifyHelp (array &$help, array $options, array &$tocData)
 
 makeHelpMsg ()
 
 makeHelpMsgParameters ()
 
 getModuleProfileName ($db=false)
 
 profileIn ()
 
 profileOut ()
 
 safeProfileOut ()
 
 getProfileTime ()
 
 profileDBIn ()
 
 profileDBOut ()
 
 getProfileDBTime ()
 
 getResultData ()
 
- Public Member Functions inherited from ContextSource
 getContext ()
 
 setContext (IContextSource $context)
 
 getConfig ()
 
 getRequest ()
 
 getTitle ()
 
 canUseWikiPage ()
 
 getWikiPage ()
 
 getOutput ()
 
 getUser ()
 
 getLanguage ()
 
 getSkin ()
 
 getTiming ()
 
 getStats ()
 
 msg ()
 
 exportSession ()
 

Public Attributes

 $mDb
 
 $tables
 
 $where
 
 $fields
 
 $options
 
 $join_conds
 
- Public Attributes inherited from ApiBase
const LIMIT_BIG1 = 500
 
const LIMIT_BIG2 = 5000
 
const LIMIT_SML1 = 50
 
const LIMIT_SML2 = 500
 
const GET_VALUES_FOR_HELP = 1
 
 $mModulePrefix
 
const PARAM_DFLT = 0
 
const PARAM_ISMULTI = 1
 
const PARAM_TYPE = 2
 
const PARAM_MAX = 3
 
const PARAM_MAX2 = 4
 
const PARAM_MIN = 5
 
const PARAM_ALLOW_DUPLICATES = 6
 
const PARAM_DEPRECATED = 7
 
const PARAM_REQUIRED = 8
 
const PARAM_RANGE_ENFORCE = 9
 
const PARAM_HELP_MSG = 10
 
const PARAM_HELP_MSG_APPEND = 11
 
const PARAM_HELP_MSG_INFO = 12
 
const PARAM_VALUE_LINKS = 13
 
const PARAM_HELP_MSG_PER_VALUE = 14
 
const PARAM_SUBMODULE_MAP = 15
 
const PARAM_SUBMODULE_PARAM_PREFIX = 16
 
const PARAM_SENSITIVE = 17
 

Data access

 getQuery ()
 
 getParent ()
 
 selectNamedDB ($name, $db, $groups)
 
 getDB ()
 
 getPageSet ()
 

Querying

 prepareUrlQuerySearchString ($query=null, $protocol=null)
 
 showHiddenUsersAddBlockInfo ($showBlockInfo)
 
 resetQueryParams ()
 
 addTables ($tables, $alias=null)
 
 addJoinConds ($join_conds)
 
 addFields ($value)
 
 addFieldsIf ($value, $condition)
 
 addWhere ($value)
 
 addWhereIf ($value, $condition)
 
 addWhereFld ($field, $value)
 
 addWhereRange ($field, $dir, $start, $end, $sort=true)
 
 addTimestampWhereRange ($field, $dir, $start, $end, $sort=true)
 
 addOption ($name, $value=null)
 
 select ($method, $extraQuery=[])
 

Utility methods

 titlePartToKey ($titlePart, $namespace=NS_MAIN)
 
 prefixedTitlePartToKey ($titlePart, $defaultNamespace=NS_MAIN)
 
 validateSha1Hash ($hash)
 
 validateSha1Base36Hash ($hash)
 
 userCanSeeRevDel ()
 
 addPageSubItems ($pageId, $data)
 
 addPageSubItem ($pageId, $item, $elemname=null)
 
 setContinueEnumParameter ($paramName, $paramValue)
 
static addTitleInfo (&$arr, $title, $prefix= '')
 

Detailed Description

This is a base class for all Query modules. It provides some common functionality such as constructing various SQL queries.

Constructor & Destructor Documentation

ApiQueryBase::__construct ( ApiQuery  $queryModule,
  $moduleName,
  $paramPrefix = '' 
)
Parameters
ApiQuery$queryModule
string$moduleName
string$paramPrefix

Member Function Documentation

ApiQueryBase::addFields (   $value)
protected

Add a set of fields to select to the internal array

Parameters
array | string$valueField name or array of field names
ApiQueryBase::addFieldsIf (   $value,
  $condition 
)
protected

Same as addFields(), but add the fields only if a condition is met

Parameters
array | string$valueSee addFields()
bool$conditionIf false, do nothing
Returns
bool $condition
ApiQueryBase::addJoinConds (   $join_conds)
protected

Add a set of JOIN conditions to the internal array

JOIN conditions are formatted as array( tablename => array(jointype, conditions) e.g. array('page' => array('LEFT JOIN', 'page_id=rev_page')) . conditions may be a string or an addWhere()-style array

Parameters
array$join_condsJOIN conditions
ApiQueryBase::addOption (   $name,
  $value = null 
)
protected

Add an option such as LIMIT or USE INDEX. If an option was set before, the old value will be overwritten

Parameters
string$nameOption name
string$valueOption value
ApiQueryBase::addPageSubItem (   $pageId,
  $item,
  $elemname = null 
)
protected

Same as addPageSubItems(), but one element of $data at a time

Parameters
int$pageIdPage ID
array$itemData array à la ApiResult
string$elemnameXML element name. If null, getModuleName() is used
Returns
bool Whether the element fit in the result
ApiQueryBase::addPageSubItems (   $pageId,
  $data 
)
protected

Add a sub-element under the page element with the given page ID

Parameters
int$pageIdPage ID
array$dataData array à la ApiResult
Returns
bool Whether the element fit in the result
ApiQueryBase::addTables (   $tables,
  $alias = null 
)
protected

Add a set of tables to the internal array

Parameters
string|string[]$tables Table name or array of table names
string | null$aliasTable alias, or null for no alias. Cannot be used with multiple tables
ApiQueryBase::addTimestampWhereRange (   $field,
  $dir,
  $start,
  $end,
  $sort = true 
)
protected

Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end to database timestamps.

See Also
addWhereRange
Parameters
string$field
string$dir
string$start
string$end
bool$sort
static ApiQueryBase::addTitleInfo ( $arr,
  $title,
  $prefix = '' 
)
static

Add information (title and namespace) about a Title object to a result array

Parameters
array$arrResult array à la ApiResult
Title$title
string$prefixModule prefix
ApiQueryBase::addWhere (   $value)
protected

Add a set of WHERE clauses to the internal array. Clauses can be formatted as 'foo=bar' or array('foo' => 'bar'), the latter only works if the value is a constant (i.e. not another field)

If $value is an empty array, this function does nothing.

For example, array('foo=bar', 'baz' => 3, 'bla' => 'foo') translates to "foo=bar AND baz='3' AND bla='foo'"

Parameters
string | array$value
ApiQueryBase::addWhereFld (   $field,
  $value 
)
protected

Equivalent to addWhere(array($field => $value))

Parameters
string$fieldField name
string$valueValue; ignored if null or empty array;
ApiQueryBase::addWhereIf (   $value,
  $condition 
)
protected

Same as addWhere(), but add the WHERE clauses only if a condition is met

Parameters
string | array$value
bool$conditionIf false, do nothing
Returns
bool $condition
ApiQueryBase::addWhereRange (   $field,
  $dir,
  $start,
  $end,
  $sort = true 
)
protected

Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction

Parameters
string$fieldField name
string$dirIf 'newer', sort in ascending order, otherwise sort in descending order
string$startValue to start the list at. If $dir == 'newer' this is the lower boundary, otherwise it's the upper boundary
string$endValue to end the list at. If $dir == 'newer' this is the upper boundary, otherwise it's the lower boundary
bool$sortIf false, don't add an ORDER BY clause
ApiQueryBase::getCacheMode (   $params)

Get the cache mode for the data generated by this module. Override this in the module subclass. For possible return values and other details about cache modes, see ApiMain::setCacheMode()

Public caching will only be allowed if all the modules that supply data for a given request return a cache mode of public.

Parameters
array$params
Returns
string
ApiQueryBase::getDB ( )
protected

Get the Query database connection (read-only)

Returns
DatabaseBase
ApiQueryBase::getPageSet ( )
protected

Get the PageSet object to work on

Returns
ApiPageSet
ApiQueryBase::getParent ( )
ApiQueryBase::getQuery ( )

Get the main Query module

Returns
ApiQuery
ApiQueryBase::prefixedTitlePartToKey (   $titlePart,
  $defaultNamespace = NS_MAIN 
)

Convert an input title or title prefix into a namespace constant and dbkey.

Since
1.26
Parameters
string$titlePartTitle part
int$defaultNamespaceDefault namespace if none is given
Returns
array (int, string) Namespace number and DBkey
ApiQueryBase::prepareUrlQuerySearchString (   $query = null,
  $protocol = null 
)
Parameters
string$query
string$protocol
Returns
null|string
ApiQueryBase::requestExtraData (   $pageSet)

Override this method to request extra fields from the pageSet using $pageSet->requestField('fieldName')

Note this only makes sense for 'prop' modules, as 'list' and 'meta' modules should not be using the pageset.

Parameters
ApiPageSet$pageSet
ApiQueryBase::resetQueryParams ( )
protected

Blank the internal arrays with query parameters

ApiQueryBase::select (   $method,
  $extraQuery = [] 
)
protected

Execute a SELECT query based on the values in the internal arrays

Parameters
string$methodFunction the query should be attributed to. You should usually use METHOD here
array$extraQueryQuery data to add but not store in the object Format is array( 'tables' => ..., 'fields' => ..., 'where' => ..., 'options' => ..., 'join_conds' => ... )
Returns
ResultWrapper
ApiQueryBase::selectNamedDB (   $name,
  $db,
  $groups 
)

Selects the query database connection with the given name. See ApiQuery::getNamedDB() for more information

Parameters
string$nameName to assign to the database connection
int$dbOne of the DB_* constants
array$groupsQuery groups
Returns
DatabaseBase
ApiQueryBase::setContinueEnumParameter (   $paramName,
  $paramValue 
)
protected

Set a query-continue value

Parameters
string$paramNameParameter name
string | array$paramValueParameter value
ApiQueryBase::showHiddenUsersAddBlockInfo (   $showBlockInfo)

Filters hidden users (where the user doesn't have the right to view them) Also adds relevant block information

Parameters
bool$showBlockInfo
Returns
void
ApiQueryBase::titlePartToKey (   $titlePart,
  $namespace = NS_MAIN 
)

Convert an input title or title prefix into a dbkey.

$namespace should always be specified in order to handle per-namespace capitalization settings.

Parameters
string$titlePartTitle part
int$namespaceNamespace of the title
Returns
string DBkey (no namespace prefix)
ApiQueryBase::userCanSeeRevDel ( )

Check whether the current user has permission to view revision-deleted fields.

Returns
bool
ApiQueryBase::validateSha1Base36Hash (   $hash)
Parameters
string$hash
Returns
bool
ApiQueryBase::validateSha1Hash (   $hash)
Parameters
string$hash
Returns
bool

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