Index: trunk/phase3/includes/MagicWord.php |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | define('MAG_NAMESPACE', 32); |
47 | 47 | define('MAG_TOC', 33); |
48 | 48 | define('MAG_GRAMMAR', 34); |
| 49 | +define('MAG_NOTITLECONVERT', 35); |
49 | 50 | |
50 | 51 | $wgVariableIDs = array( |
51 | 52 | MAG_CURRENTMONTH, |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -235,7 +235,8 @@ |
236 | 236 | MAG_LOCALURL => array( 0, 'LOCALURL:' ), |
237 | 237 | MAG_LOCALURLE => array( 0, 'LOCALURLE:' ), |
238 | 238 | MAG_SERVER => array( 0, 'SERVER' ), |
239 | | - MAG_GRAMMAR => array( 0, 'GRAMMAR:' ) |
| 239 | + MAG_GRAMMAR => array( 0, 'GRAMMAR:' ), |
| 240 | + MAG_NOTITLECONVERT => array( 0, '__NOTITLECONVERT__', '__NOTC__'), |
240 | 241 | ); |
241 | 242 | |
242 | 243 | #------------------------------------------------------------------- |
Index: trunk/phase3/languages/LanguageZh.php |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | var $mTables=false; //the mapping tables |
39 | 39 | var $mTablesLoaded = false; |
40 | 40 | var $mCacheKey; |
| 41 | + var $mDoTitleConvert = true; |
41 | 42 | function LanguageZh() { |
42 | 43 | global $wgDBname; |
43 | 44 | $this->mCacheKey = $wgDBname . ":zhtables"; |
— | — | @@ -76,6 +77,7 @@ |
77 | 78 | |
78 | 79 | $cached = $this->parseCachedTable( $wgMessageCache->get( 'zhconversiontable/zh-hk', true, true, true ) ); |
79 | 80 | $this->mTables['zh-hk'] = array_merge($this->mTables['zh-hk'], $cached); |
| 81 | + |
80 | 82 | } |
81 | 83 | $wgMemc->set($this->mCacheKey, $this->mTables, 43200); |
82 | 84 | } |
— | — | @@ -204,16 +206,22 @@ |
205 | 207 | # -{text}- in which case no conversion should take place for text |
206 | 208 | function convert( $text , $isTitle=false) { |
207 | 209 | global $wgDisableLangConversion; |
208 | | - |
209 | 210 | if($wgDisableLangConversion) |
210 | 211 | return $text; |
211 | | - |
| 212 | + |
| 213 | + $mw =& MagicWord::get( MAG_NOTITLECONVERT ); |
| 214 | + if( $mw->matchAndRemove( $text ) ) |
| 215 | + $this->mDoTitleConvert = false; |
| 216 | + |
212 | 217 | // no conversion if redirecting |
213 | | - if(strtolower( substr( $text,0,9 ) ) == "#redirect") { |
| 218 | + $mw =& MagicWord::get( MAG_REDIRECT ); |
| 219 | + if( $mw->matchStart( $text )) |
214 | 220 | return $text; |
215 | | - } |
216 | 221 | |
217 | 222 | if( $isTitle ) { |
| 223 | + if( !$this->mDoTitleConvert ) |
| 224 | + return $text; |
| 225 | + |
218 | 226 | global $wgRequest; |
219 | 227 | $isredir = $wgRequest->getText( 'redirect', 'yes' ); |
220 | 228 | $action = $wgRequest->getText( 'action' ); |
— | — | @@ -221,8 +229,7 @@ |
222 | 230 | return $text; |
223 | 231 | } |
224 | 232 | else { |
225 | | - $text = $this->convertTitle($text); |
226 | | - return $text; |
| 233 | + return $this->autoConvert($text); |
227 | 234 | } |
228 | 235 | } |
229 | 236 | |
— | — | @@ -272,18 +279,6 @@ |
273 | 280 | } |
274 | 281 | |
275 | 282 | |
276 | | - # only convert titles having more than one character |
277 | | - function convertTitle($text) { |
278 | | - $len=0; |
279 | | - if( function_exists( 'mb_strlen' ) ) |
280 | | - $len = mb_strlen($text); |
281 | | - else |
282 | | - $len = strlen($text)/3; |
283 | | - if($len>1) |
284 | | - return $this->autoConvert( $text); |
285 | | - return $text; |
286 | | - } |
287 | | - |
288 | 283 | function getVariants() { |
289 | 284 | return array("zh", "zh-cn", "zh-tw", "zh-sg", "zh-hk"); |
290 | 285 | } |