From: Alexandre Emsenhuber Date: Sat, 28 Apr 2012 18:20:11 +0000 (+0200) Subject: Use local context to get messages and time formatting methods of Language class X-Git-Tag: 1.31.0-rc.0~23772^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=b233a23077db4f578b2f5c1159c91a2c9428ce0c;p=lhc%2Fweb%2Fwiklou.git Use local context to get messages and time formatting methods of Language class Also factorised calls to $this->getUser() and $this->getLanguage() in SpecialRecentChanges::optionsPanel(). Change-Id: I7fa666947cdce400e0fba3c8d6921376c66cbdb9 --- diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index c05aaad6f2..a7a87f0f8e 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -190,8 +190,8 @@ class SpecialRecentChanges extends IncludableSpecialPage { public function getFeedObject( $feedFormat ){ $changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' ); $formatter = $changesFeed->getFeedObject( - wfMsgForContent( 'recentchanges' ), - wfMsgForContent( 'recentchanges-feed-description' ), + $this->msg( 'recentchanges' )->inContentLanguage()->text(), + $this->msg( 'recentchanges-feed-description' )->inContentLanguage()->text(), $this->getTitle()->getFullURL() ); return array( $changesFeed, $formatter ); @@ -565,7 +565,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $extraOpts = $this->getExtraOptions( $opts ); $extraOptsCount = count( $extraOpts ); $count = 0; - $submit = ' ' . Xml::submitbutton( wfMsg( 'allpagessubmit' ) ); + $submit = ' ' . Xml::submitbutton( $this->msg( 'allpagessubmit' )->text() ); $out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) ); foreach( $extraOpts as $name => $optionRow ) { @@ -596,7 +596,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $panelString = implode( "\n", $panel ); $this->getOutput()->addHTML( - Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) ) + Xml::fieldset( $this->msg( 'recentchanges-legend' )->text(), $panelString, array( 'class' => 'rcoptions' ) ) ); $this->setBottomText( $opts ); @@ -636,7 +636,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $this->getOutput()->addWikiText( Html::rawElement( 'p', array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ), - "\n" . wfMsgForContentNoTrans( 'recentchangestext' ) . "\n" + "\n" . $this->msg( 'recentchangestext' )->inContentLanguage()->plain() . "\n" ), /* $lineStart */ false, /* $interface */ false @@ -663,16 +663,16 @@ class SpecialRecentChanges extends IncludableSpecialPage { array( 'selected' => $opts['namespace'], 'all' => '' ), array( 'name' => 'namespace', 'id' => 'namespace' ) ); - $nsLabel = Xml::label( wfMsg( 'namespace' ), 'namespace' ); + $nsLabel = Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ); $invert = Xml::checkLabel( - wfMsg( 'invert' ), 'invert', 'nsinvert', + $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $opts['invert'], - array( 'title' => wfMsg( 'tooltip-invert' ) ) + array( 'title' => $this->msg( 'tooltip-invert' )->text() ) ); $associated = Xml::checkLabel( - wfMsg( 'namespace_association' ), 'associated', 'nsassociated', + $this->msg( 'namespace_association' )->text(), 'associated', 'nsassociated', $opts['associated'], - array( 'title' => wfMsg( 'tooltip-namespace_association' ) ) + array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() ) ); return array( $nsLabel, "$nsSelect $invert $associated" ); } @@ -684,10 +684,10 @@ class SpecialRecentChanges extends IncludableSpecialPage { * @return Array */ protected function categoryFilterForm( FormOptions $opts ) { - list( $label, $input ) = Xml::inputLabelSep( wfMsg( 'rc_categories' ), + list( $label, $input ) = Xml::inputLabelSep( $this->msg( 'rc_categories' )->text(), 'categories', 'mw-categories', false, $opts['categories'] ); - $input .= ' ' . Xml::checkLabel( wfMsg( 'rc_categories_any' ), + $input .= ' ' . Xml::checkLabel( $this->msg( 'rc_categories_any' )->text(), 'categories_any', 'mw-categories_any', $opts['categories_any'] ); return array( $label, $input ); @@ -788,16 +788,18 @@ class SpecialRecentChanges extends IncludableSpecialPage { $options = $nondefaults + $defaults; $note = ''; - if( !wfEmptyMsg( 'rclegend' ) ) { - $note .= '
' . - wfMsgExt( 'rclegend', array( 'parseinline' ) ) . "
\n"; + $msg = $this->msg( 'rclegend' ); + if( !$msg->isDisabled() ) { + $note .= '
' . $msg->parse() . "
\n"; } + + $lang = $this->getLanguage(); + $user = $this->getUser(); if( $options['from'] ) { - $note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ), - $this->getLanguage()->formatNum( $options['limit'] ), - $this->getLanguage()->timeanddate( $options['from'], true ), - $this->getLanguage()->date( $options['from'], true ), - $this->getLanguage()->time( $options['from'], true ) ) . '
'; + $note .= $this->msg( 'rcnotefrom' )->numParams( $options['limit'] )->params( + $lang->userTimeAndDate( $options['from'], $user ), + $lang->userDate( $options['from'], $user ), + $lang->userTime( $options['from'], $user ) )->parse() . '
'; } # Sort data for display and make sure it's unique after we've added user data. @@ -810,21 +812,21 @@ class SpecialRecentChanges extends IncludableSpecialPage { // limit links foreach( $wgRCLinkLimits as $value ) { - $cl[] = $this->makeOptionsLink( $this->getLanguage()->formatNum( $value ), + $cl[] = $this->makeOptionsLink( $lang->formatNum( $value ), array( 'limit' => $value ), $nondefaults, $value == $options['limit'] ); } - $cl = $this->getLanguage()->pipeList( $cl ); + $cl = $lang->pipeList( $cl ); // day links, reset 'from' to none foreach( $wgRCLinkDays as $value ) { - $dl[] = $this->makeOptionsLink( $this->getLanguage()->formatNum( $value ), + $dl[] = $this->makeOptionsLink( $lang->formatNum( $value ), array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] ); } - $dl = $this->getLanguage()->pipeList( $dl ); + $dl = $lang->pipeList( $dl ); // show/hide links - $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) ); + $showhide = array( $this->msg( 'show' )->text(), $this->msg( 'hide' )->text() ); $filters = array( 'hideminor' => 'rcshowhideminor', 'hidebots' => 'rcshowhidebots', @@ -837,7 +839,7 @@ class SpecialRecentChanges extends IncludableSpecialPage { $filters[$key] = $params['msg']; } // Disable some if needed - if ( !$this->getUser()->useRCPatrol() ) { + if ( !$user->useRCPatrol() ) { unset( $filters['hidepatrolled'] ); } @@ -845,19 +847,18 @@ class SpecialRecentChanges extends IncludableSpecialPage { foreach ( $filters as $key => $msg ) { $link = $this->makeOptionsLink( $showhide[1 - $options[$key]], array( $key => 1-$options[$key] ), $nondefaults ); - $links[] = wfMsgHtml( $msg, $link ); + $links[] = $this->msg( $msg )->rawParams( $link )->escaped(); } // show from this onward link $timestamp = wfTimestampNow(); - $now = $this->getLanguage()->timeanddate( $timestamp, true ); + $now = $lang->userTimeAndDate( $timestamp, $user ); $tl = $this->makeOptionsLink( $now, array( 'from' => $timestamp ), $nondefaults ); - $rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ), - $cl, $dl, $this->getLanguage()->pipeList( $links ) ); - $rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl ); + $rclinks = $this->msg( 'rclinks' )->rawParams( $cl, $dl, $lang->pipeList( $links ) )->parse(); + $rclistfrom = $this->msg( 'rclistfrom' )->rawParams( $tl )->parse(); return "{$note}$rclinks
$rclistfrom"; }