Index: trunk/phase3/maintenance/generateSitemap.php
===================================================================
--- trunk/phase3/maintenance/generateSitemap.php (revision 16966)
+++ trunk/phase3/maintenance/generateSitemap.php (revision 16967)
@@ -264,6 +264,16 @@
$entry = $this->fileEntry( $title->getFullURL(), $date, $this->priority( $namespace ) );
$length += strlen( $entry );
$this->write( $this->file, $entry );
+ // generate pages for language variants
+ if($wgContLang->hasVariants()){
+ $variants = $wgContLang->getVariants();
+ foreach($variants as $vCode){
+ if($vCode==$wgContLang->getCode()) continue; // we don't want default variant
+ $entry = $this->fileEntry( $title->getFullURL('',$vCode), $date, $this->priority( $namespace ) );
+ $length += strlen( $entry );
+ $this->write( $this->file, $entry );
+ }
+ }
}
if ( $this->file ) {
$this->write( $this->file, $this->closeFile() );
Index: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php (revision 16966)
+++ trunk/phase3/includes/Title.php (revision 16967)
@@ -769,14 +769,15 @@
*
* @param string $query an optional query string, not used
* for interwiki links
+ * @param string $variant language variant of url (for sr, zh..)
* @return string the URL
* @access public
*/
- function getFullURL( $query = '' ) {
+ function getFullURL( $query = '', $variant = false ) {
global $wgContLang, $wgServer, $wgRequest;
if ( '' == $this->mInterwiki ) {
- $url = $this->getLocalUrl( $query );
+ $url = $this->getLocalUrl( $query, $variant );
// Ugly quick hack to avoid duplicate prefixes (bug 4571 etc)
// Correct fix would be to move the prepending elsewhere.
@@ -816,12 +817,21 @@
* with action=render, $wgServer is prepended.
* @param string $query an optional query string; if not specified,
* $wgArticlePath will be used.
+ * @param string $variant language variant of url (for sr, zh..)
* @return string the URL
* @access public
*/
- function getLocalURL( $query = '' ) {
+ function getLocalURL( $query = '', $variant = false ) {
global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
+ global $wgVariantArticlePath, $wgContLang, $wgUser;
+ // internal links should point to same variant as current page (only anonymous users)
+ if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){
+ $pref = $wgContLang->getPreferredVariant(false);
+ if($pref != $wgContLang->getCode())
+ $variant = $pref;
+ }
+
if ( $this->isExternal() ) {
$url = $this->getFullURL();
if ( $query ) {
@@ -834,7 +844,17 @@
} else {
$dbkey = wfUrlencode( $this->getPrefixedDBkey() );
if ( $query == '' ) {
- $url = str_replace( '$1', $dbkey, $wgArticlePath );
+ if($variant!=false && $wgContLang->hasVariants()){
+ if($wgVariantArticlePath==false)
+ $variantArticlePath = "$wgScript?title=$1&variant=$2"; // default
+ else
+ $variantArticlePath = $wgVariantArticlePath;
+
+ $url = str_replace( '$1', $dbkey, $variantArticlePath );
+ $url = str_replace( '$2', urlencode( $variant ), $url );
+ }
+ else
+ $url = str_replace( '$1', $dbkey, $wgArticlePath );
} else {
global $wgActionPaths;
$url = false;
@@ -896,12 +916,13 @@
* internal hostname for the server from the exposed one.
*
* @param string $query an optional query string
+ * @param string $variant language variant of url (for sr, zh..)
* @return string the URL
* @access public
*/
- function getInternalURL( $query = '' ) {
+ function getInternalURL( $query = '', $variant = false ) {
global $wgInternalServer;
- $url = $wgInternalServer . $this->getLocalURL( $query );
+ $url = $wgInternalServer . $this->getLocalURL( $query, $variant );
wfRunHooks( 'GetInternalURL', array( &$this, &$url, $query ) );
return $url;
}
@@ -1698,10 +1719,23 @@
* @access public
*/
function getSquidURLs() {
- return array(
+ global $wgContLang;
+
+ $urls = array(
$this->getInternalURL(),
$this->getInternalURL( 'action=history' )
);
+
+ // purge variant urls as well
+ if($wgContLang->hasVariants()){
+ $variants = $wgContLang->getVariants();
+ foreach($variants as $vCode){
+ if($vCode==$wgContLang->getCode()) continue; // we don't want default variant
+ $urls[] = $this->getInternalURL('',$vCode);
+ }
+ }
+
+ return $urls;
}
function purgeSquid() {
Index: trunk/phase3/includes/SkinTemplate.php
===================================================================
--- trunk/phase3/includes/SkinTemplate.php (revision 16966)
+++ trunk/phase3/includes/SkinTemplate.php (revision 16967)
@@ -765,7 +765,7 @@
$content_actions['varlang-' . $vcount] = array(
'class' => $selected,
'text' => $varname,
- 'href' => $this->mTitle->getLocalUrl( $actstr . 'variant=' . urlencode( $code ) )
+ 'href' => $this->mTitle->getLocalURL('',$code)
);
$vcount ++;
}
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php (revision 16966)
+++ trunk/phase3/includes/DefaultSettings.php (revision 16967)
@@ -124,6 +124,7 @@
$wgStyleDirectory = "{$IP}/skins";
$wgStyleSheetPath = &$wgStylePath;
$wgArticlePath = "{$wgScript}?title=$1";
+$wgVariantArticlePath = false;
$wgUploadPath = "{$wgScriptPath}/images";
$wgUploadDirectory = "{$IP}/images";
$wgHashedUploadDirectory = true;
Index: trunk/phase3/languages/LanguageConverter.php
===================================================================
--- trunk/phase3/languages/LanguageConverter.php (revision 16966)
+++ trunk/phase3/languages/LanguageConverter.php (revision 16967)
@@ -96,6 +96,13 @@
return $req;
}
+ // check the syntax /code/ArticleTitle
+ $scriptBase = basename( $_SERVER['SCRIPT_NAME'] );
+ if(in_array($scriptBase,$this->mVariants)){
+ $this->mPreferredVariant = $scriptBase;
+ return $this->mPreferredVariant;
+ }
+
// get language variant preference from logged in users
// Don't call this on stub objects because that causes infinite
// recursion during initialisation