r94987 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94986‎ | r94987 | r94988 >
Date:05:14, 19 August 2011
Author:jlemley
Status:deferred
Tags:
Comment:
Added new parameter ($wgFavoritesPersonalURL), fixed css path.
Modified paths:
  • /trunk/extensions/Favorites/Favorites.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Favorites/Favorites.php
@@ -22,11 +22,12 @@
2323 'name' => 'Favorites',
2424 'author' => 'Jeremy Lemley',
2525 'descriptionmsg' => 'favorites-desc',
26 - 'version' => '0.2.2',
 26+ 'version' => '0.2.6',
2727 'url' => "http://www.mediawiki.org/wiki/Extension:Favorites",
2828 );
2929
30 -global $wgUseIconFavorite;
 30+global $wgUseIconFavorite, $wgFavoritesPersonalURL;
 31+
3132 $dir = dirname(__FILE__) . '/';
3233 $wgExtensionMessagesFiles['Favorites'] = $dir . 'favorites.i18n.php';
3334 $wgAutoloadClasses['Favorites'] = $dir . 'Favorites_body.php';
@@ -62,7 +63,32 @@
6364 $wgHooks['TitleMoveComplete'][] = 'fnHookMoveToFav';
6465 $wgHooks['ArticleDeleteComplete'][] = 'fnHookDeleteFav';
6566
 67+// Do we want to display a "My Favorites" link in the personal urls area?
 68+if ($wgFavoritesPersonalURL) {
 69+ $wgHooks['PersonalUrls'][] = 'onAddPersonalUrls';
 70+}
6671
 72+function onAddPersonalUrls( &$personal_urls, &$wgTitle ) {
 73+ global $wgUser;
 74+
 75+ // $skin = $wgUser->getSkin();
 76+ $title = Title::newFromText( 'Special:Favoritelist' );
 77+ if( $wgUser->getID() ) {
 78+ $url['userpage'] = array_shift( $personal_urls );
 79+ $url[] = array_shift( $personal_urls );
 80+ $url[] = array_shift( $personal_urls );
 81+
 82+ $url[] = array( 'text' => wfMsg( 'myfavoritelist' ),
 83+ 'href' => $title->getLocalURL( )
 84+ );
 85+
 86+
 87+ $personal_urls = $url + $personal_urls;
 88+ }
 89+
 90+ return true;
 91+}
 92+
6793 function fnAction ($action, $article) {
6894 $title = new Title();
6995 $favArticle = new FavArticle($title);
@@ -106,8 +132,8 @@
107133 }
108134
109135 function fnAddCss (&$out) {
110 - global $wgScriptPath;
111 - $out->addStyle($wgScriptPath. '/extensions/Favorites/favorites.css');
 136+ global $wgExtensionAssetsPath;
 137+ $out->addStyle($wgExtensionAssetsPath . '/Favorites/favorites.css');
112138 return true;
113139 }
114140

Status & tagging log