Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -256,7 +256,7 @@ |
257 | 257 | $feeds = array(); |
258 | 258 | foreach( $out->getSyndicationLinks() as $format => $link ) { |
259 | 259 | $feeds[$format] = array( |
260 | | - 'text' => wfMsg( "feed-$format" ), |
| 260 | + 'text' => $this->msg( "feed-$format" )->text(), |
261 | 261 | 'href' => $link |
262 | 262 | ); |
263 | 263 | } |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | $tpl->set( 'exists', $this->getTitle()->getArticleID() != 0 ); |
283 | 283 | $tpl->set( 'watch', $this->getTitle()->userIsWatching() ? 'unwatch' : 'watch' ); |
284 | 284 | $tpl->set( 'protect', count( $this->getTitle()->isProtected() ) ? 'unprotect' : 'protect' ); |
285 | | - $tpl->set( 'helppage', wfMsg( 'helppage' ) ); |
| 285 | + $tpl->set( 'helppage', $this->msg( 'helppage' )->text() ); |
286 | 286 | */ |
287 | 287 | $tpl->set( 'searchaction', $this->escapeSearchLink() ); |
288 | 288 | $tpl->set( 'searchtitle', SpecialPage::getTitleFor( 'Search' )->getPrefixedDBKey() ); |
— | — | @@ -336,9 +336,9 @@ |
337 | 337 | if ( $this->isRevisionCurrent() ) { |
338 | 338 | $article = new Article( $this->getTitle(), 0 ); |
339 | 339 | if ( !$wgDisableCounters ) { |
340 | | - $viewcount = $this->getLang()->formatNum( $article->getCount() ); |
| 340 | + $viewcount = $article->getCount(); |
341 | 341 | if ( $viewcount ) { |
342 | | - $tpl->set( 'viewcount', wfMsgExt( 'viewcount', array( 'parseinline' ), $viewcount ) ); |
| 342 | + $tpl->set( 'viewcount', $this->msg( 'viewcount' )->numParams( $viewcount )->parse() ); |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
— | — | @@ -350,8 +350,7 @@ |
351 | 351 | ); |
352 | 352 | if( $num > 0 ) { |
353 | 353 | $tpl->set( 'numberofwatchingusers', |
354 | | - wfMsgExt( 'number_of_watching_users_pageview', array( 'parseinline' ), |
355 | | - $this->getLang()->formatNum( $num ) ) |
| 354 | + $this->msg( 'number_of_watching_users_pageview' )->numParams( $num )->parse() |
356 | 355 | ); |
357 | 356 | } |
358 | 357 | } |
— | — | @@ -566,20 +565,20 @@ |
567 | 566 | ); |
568 | 567 | $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage ); |
569 | 568 | $personal_urls['mytalk'] = array( |
570 | | - 'text' => wfMsg( 'mytalk' ), |
| 569 | + 'text' => $this->msg( 'mytalk' )->text(), |
571 | 570 | 'href' => &$usertalkUrlDetails['href'], |
572 | 571 | 'class' => $usertalkUrlDetails['exists'] ? false : 'new', |
573 | 572 | 'active' => ( $usertalkUrlDetails['href'] == $pageurl ) |
574 | 573 | ); |
575 | 574 | $href = self::makeSpecialUrl( 'Preferences' ); |
576 | 575 | $personal_urls['preferences'] = array( |
577 | | - 'text' => wfMsg( 'mypreferences' ), |
| 576 | + 'text' => $this->msg( 'mypreferences' )->text(), |
578 | 577 | 'href' => $href, |
579 | 578 | 'active' => ( $href == $pageurl ) |
580 | 579 | ); |
581 | 580 | $href = self::makeSpecialUrl( 'Watchlist' ); |
582 | 581 | $personal_urls['watchlist'] = array( |
583 | | - 'text' => wfMsg( 'mywatchlist' ), |
| 582 | + 'text' => $this->msg( 'mywatchlist' )->text(), |
584 | 583 | 'href' => $href, |
585 | 584 | 'active' => ( $href == $pageurl ) |
586 | 585 | ); |
— | — | @@ -601,12 +600,12 @@ |
602 | 601 | |
603 | 602 | $href = self::makeSpecialUrlSubpage( 'Contributions', $this->username ); |
604 | 603 | $personal_urls['mycontris'] = array( |
605 | | - 'text' => wfMsg( 'mycontris' ), |
| 604 | + 'text' => $this->msg( 'mycontris' )->text(), |
606 | 605 | 'href' => $href, |
607 | 606 | 'active' => $active |
608 | 607 | ); |
609 | 608 | $personal_urls['logout'] = array( |
610 | | - 'text' => wfMsg( 'userlogout' ), |
| 609 | + 'text' => $this->msg( 'userlogout' )->text(), |
611 | 610 | 'href' => self::makeSpecialUrl( 'Userlogout', |
612 | 611 | // userlogout link must always contain an & character, otherwise we might not be able |
613 | 612 | // to detect a buggy precaching proxy (bug 17790) |
— | — | @@ -623,13 +622,13 @@ |
624 | 623 | |
625 | 624 | # anonlogin & login are the same |
626 | 625 | $login_url = array( |
627 | | - 'text' => wfMsg( $loginlink ), |
| 626 | + 'text' => $this->msg( $loginlink )->text(), |
628 | 627 | 'href' => self::makeSpecialUrl( 'Userlogin', $returnto ), |
629 | 628 | 'active' => $title->isSpecial( 'Userlogin' ) && ( $loginlink == "nav-login-createaccount" || !$is_signup ) |
630 | 629 | ); |
631 | 630 | if ( $this->getUser()->isAllowed( 'createaccount' ) && !$useCombinedLoginLink ) { |
632 | 631 | $createaccount_url = array( |
633 | | - 'text' => wfMsg( 'createaccount' ), |
| 632 | + 'text' => $this->msg( 'createaccount' )->text(), |
634 | 633 | 'href' => self::makeSpecialUrl( 'Userlogin', "$returnto&type=signup" ), |
635 | 634 | 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup |
636 | 635 | ); |
— | — | @@ -662,7 +661,7 @@ |
663 | 662 | $usertalkUrlDetails = $this->makeTalkUrlDetails( $this->userpage ); |
664 | 663 | $href = &$usertalkUrlDetails['href']; |
665 | 664 | $personal_urls['anontalk'] = array( |
666 | | - 'text' => wfMsg( 'anontalk' ), |
| 665 | + 'text' => $this->msg( 'anontalk' )->text(), |
667 | 666 | 'href' => $href, |
668 | 667 | 'class' => $usertalkUrlDetails['exists'] ? false : 'new', |
669 | 668 | 'active' => ( $pageurl == $href ) |
— | — | @@ -702,7 +701,7 @@ |
703 | 702 | |
704 | 703 | // wfMessageFallback will nicely accept $message as an array of fallbacks |
705 | 704 | // or just a single key |
706 | | - $msg = wfMessageFallback( $message ); |
| 705 | + $msg = wfMessageFallback( $message )->setContext( $this->getContext() ); |
707 | 706 | if ( is_array($message) ) { |
708 | 707 | // for hook compatibility just keep the last message name |
709 | 708 | $message = end($message); |
— | — | @@ -882,7 +881,7 @@ |
883 | 882 | "edit" : "create"; |
884 | 883 | $content_navigation['views']['edit'] = array( |
885 | 884 | 'class' => ( $selected ? 'selected' : '' ) . $isTalkClass, |
886 | | - 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->text(), |
| 885 | + 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->setContext( $this->getContext() )->text(), |
887 | 886 | 'href' => $title->getLocalURL( $this->editUrlOptions() ), |
888 | 887 | 'primary' => true, // don't collapse this in vector |
889 | 888 | ); |
— | — | @@ -895,7 +894,7 @@ |
896 | 895 | //$content_navigation['actions']['addsection'] |
897 | 896 | $content_navigation['views']['addsection'] = array( |
898 | 897 | 'class' => $section == 'new' ? 'selected' : false, |
899 | | - 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->text(), |
| 898 | + 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->setContext( $this->getContext() )->text(), |
900 | 899 | 'href' => $title->getLocalURL( 'action=edit§ion=new' ) |
901 | 900 | ); |
902 | 901 | } |
— | — | @@ -905,7 +904,7 @@ |
906 | 905 | // Adds view source view link |
907 | 906 | $content_navigation['views']['viewsource'] = array( |
908 | 907 | 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false, |
909 | | - 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->text(), |
| 908 | + 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->setContext( $this->getContext() )->text(), |
910 | 909 | 'href' => $title->getLocalURL( $this->editUrlOptions() ), |
911 | 910 | 'primary' => true, // don't collapse this in vector |
912 | 911 | ); |
— | — | @@ -919,7 +918,7 @@ |
920 | 919 | // Adds history view link |
921 | 920 | $content_navigation['views']['history'] = array( |
922 | 921 | 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false, |
923 | | - 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->text(), |
| 922 | + 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->setContext( $this->getContext() )->text(), |
924 | 923 | 'href' => $title->getLocalURL( 'action=history' ), |
925 | 924 | 'rel' => 'archives', |
926 | 925 | ); |
— | — | @@ -927,7 +926,7 @@ |
928 | 927 | if( $user->isAllowed( 'delete' ) ) { |
929 | 928 | $content_navigation['actions']['delete'] = array( |
930 | 929 | 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false, |
931 | | - 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->text(), |
| 930 | + 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->setContext( $this->getContext() )->text(), |
932 | 931 | 'href' => $title->getLocalURL( 'action=delete' ) |
933 | 932 | ); |
934 | 933 | } |
— | — | @@ -935,7 +934,7 @@ |
936 | 935 | $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() ); |
937 | 936 | $content_navigation['actions']['move'] = array( |
938 | 937 | 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false, |
939 | | - 'text' => wfMessageFallback( "$skname-action-move", 'move' )->text(), |
| 938 | + 'text' => wfMessageFallback( "$skname-action-move", 'move' )->setContext( $this->getContext() )->text(), |
940 | 939 | 'href' => $moveTitle->getLocalURL() |
941 | 940 | ); |
942 | 941 | } |
— | — | @@ -944,7 +943,7 @@ |
945 | 944 | $mode = !$title->isProtected() ? 'protect' : 'unprotect'; |
946 | 945 | $content_navigation['actions'][$mode] = array( |
947 | 946 | 'class' => ( $onPage && $action == $mode ) ? 'selected' : false, |
948 | | - 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->text(), |
| 947 | + 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(), |
949 | 948 | 'href' => $title->getLocalURL( "action=$mode" ) |
950 | 949 | ); |
951 | 950 | } |
— | — | @@ -959,7 +958,7 @@ |
960 | 959 | $content_navigation['actions']['undelete'] = array( |
961 | 960 | 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false, |
962 | 961 | 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" ) |
963 | | - ->params( $this->getLang()->formatNum( $n ) )->text(), |
| 962 | + ->setContext( $this->getContext() )->numParams( $n )->text(), |
964 | 963 | 'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) ) |
965 | 964 | ); |
966 | 965 | } |
— | — | @@ -969,7 +968,7 @@ |
970 | 969 | $mode = !$title->getRestrictions( 'create' ) ? 'protect' : 'unprotect'; |
971 | 970 | $content_navigation['actions'][$mode] = array( |
972 | 971 | 'class' => ( $onPage && $action == $mode ) ? 'selected' : false, |
973 | | - 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->text(), |
| 972 | + 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->setContext( $this->getContext() )->text(), |
974 | 973 | 'href' => $title->getLocalURL( "action=$mode" ) |
975 | 974 | ); |
976 | 975 | } |
— | — | @@ -991,7 +990,7 @@ |
992 | 991 | $token = WatchAction::getWatchToken( $title, $user, $mode ); |
993 | 992 | $content_navigation['actions'][$mode] = array( |
994 | 993 | 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false, |
995 | | - 'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message |
| 994 | + 'text' => $this->msg( $mode )->text(), // uses 'watch' or 'unwatch' message |
996 | 995 | 'href' => $title->getLocalURL( array( 'action' => $mode, 'token' => $token ) ) |
997 | 996 | ); |
998 | 997 | } |
— | — | @@ -1001,7 +1000,7 @@ |
1002 | 1001 | // If it's not content, it's got to be a special page |
1003 | 1002 | $content_navigation['namespaces']['special'] = array( |
1004 | 1003 | 'class' => 'selected', |
1005 | | - 'text' => wfMsg( 'nstab-special' ), |
| 1004 | + 'text' => $this->msg( 'nstab-special' )->text(), |
1006 | 1005 | 'href' => $request->getRequestURL(), // @bug 2457, 2510 |
1007 | 1006 | 'context' => 'subject' |
1008 | 1007 | ); |
— | — | @@ -1163,7 +1162,7 @@ |
1164 | 1163 | if( $out->isArticle() ) { |
1165 | 1164 | if ( !$out->isPrintable() ) { |
1166 | 1165 | $nav_urls['print'] = array( |
1167 | | - 'text' => wfMsg( 'printableversion' ), |
| 1166 | + 'text' => $this->msg( 'printableversion' )->text(), |
1168 | 1167 | 'href' => $this->getTitle()->getLocalURL( |
1169 | 1168 | $request->appendQueryValue( 'printable', 'yes', true ) ) |
1170 | 1169 | ); |
— | — | @@ -1173,7 +1172,7 @@ |
1174 | 1173 | $revid = $this->getRevisionId(); |
1175 | 1174 | if ( $revid ) { |
1176 | 1175 | $nav_urls['permalink'] = array( |
1177 | | - 'text' => wfMsg( 'permalink' ), |
| 1176 | + 'text' => $this->msg( 'permalink' )->text(), |
1178 | 1177 | 'href' => $out->getTitle()->getLocalURL( "oldid=$revid" ) |
1179 | 1178 | ); |
1180 | 1179 | } |
— | — | @@ -1411,6 +1410,28 @@ |
1412 | 1411 | abstract class BaseTemplate extends QuickTemplate { |
1413 | 1412 | |
1414 | 1413 | /** |
| 1414 | + * Get a Message object with its context set |
| 1415 | + * |
| 1416 | + * @param $name Str message name |
| 1417 | + * @return Message |
| 1418 | + */ |
| 1419 | + public function getMsg( $name ) { |
| 1420 | + return $this->getSkin()->msg( $name ); |
| 1421 | + } |
| 1422 | + |
| 1423 | + function msg( $str ) { |
| 1424 | + echo $this->getMsg( $str )->escaped(); |
| 1425 | + } |
| 1426 | + |
| 1427 | + function msgHtml( $str ) { |
| 1428 | + echo $this->getMsg( $str )->text(); |
| 1429 | + } |
| 1430 | + |
| 1431 | + function msgWiki( $str ) { |
| 1432 | + echo $this->getMsg( $str )->parseAsBlock(); |
| 1433 | + } |
| 1434 | + |
| 1435 | + /** |
1415 | 1436 | * Create an array of common toolbox items from the data in the quicktemplate |
1416 | 1437 | * stored by SkinTemplate. |
1417 | 1438 | * The resulting array is built acording to a format intended to be passed |
— | — | @@ -1533,13 +1554,13 @@ |
1534 | 1555 | // Search is a special case, skins should custom implement this |
1535 | 1556 | $boxes[$boxName] = array( |
1536 | 1557 | 'id' => "p-search", |
1537 | | - 'header' => wfMessage( 'search' )->text(), |
| 1558 | + 'header' => $this->getMsg( 'search' )->text(), |
1538 | 1559 | 'generated' => false, |
1539 | 1560 | 'content' => true, |
1540 | 1561 | ); |
1541 | 1562 | break; |
1542 | 1563 | case 'TOOLBOX': |
1543 | | - $msgObj = wfMessage( 'toolbox' ); |
| 1564 | + $msgObj = $this->getMsg( 'toolbox' ); |
1544 | 1565 | $boxes[$boxName] = array( |
1545 | 1566 | 'id' => "p-tb", |
1546 | 1567 | 'header' => $msgObj->exists() ? $msgObj->text() : 'toolbox', |
— | — | @@ -1549,7 +1570,7 @@ |
1550 | 1571 | break; |
1551 | 1572 | case 'LANGUAGES': |
1552 | 1573 | if ( $this->data['language_urls'] ) { |
1553 | | - $msgObj = wfMessage( 'otherlanguages' ); |
| 1574 | + $msgObj = $this->getMsg( 'otherlanguages' ); |
1554 | 1575 | $boxes[$boxName] = array( |
1555 | 1576 | 'id' => "p-lang", |
1556 | 1577 | 'header' => $msgObj->exists() ? $msgObj->text() : 'otherlanguages', |
— | — | @@ -1559,7 +1580,7 @@ |
1560 | 1581 | } |
1561 | 1582 | break; |
1562 | 1583 | default: |
1563 | | - $msgObj = wfMessage( $boxName ); |
| 1584 | + $msgObj = $this->getMsg( $boxName ); |
1564 | 1585 | $boxes[$boxName] = array( |
1565 | 1586 | 'id' => "p-$boxName", |
1566 | 1587 | 'header' => $msgObj->exists() ? $msgObj->text() : $boxName, |