Manual:Developing extensions

Su carrera como sommelier comenzó en la Argentina, donde trabajó para los restaurantes Restó y Nectarine, y, simultáneamente, se desempeñó como docente y fue jurado del prestigiosos concurso internacional Decanter World Wine Awards.Actualmente se desempeña como operador de Colonia Suiza



When you develop an extension, replace MyExtension above with the name of your extension. Use UpperCamelCase names for its directory and PHP file(s); this is the general file naming convention. (The is a good starting point for your extension.)

The three parts of an extension, setup, execution, and, localisation as well as extension types and licensing and publishing your extension are described in the following sections of this page.



Registering features with MediaWiki
MediaWiki lists all the extensions that have been installed on its  page. For example, you can see all the extensions installed on this wiki at Special:Version. It is good form to make sure that your extension is also listed on this page. To do this, you will need to add an entry to $wgExtensionCredits for each media handler, parser function, special page, custom XML tag, and variable used by your extension. The entry will look something like this:

Localisation
(Note: While developing, you may want to disable both cache by setting $wgMainCacheType = CACHE_NONE and $wgCacheDirectory = false, otherwise your system message changes may not show up).

If you want your extension to be used on wikis that have a multi-lingual readership, you will need to add localisation support to your extension.

Store messages in .json

 * Store message definitions in a localisation JSON-file, one for each language key your extension is translated in. The messages are saved with a message key and the message itself using standard JSON format. Each message id should be lowercase and may not contain spaces.  An example you can find e.g. in extension MobileFrontend. Here is an example of a minimal JSON file (in this case en.json:

en.json

Store message documentation in qqq.json
The documentation for message keys can be stored in the JSON file for the pseudo language with code qqq. A documentation of the example above can be:

qqq.json:

Define messages

 * Assign each message a unique, lowercase, no space message id; e.g., uploadwizard-desc
 * For any text string displayed to the user, define a message.
 * MediaWiki supports parameterized messages and that feature should be used when a message is dependent on information generated at runtime. Parameter placeholders are specified with $n, where n represents the index of the placeholder; e.g.,

Define message documentation

 * Each message you define needs to have an associated message documentation entry Localisation; in qqq.json e.g.

Load the localisation file

 * In your setup routine, define the location of your messages files (e.g. in directory i18n/):

Use wfMessage in PHP

 * In your setup and implementation code, replace each literal use of the message with a call to . In classes that implement IContextSource (as well as some others such as subclasses of SpecialPage), you can use   instead. Example:

Use mw.message in JavaScript
It's possible to use i18n functions in JavaScript too. Look at Manual:Messages_API for details.

Extension types
Extensions can be categorized based on the programming techniques used to achieve their effect. Most complex extensions will use more than one of these techniques:


 * Subclassing: MediaWiki expects certain kinds of extensions to be implemented as subclasses of a MediaWiki-provided base class:
 * Special pages – Subclasses of the SpecialPage class are used to build pages whose content is dynamically generated using a combination of the current system state, user input parameters, and database queries. Both reports and data entry forms can be generated.  They are used for both reporting and administration purposes.
 * Skins – Skins change the look and feel of MediaWiki by altering the code that outputs pages by subclassing the MediaWiki class SkinTemplate.
 * Hooks – A technique for injecting custom php code at key points within MediaWiki processing. They are widely used by MediaWiki's parser, its localization engine, its extension management system, and its page maintenance system.
 * Tag-function associations – XML style tags that are associated with a php function that outputs HTML code. You do not need to limit yourself to formatting the text inside the tags.  You don't even need to display it.  Many tag extensions use the text as parameters that guide the generation of HTML that embeds google objects, data entry forms, RSS feeds, excerpts from selected wiki articles.
 * Magic words – A technique for mapping a variety of wiki text string to a single id that is associated with a function. Both variables and parser functions use this technique. All text mapped to that id will be replaced with the return value of the function.  The mapping between the text strings and the id is stored in the array $magicWords. The interpretation of the id is a somewhat complex process – see Manual:Magic words for more information.
 * Variables – Variables are something of a misnomer. They are bits of wikitext that look like templates but have no parameters and have been assigned hard-coded values. Standard wiki markup such as   or   are examples of variables.  They get their name from the source of their value: a php variable or something that could be assigned to a variable, e.g. a string, a number, an expression, or a function return value.
 * Parser functions – .  Similar to tag extensions, parser functions process arguments and returns a value.  Unlike tag extensions, the result of parser functions is wikitext.
 * API modules – you can add custom modules to MediaWiki's "action" web API, that can be invoked by JavaScript, bots or third-party clients.

Support other core versions
You can visit the extension support portal to keep on top of changes in future versions of mediawiki and also add support for older versions that are still popular.

Publishing
To autocategorize and standardize the documentation of your existing extension, please see Template:Extension. To add your new extension to this Wiki:

Deploying and registering
Consult Writing an extension for deployment. If your extension adds namespaces, you may wish to register its default namespaces; likewise, if it adds database tables or fields, you may want to register those at database table and field registration.

Help documentation
You should provide public-domain help documentation for features provided by your extension. Help:CirrusSearch is a good example. You should give users a link to the documentation via the addHelpLink function.

Providing support / collaboration
Extension developers should open an account on Wikimedia's Phabricator, and request a new project for the extension. This provides a public venue where users can submit issues and suggestions, and you can collaborate with users and other developers to triage bugs and plan features of your extension.