Extension:WikiOpener

Foreword
This extension has been developed in the context of a bioinformatics/genomic context aiming at augmenting the wiki features to be able to include and update external structured data and run analysis tools. It allows to rapidly add specific component to include content extracted from databases (local or remote), files, and so on, to retrieve online data such as DAS servers, xml feeds, and so on, and also pass parameters to some software and format the results prior to their inclusion in the generated page.

For the above reasons, please bear in mind that this extension is generic and needs to be extended by specific components and is thus intended to developers.

What can this extension do?
The main purpose of this 'generic' extension is to interact with outside through the registration of specific components to: With this aim, a new tag, inout, has been defined and has the following usage:  Specific Component | Layout template | optional parameters separated by vertical bars . The extension will fetch the layout template (wiki text stored as a wiki article) and will replace the variable names by their actual values returned by the specific component (PHP wrapper).
 * manage structured data (databases, files, ...)
 * run (on-the-fly) analysis tools

For example, a specific component can retrieve data from a database about genes associated to a specific congenital heart defect (CHD) and would be called as follows:  genesForChdProvider | genesForChdLayoutTemplate | Atrial septal defect 

Additionally, the extension provides the possibility to register specific components to be called to include content before and/or after an article. The registration can be done for all pages, a specific page, all pages in a namespace, or a specific page of a given namespace.

Moreover, to ease interaction with structured data (databases), a mechanism to generate web forms is implemented. Similar to the rendering of a components results, the layout is specified in wiki text in an article. Also, another article describes the form input fields (textfield, textarea, popup menu, ...). Then a specific component may be implemented to retrieve and provide default values in the web form and also to process posted values.

As articles with no wiki content may actually contain automatically included content (all pages in a namespace for example), it is also possible to extend
 * the search function to perform a search in a database for example,
 * the articleExists function so that links look like they point to an existing page.

Download instructions
The extension code is available at http://www.esat.kuleuven.be/~bioiuser/chdwiki/inout.tar.gz

Installation
After downloading, unpack and move the entire inout directory to the extensions directory. Note that only inout/inout.php is required, the rest of the files are provided as a tutorial or quickstart guide.

To install this extension, add the following to LocalSettings.php:

Manual modifications to MediaWiki source
The extension makes use of hooks to
 * 1) automatically include content before or after an article, therefore the hook must be added in includes/Article.php
 * 2) extend the search engine to be able to search outside resources (e.g. databases). This means that includes/searchEngine.php is to be modified.
 * 3) trick the articleExists function to properly link to empty wiki articles that do contain automatic content. This is done in includes/Title.php

Note: if you only intend to use the inout tag, then these modifications are not needed.

includes/Article.php
In MediaWiki 1.13.1 before line 801, i.e. in method view before the comment Fetch content and check for errors add the followinghook: wfRunHooks('wgOutBeforeArticleContent',array(&$this,&$wgOut));

Then after the previous block (if (! $outputDone) ...), originally at after line 813 in MediaWiki 1.13.1 and before the comment Another whitelist check in case oldid is altering the title: wfRunHooks('wgOutAfterArticleContent',array(&$this,&$wgOut));

includes/SearchEngine.php
In method getNearMatch around lines 64-72 in MW 1.13.1, replace $title = Title::newFromText( $term ); if (is_null($title)) return NULL; if ( $title->getNamespace == NS_SPECIAL || $title->exists ) { return $title; } with $title = Title::newFromText( $term ); if (is_null($title)) return NULL; $found = false; wfRunHooks('wgSearchEngineGetNearMatch',array(&$term,&$title,&$found)); if ($found) { return $title; }				 if ( $title->getNamespace == NS_SPECIAL || $title->exists ) { return $title; }
 * 1) Exact match? No need to look further.
 * 1) Exact match? No need to look further.

includes/Title.php
Replace method (lines 3058-3069 in MW 1.13.1) public function isAlwaysKnown { // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes // the full l10n of that language to be loaded. That takes much memory and // isn't needed. So we strip the language part away. // Also, extension messages which are not loaded, are shown as red, because // we don't call MessageCache::loadAllMessages. list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 ); return $this->isExternal || ( $this->mNamespace == NS_MAIN && $this->mDbkeyform == '' ) || ( $this->mNamespace == NS_MEDIAWIKI && wfMsgWeirdKey( $basename ) ); } with public function isAlwaysKnown { // If the page is form Mediawiki:message/lang, calling wfMsgWeirdKey causes // the full l10n of that language to be loaded. That takes much memory and // isn't needed. So we strip the language part away. // Also, extension messages which are not loaded, are shown as red, because // we don't call MessageCache::loadAllMessages. list( $basename, /* rest */ ) = explode( '/', $this->mDbkeyform, 2 ); return _inout_articleExists($this) || $this->isExternal || ( $this->mNamespace == NS_MAIN && $this->mDbkeyform == '' ) || ( $this->mNamespace == NS_MEDIAWIKI && wfMsgWeirdKey( $basename ) ); }