r113659 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113658‎ | r113659 | r113660 >
Date:20:33, 12 March 2012
Author:van-de-bugger
Status:new
Tags:
Comment:
Parser function #semantic-title implemented.
Modified paths:
  • /trunk/extensions/SemanticTitle/SemanticTitle.class.php (modified) (history)
  • /trunk/extensions/SemanticTitle/SemanticTitle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticTitle/SemanticTitle.php
@@ -27,8 +27,10 @@
2828 $wgAutoloadClasses[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.class.php';
2929
3030 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';
3335
3436 global $wgExtensionMessagesFiles;
3537 $wgExtensionMessagesFiles[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.i18n.php';
@@ -41,7 +43,7 @@
4244 'path' => __FILE__,
4345 'name' => 'SemanticTitle',
4446 'license' => 'AGPLv3',
45 - 'version' => '0.0.1',
 47+ 'version' => '0.0.2',
4648 'author' => array( '[https://www.mediawiki.org/wiki/User:Van_de_Bugger Van de Bugger]' ),
4749 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticTitle',
4850 'descriptionmsg' => 'semantictitle-desc',
Index: trunk/extensions/SemanticTitle/SemanticTitle.class.php
@@ -117,6 +117,33 @@
118118 } // function onBeforePageDisplay
119119
120120
 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+
121148 } // class SemanticTitle
122149
123150 // end of file //

Status & tagging log