From: Ævar Arnfjörð Bjarmason Date: Sat, 23 Jul 2005 05:41:03 +0000 (+0000) Subject: * Now sorting interwiki links by iw_prefix and avoiding duplicates X-Git-Tag: 1.5.0beta4~57 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=58290b1f6f0675e2904fa1f84ccf5e613d2c9054;p=lhc%2Fweb%2Fwiklou.git * Now sorting interwiki links by iw_prefix and avoiding duplicates --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 13a9cc9df7..8069d8fd8e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -594,7 +594,7 @@ of MediaWiki:Newpagetext) to &action=edit, if page is new. example of this. * (bug 740) Messages from extensions now appear in Special:Allmessages * (bug 2857) fixed parsing of lists in
 sections
-
+* Now sorting interwiki links by iw_prefix and avoiding duplicates
 
 === Caveats ===
 
diff --git a/includes/Skin.php b/includes/Skin.php
index 43f6c60e88..d2de740170 100644
--- a/includes/Skin.php
+++ b/includes/Skin.php
@@ -1121,6 +1121,7 @@ END;
 		}
 
 		$a = $wgOut->getLanguageLinks();
+		$a = $this->sortInterwikiLinks( $a );
 		if ( 0 == count( $a ) ) {
 			return '';
 		}
@@ -1318,6 +1319,23 @@ END;
 		wfProfileOut( $fname );
 		return $bar;
 	}
+
+	function sortInterwikiLinks( $links ) {
+		$nlinks = $nnlinks = array();
+		
+		foreach($links as $link) {
+			list($iso, $url) = explode( ':', $link, 2 );
+			$nlinks[$iso] = $url;
+		}
+		
+		ksort( $nlinks );
+
+		foreach($nlinks as $k => $v) {
+			$nnlinks[] = implode( ':', array($k, $v) );
+		}
+
+		return $nnlinks;
+	}
 }
 
 }
diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php
index 9ffb74d0c8..775c7783b1 100644
--- a/includes/SkinTemplate.php
+++ b/includes/SkinTemplate.php
@@ -357,7 +357,9 @@ class SkinTemplate extends Skin {
 		$language_urls = array();
 
 		if ( !$wgHideInterlanguageLinks ) {
-			foreach( $wgOut->getLanguageLinks() as $l ) {
+			$iwlinks = $wgOut->getLanguageLinks();
+			$iwlinks = $this->sortInterwikiLinks( $iwlinks );
+			foreach( $iwlinks as $l ) {
 				$nt = Title::newFromText( $l );
 				$language_urls[] = array('href' => $nt->getFullURL(),
 				'text' => ($wgContLang->getLanguageName( $nt->getInterwiki()) != ''?$wgContLang->getLanguageName( $nt->getInterwiki()) : $l),