From c7e8a273da4beb70ca3337ffa10b5c68541d0878 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Wed, 28 Dec 2005 14:47:30 +0000 Subject: [PATCH] now displays system messages in their edit box even if they are not set in the database yet --- includes/Article.php | 15 ++++++++++++--- includes/EditPage.php | 2 ++ includes/GlobalFunctions.php | 19 +++++++++++++++++++ includes/OutputPage.php | 7 ++++++- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 79d2919914..e91153de80 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -106,7 +106,12 @@ class Article { wfProfileOut( $fname ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); - $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ); + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { + $ret = wfMsgWeirdKey ( $this->mTitle->getText() ) ; + } else { + $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ); + } + return "
$ret
"; } else { $this->loadContent( $noredir ); @@ -376,7 +381,7 @@ class Article { $redirect = ($redirect == 'no') ? 'no' : 'yes'; $t .= ',redirect='.$redirect; } - $this->mContent = wfMsg( 'missingarticle', $t ); + $this->mContent = wfMsg( 'missingarticle', $t ) ; if( $oldid ) { $revision = Revision::newFromId( $oldid ); @@ -2431,7 +2436,11 @@ class Article { # first, see if the page exists at all. $exists = $page->getArticleId() != 0; if( !$exists ) { - $wgOut->addHTML( wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) ); + if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) { + $wgOut->addHTML(wfMsgWeirdKey ( $this->mTitle->getText() ) ); + } else { + $wgOut->addHTML(wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) ); + } } else { $dbr =& $this->getDB( DB_SLAVE ); $wl_clause = array( diff --git a/includes/EditPage.php b/includes/EditPage.php index 54f1366486..7554022a5b 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -653,6 +653,8 @@ class EditPage { $this->edittime = $this->mArticle->getTimestamp(); $this->textbox1 = $this->mArticle->getContent( true ); $this->summary = ''; + if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI ) + $this->textbox1 = wfMsgWeirdKey ( $this->mArticle->mTitle->getText() ) ; wfProxyCheck(); } diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 7bfa34a9be..fc1c0cb32f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -380,6 +380,25 @@ function wfMsgReal( $key, $args, $useDB, $forContent=false, $transform = true ) return $message; } +/** + * This function provides the message source for messages to be edited which are *not* stored in the database +*/ + +function wfMsgWeirdKey ( $key ) { + $subsource = str_replace ( ' ' , '_' , $key ) ; + $source = wfMsg ( $subsource ) ; + if ( $source == "<{$subsource}>" ) { + # Try again with first char lower case + $subsource = strtolower ( substr ( $subsource , 0 , 1 ) ) . substr ( $subsource , 1 ) ; + $source = wfMsg ( $subsource ) ; + } + if ( $source == "<{$subsource}>" ) { + # Didn't work either, return blank text + $source = "" ; + } + return $source ; +} + /** * Fetch a message string value, but don't replace any keys yet. * @param string $key diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f75c90e952..1e03a5c32a 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -748,7 +748,12 @@ class OutputPage { if( is_string( $source ) ) { if( strcmp( $source, '' ) == 0 ) { - $source = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ); + global $wgTitle ; + if ( $wgTitle->getNamespace() == NS_MEDIAWIKI ) { + $source = wfMsgWeirdKey ( $wgTitle->getText() ) ; + } else { + $source = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ); + } } $rows = $wgUser->getOption( 'rows' ); $cols = $wgUser->getOption( 'cols' ); -- 2.20.1