Index: trunk/phase3/languages/Language.php |
— | — | @@ -202,6 +202,8 @@ |
203 | 203 | * not it exists. This includes codes which are used solely for |
204 | 204 | * customisation via the MediaWiki namespace. |
205 | 205 | * |
| 206 | + * @param $code string |
| 207 | + * |
206 | 208 | * @return bool |
207 | 209 | */ |
208 | 210 | public static function isValidCode( $code ) { |
— | — | @@ -213,6 +215,10 @@ |
214 | 216 | /** |
215 | 217 | * Returns true if a language code is of a valid form for the purposes of |
216 | 218 | * internal customisation of MediaWiki, via Messages*.php. |
| 219 | + * |
| 220 | + * @param $code string |
| 221 | + * |
| 222 | + * @return bool |
217 | 223 | */ |
218 | 224 | public static function isValidBuiltInCode( $code ) { |
219 | 225 | return preg_match( '/^[a-z0-9-]*$/i', $code ); |
— | — | @@ -258,6 +264,9 @@ |
259 | 265 | */ |
260 | 266 | function initContLang() { } |
261 | 267 | |
| 268 | + /** |
| 269 | + * @return array|bool |
| 270 | + */ |
262 | 271 | function getFallbackLanguageCode() { |
263 | 272 | if ( $this->mCode === 'en' ) { |
264 | 273 | return false; |
— | — | @@ -345,6 +354,8 @@ |
346 | 355 | * getNsText() except with '_' changed to ' ', useful for |
347 | 356 | * producing output. |
348 | 357 | * |
| 358 | + * @param $index string |
| 359 | + * |
349 | 360 | * @return array |
350 | 361 | */ |
351 | 362 | function getFormattedNsText( $index ) { |
— | — | @@ -389,6 +400,9 @@ |
390 | 401 | return isset( $ids[$lctext] ) ? $ids[$lctext] : false; |
391 | 402 | } |
392 | 403 | |
| 404 | + /** |
| 405 | + * @return array |
| 406 | + */ |
393 | 407 | function getNamespaceAliases() { |
394 | 408 | if ( is_null( $this->namespaceAliases ) ) { |
395 | 409 | $aliases = self::$dataCache->getItem( $this->mCode, 'namespaceAliases' ); |
— | — | @@ -416,6 +430,9 @@ |
417 | 431 | return $this->namespaceAliases; |
418 | 432 | } |
419 | 433 | |
| 434 | + /** |
| 435 | + * @return array |
| 436 | + */ |
420 | 437 | function getNamespaceIds() { |
421 | 438 | if ( is_null( $this->mNamespaceIds ) ) { |
422 | 439 | global $wgNamespaceAliases; |
— | — | @@ -466,6 +483,10 @@ |
467 | 484 | return $this->getMessageFromDB( "variantname-$code" ); |
468 | 485 | } |
469 | 486 | |
| 487 | + /** |
| 488 | + * @param $name string |
| 489 | + * @return string |
| 490 | + */ |
470 | 491 | function specialPage( $name ) { |
471 | 492 | $aliases = $this->getSpecialPageAliases(); |
472 | 493 | if ( isset( $aliases[$name][0] ) ) { |
— | — | @@ -474,6 +495,9 @@ |
475 | 496 | return $this->getNsText( NS_SPECIAL ) . ':' . $name; |
476 | 497 | } |
477 | 498 | |
| 499 | + /** |
| 500 | + * @return array |
| 501 | + */ |
478 | 502 | function getQuickbarSettings() { |
479 | 503 | return array( |
480 | 504 | $this->getMessage( 'qbsettings-none' ), |
— | — | @@ -484,14 +508,23 @@ |
485 | 509 | ); |
486 | 510 | } |
487 | 511 | |
| 512 | + /** |
| 513 | + * @return array |
| 514 | + */ |
488 | 515 | function getDatePreferences() { |
489 | 516 | return self::$dataCache->getItem( $this->mCode, 'datePreferences' ); |
490 | 517 | } |
491 | 518 | |
| 519 | + /** |
| 520 | + * @return array |
| 521 | + */ |
492 | 522 | function getDateFormats() { |
493 | 523 | return self::$dataCache->getItem( $this->mCode, 'dateFormats' ); |
494 | 524 | } |
495 | 525 | |
| 526 | + /** |
| 527 | + * @return array|string |
| 528 | + */ |
496 | 529 | function getDefaultDateFormat() { |
497 | 530 | $df = self::$dataCache->getItem( $this->mCode, 'defaultDateFormat' ); |
498 | 531 | if ( $df === 'dmy or mdy' ) { |
— | — | @@ -502,22 +535,39 @@ |
503 | 536 | } |
504 | 537 | } |
505 | 538 | |
| 539 | + /** |
| 540 | + * @return array |
| 541 | + */ |
506 | 542 | function getDatePreferenceMigrationMap() { |
507 | 543 | return self::$dataCache->getItem( $this->mCode, 'datePreferenceMigrationMap' ); |
508 | 544 | } |
509 | 545 | |
| 546 | + /** |
| 547 | + * @param $image |
| 548 | + * @return array|null |
| 549 | + */ |
510 | 550 | function getImageFile( $image ) { |
511 | 551 | return self::$dataCache->getSubitem( $this->mCode, 'imageFiles', $image ); |
512 | 552 | } |
513 | 553 | |
| 554 | + /** |
| 555 | + * @return array |
| 556 | + */ |
514 | 557 | function getDefaultUserOptionOverrides() { |
515 | 558 | return self::$dataCache->getItem( $this->mCode, 'defaultUserOptionOverrides' ); |
516 | 559 | } |
517 | 560 | |
| 561 | + /** |
| 562 | + * @return array |
| 563 | + */ |
518 | 564 | function getExtraUserToggles() { |
519 | 565 | return self::$dataCache->getItem( $this->mCode, 'extraUserToggles' ); |
520 | 566 | } |
521 | 567 | |
| 568 | + /** |
| 569 | + * @param $tog |
| 570 | + * @return string |
| 571 | + */ |
522 | 572 | function getUserToggle( $tog ) { |
523 | 573 | return $this->getMessageFromDB( "tog-$tog" ); |
524 | 574 | } |
— | — | @@ -525,6 +575,10 @@ |
526 | 576 | /** |
527 | 577 | * Get language names, indexed by code. |
528 | 578 | * If $customisedOnly is true, only returns codes with a messages file |
| 579 | + * |
| 580 | + * @param $customisedOnly bool |
| 581 | + * |
| 582 | + * @return array |
529 | 583 | */ |
530 | 584 | public static function getLanguageNames( $customisedOnly = false ) { |
531 | 585 | global $wgExtraLanguageNames; |
— | — | @@ -581,6 +635,10 @@ |
582 | 636 | return wfMsgExt( $msg, array( 'parsemag', 'language' => $this ) ); |
583 | 637 | } |
584 | 638 | |
| 639 | + /** |
| 640 | + * @param $code string |
| 641 | + * @return string |
| 642 | + */ |
585 | 643 | function getLanguageName( $code ) { |
586 | 644 | $names = self::getLanguageNames(); |
587 | 645 | if ( !array_key_exists( $code, $names ) ) { |
— | — | @@ -589,10 +647,17 @@ |
590 | 648 | return $names[$code]; |
591 | 649 | } |
592 | 650 | |
| 651 | + /** |
| 652 | + * @param $key string |
| 653 | + * @return string |
| 654 | + */ |
593 | 655 | function getMonthName( $key ) { |
594 | 656 | return $this->getMessageFromDB( self::$mMonthMsgs[$key - 1] ); |
595 | 657 | } |
596 | 658 | |
| 659 | + /** |
| 660 | + * @return array |
| 661 | + */ |
597 | 662 | function getMonthNamesArray() { |
598 | 663 | $monthNames = array( '' ); |
599 | 664 | for ( $i=1; $i < 13; $i++ ) { |
— | — | @@ -601,42 +666,77 @@ |
602 | 667 | return $monthNames; |
603 | 668 | } |
604 | 669 | |
| 670 | + /** |
| 671 | + * @param $key string |
| 672 | + * @return string |
| 673 | + */ |
605 | 674 | function getMonthNameGen( $key ) { |
606 | 675 | return $this->getMessageFromDB( self::$mMonthGenMsgs[$key - 1] ); |
607 | 676 | } |
608 | 677 | |
| 678 | + /** |
| 679 | + * @param $key string |
| 680 | + * @return string |
| 681 | + */ |
609 | 682 | function getMonthAbbreviation( $key ) { |
610 | 683 | return $this->getMessageFromDB( self::$mMonthAbbrevMsgs[$key - 1] ); |
611 | 684 | } |
612 | 685 | |
| 686 | + /** |
| 687 | + * @return array |
| 688 | + */ |
613 | 689 | function getMonthAbbreviationsArray() { |
614 | | - $monthNames = array(''); |
| 690 | + $monthNames = array( '' ); |
615 | 691 | for ( $i=1; $i < 13; $i++ ) { |
616 | 692 | $monthNames[] = $this->getMonthAbbreviation( $i ); |
617 | 693 | } |
618 | 694 | return $monthNames; |
619 | 695 | } |
620 | 696 | |
| 697 | + /** |
| 698 | + * @param $key string |
| 699 | + * @return string |
| 700 | + */ |
621 | 701 | function getWeekdayName( $key ) { |
622 | 702 | return $this->getMessageFromDB( self::$mWeekdayMsgs[$key - 1] ); |
623 | 703 | } |
624 | 704 | |
| 705 | + /** |
| 706 | + * @param $key string |
| 707 | + * @return string |
| 708 | + */ |
625 | 709 | function getWeekdayAbbreviation( $key ) { |
626 | 710 | return $this->getMessageFromDB( self::$mWeekdayAbbrevMsgs[$key - 1] ); |
627 | 711 | } |
628 | 712 | |
| 713 | + /** |
| 714 | + * @param $key string |
| 715 | + * @return string |
| 716 | + */ |
629 | 717 | function getIranianCalendarMonthName( $key ) { |
630 | 718 | return $this->getMessageFromDB( self::$mIranianCalendarMonthMsgs[$key - 1] ); |
631 | 719 | } |
632 | 720 | |
| 721 | + /** |
| 722 | + * @param $key string |
| 723 | + * @return string |
| 724 | + */ |
633 | 725 | function getHebrewCalendarMonthName( $key ) { |
634 | 726 | return $this->getMessageFromDB( self::$mHebrewCalendarMonthMsgs[$key - 1] ); |
635 | 727 | } |
636 | 728 | |
| 729 | + /** |
| 730 | + * @param $key string |
| 731 | + * @return string |
| 732 | + */ |
637 | 733 | function getHebrewCalendarMonthNameGen( $key ) { |
638 | 734 | return $this->getMessageFromDB( self::$mHebrewCalendarMonthGenMsgs[$key - 1] ); |
639 | 735 | } |
640 | 736 | |
| 737 | + /** |
| 738 | + * @param $key string |
| 739 | + * @return string |
| 740 | + */ |
641 | 741 | function getHijriCalendarMonthName( $key ) { |
642 | 742 | return $this->getMessageFromDB( self::$mHijriCalendarMonthMsgs[$key - 1] ); |
643 | 743 | } |
— | — | @@ -772,6 +872,8 @@ |
773 | 873 | * YYYYMMDDHHMMSS |
774 | 874 | * 01234567890123 |
775 | 875 | * @todo handling of "o" format character for Iranian, Hebrew, Hijri & Thai? |
| 876 | + * |
| 877 | + * @return string |
776 | 878 | */ |
777 | 879 | function sprintfDate( $format, $ts ) { |
778 | 880 | $s = ''; |
— | — | @@ -1084,6 +1186,7 @@ |
1085 | 1187 | |
1086 | 1188 | private static $GREG_DAYS = array( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ); |
1087 | 1189 | private static $IRANIAN_DAYS = array( 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 ); |
| 1190 | + |
1088 | 1191 | /** |
1089 | 1192 | * Algorithm by Roozbeh Pournader and Mohammad Toossi to convert |
1090 | 1193 | * Gregorian dates to Iranian dates. Originally written in C, it |
— | — | @@ -1091,6 +1194,10 @@ |
1092 | 1195 | * License. Conversion to PHP was performed by Niklas Laxström. |
1093 | 1196 | * |
1094 | 1197 | * Link: http://www.farsiweb.info/jalali/jalali.c |
| 1198 | + * |
| 1199 | + * @param $ts string |
| 1200 | + * |
| 1201 | + * @return string |
1095 | 1202 | */ |
1096 | 1203 | private static function tsToIranian( $ts ) { |
1097 | 1204 | $gy = substr( $ts, 0, 4 ) -1600; |
— | — | @@ -1146,6 +1253,10 @@ |
1147 | 1254 | * Based on a PHP-Nuke block by Sharjeel which is released under GNU/GPL license |
1148 | 1255 | * |
1149 | 1256 | * @link http://phpnuke.org/modules.php?name=News&file=article&sid=8234&mode=thread&order=0&thold=0 |
| 1257 | + * |
| 1258 | + * @param $ts string |
| 1259 | + * |
| 1260 | + * @return string |
1150 | 1261 | */ |
1151 | 1262 | private static function tsToHijri( $ts ) { |
1152 | 1263 | $year = substr( $ts, 0, 4 ); |
— | — | @@ -1193,6 +1304,10 @@ |
1194 | 1305 | * |
1195 | 1306 | * The months are counted from Tishrei = 1. In a leap year, Adar I is 13 |
1196 | 1307 | * and Adar II is 14. In a non-leap year, Adar is 6. |
| 1308 | + * |
| 1309 | + * @param $ts string |
| 1310 | + * |
| 1311 | + * @return string |
1197 | 1312 | */ |
1198 | 1313 | private static function tsToHebrew( $ts ) { |
1199 | 1314 | # Parse date |
— | — | @@ -1330,6 +1445,10 @@ |
1331 | 1446 | * This calculates the Hebrew year start, as days since 1 September. |
1332 | 1447 | * Based on Carl Friedrich Gauss algorithm for finding Easter date. |
1333 | 1448 | * Used for Hebrew date. |
| 1449 | + * |
| 1450 | + * @param $year int |
| 1451 | + * |
| 1452 | + * @return string |
1334 | 1453 | */ |
1335 | 1454 | private static function hebrewYearStart( $year ) { |
1336 | 1455 | $a = intval( ( 12 * ( $year - 1 ) + 17 ) % 19 ); |
— | — | @@ -1443,6 +1562,10 @@ |
1444 | 1563 | |
1445 | 1564 | /** |
1446 | 1565 | * Roman number formatting up to 3000 |
| 1566 | + * |
| 1567 | + * @param $num int |
| 1568 | + * |
| 1569 | + * @return string |
1447 | 1570 | */ |
1448 | 1571 | static function romanNumeral( $num ) { |
1449 | 1572 | static $table = array( |
— | — | @@ -1469,6 +1592,10 @@ |
1470 | 1593 | |
1471 | 1594 | /** |
1472 | 1595 | * Hebrew Gematria number formatting up to 9999 |
| 1596 | + * |
| 1597 | + * @param $num int |
| 1598 | + * |
| 1599 | + * @return string |
1473 | 1600 | */ |
1474 | 1601 | static function hebrewNumeral( $num ) { |
1475 | 1602 | static $table = array( |
— | — | @@ -1646,14 +1773,27 @@ |
1647 | 1774 | return $this->sprintfDate( $df, $ts ); |
1648 | 1775 | } |
1649 | 1776 | |
| 1777 | + /** |
| 1778 | + * @param $key string |
| 1779 | + * @return array|null |
| 1780 | + */ |
1650 | 1781 | function getMessage( $key ) { |
1651 | 1782 | return self::$dataCache->getSubitem( $this->mCode, 'messages', $key ); |
1652 | 1783 | } |
1653 | 1784 | |
| 1785 | + /** |
| 1786 | + * @return array |
| 1787 | + */ |
1654 | 1788 | function getAllMessages() { |
1655 | 1789 | return self::$dataCache->getItem( $this->mCode, 'messages' ); |
1656 | 1790 | } |
1657 | 1791 | |
| 1792 | + /** |
| 1793 | + * @param $in |
| 1794 | + * @param $out |
| 1795 | + * @param $string |
| 1796 | + * @return string |
| 1797 | + */ |
1658 | 1798 | function iconv( $in, $out, $string ) { |
1659 | 1799 | # This is a wrapper for iconv in all languages except esperanto, |
1660 | 1800 | # which does some nasty x-conversions beforehand |
— | — | @@ -1669,28 +1809,53 @@ |
1670 | 1810 | } |
1671 | 1811 | |
1672 | 1812 | // callback functions for uc(), lc(), ucwords(), ucwordbreaks() |
| 1813 | + |
| 1814 | + /** |
| 1815 | + * @param $matches array |
| 1816 | + * @return mixed|string |
| 1817 | + */ |
1673 | 1818 | function ucwordbreaksCallbackAscii( $matches ) { |
1674 | 1819 | return $this->ucfirst( $matches[1] ); |
1675 | 1820 | } |
1676 | 1821 | |
| 1822 | + /** |
| 1823 | + * @param $matches array |
| 1824 | + * @return string |
| 1825 | + */ |
1677 | 1826 | function ucwordbreaksCallbackMB( $matches ) { |
1678 | 1827 | return mb_strtoupper( $matches[0] ); |
1679 | 1828 | } |
1680 | 1829 | |
| 1830 | + /** |
| 1831 | + * @param $matches array |
| 1832 | + * @return string |
| 1833 | + */ |
1681 | 1834 | function ucCallback( $matches ) { |
1682 | 1835 | list( $wikiUpperChars ) = self::getCaseMaps(); |
1683 | 1836 | return strtr( $matches[1], $wikiUpperChars ); |
1684 | 1837 | } |
1685 | 1838 | |
| 1839 | + /** |
| 1840 | + * @param $matches array |
| 1841 | + * @return string |
| 1842 | + */ |
1686 | 1843 | function lcCallback( $matches ) { |
1687 | 1844 | list( , $wikiLowerChars ) = self::getCaseMaps(); |
1688 | 1845 | return strtr( $matches[1], $wikiLowerChars ); |
1689 | 1846 | } |
1690 | 1847 | |
| 1848 | + /** |
| 1849 | + * @param $matches array |
| 1850 | + * @return string |
| 1851 | + */ |
1691 | 1852 | function ucwordsCallbackMB( $matches ) { |
1692 | 1853 | return mb_strtoupper( $matches[0] ); |
1693 | 1854 | } |
1694 | 1855 | |
| 1856 | + /** |
| 1857 | + * @param $matches array |
| 1858 | + * @return string |
| 1859 | + */ |
1695 | 1860 | function ucwordsCallbackWiki( $matches ) { |
1696 | 1861 | list( $wikiUpperChars ) = self::getCaseMaps(); |
1697 | 1862 | return strtr( $matches[0], $wikiUpperChars ); |
— | — | @@ -1698,6 +1863,10 @@ |
1699 | 1864 | |
1700 | 1865 | /** |
1701 | 1866 | * Make a string's first character uppercase |
| 1867 | + * |
| 1868 | + * @param $str string |
| 1869 | + * |
| 1870 | + * @return string |
1702 | 1871 | */ |
1703 | 1872 | function ucfirst( $str ) { |
1704 | 1873 | $o = ord( $str ); |
— | — | @@ -1713,6 +1882,11 @@ |
1714 | 1883 | |
1715 | 1884 | /** |
1716 | 1885 | * Convert a string to uppercase |
| 1886 | + * |
| 1887 | + * @param $str string |
| 1888 | + * @param $first bool |
| 1889 | + * |
| 1890 | + * @return string |
1717 | 1891 | */ |
1718 | 1892 | function uc( $str, $first = false ) { |
1719 | 1893 | if ( function_exists( 'mb_strtoupper' ) ) { |
— | — | @@ -1739,6 +1913,10 @@ |
1740 | 1914 | } |
1741 | 1915 | } |
1742 | 1916 | |
| 1917 | + /** |
| 1918 | + * @param $str string |
| 1919 | + * @return mixed|string |
| 1920 | + */ |
1743 | 1921 | function lcfirst( $str ) { |
1744 | 1922 | $o = ord( $str ); |
1745 | 1923 | if ( !$o ) { |
— | — | @@ -1753,6 +1931,11 @@ |
1754 | 1932 | } |
1755 | 1933 | } |
1756 | 1934 | |
| 1935 | + /** |
| 1936 | + * @param $str string |
| 1937 | + * @param $first bool |
| 1938 | + * @return mixed|string |
| 1939 | + */ |
1757 | 1940 | function lc( $str, $first = false ) { |
1758 | 1941 | if ( function_exists( 'mb_strtolower' ) ) { |
1759 | 1942 | if ( $first ) { |
— | — | @@ -1778,10 +1961,18 @@ |
1779 | 1962 | } |
1780 | 1963 | } |
1781 | 1964 | |
| 1965 | + /** |
| 1966 | + * @param $str string |
| 1967 | + * @return bool |
| 1968 | + */ |
1782 | 1969 | function isMultibyte( $str ) { |
1783 | 1970 | return (bool)preg_match( '/[\x80-\xff]/', $str ); |
1784 | 1971 | } |
1785 | 1972 | |
| 1973 | + /** |
| 1974 | + * @param $str string |
| 1975 | + * @return mixed|string |
| 1976 | + */ |
1786 | 1977 | function ucwords( $str ) { |
1787 | 1978 | if ( $this->isMultibyte( $str ) ) { |
1788 | 1979 | $str = $this->lc( $str ); |
— | — | @@ -1808,7 +1999,12 @@ |
1809 | 2000 | } |
1810 | 2001 | } |
1811 | 2002 | |
1812 | | - # capitalize words at word breaks |
| 2003 | + /** |
| 2004 | + * capitalize words at word breaks |
| 2005 | + * |
| 2006 | + * @param $str string |
| 2007 | + * @return mixed |
| 2008 | + */ |
1813 | 2009 | function ucwordbreaks( $str ) { |
1814 | 2010 | if ( $this->isMultibyte( $str ) ) { |
1815 | 2011 | $str = $this->lc( $str ); |
— | — | @@ -1851,11 +2047,19 @@ |
1852 | 2048 | * Do *not* perform any other normalisation in this function. If a caller |
1853 | 2049 | * uses this function when it should be using a more general normalisation |
1854 | 2050 | * function, then fix the caller. |
| 2051 | + * |
| 2052 | + * @param $s string |
| 2053 | + * |
| 2054 | + * @return string |
1855 | 2055 | */ |
1856 | 2056 | function caseFold( $s ) { |
1857 | 2057 | return $this->uc( $s ); |
1858 | 2058 | } |
1859 | 2059 | |
| 2060 | + /** |
| 2061 | + * @param $s string |
| 2062 | + * @return string |
| 2063 | + */ |
1860 | 2064 | function checkTitleEncoding( $s ) { |
1861 | 2065 | if ( is_array( $s ) ) { |
1862 | 2066 | wfDebugDieBacktrace( 'Given array to checkTitleEncoding.' ); |
— | — | @@ -1887,6 +2091,8 @@ |
1888 | 2092 | * Some languages such as Chinese don't conventionally do this, |
1889 | 2093 | * which requires special handling when breaking up words for |
1890 | 2094 | * searching etc. |
| 2095 | + * |
| 2096 | + * @return bool |
1891 | 2097 | */ |
1892 | 2098 | function hasWordBreaks() { |
1893 | 2099 | return true; |
— | — | @@ -1917,6 +2123,10 @@ |
1918 | 2124 | /** |
1919 | 2125 | * convert double-width roman characters to single-width. |
1920 | 2126 | * range: ff00-ff5f ~= 0020-007f |
| 2127 | + * |
| 2128 | + * @param $string string |
| 2129 | + * |
| 2130 | + * @return string |
1921 | 2131 | */ |
1922 | 2132 | protected static function convertDoubleWidth( $string ) { |
1923 | 2133 | static $full = null; |
— | — | @@ -1933,12 +2143,21 @@ |
1934 | 2144 | return $string; |
1935 | 2145 | } |
1936 | 2146 | |
| 2147 | + /** |
| 2148 | + * @param $string string |
| 2149 | + * @param $pattern string |
| 2150 | + * @return string |
| 2151 | + */ |
1937 | 2152 | protected static function insertSpace( $string, $pattern ) { |
1938 | 2153 | $string = preg_replace( $pattern, " $1 ", $string ); |
1939 | 2154 | $string = preg_replace( '/ +/', ' ', $string ); |
1940 | 2155 | return $string; |
1941 | 2156 | } |
1942 | 2157 | |
| 2158 | + /** |
| 2159 | + * @param $termsArray array |
| 2160 | + * @return array |
| 2161 | + */ |
1943 | 2162 | function convertForSearchResult( $termsArray ) { |
1944 | 2163 | # some languages, e.g. Chinese, need to do a conversion |
1945 | 2164 | # in order for search results to be displayed correctly |
— | — | @@ -2010,6 +2229,10 @@ |
2011 | 2230 | # an override to the defaults can be set here on startup. |
2012 | 2231 | } |
2013 | 2232 | |
| 2233 | + /** |
| 2234 | + * @param $s string |
| 2235 | + * @return string |
| 2236 | + */ |
2014 | 2237 | function recodeForEdit( $s ) { |
2015 | 2238 | # For some languages we'll want to explicitly specify |
2016 | 2239 | # which characters make it into the edit box raw |
— | — | @@ -2025,6 +2248,10 @@ |
2026 | 2249 | } |
2027 | 2250 | } |
2028 | 2251 | |
| 2252 | + /** |
| 2253 | + * @param $s string |
| 2254 | + * @return string |
| 2255 | + */ |
2029 | 2256 | function recodeInput( $s ) { |
2030 | 2257 | # Take the previous into account. |
2031 | 2258 | global $wgEditEncoding; |
— | — | @@ -2046,6 +2273,10 @@ |
2047 | 2274 | * to the modern Unicode equivalent. |
2048 | 2275 | * |
2049 | 2276 | * This is language-specific for performance reasons only. |
| 2277 | + * |
| 2278 | + * @param $s string |
| 2279 | + * |
| 2280 | + * @return string |
2050 | 2281 | */ |
2051 | 2282 | function normalize( $s ) { |
2052 | 2283 | global $wgAllUnicodeFixes; |
— | — | @@ -2065,6 +2296,11 @@ |
2066 | 2297 | * |
2067 | 2298 | * The data is cached in process memory. This will go faster if you have the |
2068 | 2299 | * FastStringSearch extension. |
| 2300 | + * |
| 2301 | + * @param $file string |
| 2302 | + * @param $string string |
| 2303 | + * |
| 2304 | + * @return string |
2069 | 2305 | */ |
2070 | 2306 | function transformUsingPairFile( $file, $string ) { |
2071 | 2307 | if ( !isset( $this->transformData[$file] ) ) { |
— | — | @@ -2169,7 +2405,11 @@ |
2170 | 2406 | wfProfileOut( 'LanguageGetMagic' ); |
2171 | 2407 | } |
2172 | 2408 | |
2173 | | - # Fill a MagicWord object with data from here |
| 2409 | + /** |
| 2410 | + * Fill a MagicWord object with data from here |
| 2411 | + * |
| 2412 | + * @param $mw |
| 2413 | + */ |
2174 | 2414 | function getMagic( $mw ) { |
2175 | 2415 | $this->doMagicHook(); |
2176 | 2416 | |
— | — | @@ -2194,6 +2434,8 @@ |
2195 | 2435 | |
2196 | 2436 | /** |
2197 | 2437 | * Add magic words to the extension array |
| 2438 | + * |
| 2439 | + * @param $newWords array |
2198 | 2440 | */ |
2199 | 2441 | function addMagicWordsByLang( $newWords ) { |
2200 | 2442 | $code = $this->getCode(); |
— | — | @@ -2284,6 +2526,10 @@ |
2285 | 2527 | return $number; |
2286 | 2528 | } |
2287 | 2529 | |
| 2530 | + /** |
| 2531 | + * @param $number string |
| 2532 | + * @return string |
| 2533 | + */ |
2288 | 2534 | function parseFormattedNumber( $number ) { |
2289 | 2535 | $s = $this->digitTransformTable(); |
2290 | 2536 | if ( $s ) { |
— | — | @@ -2309,10 +2555,16 @@ |
2310 | 2556 | return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) ); |
2311 | 2557 | } |
2312 | 2558 | |
| 2559 | + /** |
| 2560 | + * @return array |
| 2561 | + */ |
2313 | 2562 | function digitTransformTable() { |
2314 | 2563 | return self::$dataCache->getItem( $this->mCode, 'digitTransformTable' ); |
2315 | 2564 | } |
2316 | 2565 | |
| 2566 | + /** |
| 2567 | + * @return array |
| 2568 | + */ |
2317 | 2569 | function separatorTransformTable() { |
2318 | 2570 | return self::$dataCache->getItem( $this->mCode, 'separatorTransformTable' ); |
2319 | 2571 | } |
— | — | @@ -2607,8 +2859,17 @@ |
2608 | 2860 | return $ret; |
2609 | 2861 | } |
2610 | 2862 | |
2611 | | - // truncateHtml() helper function |
2612 | | - // like strcspn() but adds the skipped chars to $ret |
| 2863 | + /** |
| 2864 | + * truncateHtml() helper function |
| 2865 | + * like strcspn() but adds the skipped chars to $ret |
| 2866 | + * |
| 2867 | + * @param $ret |
| 2868 | + * @param $text |
| 2869 | + * @param $search |
| 2870 | + * @param $start |
| 2871 | + * @param $len |
| 2872 | + * @return int |
| 2873 | + */ |
2613 | 2874 | private function truncate_skip( &$ret, $text, $search, $start, $len = null ) { |
2614 | 2875 | if ( $len === null ) { |
2615 | 2876 | $len = -1; // -1 means "no limit" for strcspn |
— | — | @@ -2669,6 +2930,11 @@ |
2670 | 2931 | * but only in (some) interface messages; otherwise default gender is used. |
2671 | 2932 | * If second or third parameter are not specified, masculine is used. |
2672 | 2933 | * These details may be overriden per language. |
| 2934 | + * |
| 2935 | + * @param $gender string |
| 2936 | + * @param $forms array |
| 2937 | + * |
| 2938 | + * @return string |
2673 | 2939 | */ |
2674 | 2940 | function gender( $gender, $forms ) { |
2675 | 2941 | if ( !count( $forms ) ) { |
— | — | @@ -2775,27 +3041,52 @@ |
2776 | 3042 | return $text; |
2777 | 3043 | } |
2778 | 3044 | |
2779 | | - # convert text to all supported variants |
| 3045 | + /** |
| 3046 | + * convert text to all supported variants |
| 3047 | + * |
| 3048 | + * @param $text string |
| 3049 | + * @return array |
| 3050 | + */ |
2780 | 3051 | function autoConvertToAllVariants( $text ) { |
2781 | 3052 | return $this->mConverter->autoConvertToAllVariants( $text ); |
2782 | 3053 | } |
2783 | 3054 | |
2784 | | - # convert text to different variants of a language. |
| 3055 | + /** |
| 3056 | + * convert text to different variants of a language. |
| 3057 | + * |
| 3058 | + * @param $text string |
| 3059 | + * @return string |
| 3060 | + */ |
2785 | 3061 | function convert( $text ) { |
2786 | 3062 | return $this->mConverter->convert( $text ); |
2787 | 3063 | } |
2788 | 3064 | |
2789 | | - # Convert a Title object to a string in the preferred variant |
| 3065 | + |
| 3066 | + /** |
| 3067 | + * Convert a Title object to a string in the preferred variant |
| 3068 | + * |
| 3069 | + * @param $title Title |
| 3070 | + * @return string |
| 3071 | + */ |
2790 | 3072 | function convertTitle( $title ) { |
2791 | 3073 | return $this->mConverter->convertTitle( $title ); |
2792 | 3074 | } |
2793 | 3075 | |
2794 | | - # Check if this is a language with variants |
| 3076 | + /** |
| 3077 | + * Check if this is a language with variants |
| 3078 | + * |
| 3079 | + * @return bool |
| 3080 | + */ |
2795 | 3081 | function hasVariants() { |
2796 | 3082 | return sizeof( $this->getVariants() ) > 1; |
2797 | 3083 | } |
2798 | 3084 | |
2799 | | - # Put custom tags (e.g. -{ }-) around math to prevent conversion |
| 3085 | + /** |
| 3086 | + * Put custom tags (e.g. -{ }-) around math to prevent conversion |
| 3087 | + * |
| 3088 | + * @param $text string |
| 3089 | + * @return string |
| 3090 | + */ |
2800 | 3091 | function armourMath( $text ) { |
2801 | 3092 | return $this->mConverter->armourMath( $text ); |
2802 | 3093 | } |
— | — | @@ -2872,6 +3163,10 @@ |
2873 | 3164 | * 'variant' => text in that variant |
2874 | 3165 | * |
2875 | 3166 | * @deprecated since 1.17 Use autoConvertToAllVariants() |
| 3167 | + * |
| 3168 | + * @param $text string |
| 3169 | + * |
| 3170 | + * @return string |
2876 | 3171 | */ |
2877 | 3172 | function convertLinkToAllVariants( $text ) { |
2878 | 3173 | return $this->mConverter->convertLinkToAllVariants( $text ); |
— | — | @@ -2903,7 +3198,7 @@ |
2904 | 3199 | * various functions in the Parser |
2905 | 3200 | * |
2906 | 3201 | * @param $text String: text to be tagged for no conversion |
2907 | | - * @param $noParse |
| 3202 | + * @param $noParse bool |
2908 | 3203 | * @return string the tagged text |
2909 | 3204 | */ |
2910 | 3205 | function markNoConversion( $text, $noParse = false ) { |
— | — | @@ -2929,11 +3224,16 @@ |
2930 | 3225 | |
2931 | 3226 | /** |
2932 | 3227 | * Get the RFC 3066 code for this language object |
| 3228 | + * |
| 3229 | + * @return string |
2933 | 3230 | */ |
2934 | 3231 | function getCode() { |
2935 | 3232 | return $this->mCode; |
2936 | 3233 | } |
2937 | 3234 | |
| 3235 | + /** |
| 3236 | + * @param $code string |
| 3237 | + */ |
2938 | 3238 | function setCode( $code ) { |
2939 | 3239 | $this->mCode = $code; |
2940 | 3240 | } |
— | — | @@ -2994,6 +3294,8 @@ |
2995 | 3295 | /** |
2996 | 3296 | * Get the fallback for a given language |
2997 | 3297 | * |
| 3298 | + * @param $code string |
| 3299 | + * |
2998 | 3300 | * @return false|string |
2999 | 3301 | */ |
3000 | 3302 | static function getFallbackFor( $code ) { |
— | — | @@ -3008,6 +3310,10 @@ |
3009 | 3311 | /** |
3010 | 3312 | * Get all messages for a given language |
3011 | 3313 | * WARNING: this may take a long time |
| 3314 | + * |
| 3315 | + * @param $code string |
| 3316 | + * |
| 3317 | + * @return array |
3012 | 3318 | */ |
3013 | 3319 | static function getMessagesFor( $code ) { |
3014 | 3320 | return self::getLocalisationCache()->getItem( $code, 'messages' ); |
— | — | @@ -3015,11 +3321,20 @@ |
3016 | 3322 | |
3017 | 3323 | /** |
3018 | 3324 | * Get a message for a given language |
| 3325 | + * |
| 3326 | + * @param $key string |
| 3327 | + * @param $code string |
| 3328 | + * |
| 3329 | + * @return string |
3019 | 3330 | */ |
3020 | 3331 | static function getMessageFor( $key, $code ) { |
3021 | 3332 | return self::getLocalisationCache()->getSubitem( $code, 'messages', $key ); |
3022 | 3333 | } |
3023 | 3334 | |
| 3335 | + /** |
| 3336 | + * @param $talk |
| 3337 | + * @return mixed |
| 3338 | + */ |
3024 | 3339 | function fixVariableInNamespace( $talk ) { |
3025 | 3340 | if ( strpos( $talk, '$1' ) === false ) { |
3026 | 3341 | return $talk; |
— | — | @@ -3037,10 +3352,18 @@ |
3038 | 3353 | return str_replace( ' ', '_', $talk ); |
3039 | 3354 | } |
3040 | 3355 | |
| 3356 | + /** |
| 3357 | + * @param $m string |
| 3358 | + * @return string |
| 3359 | + */ |
3041 | 3360 | function replaceGrammarInNamespace( $m ) { |
3042 | 3361 | return $this->convertGrammar( trim( $m[2] ), trim( $m[1] ) ); |
3043 | 3362 | } |
3044 | 3363 | |
| 3364 | + /** |
| 3365 | + * @throws MWException |
| 3366 | + * @return array |
| 3367 | + */ |
3045 | 3368 | static function getCaseMaps() { |
3046 | 3369 | static $wikiUpperChars, $wikiLowerChars; |
3047 | 3370 | if ( isset( $wikiUpperChars ) ) { |
— | — | @@ -3087,7 +3410,7 @@ |
3088 | 3411 | |
3089 | 3412 | /** |
3090 | 3413 | * @todo Document |
3091 | | - * @param $seconds String |
| 3414 | + * @param $seconds String |
3092 | 3415 | * @return string |
3093 | 3416 | */ |
3094 | 3417 | function formatTimePeriod( $seconds ) { |
— | — | @@ -3122,6 +3445,10 @@ |
3123 | 3446 | } |
3124 | 3447 | } |
3125 | 3448 | |
| 3449 | + /** |
| 3450 | + * @param $bps int |
| 3451 | + * @return string |
| 3452 | + */ |
3126 | 3453 | function formatBitrate( $bps ) { |
3127 | 3454 | $units = array( 'bps', 'kbps', 'Mbps', 'Gbps' ); |
3128 | 3455 | if ( $bps <= 0 ) { |
— | — | @@ -3172,6 +3499,8 @@ |
3173 | 3500 | |
3174 | 3501 | /** |
3175 | 3502 | * Get the conversion rule title, if any. |
| 3503 | + * |
| 3504 | + * @return string |
3176 | 3505 | */ |
3177 | 3506 | function getConvRuleTitle() { |
3178 | 3507 | return $this->mConverter->getConvRuleTitle(); |