Integration of mediawiki
From Dokeos
The mediawiki, perhaps the most powerful wiki software on the planet and used for large collections of knowledge like the wikipedia, is not the easiest wiki to integrate. However, it can be accomplished.
The mediawiki is a database-driven wiki. It uses one central index.php file - with dozens of includes - to manage everything. So that seems simple: just add the Dokeos context, header and foter to and and we're halfway there.
This page describe how to do that, while we're doing it- we are not finished yet.
Contents |
General issues
- The mediawiki uses a complex caching and buffering system. One integration test produced nothing but empty pages, until we changed all echo statements to print statements.
Getting the Dokeos context
Including the claro_init_global.inc.php into the index.php immediately gives an error. Why? The mediawiki has a Database class. Dokeos also has a Database class. PHP has no namespaces or clear class organisations like e.g. Java has, so this sort of thing pops up regularly.
A quick fix
One simple solution is to create a special claro_init_global.inc.php file that does not include the Database class of Dokeos. This works, and after that you have the Dokeos context and you can include the header and footer. As a proof of concept, this sure is nice. For production use, this is wading knee-deep in the foggy marsh.
As Dokeos developer, it made more sense to let Dokeos stay as is, and change the meadiwiki to fit our needs. Vice-versa is howevr also possible. This is a possible fix: do a global find-and-replace of Database in the mediawiki, replacing it by "WikiDatabase". That should solve it (or completely screw the wiki up - this needs to be tested).
Mediawiki index.php changes
Add this to the start of the index.php file, just below the <?php
//DOKEOS ----------------------------------------------------
$dirname = dirname(__FILE__);
//modify this to be correct for your Dokeos version
//this is relative to your mediawiki folder
//special global init file, without include of Database class
$dokeos_global_init_script = $dirname . "/../../claroline/inc/wiki_init_global.inc.php";
//normal global init file, this works only if you've changed the name of one of the Database classes
$dokeos_global_init_script = $dirname . "/../../claroline/inc/claro_init_global.inc.php";
$langFile = array ('courses', 'index');
require_once($dokeos_global_init_script);
//DOKEOS ----------------------------------------------------
Including the header and footer
The includes/OutputPage has an output() method. Here you can make changes, we're not saying that this is the best place to put things but it works. Near he end, we've added include statements:
//DOKEOS ----------------------------------------------------
$dokeos_include_path = api_get_include_path();
include_once($dokeos_include_path . '/wiki_init_banner.inc.php');
//DOKEOS ----------------------------------------------------
if ($this->mArticleBodyOnly) {
$this->out($this->mBodytext);
} else {
wfProfileIn( 'Output-skin' );
$sk->outputPage( $this );
wfProfileOut( 'Output-skin' );
}
//DOKEOS ----------------------------------------------------
$dokeos_include_path = api_get_include_path();
//print "dokeos include path = $dokeos_include_path";
include_once($dokeos_include_path . '/wiki_dokeos_footer.inc.php');
//DOKEOS ----------------------------------------------------
Why do we need a special wiki version of the Dokeos header and footer? Because using echo statements like in the normal header and footer seems to mess up the whole output system of Mediawiki.
Here's a quick version of the footer:
print '< div class="clear">

