From 28346910c6918d6666113c3d1ef451f183e1992e Mon Sep 17 00:00:00 2001 From: Arne Heizmann Date: Sun, 1 Aug 2004 01:57:26 +0000 Subject: [PATCH] Since nobody commented on this, I assume all the changes are OK (http://mail.wikipedia.org/pipermail/wikitech-l/2004-July/011789.html) Use wfMsg's own replacement functionality instead of str_replace ( "$1", ... ) --- includes/OutputPage.php | 11 ++++------- includes/Skin.php | 4 ++-- includes/SpecialAllmessages.php | 2 +- includes/SpecialContributions.php | 2 +- includes/SpecialValidate.php | 16 +++++++--------- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 96c5358978..d0b55a4ff8 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -538,16 +538,13 @@ class OutputPage { $this->mRedirect = ""; if ( $wgCommandLineMode ) { - $msg = wfMsgNoDB( "dberrortextcl" ); + $msg = wfMsgNoDB( "dberrortextcl", htmlspecialchars( $sql ), + htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) ); } else { - $msg = wfMsgNoDB( "dberrortext" ); + $msg = wfMsgNoDB( "dberrortext", htmlspecialchars( $sql ), + htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) ); } - $msg = str_replace( "$1", htmlspecialchars( $sql ), $msg ); - $msg = str_replace( "$2", htmlspecialchars( $fname ), $msg ); - $msg = str_replace( "$3", $errno, $msg ); - $msg = str_replace( "$4", htmlspecialchars( $error ), $msg ); - if ( $wgCommandLineMode || !is_object( $wgUser )) { print "$msg\n"; wfErrorExit(); diff --git a/includes/Skin.php b/includes/Skin.php index 86ed82ee2a..9b688888fd 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1858,7 +1858,7 @@ class Skin { $u = $nt->escapeLocalURL(); if ( $url == '' ) { - $s = str_replace( "$1", $img->getName(), wfMsg('missingimage') ); + $s = wfMsg( 'missingimage', $img->getName() ); $s .= "
{$alt}
{$url}
\n"; } else { $s = '' . @@ -1929,7 +1929,7 @@ class Skin { $s = "
"; if ( $thumbUrl == '' ) { - $s .= str_replace( "$1", $img->getName(), wfMsg('missingimage') ); + $s .= wfMsg( 'missingimage', $img->getName() ); $zoomicon = ''; } else { $s .= ''. diff --git a/includes/SpecialAllmessages.php b/includes/SpecialAllmessages.php index 01f0bd271b..30b17411a4 100644 --- a/includes/SpecialAllmessages.php +++ b/includes/SpecialAllmessages.php @@ -6,7 +6,7 @@ $ot = $wgRequest->getText('ot'); $mwMsg =& MagicWord::get( MAG_MSG ); set_time_limit(0); - $navText = str_replace( "$1", $mwMsg->getSynonym( 0 ), wfMsg("allmessagestext" ) ); + $navText = wfMsg( 'allmessagestext', $mwMsg->getSynonym( 0 ) ); $first = true; $sortedArray = $wgAllMessagesEn; ksort( $sortedArray ); diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index cf3e4cb5b4..a88da3022d 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -146,7 +146,7 @@ function wfSpecialContributions( $par = "" ) # Validations $val = new Validation ; $val = $val->countUserValidations ( $id ) ; - $val = str_replace ( "$1" , $val , wfMsg ( 'val_user_validations' ) ) ; + $val = wfMsg ( 'val_user_validations', $val ) ; $wgOut->addHTML( $val ); } diff --git a/includes/SpecialValidate.php b/includes/SpecialValidate.php index e4c191038e..b138249222 100644 --- a/includes/SpecialValidate.php +++ b/includes/SpecialValidate.php @@ -181,14 +181,14 @@ class Validation { $tablestyle = "cellspacing=0 cellpadding=2" ; if ( $article_time == $time ) $tablestyle .=" style='border: 2px solid red'" ; - $html .= "

" . str_replace ( "$1" , gmdate("F d, Y H:i:s",wfTimestamp2Unix($time)) , wfMsg("val_version_of") ) ; + $html .= "

" . wfMsg( 'val_version_of', gmdate( "F d, Y H:i:s", wfTimestamp2Unix( $time ) ) ) ; $this->find_this_version ( $article_title , $time , $table_id , $table_name ) ; if ( $table_name == "cur" ) $html .= " (" . wfMsg ( 'val_this_is_current_version' ) . ")" ; $html .= "

\n" ; $html .= "
\n" ; $html .= "" ; $html .= "\n" ; - $html .= str_replace ( "$1" , $tabsep , wfMsg("val_table_header") ) ; + $html .= wfMsg( 'val_table_header', $tabsep ) ; for ( $idx = 0 ; $idx < count ( $validationtypes) ; $idx++ ) { $x = explode ( "|" , $validationtypes[$idx] , 4 ) ; @@ -318,13 +318,11 @@ class Validation $average = 100 * $vcur[$idx] / $vmax[$idx] ; $total_count += 1 ; $total_percent += $average ; - if ( $users[$idx] > 1 ) $h = wfMsg ( "val_percent" ) ; - else $h = wfMsg ( "val_percent_single" ) ; - $h = str_replace ( "$1" , number_format ( $average , 2 ) , $h ) ; - $h = str_replace ( "$2" , $vcur[$idx] , $h ) ; - $h = str_replace ( "$3" , $vmax[$idx] , $h ) ; - $h = str_replace ( "$4" , $users[$idx] , $h ) ; - $html .= "
" . $h ; + if ( $users[$idx] > 1 ) $msgid = "val_percent" ; + else $msgid = "val_percent_single" ; + $html .= "" . + wfMsg ( $msgid, number_format ( $average , 2 ) , + $vcur[$idx] , $vmax[$idx] , $users[$idx] ) ; } else { -- 2.20.1