Data arrays

From Apibot
Jump to: navigation, search

The data Apibot fetches, processes and writes back can be used as either objects or PHP arrays. Most of the objects are descendants of the Dataobject class. Here are described the PHP arrays used.

Queried info entries

Page

Objects of the Page class are typically used around a page fetched for editing. The object data() function will return the page array, as it was fetched by the API (or simulated by the Web backend).

In addition, if one or more revisions are fetched (the default case), the first of them will be used as the actual page revision. The following properties of it will be moved for ease of use directly to the page array:

  • * (as text)
  • timestamp
  • revid
  • parentid
  • size
  • user
  • comment

Page elements

Many methods of the Page class extract or work with page elements, represented as arrays. A short description follows:

Wikilink

A wikilink array will have the following members:

  • colon (boolean) - true if the wikilink starts with a colon, false if it doesn't
  • wiki - the wiki part of the wikilink; empty string or NULL if not present
  • namespace - the namespace part of the wikilink; empty string or NULL if not present
  • name - the page name part of the wikilink
  • anchor - the anchor part of the wikilink; empty string or NULL if not present
  • text - the text part of the wikilink; empty string or NULL if not present
  • newline_after (boolean) - true if the wikilink is followed by a newline, false if it is not

Category

A category array will have the following members:

  • namespace - the namespace part of the category, if present; empty string or NULL if not present
  • name - the category name part of the category
  • sortkey - the sortkey part of the category; empty string or NULL if not present
  • newline_after (boolean) - true if the category is followed by a newline, false if it is not

Interwiki

An interwiki array will have the following members:

  • wiki - the wiki part of the interwiki; empty string or NULL if not present
  • namespace - the namespace part of the interwiki, if present; empty string or NULL if not present
  • name - the page name part of the interwiki
  • newline_after (boolean) - true if the interwiki is followed by a newline, false if it is not

Filelink

A filelink array will have the following members:

  • namespace - the namespace part of the filelink, if present; empty string or NULL if not present
  • name - the file name part of the filelink
  • params - an array with the filelink parameters:
    • format - the filelink format field (stuff like "border", "frame", "frameless", "thumb", "thunbnail" etc)
    • resize - the filelink size field (stuff like "img_width", "upright" etc)
    • align - the filelink horizontal alignment field ("left", "right", "center", "none"...)
    • valign - the filelink vertical alignment field ("baseline", "sub", "super", "top", "text-top", "middle", "bottom", "text-bottom"...)
    • link - the filelink image link
    • alt - the filelink image "alt" text
    • page - the filelink image page text

Template

A template array will have the following members:

  • wiki - the wiki name part of the template, if present; empty string or NULL if not present
  • namespace - the namespace part of the template, if present; empty string or NULL if not present
  • name - the file name part of the template
  • params - an array with the template parameters (names / numbers as keys, parameter content as values)