r114069 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114068‎ | r114069 | r114070 >
Date:21:05, 17 March 2012
Author:van-de-bugger
Status:new (Comments)
Tags:
Comment:
SemanticTitle: New hook implemented to eliminate need in DEFAULTSORT, but not enabled due to issue (unknown parser).
Modified paths:
  • /trunk/extensions/SemanticTitle/SemanticTitle.class.php (modified) (history)
  • /trunk/extensions/SemanticTitle/SemanticTitle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticTitle/SemanticTitle.class.php
@@ -131,6 +131,43 @@
132132 } // function onParserFirstCallInit
133133
134134
 135+ // This hook is not enabled yet.
 136+ static public function onSMWStore_updateDataAfter( SMWStore $smw_store, SMWSemanticData $data ) {
 137+
 138+ global $egSemanticTitle;
 139+
 140+ $subject = $data->getSubject();
 141+ if ( ! $subject->getDIType() == SMWDataItem::TYPE_WIKIPAGE ) {
 142+ return true;
 143+ }; // if
 144+ $ns = $subject->getNamespace();
 145+ if ( ! isset( $egSemanticTitle[ $ns ] ) ) {
 146+ return true;
 147+ }; // if
 148+ $name = $egSemanticTitle[ $ns ];
 149+ $props = $data->getProperties();
 150+ if ( ! isset( $props[ $name ] ) ) {
 151+ return true;
 152+ }; // if
 153+ $values = $data->getPropertyValues( $props[ $name ] );
 154+ if ( count( $values ) == 0 ) {
 155+ return true;
 156+ }; // if
 157+ $value = array_shift( $values );
 158+ if ( $value->getDIType() != SMWDataItem::TYPE_STRING ) {
 159+ return true;
 160+ }; // if
 161+ $semantic = $value->getString();
 162+ $title = $subject->getTitle();
 163+
 164+ // Oops. I need parser to set default sort key. :-(
 165+ // $parser->setDefaultSort( $semantic );
 166+
 167+ return true;
 168+
 169+ } // function onSMWStore_updateDataAfter
 170+
 171+
135172 static public function hookSemanticTitle( $parser, $arg ) {
136173 $res = $arg;
137174 $title = Title::newFromText( $arg );
Index: trunk/extensions/SemanticTitle/SemanticTitle.php
@@ -27,10 +27,12 @@
2828 $wgAutoloadClasses[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.class.php';
2929
3030 global $wgHooks;
31 -$wgHooks[ 'BeforePageDisplay' ][] = 'SemanticTitle::onBeforePageDisplay';
32 -$wgHooks[ 'LanguageGetMagic' ][] = 'SemanticTitle::onLanguageGetMagic';
33 -$wgHooks[ 'LinkBegin' ][] = 'SemanticTitle::onLinkBegin';
34 -$wgHooks[ 'ParserFirstCallInit' ][] = 'SemanticTitle::onParserFirstCallInit';
 31+$wgHooks[ 'BeforePageDisplay' ][] = 'SemanticTitle::onBeforePageDisplay';
 32+$wgHooks[ 'LanguageGetMagic' ][] = 'SemanticTitle::onLanguageGetMagic';
 33+$wgHooks[ 'LinkBegin' ][] = 'SemanticTitle::onLinkBegin';
 34+$wgHooks[ 'ParserFirstCallInit' ][] = 'SemanticTitle::onParserFirstCallInit';
 35+// Not yet implemented.
 36+//~ $wgHooks[ 'SMWStore::updateDataAfter' ][] = 'SemanticTitle::onSMWStore_updateDataAfter';
3537
3638 global $wgExtensionMessagesFiles;
3739 $wgExtensionMessagesFiles[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.i18n.php';
@@ -43,7 +45,7 @@
4446 'path' => __FILE__,
4547 'name' => 'SemanticTitle',
4648 'license' => 'AGPLv3',
47 - 'version' => '0.0.2',
 49+ 'version' => '0.0.2+',
4850 'author' => array( '[https://www.mediawiki.org/wiki/User:Van_de_Bugger Van de Bugger]' ),
4951 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticTitle',
5052 'descriptionmsg' => 'semantictitle-desc',

Follow-up revisions

RevisionCommit summaryAuthorDate
r114153Follow-up to r114069: spce indentation fixed to tab.van-de-bugger16:50, 19 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   08:55, 19 March 2012

Spaces on line 148.

And there is no need to use ; after if-block.

#Comment by Van de Bugger (talk | contribs)   16:51, 19 March 2012

> Spaces on line 148.

Fixed in r114153.

Status & tagging log