Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php |
— | — | @@ -85,16 +85,12 @@ |
86 | 86 | $wgAPIListModules['semanticwatchlist'] = 'ApiQuerySemanticWatchlist'; |
87 | 87 | |
88 | 88 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'SWLHooks::onSchemaUpdate'; |
89 | | - |
90 | 89 | $wgHooks['SMWStore::updateDataBefore'][] = 'SWLHooks::onDataUpdate'; |
91 | | - |
92 | 90 | $wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences'; |
93 | | - |
94 | 91 | $wgHooks['UserSaveOptions'][] = 'SWLHooks::onUserSaveOptions'; |
95 | | - |
96 | 92 | $wgHooks['AdminLinks'][] = 'SWLHooks::addToAdminLinks'; |
| 93 | +$wgHooks['PersonalUrls'][] = 'SWLHooks::onPersonalUrls'; |
97 | 94 | |
98 | | - |
99 | 95 | $moduleTemplate = array( |
100 | 96 | 'localBasePath' => dirname( __FILE__ ), |
101 | 97 | 'remoteBasePath' => $egSWLScriptPath |
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php |
— | — | @@ -286,4 +286,35 @@ |
287 | 287 | return true; |
288 | 288 | } |
289 | 289 | |
| 290 | + /** |
| 291 | + * Called after the personal URLs have been set up, before they are shown. |
| 292 | + * https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Manual:Hooks/PersonalUrls |
| 293 | + * |
| 294 | + * @param array $personal_urls |
| 295 | + * @param Title $title |
| 296 | + */ |
| 297 | + public static function onPersonalUrls( array &$personal_urls, Title &$title ) { |
| 298 | + if ( $GLOBALS['egSWLEnableTopLink'] ) { |
| 299 | + global $wgUser; |
| 300 | + |
| 301 | + // Find the watchlist item and replace it by itself and the semantic watchlist. |
| 302 | + if ( $wgUser->isLoggedIn() && $wgUser->getOption( 'swl_watchlisttoplink' ) ) { |
| 303 | + $keys = array_keys( $personal_urls ); |
| 304 | + $watchListLocation = array_search( 'watchlist', $keys ); |
| 305 | + $watchListItem = $personal_urls[$keys[$watchListLocation]]; |
| 306 | + |
| 307 | + $url = SpecialPage::getTitleFor( 'SemanticWatchlist' )->getLinkUrl(); |
| 308 | + $semanticWatchlist = array( |
| 309 | + 'text' => wfMsg( 'special-semanticwatchlist' ), |
| 310 | + 'href' => $url, |
| 311 | + 'active' => ( $url == $title->getLinkUrl() ) |
| 312 | + ); |
| 313 | + |
| 314 | + array_splice( $personal_urls, $watchListLocation, 1, array( $watchListItem, $semanticWatchlist ) ); |
| 315 | + } |
| 316 | + } |
| 317 | + |
| 318 | + return true; |
| 319 | + } |
| 320 | + |
290 | 321 | } |
\ No newline at end of file |