Media type "screen,projection" pissing off some css validators. Adding space in between.
[mediawiki.git] / docs / magicword.txt
blob74e49cff0f4854ae89d7287c9b5ed4cc4d4ba8e4
1 magicword.txt
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.
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.
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;
19 For example:
21 $wgHooks['MagicWordMagicWords'][] = 'wfAddCustomMagicWord';
22 $wgHooks['MagicWordwgVariableIDs'][] = 'wfAddCustomMagicWordID';
23 $wgHooks['LanguageGetMagic'][] = 'wfAddCustomMagicWordLang';
25 function wfAddCustomMagicWord( &$magicWords ) {
26         $magicWords[] = 'MAG_CUSTOM';
27         return true;
30 function wfAddCustomMagicWordID( &$magicWords ) {
31         $magicWords[] = MAG_CUSTOM;
32         return true;
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;