r93227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93226‎ | r93227 | r93228 >
Date:17:57, 26 July 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added top link to watchlist
Modified paths:
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php (modified) (history)
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
@@ -85,16 +85,12 @@
8686 $wgAPIListModules['semanticwatchlist'] = 'ApiQuerySemanticWatchlist';
8787
8888 $wgHooks['LoadExtensionSchemaUpdates'][] = 'SWLHooks::onSchemaUpdate';
89 -
9089 $wgHooks['SMWStore::updateDataBefore'][] = 'SWLHooks::onDataUpdate';
91 -
9290 $wgHooks['GetPreferences'][] = 'SWLHooks::onGetPreferences';
93 -
9491 $wgHooks['UserSaveOptions'][] = 'SWLHooks::onUserSaveOptions';
95 -
9692 $wgHooks['AdminLinks'][] = 'SWLHooks::addToAdminLinks';
 93+$wgHooks['PersonalUrls'][] = 'SWLHooks::onPersonalUrls';
9794
98 -
9995 $moduleTemplate = array(
10096 'localBasePath' => dirname( __FILE__ ),
10197 'remoteBasePath' => $egSWLScriptPath
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.hooks.php
@@ -286,4 +286,35 @@
287287 return true;
288288 }
289289
 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+
290321 }
\ No newline at end of file