Info object

From Apibot
Revision as of 03:13, 14 April 2014 by Grigor Gatchev (talk | contribs) (11 replacements)
Jump to: navigation, search

A MediaWiki installation is able to supply an enormous wealth of info that can be useful for bot tasks. Apibot is able to fetch this info and supply it to the programs that use it. To decrease the wiki online traffic, the info is cached and reused according to specified settings. All this is done by the Info object, which is part of the Apibot Mains object.

This class exports over 500 functions that return wiki and user info, as well as some useful conversions and tasks that rely on this info - more than any other part of Apibot. If the bot doesn't know the information returned by the function you called, it will try to auto-fetch and possibly cache it. If the information is still unavailable, the function will typically return NULL.

Types of info

Apibot divides the information from the wiki into several types:

  • general - common things about the wiki; matches the General subtype of the MediaWiki Meta Siteinfo.
  • siteinfo - all other MediaWiki Meta Siteinfo
  • userinfo - the MediaWiki Meta Userinfo
  • allmessages - the MediaWiki Meta Allmessages
  • paraminfo - the MediaWiki Paraminfo

Info classes

The Info class is actually the last descendant in a class hierarchy:

  • Info_Fetcher - fetches the info; also, exports functions that return the general info
  • Base_Info - extends Info_Fetcher; exports functions that return the siteinfo, userinfo, allmessages and paraminfo
  • Extended_Info - extends Base_Info; exports functions that are convenient shortcuts for some frequently used specific function calls, and functions that provide useful stuff relying on the wiki info
  • Info - extends Extended_Info; by default implements no new functions - it is a place for the bot user's custom functions, should s/he implement some. The Info object in the Apibot Mains object is of this class.

All of these classes are implemented in PHP files with matching names, situated in the directory common/info.

Creating

Creating an object of the class Info requires three parameters:

In addition, it can also take forth paramerer:

  • $force_load - if true, will automatically fetch all wiki info on the object creation. Default is false - this allows fetching the info from the wiki only when it is needed.

Public properties

  • $autoload - whether to request the info from the wiki automatically on need. Default is true. If false, info will be requested from wiki only if the wiki info fetching functions are explicitly called.

Public functions

Due to their numbers, the functions are listed in separate subpages:

(The class may also contain other types of info functions, eg. global user info, which are still not official.)