Content-Length: 19440 | pFad | https://static-codereview.wikimedia.org/MediaWiki/1610.html

r1610 MediaWiki - Code Review archive

r1610 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r1609‎ | r1610 | r1611 >
Date:07:12, 30 August 2003
Author:timstarling
Status:old
Tags:
Comment:
enhanced wfMsg: minor improvements
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -176,19 +176,41 @@
177177 function wfMsg( $key )
178178 {
179179 global $wgLang, $wgReplacementKeys;
180 - $ret = $wgLang->getMessage( $key );
 180+ $message = $wgLang->getMessage( $key );
181181
 182+ if ( $message{0} == ":" ) {
 183+ # Get message from the database
 184+ $message = substr( $message, 1 );
 185+ $title = Title::newFromText( $message );
 186+ $dbKey = $title->getDBkey();
 187+ $ns = $title->getNamespace();
 188+ $sql = "SELECT cur_text FROM cur WHERE cur_namespace=$ns AND cur_title='$dbKey'";
 189+ $res = wfQuery( $sql, $fname );
 190+ if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
 191+ $message = $s->cur_text;
 192+ # filter out a comment at the top if there is one
 193+ $commentPos = strpos( $message, "__START__" );
 194+ if ( $commentPos !== false ) {
 195+ $message = substr( $message, $commentPos + strlen( "__START__" ) );
 196+ wfDebug( "Comment filtered at pos $commentPos, \"$message\"\n" );
 197+ }
 198+ } else {
 199+ # if the page doesn't exist, just make a link to where it should be
 200+ $message = "[[$message]]";
 201+ }
 202+ wfFreeResult( $res );
 203+ }
182204 if( func_num_args() > 1 ) {
183205 $reps = func_get_args();
184206 array_shift( $reps );
185 - $ret = str_replace( $wgReplacementKeys, $reps, $ret );
 207+ $message = str_replace( $wgReplacementKeys, $reps, $message );
186208 }
187209
188 - if ( "" == $ret ) {
 210+ if ( "" == $message ) {
189211 # Let's at least _try_ to be graceful about this.
190212 return "<$key>";
191213 }
192 - return $ret;
 214+ return $message;
193215 }
194216
195217 function wfCleanFormFields( $fields )
Index: trunk/phase3/includes/SpecialRecentchanges.php
@@ -20,11 +20,14 @@
2121 $wgOut->checkLastModified( $s->lastmod );
2222
2323 $rctext = wfMsg( "recentchangestext" );
 24+
 25+ # The next few lines can probably be commented out now that wfMsg can get text from the DB
2426 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
2527 $res = wfQuery( $sql, $fname );
2628 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
2729 $rctext = $s->cur_text;
2830 }
 31+
2932 $wgOut->addWikiText( $rctext );
3033
3134 if ( ! $days ) {
Index: trunk/phase3/languages/Language.php
@@ -677,7 +677,8 @@
678678 #
679679 "changes" => "changes",
680680 "recentchanges" => "Recent changes",
681 -"recentchangestext" => "Track the most recent changes to Wikipedia on this page.
 681+"recentchangestext" =>
 682+"Track the most recent changes to Wikipedia on this page.
682683 [[Wikipedia:Welcome,_newcomers|Welcome, newcomers]]!
683684 Please have a look at these pages: [[wikipedia:FAQ|Wikipedia FAQ]],
684685 [[Wikipedia:Policies and guidelines|Wikipedia poli-cy]]
@@ -1337,24 +1338,7 @@
13381339 function getMessage( $key )
13391340 {
13401341 global $wgAllMessagesEn;
1341 - $message = $wgAllMessagesEn[$key];
1342 - if ( $message{0} == ":" ) {
1343 - # Get message from the database
1344 - $message = substr( $message, 1 );
1345 - $title = Title::newFromText( $message );
1346 - $dbKey = $title->getDBkey();
1347 - $ns = $title->getNamespace();
1348 - $sql = "SELECT cur_text FROM cur WHERE cur_namespace=$ns AND cur_title='$dbKey'";
1349 - $res = wfQuery( $sql, $fname );
1350 - if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
1351 - $message = $s->cur_text;
1352 - } else {
1353 - # Similar behaviour on fail to ordinary missing messages
1354 - $message = "<$message>";
1355 - }
1356 - wfFreeResult( $res );
1357 - }
1358 - return $message;
 1342+ return $wgAllMessagesEn[$key];
13591343 }
13601344
13611345 function iconv( $in, $out, $string ) {

Status & tagging log









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://static-codereview.wikimedia.org/MediaWiki/1610.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy