WikiToLearn

WikiToLearn uses mediawiki, which is a massive framework for making wikis written in PHP. It is designed to be very flexible, allowing many different kinds of extensions.

MediaWiki supports two different types of flexibility: skins and extensions. Here we will discuss the steps you need to go through to make extensions.

How MediaWiki works
MediaWiki is driven by a text format called wikitext--it contains all the content, formatting, images, and everything else for a page. This is stored in a database, along with other metadata like title.

Most extensions extend MediaWiki by utilizing what are called hooks, which define a place to register a callback to an event. (Think signal/slots). A full list of basic hooks lives here.

Different languages
There are many ways to separate content for different languages in a wiki, but WikiToLearn just has an entirely different wiki for each language (except for meta and pool)

The file
The  defines the extensions that should be loaded for a wiki, and the settings for each extension. You can look at WikiToLearn's here. Every wiki must have this file.

Loading an extension
There are two different "types" of extensions: ones that use the new extension format and those who don't. We will explain the difference in the files later.

Loading an extension with the old format
The old format for extensions just uses a simple `require_once` for loading the extension: For example:

Loading an extension with the new format
Loading an extension with the new format is much easier: For example:

Checking if an extension is loaded
Many extensions aren't obvious when they are enabled, so it is often helpful to check if you extension is loaded. To do this, go to  so in the case of a local instance, it would be en.tuttorotto.biz/Special:Version. This page has a list of the extensions, the authors, copyright information, etc for each extension.

The extension file structure
Extensions need only a few files to work:

WikiToLearn
 * extensions
 * {extension_name}
 * extension.json
 * {other php files}
 * i18n
 * {language code}.json
 * COPYING (optional)
 * COPYING (optional)

The {extension_name} directory
This is in the  directory of the root WikiToLearn folder. At WikiToLearn, we put all of our extensions in different repositories, and then link then into the  using a git submodule. Extension are almost always not necessarily specific for WikiToLearn, so there is no reason not to be modular when it is so easy.

The file
This file defines all of the data that MediaWiki needs to load the extension. This includes the authors, copyright, hooks, classes to load, and many more things.

Making a file
The first thing you are going to want to do when you make an extension is to make the  file, without it you cannot load your extension!

Start with the opening  that every JSON file must start with:

Now let's add the extension name:



Now a list of authors:



Then the licence file. In order to get a working link to your license in the Special:Version page, you need to have the  file. In the  file you will only define the name of the license, it will be linked to the   automatically.



Next, you can provide an (optional) url to a homepage for your extension. This will often be mediawiki.org/wiki/Extension:{extension name}.