Documentation file about the magic words.
[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 * "LanguageGetMagic" should be used to add the different names of the magic word. Use both
17 the localized name and the English name. Get the language code by the parameter $langCode;
18
19 For example:
20
21 $wgHooks['MagicWordMagicWords'][] = 'wfAddCustomMagicWord';
22 $wgHooks['MagicWordwgVariableIDs'][] = 'wfAddCustomMagicWordID';
23 $wgHooks['LanguageGetMagic'][] = 'wfAddCustomMagicWordLang';
24
25 function wfAddCustomMagicWord( &$magicWords ) {
26 $magicWords[] = 'MAG_CUSTOM';
27 return true;
28 }
29
30 function wfAddCustomMagicWordID( &$magicWords ) {
31 $magicWords[] = MAG_CUSTOM;
32 return true;
33 }
34
35 function wfAddCustomMagicWordLang( &$magicWords, $langCode ) {
36 switch ( $langCode ) {
37 case 'es':
38 $magicWords[MAG_CUSTOM] = array( 0, "#aduanero", "#custom" );
39 break;
40 default:
41 $magicWords[MAG_CUSTOM] = array( 0, "#custom" );
42 }
43 return true;
44 }