* Now sorting interwiki links by iw_prefix and avoiding duplicates
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 23 Jul 2005 05:41:03 +0000 (05:41 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 23 Jul 2005 05:41:03 +0000 (05:41 +0000)
RELEASE-NOTES
includes/Skin.php
includes/SkinTemplate.php

index 13a9cc9..8069d8f 100644 (file)
@@ -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 <pre> sections
-
+* Now sorting interwiki links by iw_prefix and avoiding duplicates
 
 === Caveats ===
 
index 43f6c60..d2de740 100644 (file)
@@ -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;
+       }
 }
 
 }
index 9ffb74d..775c778 100644 (file)
@@ -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),