Since nobody commented on this, I assume all the changes are OK
authorArne Heizmann <timwi@users.mediawiki.org>
Sun, 1 Aug 2004 01:57:26 +0000 (01:57 +0000)
committerArne Heizmann <timwi@users.mediawiki.org>
Sun, 1 Aug 2004 01:57:26 +0000 (01:57 +0000)
(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
includes/Skin.php
includes/SpecialAllmessages.php
includes/SpecialContributions.php
includes/SpecialValidate.php

index 96c5358..d0b55a4 100644 (file)
@@ -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();
index 86ed82e..9b68888 100644 (file)
@@ -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 .= "<br>{$alt}<br>{$url}<br>\n";
                } else {
                        $s = '<a href="'.$u.'" class="image" title="'.$alt.'">' .
@@ -1929,7 +1929,7 @@ class Skin {
 
                $s = "<div class=\"thumb t{$align}\"><div style=\"width:{$oboxwidth}px;\">";
                if ( $thumbUrl == '' ) {
-                       $s .= str_replace( "$1", $img->getName(), wfMsg('missingimage') );
+                       $s .= wfMsg( 'missingimage', $img->getName() );
                        $zoomicon = '';
                } else {
                        $s .= '<a href="'.$u.'" class="internal" title="'.$alt.'">'.
index 01f0bd2..30b1741 100644 (file)
@@ -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 );
index cf3e4cb..a88da30 100644 (file)
@@ -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 );
 }
 
index e4c1910..b138249 100644 (file)
@@ -181,14 +181,14 @@ class Validation
                        {
                        $tablestyle = "cellspacing=0 cellpadding=2" ;
                        if ( $article_time == $time ) $tablestyle .=" style='border: 2px solid red'" ;
-                       $html .= "<h2>" . str_replace ( "$1" , gmdate("F d, Y H:i:s",wfTimestamp2Unix($time)) , wfMsg("val_version_of") ) ;
+                       $html .= "<h2>" . 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 .= "</h2>\n" ;
                        $html .= "<form method=post>\n" ;
                        $html .= "<input type=hidden name=oldtime value='{$time}'>" ;
                        $html .= "<table {$tablestyle}>\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 .= "<td align=center valign=top>" . $h ;
+                                       if ( $users[$idx] > 1 ) $msgid = "val_percent" ;
+                                       else $msgid = "val_percent_single" ;
+                                       $html .= "<td align=center valign=top>" .
+                                                       wfMsg ( $msgid, number_format ( $average , 2 ) ,
+                                                                       $vcur[$idx] , $vmax[$idx] , $users[$idx] ) ;
                                        }
                                else
                                        {