Go to the documentation of this file.
44 parent::__construct(
$query->getMain(), $moduleName, $paramPrefix );
45 $this->mQueryModule =
$query;
69 $this->tables =
array();
70 $this->where =
array();
71 $this->fields =
array();
73 $this->join_conds =
array();
84 if ( !is_null( $alias ) ) {
87 $this->tables = array_merge( $this->tables,
$tables );
89 if ( !is_null( $alias ) ) {
90 $this->tables[$alias] =
$tables;
110 $this->join_conds = array_merge( $this->join_conds,
$join_conds );
118 if ( is_array(
$value ) ) {
119 $this->fields = array_merge( $this->fields,
$value );
153 if ( is_array(
$value ) ) {
157 $this->where = array_merge( $this->where,
$value );
189 $this->where[$field] =
$value;
206 $isDirNewer = (
$dir ===
'newer' );
207 $after = ( $isDirNewer ?
'>=' :
'<=' );
208 $before = ( $isDirNewer ?
'<=' :
'>=' );
209 $db = $this->
getDB();
211 if ( !is_null( $start ) ) {
212 $this->
addWhere( $field . $after . $db->addQuotes( $start ) );
215 if ( !is_null( $end ) ) {
216 $this->
addWhere( $field . $before . $db->addQuotes( $end ) );
220 $order = $field . ( $isDirNewer ?
'' :
' DESC' );
222 $optionOrderBy = isset( $this->
options[
'ORDER BY'] )
225 $optionOrderBy[] = $order;
226 $this->
addOption(
'ORDER BY', $optionOrderBy );
241 $db = $this->getDb();
243 $db->timestampOrNull( $start ), $db->timestampOrNull( $end ),
$sort );
253 if ( is_null(
$value ) ) {
278 isset( $extraQuery[
'tables'] ) ? (
array)$extraQuery[
'tables'] :
array()
282 isset( $extraQuery[
'fields'] ) ? (
array)$extraQuery[
'fields'] :
array()
286 isset( $extraQuery[
'where'] ) ? (
array)$extraQuery[
'where'] :
array()
290 isset( $extraQuery[
'options'] ) ? (
array)$extraQuery[
'options'] :
array()
294 isset( $extraQuery[
'join_conds'] ) ? (
array)$extraQuery[
'join_conds'] :
array()
298 $db = $this->
getDB();
313 $db = $this->
getDB();
315 $rowcount = $db->estimateRowCount(
325 if ( $rowcount > $wgAPIMaxDBRows ) {
340 $arr[$prefix .
'ns'] = intval(
$title->getNamespace() );
341 $arr[$prefix .
'title'] =
$title->getPrefixedText();
370 return $result->addValue(
array(
'query',
'pages', intval( $pageId ) ),
384 if ( is_null( $elemname ) ) {
388 $fit =
$result->addValue(
array(
'query',
'pages', $pageId,
393 $result->setIndexedTagName_internal(
array(
'query',
'pages', $pageId,
406 $msg =
array( $paramName => $paramValue );
418 if ( is_null( $this->mDb ) ) {
419 $this->mDb = $this->
getQuery()->getDB();
434 $this->mDb = $this->
getQuery()->getNamedDB(
$name, $db, $groups );
442 return $this->
getQuery()->getPageSet();
452 if ( trim(
$title ) ==
'' ) {
460 return $t->getPrefixedDBkey();
470 if ( trim( $key ) ==
'' ) {
479 return $t->getPrefixedText();
496 if ( $defaultNamespace !=
$t->getNamespace() ||
$t->isExternal() ) {
505 return substr(
$t->getDbKey(), 0, -1 );
514 return substr( $this->
keyToTitle( $keyPart .
'x' ), 0, -1 );
526 "In which direction to enumerate{$extraDirText}",
527 " newer - List oldest first. Note: {$p}start has to be before {$p}end.",
528 " older - List newest first (default). Note: {$p}start has to be later than {$p}end.",
538 $db = $this->getDb();
540 if ( is_null( $protocol ) ) {
541 $protocol =
'http://';
546 $this->
dieUsage(
'Invalid query',
'bad_query' );
551 return 'el_index ' . $db->buildLike( $likeQuery );
552 } elseif ( !is_null( $protocol ) ) {
553 return 'el_index ' . $db->buildLike(
"$protocol", $db->anyString() );
569 'ipblocks' =>
array(
'LEFT JOIN',
'ipb_user=user_id' ),
574 if ( $showBlockInfo ) {
575 $this->
addFields(
array(
'ipb_id',
'ipb_by',
'ipb_by_text',
'ipb_reason',
'ipb_expiry' ) );
579 if ( !$this->
getUser()->isAllowed(
'hideuser' ) ) {
580 $this->
addWhere(
'ipb_deleted = 0 OR ipb_deleted IS NULL' );
589 return preg_match(
'/^[a-f0-9]{40}$/',
$hash );
597 return preg_match(
'/^[a-z0-9]{31}$/',
$hash );
604 $errors = parent::getPossibleErrors();
605 $errors = array_merge( $errors,
array(
606 array(
'invalidtitle',
'title' ),
607 array(
'invalidtitle',
'key' ),
619 return $this->
getUser()->isAllowedAny(
'deletedhistory',
'deletedtext',
'suppressrevision' );
638 if ( $generatorPageSet ===
null ) {
639 ApiBase::dieDebug( __METHOD__,
'Required parameter missing - $generatorPageSet' );
641 $this->mGeneratorPageSet = $generatorPageSet;
650 if ( $this->mGeneratorPageSet !==
null ) {
654 return parent::getPageSet();
663 if ( $this->mGeneratorPageSet !==
null ) {
664 return 'g' . parent::encodeParamName( $paramName );
666 return parent::encodeParamName( $paramName );
678 if ( $this->mGeneratorPageSet ===
null
679 || !$this->
getQuery()->setGeneratorContinue( $this, $paramName, $paramValue )
681 parent::setContinueEnumParameter( $paramName, $paramValue );
validateSha1Base36Hash( $hash)
showHiddenUsersAddBlockInfo( $showBlockInfo)
Filters hidden users (where the user doesn't have the right to view them) Also adds relevant block in...
addPageSubItems( $pageId, $data)
Add a sub-element under the page element with the given page ID.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
addFields( $value)
Add a set of fields to select to the internal array.
encodeParamName( $paramName)
Overrides base class to prepend 'g' to every generator parameter.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
resetQueryParams()
Blank the internal arrays with query parameters.
executeGenerator( $resultPageSet)
Execute this module as a generator.
keyToTitle( $key)
The inverse of titleToKey()
addTimestampWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, similar to addWhereRange, but converts $start and $end t...
dieUsageMsg( $error)
Output the error message related to a certain array.
static keepOneWildcard( $arr)
Filters an array returned by makeLikeArray(), removing everything past first pattern placeholder.
profileDBIn()
Start module profiling.
getResult()
Get the result object.
getQuery()
Get the main Query module.
select( $method, $extraQuery=array())
Execute a SELECT query based on the values in the internal arrays.
profileDBOut()
End database profiling.
getDirectionDescription( $p='', $extraDirText='')
Gets the personalised direction parameter description.
setGeneratorMode(ApiPageSet $generatorPageSet)
Switch this module to generator mode.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
getUser()
Get the User object.
addFieldsIf( $value, $condition)
Same as addFields(), but add the fields only if a condition is met.
This class contains a list of pages that the client has requested.
This abstract class implements many basic API functions, and is the base of all API classes.
__construct(ApiBase $query, $moduleName, $paramPrefix='')
setContinueEnumParameter( $paramName, $paramValue)
Overrides base in case of generator & smart continue to notify ApiQueryMain instead of adding them to...
getPageSet()
Get the PageSet object to work on.
This is a base class for all Query modules.
getDB()
Get the Query database connection (read-only)
static makeLikeArray( $filterEntry, $protocol='http://')
Make an array to be used for calls to DatabaseBase::buildLike(), which will match the specified strin...
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
when a variable name is used in a it is silently declared as a new masking the global
titleToKey( $title)
Convert a title to a DB key.
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
checkRowCount()
Estimate the row count for the SELECT query that would be run if we called select() right now,...
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
presenting them properly to the user as errors is done by the caller $title
Allows to change the fields on the form that will be generated $name
encodeParamName( $paramName)
This method mangles parameter name based on the prefix supplied to the constructor.
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
static newFromDBkey( $key)
Create a new Title from a prefixed DB key.
requestExtraData( $pageSet)
Override this method to request extra fields from the pageSet using $pageSet->requestField('fieldName...
addJoinConds( $join_conds)
Add a set of JOIN conditions to the internal array.
titlePartToKey( $titlePart, $defaultNamespace=NS_MAIN)
An alternative to titleToKey() that doesn't trim trailing spaces, and does not mangle the input if st...
addWhereFld( $field, $value)
Equivalent to addWhere(array($field => $value))
getCacheMode( $params)
Get the cache mode for the data generated by this module.
getPageSet()
Get the PageSet object to work on.
return false to override stock group addition can be modified try getUserPermissionsErrors userCan checks are continued by internal code can override on output return false to not delete it return false to override the default password checks & $hash
const ADD_ON_TOP
For addValue() and setElement(), if the value does not exist, add it as the first element.
selectNamedDB( $name, $db, $groups)
Selects the query database connection with the given name.
if(count( $args)==0) $dir
getModuleName()
Get the name of the module being executed by this instance.
addWhere( $value)
Add a set of WHERE clauses to the internal array.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
prepareUrlQuerySearchString( $query=null, $protocol=null)
keyPartToTitle( $keyPart)
An alternative to keyToTitle() that doesn't trim trailing spaces.
userCanSeeRevDel()
Check whether the current user has permission to view revision-deleted fields.
addPageSubItem( $pageId, $item, $elemname=null)
Same as addPageSubItems(), but one element of $data at a time.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
addWhereIf( $value, $condition)
Same as addWhere(), but add the WHERE clauses only if a condition is met.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.