function wfMsg( $key )
{
global $wgLang, $wgReplacementKeys;
- $ret = $wgLang->getMessage( $key );
+ $message = $wgLang->getMessage( $key );
+ if ( $message{0} == ":" ) {
+ # Get message from the database
+ $message = substr( $message, 1 );
+ $title = Title::newFromText( $message );
+ $dbKey = $title->getDBkey();
+ $ns = $title->getNamespace();
+ $sql = "SELECT cur_text FROM cur WHERE cur_namespace=$ns AND cur_title='$dbKey'";
+ $res = wfQuery( $sql, $fname );
+ if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
+ $message = $s->cur_text;
+ # filter out a comment at the top if there is one
+ $commentPos = strpos( $message, "__START__" );
+ if ( $commentPos !== false ) {
+ $message = substr( $message, $commentPos + strlen( "__START__" ) );
+ wfDebug( "Comment filtered at pos $commentPos, \"$message\"\n" );
+ }
+ } else {
+ # if the page doesn't exist, just make a link to where it should be
+ $message = "[[$message]]";
+ }
+ wfFreeResult( $res );
+ }
if( func_num_args() > 1 ) {
$reps = func_get_args();
array_shift( $reps );
- $ret = str_replace( $wgReplacementKeys, $reps, $ret );
+ $message = str_replace( $wgReplacementKeys, $reps, $message );
}
- if ( "" == $ret ) {
+ if ( "" == $message ) {
# Let's at least _try_ to be graceful about this.
return "<$key>";
}
- return $ret;
+ return $message;
}
function wfCleanFormFields( $fields )
$wgOut->checkLastModified( $s->lastmod );
$rctext = wfMsg( "recentchangestext" );
+
+ # The next few lines can probably be commented out now that wfMsg can get text from the DB
$sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
$res = wfQuery( $sql, $fname );
if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
$rctext = $s->cur_text;
}
+
$wgOut->addWikiText( $rctext );
if ( ! $days ) {
#
"changes" => "changes",
"recentchanges" => "Recent changes",
-"recentchangestext" => "Track the most recent changes to Wikipedia on this page.
+"recentchangestext" =>
+"Track the most recent changes to Wikipedia on this page.
[[Wikipedia:Welcome,_newcomers|Welcome, newcomers]]!
Please have a look at these pages: [[wikipedia:FAQ|Wikipedia FAQ]],
[[Wikipedia:Policies and guidelines|Wikipedia policy]]
function getMessage( $key )
{
global $wgAllMessagesEn;
- $message = $wgAllMessagesEn[$key];
- if ( $message{0} == ":" ) {
- # Get message from the database
- $message = substr( $message, 1 );
- $title = Title::newFromText( $message );
- $dbKey = $title->getDBkey();
- $ns = $title->getNamespace();
- $sql = "SELECT cur_text FROM cur WHERE cur_namespace=$ns AND cur_title='$dbKey'";
- $res = wfQuery( $sql, $fname );
- if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text != "" ) ) {
- $message = $s->cur_text;
- } else {
- # Similar behaviour on fail to ordinary missing messages
- $message = "<$message>";
- }
- wfFreeResult( $res );
- }
- return $message;
+ return $wgAllMessagesEn[$key];
}
function iconv( $in, $out, $string ) {