Jump to content

Manual:Architectural modules/OutputPage

From mediawiki.org
Module
OutputPage
Responsibilities Represents an object incorporating the necessary information to produce the final HTML view of the page
Implementation As a single class OutputPage

Responsibilities

[edit]

OutputPage represents an object, that incorporates the necessary information to produce the final HTML view of the page. An essential part of this information comes from ParserOutput, where bodyText (HTML text of the page body) is the most important one. When these and other relevant parts are accumulated in the OutputPage, it is ready to output all this information by calling Skin module for rendering it properly. OutputPage handles outputting of all kinds of pages (articles, talk pages, file pages etc.) and special pages. It also handles the output of error pages. When something goes wrong with the request, for example, a user without right permissions is trying to delete a page, it will prepare a necessary error page and pass it to the Skin module.

Implementation Information

[edit]

OutputPage module is implemented as a single class OutputPage. It has 70 member variables that hold all the information relevant for the output of the page in HTML. Some of the common member variables for all types of pages are listed below:

  • mPageTitle – the title of the page
  • mBodyText – the text of HTML element <body>
  • mLastModified – the timestamp of last modification
  • mModules – modules (JavaScript or CSS files) that should be loaded
  • mDoNothing – indicates, whether output is disabled (a cached version from the browser will be served)
  • VaryHeader – HTTP vary header
  • ...

Some member variables are only applicable for specific types of pages. For example, history page will have such fields as mRevisionId, mRevisionTimestamp or mTemplateIds set to null, as it does not show a single page, but a list of previous revisions. And only a file page will have mFileVersion filled with value, as other pages do not have this information. Thus, OutputPage is a generic object that will be filled with data, that needs to be present for a specific type of page, leaving irrelevant fields empty.

The core method here is output(), that calls Skin module for creating the final HTML. Furthermore, it has several methods to prepare error pages, that will be eventually handled again by the output() method.