Index: trunk/phase3/maintenance/generateSitemap.php |
— | — | @@ -264,6 +264,16 @@ |
265 | 265 | $entry = $this->fileEntry( $title->getFullURL(), $date, $this->priority( $namespace ) ); |
266 | 266 | $length += strlen( $entry ); |
267 | 267 | $this->write( $this->file, $entry ); |
| 268 | + // generate pages for language variants |
| 269 | + if($wgContLang->hasVariants()){ |
| 270 | + $variants = $wgContLang->getVariants(); |
| 271 | + foreach($variants as $vCode){ |
| 272 | + if($vCode==$wgContLang->getCode()) continue; // we don't want default variant |
| 273 | + $entry = $this->fileEntry( $title->getFullURL('',$vCode), $date, $this->priority( $namespace ) ); |
| 274 | + $length += strlen( $entry ); |
| 275 | + $this->write( $this->file, $entry ); |
| 276 | + } |
| 277 | + } |
268 | 278 | } |
269 | 279 | if ( $this->file ) { |
270 | 280 | $this->write( $this->file, $this->closeFile() ); |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -124,6 +124,7 @@ |
125 | 125 | $wgStyleDirectory = "{$IP}/skins"; |
126 | 126 | $wgStyleSheetPath = &$wgStylePath; |
127 | 127 | $wgArticlePath = "{$wgScript}?title=$1"; |
| 128 | +$wgVariantArticlePath = false; |
128 | 129 | $wgUploadPath = "{$wgScriptPath}/images"; |
129 | 130 | $wgUploadDirectory = "{$IP}/images"; |
130 | 131 | $wgHashedUploadDirectory = true; |
Index: trunk/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->getLocalUrl( $actstr . 'variant=' . urlencode( $code ) ) |
| 769 | + 'href' => $this->mTitle->getLocalURL('',$code) |
770 | 770 | ); |
771 | 771 | $vcount ++; |
772 | 772 | } |
Index: trunk/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. |
— | — | @@ -816,12 +817,21 @@ |
817 | 818 | * with action=render, $wgServer is prepended. |
818 | 819 | * @param string $query an optional query string; if not specified, |
819 | 820 | * $wgArticlePath will be used. |
| 821 | + * @param string $variant language variant of url (for sr, zh..) |
820 | 822 | * @return string the URL |
821 | 823 | * @access public |
822 | 824 | */ |
823 | | - function getLocalURL( $query = '' ) { |
| 825 | + function getLocalURL( $query = '', $variant = false ) { |
824 | 826 | global $wgArticlePath, $wgScript, $wgServer, $wgRequest; |
| 827 | + global $wgVariantArticlePath, $wgContLang, $wgUser; |
825 | 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 | + |
826 | 836 | if ( $this->isExternal() ) { |
827 | 837 | $url = $this->getFullURL(); |
828 | 838 | if ( $query ) { |
— | — | @@ -834,7 +844,17 @@ |
835 | 845 | } else { |
836 | 846 | $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
837 | 847 | if ( $query == '' ) { |
838 | | - $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 ); |
839 | 859 | } else { |
840 | 860 | global $wgActionPaths; |
841 | 861 | $url = false; |
— | — | @@ -896,12 +916,13 @@ |
897 | 917 | * internal hostname for the server from the exposed one. |
898 | 918 | * |
899 | 919 | * @param string $query an optional query string |
| 920 | + * @param string $variant language variant of url (for sr, zh..) |
900 | 921 | * @return string the URL |
901 | 922 | * @access public |
902 | 923 | */ |
903 | | - function getInternalURL( $query = '' ) { |
| 924 | + function getInternalURL( $query = '', $variant = false ) { |
904 | 925 | global $wgInternalServer; |
905 | | - $url = $wgInternalServer . $this->getLocalURL( $query ); |
| 926 | + $url = $wgInternalServer . $this->getLocalURL( $query, $variant ); |
906 | 927 | wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) ); |
907 | 928 | return $url; |
908 | 929 | } |
— | — | @@ -1698,10 +1719,23 @@ |
1699 | 1720 | * @access public |
1700 | 1721 | */ |
1701 | 1722 | function getSquidURLs() { |
1702 | | - return array( |
| 1723 | + global $wgContLang; |
| 1724 | + |
| 1725 | + $urls = array( |
1703 | 1726 | $this->getInternalURL(), |
1704 | 1727 | $this->getInternalURL( 'action=history' ) |
1705 | 1728 | ); |
| 1729 | + |
| 1730 | + // purge variant urls as well |
| 1731 | + if($wgContLang->hasVariants()){ |
| 1732 | + $variants = $wgContLang->getVariants(); |
| 1733 | + foreach($variants as $vCode){ |
| 1734 | + if($vCode==$wgContLang->getCode()) continue; // we don't want default variant |
| 1735 | + $urls[] = $this->getInternalURL('',$vCode); |
| 1736 | + } |
| 1737 | + } |
| 1738 | + |
| 1739 | + return $urls; |
1706 | 1740 | } |
1707 | 1741 | |
1708 | 1742 | function purgeSquid() { |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -96,6 +96,13 @@ |
97 | 97 | return $req; |
98 | 98 | } |
99 | 99 | |
| 100 | + // check the syntax /code/ArticleTitle |
| 101 | + $scriptBase = basename( $_SERVER['SCRIPT_NAME'] ); |
| 102 | + if(in_array($scriptBase,$this->mVariants)){ |
| 103 | + $this->mPreferredVariant = $scriptBase; |
| 104 | + return $this->mPreferredVariant; |
| 105 | + } |
| 106 | + |
100 | 107 | // get language variant preference from logged in users |
101 | 108 | // Don't call this on stub objects because that causes infinite |
102 | 109 | // recursion during initialisation |