Index: trunk/extensions/SemanticTitle/SemanticTitle.php |
— | — | @@ -27,8 +27,10 @@ |
28 | 28 | $wgAutoloadClasses[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.class.php'; |
29 | 29 | |
30 | 30 | global $wgHooks; |
31 | | -$wgHooks[ 'BeforePageDisplay' ][] = 'SemanticTitle::onBeforePageDisplay'; |
32 | | -$wgHooks[ 'LinkBegin' ][] = 'SemanticTitle::onLinkBegin'; |
| 31 | +$wgHooks[ 'BeforePageDisplay' ][] = 'SemanticTitle::onBeforePageDisplay'; |
| 32 | +$wgHooks[ 'LanguageGetMagic' ][] = 'SemanticTitle::onLanguageGetMagic'; |
| 33 | +$wgHooks[ 'LinkBegin' ][] = 'SemanticTitle::onLinkBegin'; |
| 34 | +$wgHooks[ 'ParserFirstCallInit' ][] = 'SemanticTitle::onParserFirstCallInit'; |
33 | 35 | |
34 | 36 | global $wgExtensionMessagesFiles; |
35 | 37 | $wgExtensionMessagesFiles[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.i18n.php'; |
— | — | @@ -41,7 +43,7 @@ |
42 | 44 | 'path' => __FILE__, |
43 | 45 | 'name' => 'SemanticTitle', |
44 | 46 | 'license' => 'AGPLv3', |
45 | | - 'version' => '0.0.1', |
| 47 | + 'version' => '0.0.2', |
46 | 48 | 'author' => array( '[https://www.mediawiki.org/wiki/User:Van_de_Bugger Van de Bugger]' ), |
47 | 49 | 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticTitle', |
48 | 50 | 'descriptionmsg' => 'semantictitle-desc', |
Index: trunk/extensions/SemanticTitle/SemanticTitle.class.php |
— | — | @@ -117,6 +117,33 @@ |
118 | 118 | } // function onBeforePageDisplay |
119 | 119 | |
120 | 120 | |
| 121 | + static function onLanguageGetMagic( &$magicWords, $langCode ) { |
| 122 | + // 0 means the magic word is *not* case sensitive. |
| 123 | + // 1 means the magic word *is* case sensitive. |
| 124 | + $magicWords[ 'semantic-title' ] = array( 1, 'semantic-title' ); |
| 125 | + return true; |
| 126 | + } // function onLanguageGetMagic |
| 127 | + |
| 128 | + |
| 129 | + static function onParserFirstCallInit( &$parser ) { |
| 130 | + $parser->setFunctionHook( 'semantic-title', __CLASS__ . '::hookSemanticTitle' ); |
| 131 | + return true; |
| 132 | + } // function onParserFirstCallInit |
| 133 | + |
| 134 | + |
| 135 | + static public function hookSemanticTitle( $parser, $arg ) { |
| 136 | + $res = $arg; |
| 137 | + $title = Title::newFromText( $arg ); |
| 138 | + if ( $title != null ) { |
| 139 | + $semantic = self::getText( $title ); |
| 140 | + if ( $semantic !== false ) { |
| 141 | + $res = $semantic; |
| 142 | + }; // if |
| 143 | + } |
| 144 | + return $res; |
| 145 | + } // function hookSenabticTitle |
| 146 | + |
| 147 | + |
121 | 148 | } // class SemanticTitle |
122 | 149 | |
123 | 150 | // end of file // |