Index: trunk/extensions/SemanticTitle/SemanticTitle.class.php |
— | — | @@ -131,6 +131,43 @@ |
132 | 132 | } // function onParserFirstCallInit |
133 | 133 | |
134 | 134 | |
| 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 | + |
135 | 172 | static public function hookSemanticTitle( $parser, $arg ) { |
136 | 173 | $res = $arg; |
137 | 174 | $title = Title::newFromText( $arg ); |
Index: trunk/extensions/SemanticTitle/SemanticTitle.php |
— | — | @@ -27,10 +27,12 @@ |
28 | 28 | $wgAutoloadClasses[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.class.php'; |
29 | 29 | |
30 | 30 | 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'; |
35 | 37 | |
36 | 38 | global $wgExtensionMessagesFiles; |
37 | 39 | $wgExtensionMessagesFiles[ 'SemanticTitle' ] = __DIR__ . '/SemanticTitle.i18n.php'; |
— | — | @@ -43,7 +45,7 @@ |
44 | 46 | 'path' => __FILE__, |
45 | 47 | 'name' => 'SemanticTitle', |
46 | 48 | 'license' => 'AGPLv3', |
47 | | - 'version' => '0.0.2', |
| 49 | + 'version' => '0.0.2+', |
48 | 50 | 'author' => array( '[https://www.mediawiki.org/wiki/User:Van_de_Bugger Van de Bugger]' ), |
49 | 51 | 'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticTitle', |
50 | 52 | 'descriptionmsg' => 'semantictitle-desc', |