Some docs about magic words and the new hooks.
[lhc/web/wiklou.git] / docs / magicword.txt
1 magicword.txt
2
3 Magic Words are some phrases used in the wikitext. They are defined in several arrays:
4 * $magicWords (includes/MagicWord.php) includes their internal names ('MAG_XXX').
5 * $wgVariableIDs (includes/MagicWord.php) includes their IDs (MAG_XXX, which are constants),
6 after their internal names are used for "define()".
7 * Localized arrays (languages/LanguageXX.php) include their different names to be used by the users.
8
9 The localized arrays keys are the internal IDs, and the values are an array, whose include their
10 case-sensitivity and their alias forms. The first form defined is used by the program, for example,
11 when moving a page and its old name should include #REDIRECT.
12
13 Adding magic words should be done using several hooks:
14 * "MagicWordMagicWords" should be used to add the internal name ('MAG_XXX') to $magicWords.
15 * "MagicWordwgVariableIDs" should be used to add the ID (MAG_XXX constant) to $wgVariableIDs.
16 * "AddMagicWordsXX" (XX is the language code, e.g. En or De) should be used to add the
17 different names of the magic word. Use both the localized name and the English name.
18
19 For example:
20
21 $wgHooks['MagicWordMagicWords'][] = 'wfAddCustomMagicWord';
22 $wgHooks['MagicWordwgVariableIDs'][] = 'wfAddCustomMagicWordID';
23 $wgHooks['AddMagicWordsEn'][] = 'wfAddCustomMagicWordEn';
24 $wgHooks['AddMagicWordsEs'][] = 'wfAddCustomMagicWordEs';
25
26 function wfAddCustomMagicWord( &$magicWords ) {
27 $magicWords[] = 'MAG_CUSTOM';
28 }
29
30 function wfAddCustomMagicWordID( &$magicWords ) {
31 $magicWords[] = MAG_CUSTOM;
32 }
33
34 function wfAddCustomMagicWordEn( &$magicWords ) {
35 $magicWords[MAG_CUSTOM] = array( 0, "#custom" );
36 }
37
38 function wfAddCustomMagicWordEs( &$magicWords ) {
39 $magicWords[MAG_CUSTOM] = array( 0, "#aduanero", "#custom" );
40 }