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->getFullVariantURL($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/Title.php |
— | — | @@ -812,6 +812,35 @@ |
813 | 813 | } |
814 | 814 | |
815 | 815 | /** |
| 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=''; // this function 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 | + # Finally, add the fragment. |
| 836 | + if ( '' != $this->mFragment ) { |
| 837 | + $url .= '#' . $this->mFragment; |
| 838 | + } |
| 839 | + |
| 840 | + return $url; |
| 841 | + } |
| 842 | + |
| 843 | + |
| 844 | + /** |
816 | 845 | * Get a URL with no fragment or server name. If this page is generated |
817 | 846 | * with action=render, $wgServer is prepended. |
818 | 847 | * @param string $query an optional query string; if not specified, |
— | — | @@ -868,6 +897,30 @@ |
869 | 898 | } |
870 | 899 | |
871 | 900 | /** |
| 901 | + * Similar to getLocalURL, except it uses $wgVariantArticlePath |
| 902 | + * and gets the URL with no fragment or server name, but in a |
| 903 | + * certain language variant (relevant only to languages with variants) |
| 904 | + * @param string $variant caption of variant |
| 905 | + * @return string the URL |
| 906 | + * @access public |
| 907 | + */ |
| 908 | + function getLocalVariantURL( $variant='' ) { |
| 909 | + global $wgVariantArticlePath,$wgScript; |
| 910 | + if($variant=='') return $this->getLocalURL(); |
| 911 | + |
| 912 | + if($wgVariantArticlePath==false) |
| 913 | + $wgVariantArticlePath = "$wgScript?title=$1&variant=$2"; |
| 914 | + |
| 915 | + $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
| 916 | + $url = str_replace( '$1', $dbkey, $wgVariantArticlePath ); |
| 917 | + $code = urlencode( $variant ); |
| 918 | + $url = str_replace( '$2', $code, $url ); |
| 919 | + |
| 920 | + return $url; |
| 921 | + |
| 922 | + } |
| 923 | + |
| 924 | + /** |
872 | 925 | * Get an HTML-escaped version of the URL form, suitable for |
873 | 926 | * using in a link, without a server name or fragment |
874 | 927 | * @param string $query an optional query string |
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->getLocalVariantURL($code) |
770 | 770 | ); |
771 | 771 | $vcount ++; |
772 | 772 | } |
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/languages/LanguageConverter.php |
— | — | @@ -96,6 +96,14 @@ |
97 | 97 | return $req; |
98 | 98 | } |
99 | 99 | |
| 100 | + // check the syntax /code/ArticleTitle |
| 101 | + $script = $_SERVER['SCRIPT_NAME']; |
| 102 | + $variants = implode('|',$this->mVariants); |
| 103 | + if(preg_match("/($variants)$/",$script,$matches)){ |
| 104 | + $this->mPreferredVariant = $matches[1]; |
| 105 | + return $this->mPreferredVariant; |
| 106 | + } |
| 107 | + |
100 | 108 | // get language variant preference from logged in users |
101 | 109 | // Don't call this on stub objects because that causes infinite |
102 | 110 | // recursion during initialisation |