Manual:Architectural modules/Page

Responsibilities
The Page module of MediaWiki is responsible for representing different kinds of pages that are not special pages. These 'normal' pages have distinct types of content determined by the namespace (except for history page). For example, the following types of pages can be found :


 * Article page - Shows the content of the article
 * Talk page - Shows the discussion page for the 'main' page (article, user, category etc.)
 * History page - Shows all revisions of the article
 * User page - Page of the user
 * File page - Page for an image, audio or video file
 * Category page - Page for category

The Page module implements these objects as classes and handles the viewing and editing of them.

Implementation Information
There are different types of pages in MediaWiki and they are implemented in the form of hierarchy using the inheritance concept as shown on the graphic Controller pages and model pages. There is a high-level class called that is an abstract class for accepting all kinds of pages. On the next level there are and. is a class for viewing MediaWiki articles. This class handles the presentation of articles, it manages all the necessary steps to prepare an output object, that will be rendered in HTML. Besides wiki articles itself, history pages, discussion pages, user pages etc. are also instances of class. Furthermore, this class implements not only viewing, but also deleting, protecting/unprotecting and rendering of the articles. Thus class can be called a controller for these actions as it implements the business logic. is a model object for article. This class calls database objects to retrieve data or to write it. holds a as  variable.

For example, if an article needs to be deleted, i.e 'delete' request is received, class will handle all the necessary preprocessing: it will check the permissions, check that article has not been deleted yet, generate deletion reason etc. After verifying that everything is correct, it will call the actual deletion method on, that will use database objects to write changes to the database. This process is shown on figure Handling of article deletion.

and are subccasses of. is a class for viewing category page with the list of pages included in the category and the list of subcategories. is a class for viewing file description page with information about the file. and are the classes representing the model objects category page and file page respectively and follow the same concept as in the relationship  -. For instance, holds a  object as a variable.

The class handles the creation of new pages and editing of existing ones, it is a controller for edit action. If an article, category page or image page are modified or created, then this is the class that processes such requests. The relationship of to the  can be seen on the figure Relationship between EditPage and Article. , contained in, performs the actual saving of changes to the database.

Besides already mentioned classes there are 2 more classes that are included into the Page module: and. Both of these objects are member variables of class as shown on the figure Relationship between Article, WikiPage, Title and Revision.

class represents article's title, that is the name of the article that can be seen by users. Furthermore, titles serve as URL to access the article and as a key to retrieve the article from the database. object is created from the request parameter 'title'. is created from by calling.

After the creation of the  object is loaded. represents a specific version of the article and holds the text of the article for this revision. An article has one title, but can have many revisions. Thus is a sort of  a container to hold the  and specific, that was requested.

In the code Page module related classes are not grouped in a special package, but appear randomly in the package together with other unrelated classes.