From 28309ef5b42bd244b842130d4488865ef214129a Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Mon, 7 May 2012 06:38:51 +0200 Subject: [PATCH] Use local context to get messages Change-Id: Ieb3564e5532e421b4b803ed6c327d6a75ed0103c --- includes/specials/SpecialSearch.php | 130 +++++++++++----------------- 1 file changed, 52 insertions(+), 78 deletions(-) diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index a6d75bbe23..079130f982 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -233,13 +233,13 @@ class SpecialSearch extends SpecialPage { } else { $out->addHTML( Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', null, wfMsg( 'search-external' ) ) . - Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), wfMsg( 'searchdisabled' ) ) . - wfMsg( 'googlesearch', + Xml::element( 'legend', null, $this->msg( 'search-external' )->text() ) . + Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), $this->msg( 'searchdisabled' )->text() ) . + $this->msg( 'googlesearch' )->rawParams( htmlspecialchars( $term ), - htmlspecialchars( 'UTF-8' ), - htmlspecialchars( wfMsg( 'searchbutton' ) ) - ) . + 'UTF-8', + $this->msg( 'searchbutton' )->escaped() + )->text() . Xml::closeElement( 'fieldset' ) ); } @@ -286,7 +286,7 @@ class SpecialSearch extends SpecialPage { $stParams ); - $this->didYouMeanHtml = '
'.wfMsg('search-suggest',$suggestLink).'
'; + $this->didYouMeanHtml = '
' . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '
'; } // start rendering the page $out->addHtml( @@ -584,13 +584,8 @@ class SpecialSearch extends SpecialPage { $redirectText = null; $redirect = "" . - wfMsg( - 'search-redirect', - Linker::linkKnown( - $redirectTitle, - $redirectText - ) - ) . + $this->msg( 'search-redirect' )->rawParams( + Linker::linkKnown( $redirectTitle, $redirectText ) )->text() . ""; } @@ -601,12 +596,8 @@ class SpecialSearch extends SpecialPage { $sectionText = null; $section = "" . - wfMsg( - 'search-section', Linker::linkKnown( - $sectionTitle, - $sectionText - ) - ) . + $this->msg( 'search-section' )->rawParams( + Linker::linkKnown( $sectionTitle, $sectionText ) )->text() . ""; } @@ -621,7 +612,7 @@ class SpecialSearch extends SpecialPage { $score = ''; } else { $percent = sprintf( '%2.1f', $result->getScore() * 100 ); - $score = wfMsg( 'search-result-score', $lang->formatNum( $percent ) ) + $score = $this->msg( 'search-result-score' )->numParams( $percent )->text() . ' - '; } @@ -629,25 +620,17 @@ class SpecialSearch extends SpecialPage { $byteSize = $result->getByteSize(); $wordCount = $result->getWordCount(); $timestamp = $result->getTimestamp(); - $size = wfMsgExt( - 'search-result-size', - array( 'parsemag', 'escape' ), - $lang->formatSize( $byteSize ), - $lang->formatNum( $wordCount ) - ); + $size = $this->msg( 'search-result-size', $lang->formatSize( $byteSize ) ) + ->numParams( $wordCount )->escaped(); if( $t->getNamespace() == NS_CATEGORY ) { $cat = Category::newFromTitle( $t ); - $size = wfMsgExt( - 'search-result-category-size', - array( 'parsemag', 'escape' ), - $lang->formatNum( $cat->getPageCount() ), - $lang->formatNum( $cat->getSubcatCount() ), - $lang->formatNum( $cat->getFileCount() ) - ); + $size = $this->msg( 'search-result-category-size' ) + ->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() ) + ->escaped(); } - $date = $lang->timeanddate( $timestamp ); + $date = $lang->userTimeAndDate( $timestamp, $this->getUser() ); // link to related articles if supported $related = ''; @@ -656,14 +639,15 @@ class SpecialSearch extends SpecialPage { $stParams = array_merge( $this->powerSearchOptions(), array( - 'search' => wfMsgForContent( 'searchrelated' ) . ':' . $t->getPrefixedText(), - 'fulltext' => wfMsg( 'search' ) + 'search' => $this->msg( 'searchrelated' )->inContentLanguage()->text() . + ':' . $t->getPrefixedText(), + 'fulltext' => $this->msg( 'search' )->text() ) ); $related = ' -- ' . Linker::linkKnown( $st, - wfMsg('search-relatedarticle'), + $this->msg( 'search-relatedarticle' )->text(), array(), $stParams ); @@ -675,7 +659,7 @@ class SpecialSearch extends SpecialPage { if( $img ) { $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) ); if( $thumb ) { - $desc = wfMsg( 'parentheses', $img->getShortDesc() ); + $desc = $this->msg( 'parentheses' )->rawParams( $img->getShortDesc() )->escaped(); wfProfileOut( __METHOD__ ); // Float doesn't seem to interact well with the bullets. // Table messes up vertical alignment of the bullets. @@ -719,12 +703,12 @@ class SpecialSearch extends SpecialPage { $terms = $wgContLang->convertForSearchResult( $matches->termMatches() ); $out = "
". - wfMsg('search-interwiki-caption')."
\n"; + $this->msg( 'search-interwiki-caption' )->text() . "
\n"; $out .= "