User:Daniel Kinzler (WMDE)/MCR-PageTypeHandler


The idea of PageTypeHandlers is to allow extensions to concisely define new types of pages, and clearly define how they behave, what they look like.

MediaWiki supports the idea of page types through the dual class hierarchy based in Page and in Article, and less formally through special case code and hooks in WikiPage. The "file" page type is implemented by WikiFilePage extending WikiPage, ImagePage extending Article, and some special case handling in WikiPage::onArticleDelete(). Special behavior hard coded in WikiPage::doEditUpdates() effectively defines page types for "messages" and "modules".

With MCR, there is a need to somehow determine which slots exist on a page, and how they interact with the main slot. This is conceptually connected to what content model(s) the main slot of such a page should support, as well as with the need to control display, the edit interface, as well as behavior on creation, deletion, etc.

PageTypeHandler is intended to provide an abstraction for defining page types.

(interface draft TBD)

Note that conceptually, the PageTypeHandler determines the SlotRoleHandlers, which in turn determines the content model of the main slot. On the other hand, the ''actual'' content model of the main slot may determine the page type! It would be nicer to record the type of the page in the database, instead of relying on the current revision's main slot's content model to determine the page type (as would be needed e.g. to find out if a given talk page uses Flow or not).

Conceptually, changing the (main slot's) content model really means changing the page type ("flow" is a different type from the more generic "discussion" type). In order to be able to display old revisions, there may even be a need to record the page type per revision. Or we stick to determining it based on the content model - which is simpler, but conceptually messy.