Extension:PagesOnDemand

Rationale and Features
We wanted an easy way to force certain pages to use defined templates based on the structure of the page title. With PagesOnDemand, pages are created from templates when users follow links if the link matches a string comparison that tells the PagesOnDemand system that the desired page is of a desired type. For example, pages with titles that match the regular expression '/^PMID:\\d+$/' are recognized by PagesOnDemand.php (and subsequently PMID_OnDemand.php) as being about articles in the scientific literature. When the system recognizes this pattern, it creates a page based on a template for wiki articles about the scientific literature and then forwards the user to the newly created page, instead of to an edit page. PagesOnDemand effectively makes some "red links" behave like "blue links".

Installing this extension by itself won't affect the wiki in and of itself, instead offloading the real work to modules capable of performing the article insertion. PagesOnDemand hooks at ArticleFromTitle and does the following when a link is clicked: Two examples of such modules are provided with the distribution. We hope others will write additional modules.
 * short circuits and returns true if the article already exists
 * provides a hook, PagesOnDemand, that passes the title and article objects to any extensions that hook there (modules).
 * on return, ensures that the user will be forwarded to the article view after any other extensions hooking at ArticleFromTitle have had a chance to run

What the modules do
Modules should be written to examine the title using a string comparison function to determine whether a page should be created or not. If not, return true. If the module finds a match to the page title, it should generate the desired prepopulation text somehow and create the article. This is demonstated by the DemoOnDemand code (included from DemoOnDemand):

Status
Tested with MediaWiki 1.8.3 and 1.9.3. Help testing this extension on other versions will be appreciated!

Installation

 * Download pagesondemand.tgz
 * unpack in your extensions directory. Files included:
 * PagesOnDemand.php - the main extension
 * DemoOnDemand - a demo of how to write new extensions that hook into PagesOnDemand
 * PMID OnDemand - an extension to create pages for papers in the National Library of Medicine PubMed system, using a template page and PubMed's E-utilities
 * add
 * to LocalSettings.php, along with require statements for any additional extensions that use PagesOnDemand

Alternatives
Inputbox can be used to prepopulate a new page, but it takes you to an edit page, not the page itself. In particular, the Inputbox extension cannot be used to run arbitrary PHP code (the module) to generate the page text.