Topic on Extension talk:Favorites

Baumgeist (talkcontribs)

(really hating this discussion system) Setting $wgFavoritesPersonalURL = true; messes up the keys of the other links, so I copied some code from Extension:AdminLinks to fix that. Find:

		if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
			$url['userpage'] = array_shift( $personal_urls );
			$url[] = array_shift( $personal_urls );
			$url[] = array_shift( $personal_urls );
	
			$url[] = array( 'text' => wfMessage( 'myfavoritelist' )->text(),
					'href' => SpecialPage::getTitleFor( 'Favoritelist' )->getLocalURL() );
			$personal_urls = $url + $personal_urls;
		}

Replace with:

    //taken from AdminLinks_body.php of the AdminLinks-Extension
		if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
			$al = SpecialPage::getTitleFor( 'Favoritelist' );
			$href = $al->getLocalURL();
			$favorites_vals = array(
				'text' => wfMessage( 'myfavoritelist' )->text(),
				'href' => $href,
				'active' => ( $href == $wgTitle->getLocalURL() )
			);

			// find the location of the 'my preferences' link, and
			// add the link to 'AdminLinks' right before it.
			// this is a "key-safe" splice - it preserves both the
			// keys and the values of the array, by editing them
			// separately and then rebuilding the array.
			// based on the example at http://us2.php.net/manual/en/function.array-splice.php#31234
			$tab_keys = array_keys( $personal_urls );
			$tab_values = array_values( $personal_urls );
			$watch_location = array_search( 'watchlist', $tab_keys );
			array_splice( $tab_keys, $watch_location, 0, 'Favoritelist' );
			array_splice( $tab_values, $watch_location, 0, array( $favorites_vals ) );

			$personal_urls = array();
			for ( $i = 0; $i < count( $tab_keys ); $i++ ) {
				$personal_urls[$tab_keys[$i]] = $tab_values[$i];
			}
		}

Jkmartindale (talkcontribs)

I did something similar. To add the Favorites link after the Watchlist link, all you need to do is edit FavoritesHooks.php from

 92 public static function onPersonalUrls( &$personal_urls, &$title ) {
 93 	global $wgFavoritesPersonalURL, $wgUser;
 94 
 95 	if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
 96 		$url['userpage'] = array_shift( $personal_urls );
 97 		$url[] = array_shift( $personal_urls );
 98 		$url[] = array_shift( $personal_urls );
 99 
100 		$url[] = array( 'text' => wfMessage( 'myfavoritelist' )->text(),
101 				'href' => SpecialPage::getTitleFor( 'Favoritelist' )->getLocalURL() );
102 		$personal_urls = $url + $personal_urls;
103 	}
104 
105 	return true;
106 }

to

 92 public static function onPersonalUrls( &$personal_urls, &$title ) {
 93 	global $wgFavoritesPersonalURL, $wgUser;
 94 
 95 	if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
 96 		$url[] = array( 'text' => wfMessage( 'myfavoritelist' )->text(),
 97 				'href' => SpecialPage::getTitleFor( 'Favoritelist' )->getLocalURL() );
 98 		$personal_urls = wfArrayInsertAfter( $personal_urls, $url, 'watchlist' );
 99 	}
100 
101 	return true;
102 }
Reply to "Bugfix"