Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -176,19 +176,41 @@ |
177 | 177 | function wfMsg( $key ) |
178 | 178 | { |
179 | 179 | global $wgLang, $wgReplacementKeys; |
180 | | - $ret = $wgLang->getMessage( $key ); |
| 180 | + $message = $wgLang->getMessage( $key ); |
181 | 181 | |
| 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 | + } |
182 | 204 | if( func_num_args() > 1 ) { |
183 | 205 | $reps = func_get_args(); |
184 | 206 | array_shift( $reps ); |
185 | | - $ret = str_replace( $wgReplacementKeys, $reps, $ret ); |
| 207 | + $message = str_replace( $wgReplacementKeys, $reps, $message ); |
186 | 208 | } |
187 | 209 | |
188 | | - if ( "" == $ret ) { |
| 210 | + if ( "" == $message ) { |
189 | 211 | # Let's at least _try_ to be graceful about this. |
190 | 212 | return "<$key>"; |
191 | 213 | } |
192 | | - return $ret; |
| 214 | + return $message; |
193 | 215 | } |
194 | 216 | |
195 | 217 | function wfCleanFormFields( $fields ) |
Index: trunk/phase3/includes/SpecialRecentchanges.php |
— | — | @@ -20,11 +20,14 @@ |
21 | 21 | $wgOut->checkLastModified( $s->lastmod ); |
22 | 22 | |
23 | 23 | $rctext = wfMsg( "recentchangestext" ); |
| 24 | + |
| 25 | + # The next few lines can probably be commented out now that wfMsg can get text from the DB |
24 | 26 | $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'"; |
25 | 27 | $res = wfQuery( $sql, $fname ); |
26 | 28 | if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) { |
27 | 29 | $rctext = $s->cur_text; |
28 | 30 | } |
| 31 | + |
29 | 32 | $wgOut->addWikiText( $rctext ); |
30 | 33 | |
31 | 34 | if ( ! $days ) { |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -677,7 +677,8 @@ |
678 | 678 | # |
679 | 679 | "changes" => "changes", |
680 | 680 | "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. |
682 | 683 | [[Wikipedia:Welcome,_newcomers|Welcome, newcomers]]! |
683 | 684 | Please have a look at these pages: [[wikipedia:FAQ|Wikipedia FAQ]], |
684 | 685 | [[Wikipedia:Policies and guidelines|Wikipedia policy]] |
— | — | @@ -1337,24 +1338,7 @@ |
1338 | 1339 | function getMessage( $key ) |
1339 | 1340 | { |
1340 | 1341 | 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]; |
1359 | 1343 | } |
1360 | 1344 | |
1361 | 1345 | function iconv( $in, $out, $string ) { |