Manual:Architectural modules/Page
Module | |
Page | |
Responsibilities | Representing different kinds of pages that are not special pages |
Implementation | Different types of pages implemented in the form of hierarchy using the inheritance concept |
Responsibilities
editThe 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
editThere 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 Page
that is an abstract class for accepting all kinds of pages. On the next level there are Article
and WikiPage
. Article
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 (OutputPage
), that will be rendered in HTML. Besides wiki articles itself, history pages, discussion pages, user pages etc. are also instances of Article
class. Furthermore, this class implements not only viewing, but also deleting, protecting/unprotecting and rendering of the articles. Thus Article
class can be called a controller for these actions as it implements the business logic. WikiPage
is a model object for article. This class calls database objects to retrieve data or to write it. Article
holds a WikiPage
as $mPage
variable.
For example, if an article needs to be deleted, i.e 'delete' request is received, Article
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 WikiPage
, that will use database objects to write changes to the database. This process is shown on figure Handling of article deletion.
CategoryPage
and ImagePage
are subccasses of Article
. CategoryPage
is a class for viewing category page with the list of pages included in the category and the list of subcategories. ImagePage
is a class for viewing file description page with information about the file. WikiCategoryPage
and WikiFilePage
are the classes representing the model objects category page and file page respectively and follow the same concept as in the relationship Article
- WikiPage
. For instance, CategoryPage
holds a WikiCategoryPage
object as a variable $mPage
.
The class EditPage
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 EditPage
to the Article
can be seen on the figure Relationship between EditPage and Article. WikiPage
, contained in Article
, 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: Title
and Revision
. Both of these objects are member variables of WikiPage
class as shown on the figure Relationship between Article, WikiPage, Title and Revision.
Title
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. Title
object is created from the request parameter 'title'. WikiPage
is created from Title
using WikiPageFactory.
After the creation of WikiPage
the Revision
object is loaded. Revision
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 WikiPage
is a sort of a container to hold the Title
and specific Revision
, that was requested.
In the code Page module related classes are not grouped in a special package, but appear randomly in the package includes
together with other unrelated classes.