Difference between revisions of "Info object/Siteinfo"

From Apibot
Jump to: navigation, search
(+ see also section)
m (Mains -> Core)
 
Line 1: Line 1:
The MediaWiki API Siteinfo request provides a wealth of information about the MediaWiki installation. The Apibot [[Info object]] (a property of the [[Mains object]]) typically requests it, and will consider it to be one of the types of info it provides - the "site" info. (Except for the "general" subset of the API Siteinfo, which is considered as a type of info on its own - the "general" info.)
+
The MediaWiki API Siteinfo request provides a wealth of information about the MediaWiki installation. The Apibot [[Info object]] (a property of the [[Core object]]) typically requests it, and will consider it to be one of the types of info it provides - the "site" info. (Except for the "general" subset of the API Siteinfo, which is considered as a type of info on its own - the "general" info.)
  
 
In principle, all of this info can be retrieved through the <code>infotype_element ( "info", $element )</code> function, where <code>$element</code> is the info element key in the site info array. (Often the info element will be array on its own, sometimes with yet more subarrays in it.) However, retrieving this info through special functions might be more convenient (and might make the PHP code more readable). A list of the implemented site info functions follows.
 
In principle, all of this info can be retrieved through the <code>infotype_element ( "info", $element )</code> function, where <code>$element</code> is the info element key in the site info array. (Often the info element will be array on its own, sometimes with yet more subarrays in it.) However, retrieving this info through special functions might be more convenient (and might make the PHP code more readable). A list of the implemented site info functions follows.
Line 302: Line 302:
  
 
* [[Info object]]
 
* [[Info object]]
* [[Mains object]]
+
* [[Core object]]

Latest revision as of 01:42, 10 November 2014

The MediaWiki API Siteinfo request provides a wealth of information about the MediaWiki installation. The Apibot Info object (a property of the Core object) typically requests it, and will consider it to be one of the types of info it provides - the "site" info. (Except for the "general" subset of the API Siteinfo, which is considered as a type of info on its own - the "general" info.)

In principle, all of this info can be retrieved through the infotype_element ( "info", $element ) function, where $element is the info element key in the site info array. (Often the info element will be array on its own, sometimes with yet more subarrays in it.) However, retrieving this info through special functions might be more convenient (and might make the PHP code more readable). A list of the implemented site info functions follows.

Common

Elements by generic structure

  • site_info() - the entire site info structure, as a PHP array
  • site_info_isset() - true if the site info is available, false if it is not
  • site_elements_names() - an array with the names (keys) of all site info elements
  • site_known_elements_names() - an array with the names (keys) of the explicitly known to Apibot site info elements (who are accessible through the specific functions below)
  • site_unknown_elements_names() - an array with the names (keys) of the site info elements that are not explicitly known to Apibot (who might be accessible only through these general functions)
  • site_element ( $key ) - the site info element with this key
  • site_element_isset ( $key ) - true if this site info element is present, false if it is not
  • site_element_subs_count ( $key ) - the count of the subelements in the site info element (which presumably is an array) with this key
  • site_element_arraykeys ( $key ) - an array with the keys of the subelements in the site info element (which presumably is an array) with this key
  • site_sub ( $key, $subkey ) - the subelement with this subkey in the site info element (must be an array) with this key

Elements by indexes

Some types of site info are specially indexed in a way, different from their order in the standard info arrays. These functions retrieve them according to their indexed structures.

  • siteindex ( $type ) - the specified indexed info type, as an array structure
  • siteindex_element ( $type, $key ) - the specified element of this indexed info type
  • siteindex_element_isset ( $type, $key ) - true if the specified element of this indexed info type is available (also attempts to load it), false if it is not
  • siteindex_element_arraykeys ( $key ) - an array with the keys of the subelements in the indexed site info element (which presumably is an array) with this key
  • siteindex_sub ( $key, $subkey ) - the subelement with this subkey in the indexed site info element (must be an array) with this key

Specific

Namespaces

All namespaces

These functions return data about all namespaces on the wiki.

  • namespaces_are_present() - true if the info about the wiki namespaces is available, false if it is not
  • namespaces() - all namespaces info, in its generic structure
  • namespaces_count() - the count of the namespaces on this wiki
  • namespaces_ids() - an array with the numeric ids of all wiki namespaces
  • namespaces_basic_names() - an array with the basic (official) names of the wiki namespaces
  • namespaces_canonical_names() - an array with the canonical (language-independent) names of the wiki namespaces
  • namespaces_allnames() - an array with all names of the wiki namespaces (basic, canonical and aliases - thus, some namespaces may be present more than once)

By ID

These functions return data about a namespace, determined by its numeric ID.

  • namespace_by_id ( $id ) - all info about this namespace, in its generic structure
  • namespace_exists_by_id ( $id ) - true if the namespace exists, false if it does not
  • namespace_case_by_id ( $id ) - this namespace's case policy (eg. first-letter)
  • namespace_basic_name_by_id ( $id ) - the basic (official) name of this namespace
  • namespace_canonical_name_by_id ( $id ) - the canonical (language-independent) name of this namespace
  • namespace_basic_name_by_id ( $id ) - the basic (official) name of this namespace
  • namespace_allows_subpages_by_id ( $id ) - true if the namespace allows subpages, false if it does not
  • namespace_allnames_by_id ( $id ) - an array with all names of this namespace

By name

These functions return data about a namespace, determined by any of its names.

  • namespace_by_name ( $name ) - all info about this namespace, in its generic structure
  • namespace_exists_by_name ( $name ) - true if the namespace exists, false if it does not
  • namespace_case_by_name ( $name ) - this namespace's case policy (eg. first-letter)
  • namespace_basic_name_by_name ( $name ) - the basic (official) name of this namespace
  • namespace_canonical_name_by_name ( $name ) - the canonical (language-independent) name of this namespace
  • namespace_basic_name_by_name ( $name ) - the basic (official) name of this namespace
  • namespace_allows_subpages_by_name ( $name ) - true if the namespace allows subpages, false if it does not
  • namespace_allnames_by_name ( $name ) - an array with all names of this namespace

By ID or name

These functions return data about a namespace by either its numeric ID or any of its names.

  • namespace_by_id_or_name ( $id_or_name ) - all info about this namespace, in its generic structure (The proper name of this function should have been "namespace()", but this is a reserved word in PHP.)
  • namespace_exists ( $id_or_name ) - true if the namespace exists, false if it does not
  • namespace_case ( $id_or_name ) - this namespace's case policy (eg. first-letter)
  • namespace_basic_name ( $id_or_name ) - the basic (official) name of this namespace
  • namespace_canonical_name ( $id_or_name ) - the canonical (language-independent) name of this namespace
  • namespace_basic_name ( $id_or_name ) - the basic (official) name of this namespace
  • namespace_allows_subpages ( $id_or_name ) - true if the namespace allows subpages, false if it does not
  • namespace_allnames ( $id_or_name ) - an array with all names of this namespace

Namespace aliases

  • namespacealiases_are_present() - true if there is info about namespace aliases, false if there is none
  • namespacealiases_count() - the count of all namespace aliases on this wiki
  • namespacealiases_by_id ( $id ) - all namespace aliases (minus the basic and the canonical name) of the namespace with this ID
  • namespace_by_alias ( $name ) - the info generic structure of the namespace with this alias
  • namespacealiases_by_namespace ( $id_or_name ) - all aliases of the namespace with this ID or name
  • namespacealiases ( $id_or_name = NULL ) - all aliases of the namespace with this ID or name, if given, or all namespace aliases if NULL given

Special pages aliases

  • specialpagealiases_are_present() - true if there is info about special page aliases, false if there is none
  • specialpagealiases() - all special page aliases on this wiki, as this info generic structure
  • specialpagealiases_count() - the count of all special page aliases on this wiki
  • namespacealiases_names() - all real names of special page aliases
  • specialpagealiases_allnames() - all names of special page aliases (thus, some special page aliases may be present more than once)
  • specialpagealias ( $name ) - the special page alias with this name info structure
  • specialpagealias_realname ( $name ) - the special page alias with this name real name
  • specialpagealias_aliases ( $name ) - all aliases of the special page alias with this name

Magicwords

  • magicwords_are_present() - true if there is info about magicwords, false if there is none
  • magicwords() - all magicwords on this wiki, as this info generic structure
  • magicwords_count() - the count of all magicwords on this wiki
  • magicwords_names() - all magicwords names
  • magicwords_aliases() - all magicwords aliases
  • magicword_by_name ( $name ) - the info generic structure of the magicword with this name
  • magicword_by_alias ( $alias ) - the info generic structure of the magicword with this alias
  • magicword_by_name_or_alias ( $name_or_alias ) - the info generic structure of the magicword with this name or alias
  • magicword_allnames ( $name_or_alias ) - all names and aliases of the magicword with this name or alias

Interwikis

  • interwikis_are_present() - true if there is info about interwikis, false if there is none
  • interwikis() - all interwikis on this wiki, as this info generic structure
  • interwikis_count() - the count of all interwikis on this wiki
  • interwikis_prefixes() - all interwikis prefixes
  • interwikis_urls() - all interwikis URLs
  • interwikis_languages() - all interwikis languages
  • interwiki_prefix_exists ( $prefix ) - true if this interwiki prefix exists, false if it does not
  • interwiki_url_exists ( $url ) - true if this interwiki URL exists, false if it does not
  • interwiki_language_exists ( $language ) - true if this interwiki language exists, false if it does not
  • interwiki_by_prefix ( $prefix ) - the info generic structure of the interwiki with this prefix
  • interwiki_by_url ( $url ) - the info generic structure of the interwiki with this URL
  • interwiki_by_language ( $language ) - the info generic structure of the interwiki with this language
  • interwiki_url_by_prefix ( $prefix ) - the URL of the interwiki with this prefix
  • interwiki_language_by_prefix ( $prefix ) - the language of the interwiki with this prefix
  • interwiki_is_local_by_prefix ( $prefix ) - true if the interwiki with this prefix is local, false if it is not

Languages

These are structures of wiki info that describe which language translations are supported by the wiki.

  • languages_are_present() - true if there is info about languages, false if there is none
  • languages() - all languages on this wiki, as this info generic structure
  • languages_count() - the count of all languages on this wiki
  • languages_prefixes() - all languages prefixes
  • languages_languages() - all languages present
  • language_code_exists ( $code ) - true if this language code exists, false if it does not
  • language_language_exists ( $language ) - true if this language exists, false if it does not
  • language_by_code ( $code ) - the info generic structure of the language with this code
  • language_by_language ( $language ) - the info generic structure of the language with this language

Statistics

  • statistics_are_present() - true if there is info about statistics, false if there is none
  • statistics() - all statistics on this wiki, as this info generic structure
  • statistics_pages() - the count of the pages at this wiki
  • statistics_articles() - the count of the articles (pages in the main namespace) at this wiki
  • statistics_edits() - the count of the edits made at this wiki
  • statistics_images() - the count of the images at this wiki
  • statistics_users() - the count of the users at this wiki
  • statistics_activeusers() - the count of the active users at this wiki
  • statistics_admins() - the count of the administrators at this wiki
  • statistics_jobs() - the count of the active jobs at this wiki

Newer versions of MediaWiki might support other statistics for which there are no specific functions (by now). These still can be accessed by requesting statistics() and walking the array it returns.

Rightsinfo

  • rightsinfo_is_present() - true if there is info about wiki legal rights, false if there is none
  • rightsinfo() - all copyrights info on this wiki, as this info generic structure
  • rightsinfo_url() - the URL of the wiki license and/or copyright description
  • rightsinfo_text() - a text describing the wiki copyright

Newer versions of MediaWiki might support more rightsinfo entries for which there are no specific functions (by now). These still can be accessed by requesting rightsinfo() and walking the array it returns.

Database reply lag

Provides info about the wiki database servers lag (useful on large, cluster-based wikis).

  • dbrepllag_are_present() - true if there is info about dbrepllag, false if there is none
  • dbrepllag() - all dbrepllag structures on this wiki, as this info generic structure
  • dbrepllag_count() - the count of the dbrepllag entries on this wiki
  • dbrepllag_hosts() - all database hosts that exhibit reply lag
  • dbrepllag_host_exists ( $host ) - true if this database host exists (and has reply lag), false if it does not
  • dbrepllag_by_host ( $host ) - the info generic structure of the dbrepllag for this host
  • dbrepllag_lag_by_host ( $host ) - the reply lag value for this host

File extensions

Provides info about the file extensions understood (and parsed internally) on this wiki, for uploaded files.

  • fileextensions_are_present() - true if there is info about fileextensions, false if there is none
  • fileextensions() - all fileextensions structures on this wiki, as this info generic structure
  • fileextensions_count() - the count of the fileextensions entries on this wiki
  • fileextensions_exts() - all file extensions strings
  • fileextension_ext_exists ( $extension ) - true if this file extension exists, false if it does not
  • fileextension_by_ext ( $extension ) - the info generic structure of the fileextension with this extension string

User groups

  • usergroups_are_present() - true if there is info about usergroups, false if there is none
  • usergroups() - all usergroups on this wiki, as this info generic structure
  • usergroups_count() - the count of all usergroups on this wiki
  • usergroups_names() - all usergroups names
  • usergroup_name_exists ( $name ) - true if an usergroup with this name exists, false if it does not
  • usergroup_by_name ( $name ) - the info generic structure of the usergroup with this name
  • usergroups_by_right ( $right ) - all usergroups who have this right
  • usergroups_rights_by_name ( $name ) - all rights of the usergroup with this name
  • usergroup_add_by_name ( $name ) - all rights this usergroup may add
  • usergroup_remove_by_name ( $name ) - all rights this usergroup may remove
  • usergroup_number_by_name ( $name ) - the number of this usergroup
  • usergroup_has_right_by_name ( $right, $name ) - true if the usergroup with this name has this right, false if it does not

Wiki extensions

The wiki extensions are modules that add functionality to the base MediaWiki installation.

  • extensions_are_present() - true if there is info about wiki extensions, false if there is none
  • extensions() - all extensions on this wiki, as this info generic structure
  • extensions_count() - the count of all extensions on this wiki
  • extensions_names() - all extensions names
  • extensions_descriptionmsgs() - all extensions description messages
  • extension_name_exists ( $name ) - true if an extension with this name exists, false if it does not
  • extension_by_name ( $name ) - the info generic structure of the extension with this name
  • extension_descriptionmsg_exists ( $msg ) - true if an extension with this description message exists, false if it does not
  • extension_by_descriptionmsg ( $msg ) - the info generic structure of the extension with this description message
  • extensions_by_type ( $type ) - all extensions of this type
  • extensions_by_description_regex ( $regex ) - all extensions whose descriptions match this regex
  • extensions_by_author ( $author ) - all extensions by this author
  • extension_name_by_descriptionmsg ( $msg ) - the name of the extension with this description message
  • extension_type_by_name ( $name ) - the type of the extension with this name
  • extension_description_by_name ( $name ) - the description of the extension with this name
  • extension_descriptionmsg_by_name ( $name ) - the description message of the extension with this name
  • extension_author_by_name ( $name ) - the author of the extension with this name
  • extension_url_by_name ( $name ) - the URL of the extension with this name

Wiki extension tags

  • extensiontags_are_present() - true if there is info about extension tags, false if there is none
  • extensiontags() - all extension tags on this wiki, as this info generic structure
  • extensiontags_count() - the count of all extension tags on this wiki
  • extensiontag_exists ( $tag ) - true if such an extension tag exists, false if it does not

Function hooks

  • functionhooks_are_present() - true if there is info about function hooks, false if there is none
  • functionhooks() - all function hooks on this wiki, as this info generic structure
  • functionhooks_count() - the count of all function hooks on this wiki
  • functionhook_exists ( $hook ) - true if such a function hook exists, false if it does not

Show hooks

  • showhooks_are_present() - true if there is info about showhooks, false if there is none
  • showhooks() - all showhooks on this wiki, as this info generic structure
  • showhooks_count() - the count of all showhooks on this wiki
  • showhook_exists ( $hook ) - true if such a showhook exists, false if it does not
  • showhook_by_name ( $name ) - the info generic structure of the showhook with this name
  • showhooks_by_subscriber_regex ( $regex ) - all showhooks who have a subscriber matching this regex
  • showhook_subscribers_by_name ( $name ) - all subscribers of this showhook

Skins

  • skins_are_present() - true if there is info about wiki skins, false if there is none
  • skins() - all skins on this wiki, as this info generic structure
  • skins_count() - the count of all skins on this wiki
  • skins_codes() - all skins codes
  • skins_names() - all skins names
  • skin_code_exists ( $code ) - true if a skin with this code exists, false if it does not
  • skin_by_code ( $code ) - the info generic structure of the skin with this code
  • skin_name_exists ( $name ) - true if a skin with this name exists, false if it does not
  • skin_by_name ( $name ) - the info generic structure of the skin with this name
  • skin_name_by_code ( $code ) - the name of the skin with this code
  • skin_code_by_name ( $name ) - the code of the skin with this name

See also