Index: trunk/phase3/includes/api/ApiQueryBase.php |
— | — | @@ -324,10 +324,15 @@ |
325 | 325 | * @return string Page title with underscores |
326 | 326 | */ |
327 | 327 | public function titleToKey($title) { |
328 | | - global $wgContLang, $wgCapitalLinks; |
329 | | - if($wgCaptialLinks) |
330 | | - $title = $wgContLang->ucfirst($title); |
331 | | - return str_replace(' ', '_', $title); |
| 328 | + $t = Title::newFromText($title); |
| 329 | + if(!$t) |
| 330 | + { |
| 331 | + # Don't throw an error if we got an empty string |
| 332 | + if($title == '') |
| 333 | + return ''; |
| 334 | + $this->dieUsageMsg(array('invalidtitle', $title)); |
| 335 | + } |
| 336 | + return $t->getDbKey(); |
332 | 337 | } |
333 | 338 | |
334 | 339 | /** |
— | — | @@ -336,7 +341,16 @@ |
337 | 342 | * @return string Page title with spaces |
338 | 343 | */ |
339 | 344 | public function keyToTitle($key) { |
340 | | - return str_replace('_', ' ', $key); |
| 345 | + $t = Title::newFromDbKey($key); |
| 346 | + # This really shouldn't happen but we gotta check anyway |
| 347 | + if(!$t) |
| 348 | + { |
| 349 | + # Don't throw an error if we got an empty string |
| 350 | + if($key == '') |
| 351 | + return ''; |
| 352 | + $this->dieUsageMsg(array('invalidtitle', $key)); |
| 353 | + } |
| 354 | + return $t->getPrefixedText(); |
341 | 355 | } |
342 | 356 | |
343 | 357 | /** |