r16827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16826‎ | r16827 | r16828 >
Date:03:00, 7 October 2006
Author:rainman
Status:old
Tags:
Comment:

Implementation of variant syntax, e.g. /sr-ec/Article_title
Modified paths:
  • /branches/SerbianVariants/phase3/config/index.php (modified) (history)
  • /branches/SerbianVariants/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/SerbianVariants/phase3/includes/SkinTemplate.php (modified) (history)
  • /branches/SerbianVariants/phase3/includes/Title.php (modified) (history)
  • /branches/SerbianVariants/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: branches/SerbianVariants/phase3/includes/Title.php
@@ -868,6 +868,27 @@
869869 }
870870
871871 /**
 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+ /**
872893 * Get an HTML-escaped version of the URL form, suitable for
873894 * using in a link, without a server name or fragment
874895 * @param string $query an optional query string
Index: branches/SerbianVariants/phase3/includes/SkinTemplate.php
@@ -765,7 +765,7 @@
766766 $content_actions['varlang-' . $vcount] = array(
767767 'class' => $selected,
768768 'text' => $varname,
769 - 'href' => $this->mTitle->getLocalUrl( $actstr . 'variant=' . urlencode( $code ) )
 769+ 'href' => $this->mTitle->getLocalVariantURL($code)
770770 );
771771 $vcount ++;
772772 }
Index: branches/SerbianVariants/phase3/includes/DefaultSettings.php
@@ -124,6 +124,7 @@
125125 $wgStyleDirectory = "{$IP}/skins";
126126 $wgStyleSheetPath = &$wgStylePath;
127127 $wgArticlePath = "{$wgScript}?title=$1";
 128+$wgVariantArticlePath = "{$wgScript}?title=$1&variant=$2";
128129 $wgUploadPath = "{$wgScriptPath}/images";
129130 $wgUploadDirectory = "{$IP}/images";
130131 $wgHashedUploadDirectory = true;
Index: branches/SerbianVariants/phase3/config/index.php
@@ -1357,6 +1357,7 @@
13581358 ## If using PHP as a CGI module, the ?title= style usually must be used.
13591359 {$pretty}\$wgArticlePath = \"\$wgScript/\$1\";
13601360 {$ugly}\$wgArticlePath = \"\$wgScript?title=\$1\";
 1361+\$wgVariantArticlePath = \"\$wgScript?title=\$1&variant=\$2\";
13611362
13621363 \$wgStylePath = \"\$wgScriptPath/skins\";
13631364 \$wgStyleDirectory = \"\$IP/skins\";
Index: branches/SerbianVariants/phase3/languages/LanguageConverter.php
@@ -97,6 +97,14 @@
9898 return $req;
9999 }
100100
 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+
101109 // get language variant preference from logged in users
102110 // Don't call this on stub objects because that causes infinite
103111 // recursion during initialisation