Index: branches/SerbianVariants/phase3/maintenance/generateSitemap.php |
— | — | @@ -269,7 +269,7 @@ |
270 | 270 | $variants = $wgContLang->getVariants(); |
271 | 271 | foreach($variants as $vCode){ |
272 | 272 | if($vCode==$wgContLang->getCode()) continue; // we don't want default variant |
273 | | - $entry = $this->fileEntry( $title->getFullVariantURL($vCode), $date, $this->priority( $namespace ) ); |
| 273 | + $entry = $this->fileEntry( $title->getFullURL('',$vCode), $date, $this->priority( $namespace ) ); |
274 | 274 | $length += strlen( $entry ); |
275 | 275 | $this->write( $this->file, $entry ); |
276 | 276 | } |
Index: branches/SerbianVariants/phase3/includes/Title.php |
— | — | @@ -769,14 +769,15 @@ |
770 | 770 | * |
771 | 771 | * @param string $query an optional query string, not used |
772 | 772 | * for interwiki links |
| 773 | + * @param string $variant language variant of url (for sr, zh..) |
773 | 774 | * @return string the URL |
774 | 775 | * @access public |
775 | 776 | */ |
776 | | - function getFullURL( $query = '' ) { |
| 777 | + function getFullURL( $query = '', $variant = false ) { |
777 | 778 | global $wgContLang, $wgServer, $wgRequest; |
778 | 779 | |
779 | 780 | if ( '' == $this->mInterwiki ) { |
780 | | - $url = $this->getLocalUrl( $query ); |
| 781 | + $url = $this->getLocalUrl( $query, $variant ); |
781 | 782 | |
782 | 783 | // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc) |
783 | 784 | // Correct fix would be to move the prepending elsewhere. |
— | — | @@ -812,40 +813,25 @@ |
813 | 814 | } |
814 | 815 | |
815 | 816 | /** |
816 | | - * Get a real URL referring to this title in some of the variant |
817 | | - * |
818 | | - * @param string $variant variant name |
819 | | - * @return string the URL |
820 | | - * @access public |
821 | | - */ |
822 | | - function getFullVariantURL( $variant = '' ) { |
823 | | - global $wgServer, $wgRequest; |
824 | | - |
825 | | - $url = ''; // should not be called for interwiki |
826 | | - |
827 | | - if ( '' == $this->mInterwiki ) { |
828 | | - $url = $this->getLocalVariantURL( $variant ); |
829 | | - |
830 | | - if ($wgRequest->getVal('action') != 'render') { |
831 | | - $url = $wgServer . $url; |
832 | | - } |
833 | | - } |
834 | | - |
835 | | - return $url; |
836 | | - } |
837 | | - |
838 | | - |
839 | | - /** |
840 | 817 | * Get a URL with no fragment or server name. If this page is generated |
841 | 818 | * with action=render, $wgServer is prepended. |
842 | 819 | * @param string $query an optional query string; if not specified, |
843 | 820 | * $wgArticlePath will be used. |
| 821 | + * @param string $variant language variant of url (for sr, zh..) |
844 | 822 | * @return string the URL |
845 | 823 | * @access public |
846 | 824 | */ |
847 | | - function getLocalURL( $query = '' ) { |
| 825 | + function getLocalURL( $query = '', $variant = false ) { |
848 | 826 | global $wgArticlePath, $wgScript, $wgServer, $wgRequest; |
| 827 | + global $wgVariantArticlePath, $wgContLang, $wgUser; |
849 | 828 | |
| 829 | + // internal links should point to same variant as current page (only anonymous users) |
| 830 | + if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){ |
| 831 | + $pref = $wgContLang->getPreferredVariant(false); |
| 832 | + if($pref != $wgContLang->getCode()) |
| 833 | + $variant = $pref; |
| 834 | + } |
| 835 | + |
850 | 836 | if ( $this->isExternal() ) { |
851 | 837 | $url = $this->getFullURL(); |
852 | 838 | if ( $query ) { |
— | — | @@ -858,7 +844,17 @@ |
859 | 845 | } else { |
860 | 846 | $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
861 | 847 | if ( $query == '' ) { |
862 | | - $url = str_replace( '$1', $dbkey, $wgArticlePath ); |
| 848 | + if($variant!=false && $wgContLang->hasVariants()){ |
| 849 | + if($wgVariantArticlePath==false) |
| 850 | + $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default |
| 851 | + else |
| 852 | + $variantArticlePath = $wgVariantArticlePath; |
| 853 | + |
| 854 | + $url = str_replace( '$1', $dbkey, $variantArticlePath ); |
| 855 | + $url = str_replace( '$2', urlencode( $variant ), $url ); |
| 856 | + } |
| 857 | + else |
| 858 | + $url = str_replace( '$1', $dbkey, $wgArticlePath ); |
863 | 859 | } else { |
864 | 860 | global $wgActionPaths; |
865 | 861 | $url = false; |
— | — | @@ -892,32 +888,6 @@ |
893 | 889 | } |
894 | 890 | |
895 | 891 | /** |
896 | | - * Similar to getLocalURL, except it uses $wgVariantArticlePath |
897 | | - * and gets the URL with no fragment or server name, but in a |
898 | | - * certain language variant (relevant only to languages with variants) |
899 | | - * @param string $variant caption of variant |
900 | | - * @return string the URL |
901 | | - * @access public |
902 | | - */ |
903 | | - function getLocalVariantURL( $variant='' ) { |
904 | | - global $wgVariantArticlePath,$wgScript; |
905 | | - if($variant=='') return $this->getLocalURL(); |
906 | | - |
907 | | - if($wgVariantArticlePath==false) |
908 | | - $vArticlePath = "$wgScript?title=$1&variant=$2"; // default |
909 | | - else |
910 | | - $vArticlePath = $wgVariantArticlePath; |
911 | | - |
912 | | - $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
913 | | - $url = str_replace( '$1', $dbkey, $vArticlePath ); |
914 | | - $code = urlencode( $variant ); |
915 | | - $url = str_replace( '$2', $code, $url ); |
916 | | - |
917 | | - return $url; |
918 | | - |
919 | | - } |
920 | | - |
921 | | - /** |
922 | 892 | * Get an HTML-escaped version of the URL form, suitable for |
923 | 893 | * using in a link, without a server name or fragment |
924 | 894 | * @param string $query an optional query string |
— | — | @@ -946,34 +916,18 @@ |
947 | 917 | * internal hostname for the server from the exposed one. |
948 | 918 | * |
949 | 919 | * @param string $query an optional query string |
| 920 | + * @param string $variant language variant of url (for sr, zh..) |
950 | 921 | * @return string the URL |
951 | 922 | * @access public |
952 | 923 | */ |
953 | | - function getInternalURL( $query = '' ) { |
| 924 | + function getInternalURL( $query = '', $variant = false ) { |
954 | 925 | global $wgInternalServer; |
955 | | - $url = $wgInternalServer . $this->getLocalURL( $query ); |
| 926 | + $url = $wgInternalServer . $this->getLocalURL( $query, $variant ); |
956 | 927 | wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) ); |
957 | 928 | return $url; |
958 | 929 | } |
959 | 930 | |
960 | 931 | /** |
961 | | - * Get the URL form for an internal variant link. |
962 | | - * - Used in various Squid-related code, in case we have a different |
963 | | - * internal hostname for the server from the exposed one. |
964 | | - * |
965 | | - * @param string $variant an optional query string |
966 | | - * @return string the URL |
967 | | - * @access public |
968 | | - */ |
969 | | - function getInternalVariantURL( $variant = '' ) { |
970 | | - global $wgInternalServer; |
971 | | - $url = $wgInternalServer . $this->getLocalVariantURL( $variant ); |
972 | | - // not sure: wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) ); |
973 | | - return $url; |
974 | | - } |
975 | | - |
976 | | - |
977 | | - /** |
978 | 932 | * Get the edit URL for this Title |
979 | 933 | * @return string the URL, or a null string if this is an |
980 | 934 | * interwiki link |
— | — | @@ -1765,19 +1719,19 @@ |
1766 | 1720 | * @access public |
1767 | 1721 | */ |
1768 | 1722 | function getSquidURLs() { |
1769 | | - global $wgContLang,$wgVariantArticlePath; |
| 1723 | + global $wgContLang; |
1770 | 1724 | |
1771 | 1725 | $urls = array( |
1772 | 1726 | $this->getInternalURL(), |
1773 | 1727 | $this->getInternalURL( 'action=history' ) |
1774 | 1728 | ); |
1775 | 1729 | |
1776 | | - // purge variant url's as well (when using aliases) |
1777 | | - if($wgContLang->hasVariants() && $wgVariantArticlePath!=false){ |
| 1730 | + // purge variant urls as well |
| 1731 | + if($wgContLang->hasVariants()){ |
1778 | 1732 | $variants = $wgContLang->getVariants(); |
1779 | 1733 | foreach($variants as $vCode){ |
1780 | 1734 | if($vCode==$wgContLang->getCode()) continue; // we don't want default variant |
1781 | | - $urls[] = $this->getInternalVariantURL($vCode); |
| 1735 | + $urls[] = $this->getInternalURL('',$vCode); |
1782 | 1736 | } |
1783 | 1737 | } |
1784 | 1738 | |
Index: branches/SerbianVariants/phase3/includes/SkinTemplate.php |
— | — | @@ -765,7 +765,7 @@ |
766 | 766 | $content_actions['varlang-' . $vcount] = array( |
767 | 767 | 'class' => $selected, |
768 | 768 | 'text' => $varname, |
769 | | - 'href' => $this->mTitle->getLocalVariantURL($code) |
| 769 | + 'href' => $this->mTitle->getLocalURL('',$code) |
770 | 770 | ); |
771 | 771 | $vcount ++; |
772 | 772 | } |