Manual:Code

This page describes the primary source files (classes) / objects of the MediaWiki code.

index.php
on SVN (main directory)

Main acces point for the MediaWiki software. It handles the most of requests. See Manual:Index.php.

Wiki.php
on SVN (directory "includes")

This file consists of the definition of the class MediaWiki.

See also Manual:Wiki.php.

Setup.php
on SVN (directory "includes")

This file contains, among other things: With or without using function StubObject in StubObject.php, this creates an instance $wgOut of class OutputPage in OutputPage.php, etc.

User.php
on SVN (directory "includes")

Encapsulates the state of the user viewing/using the site. Can be queried for things like the user's settings, name, etc. Handles the details of getting and saving to the user table of the database, and dealing with sessions and cookies.

OutputPage.php
on SVN (directory "includes")

Contains:
 * function output, called from function finalCleanup in Wiki.php. It calls function outputPage in Skin.php.
 * function out, called from function outputPage in Skin.php a number of times, to send the HTML to the user: $mBodytext and HTML before and after it.

This file contains function (deprecated, use addWikiText in Article.php instead!)addPrimaryWikiText which:
 * applies function parse in Parser.php to the wikitext $text, resulting in the HTML text $text
 * applies function addParserOutput to the HTML text $text, which:
 * applies function addHTML to $text, which appends $text to $mBodytext.

Parser.php
on SVN (directory "includes")

This file defines the parser object used to convert a string $text from wikitext to HTML. It contains function parse, which performs the parsing in several stages:
 * 1) It calls function strip, which strips and renders nowiki, pre, math, and hiero. This function is preceded by the ParserBeforeStrip hook and followed by the ParserAfterStrip hook.
 * 2) It calls function internalParse, which converts the string $text from wikitext to HTML. It expands variables and templates, replaces wiki markup such as header codes and double and triple quotation marks with their HTML equivalents, converts double-bracketed phrases into A HREF links to internal wiki pages, and converts single-bracketed URLs into A HREF links to external pages.
 * 3) It calls function tidy, which does some HTML cleanup. This function is preceded by the ParserBeforeTidy hook and followed by the ParserAfterTidy hook.

Title.php
on SVN (directory "includes") Represents the title of an article, and does all the work of translating among various forms such as plain text, URL, database key, etc. For convenience, and for historical reasons, it also represents a few features of articles that don't involve their text, such as access rights.

Article.php
on SVN (directory "includes")

In Article.php, e.g. in function outputWikiText, function parse from wgParser is called, which is an instance of class Parser in Parser.php.

Encapsulates access to the revision table etc. of the database. The object represents an article, and maintains state such as text (in wikitext format), flags, etc.

Skin.php
on SVN (directory "includes")

Encapsulates a "look and feel" for the wiki. All of the functions that render HTML, and make choices about how to render it, are here, and called from various other places when needed.

Contains function outputPage, called from function output in OutputPage.php. Function outputPage calls function out in OutputPage.php a number of times, to send the HTML to the user: $mBodytext and HTML before and after it.

The StandardSkin object is a complete implementation, and is meant to be subclassed with other skins that may override some of its functions. The User object contains a reference to a skin (according to that user's preference), and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser->getSkin.

Language.php
on SVN (directory "languages")

Represents the language used for incidental text, and also has some character encoding functions and other locale stuff. A global one is allocated in $wgLang.

See also internationalisation.

LinkCache.php
on SVN (directory "includes")

Keeps information on existence of articles. See LINKCACHE.TXT.

API
The api code has an external access point /api.php, but can also be used internally by other code. See api page for in depth description.