Index: branches/SerbianVariants/phase3/includes/Title.php |
— | — | @@ -868,6 +868,27 @@ |
869 | 869 | } |
870 | 870 | |
871 | 871 | /** |
| 872 | + * Similar to getLocalURL, except it uses $wgVariantArticlePath |
| 873 | + * and gets the URL with no fragment or server name, but in a |
| 874 | + * certain language variant (relevant only to languages with variants) |
| 875 | + * @param string $variant caption of variant |
| 876 | + * @return string the URL |
| 877 | + * @access public |
| 878 | + */ |
| 879 | + function getLocalVariantURL( $variant='' ) { |
| 880 | + global $wgVariantArticlePath; |
| 881 | + if($variant=='') return $this->getLocalURL(); |
| 882 | + |
| 883 | + $dbkey = wfUrlencode( $this->getPrefixedDBkey() ); |
| 884 | + $url = str_replace( '$1', $dbkey, $wgVariantArticlePath ); |
| 885 | + $code = urlencode( $variant ); |
| 886 | + $url = str_replace( '$2', $code, $url ); |
| 887 | + |
| 888 | + return $url; |
| 889 | + |
| 890 | + } |
| 891 | + |
| 892 | + /** |
872 | 893 | * Get an HTML-escaped version of the URL form, suitable for |
873 | 894 | * using in a link, without a server name or fragment |
874 | 895 | * @param string $query an optional query string |
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->getLocalUrl( $actstr . 'variant=' . urlencode( $code ) ) |
| 769 | + 'href' => $this->mTitle->getLocalVariantURL($code) |
770 | 770 | ); |
771 | 771 | $vcount ++; |
772 | 772 | } |
Index: branches/SerbianVariants/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 = "{$wgScript}?title=$1&variant=$2"; |
128 | 129 | $wgUploadPath = "{$wgScriptPath}/images"; |
129 | 130 | $wgUploadDirectory = "{$IP}/images"; |
130 | 131 | $wgHashedUploadDirectory = true; |
Index: branches/SerbianVariants/phase3/config/index.php |
— | — | @@ -1357,6 +1357,7 @@ |
1358 | 1358 | ## If using PHP as a CGI module, the ?title= style usually must be used. |
1359 | 1359 | {$pretty}\$wgArticlePath = \"\$wgScript/\$1\"; |
1360 | 1360 | {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\"; |
| 1361 | +\$wgVariantArticlePath = \"\$wgScript?title=\$1&variant=\$2\"; |
1361 | 1362 | |
1362 | 1363 | \$wgStylePath = \"\$wgScriptPath/skins\"; |
1363 | 1364 | \$wgStyleDirectory = \"\$IP/skins\"; |
Index: branches/SerbianVariants/phase3/languages/LanguageConverter.php |
— | — | @@ -97,6 +97,14 @@ |
98 | 98 | return $req; |
99 | 99 | } |
100 | 100 | |
| 101 | + // check the syntax /code/ArticleTitle |
| 102 | + $script = $_SERVER['SCRIPT_NAME']; |
| 103 | + $variants = implode('|',$this->mVariants); |
| 104 | + if(preg_match("/($variants)$/",$script,$matches)){ |
| 105 | + $this->mPreferredVariant = $matches[1]; |
| 106 | + return $this->mPreferredVariant; |
| 107 | + } |
| 108 | + |
101 | 109 | // get language variant preference from logged in users |
102 | 110 | // Don't call this on stub objects because that causes infinite |
103 | 111 | // recursion during initialisation |