r12272 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12271‎ | r12272 | r12273 >
Date:14:47, 28 December 2005
Author:magnus_manske
Status:old
Tags:
Comment:
now displays system messages in their edit box even if they are not set in the database yet
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -106,7 +106,12 @@
107107 wfProfileOut( $fname );
108108 $wgOut->setRobotpolicy( 'noindex,nofollow' );
109109
110 - $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
 110+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 111+ $ret = wfMsgWeirdKey ( $this->mTitle->getText() ) ;
 112+ } else {
 113+ $ret = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
 114+ }
 115+
111116 return "<div class='noarticletext'>$ret</div>";
112117 } else {
113118 $this->loadContent( $noredir );
@@ -376,7 +381,7 @@
377382 $redirect = ($redirect == 'no') ? 'no' : 'yes';
378383 $t .= ',redirect='.$redirect;
379384 }
380 - $this->mContent = wfMsg( 'missingarticle', $t );
 385+ $this->mContent = wfMsg( 'missingarticle', $t ) ;
381386
382387 if( $oldid ) {
383388 $revision = Revision::newFromId( $oldid );
@@ -2431,7 +2436,11 @@
24322437 # first, see if the page exists at all.
24332438 $exists = $page->getArticleId() != 0;
24342439 if( !$exists ) {
2435 - $wgOut->addHTML( wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) );
 2440+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 2441+ $wgOut->addHTML(wfMsgWeirdKey ( $this->mTitle->getText() ) );
 2442+ } else {
 2443+ $wgOut->addHTML(wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' ) );
 2444+ }
24362445 } else {
24372446 $dbr =& $this->getDB( DB_SLAVE );
24382447 $wl_clause = array(
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -381,6 +381,25 @@
382382 }
383383
384384 /**
 385+ * This function provides the message source for messages to be edited which are *not* stored in the database
 386+*/
 387+
 388+function wfMsgWeirdKey ( $key ) {
 389+ $subsource = str_replace ( ' ' , '_' , $key ) ;
 390+ $source = wfMsg ( $subsource ) ;
 391+ if ( $source == "&lt;{$subsource}&gt;" ) {
 392+ # Try again with first char lower case
 393+ $subsource = strtolower ( substr ( $subsource , 0 , 1 ) ) . substr ( $subsource , 1 ) ;
 394+ $source = wfMsg ( $subsource ) ;
 395+ }
 396+ if ( $source == "&lt;{$subsource}&gt;" ) {
 397+ # Didn't work either, return blank text
 398+ $source = "" ;
 399+ }
 400+ return $source ;
 401+}
 402+
 403+/**
385404 * Fetch a message string value, but don't replace any keys yet.
386405 * @param string $key
387406 * @param bool $useDB
Index: trunk/phase3/includes/EditPage.php
@@ -653,6 +653,8 @@
654654 $this->edittime = $this->mArticle->getTimestamp();
655655 $this->textbox1 = $this->mArticle->getContent( true );
656656 $this->summary = '';
 657+ if ( !$this->mArticle->exists() && $this->mArticle->mTitle->getNamespace() == NS_MEDIAWIKI )
 658+ $this->textbox1 = wfMsgWeirdKey ( $this->mArticle->mTitle->getText() ) ;
657659 wfProxyCheck();
658660 }
659661
Index: trunk/phase3/includes/OutputPage.php
@@ -748,7 +748,12 @@
749749
750750 if( is_string( $source ) ) {
751751 if( strcmp( $source, '' ) == 0 ) {
752 - $source = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
 752+ global $wgTitle ;
 753+ if ( $wgTitle->getNamespace() == NS_MEDIAWIKI ) {
 754+ $source = wfMsgWeirdKey ( $wgTitle->getText() ) ;
 755+ } else {
 756+ $source = wfMsg( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon' );
 757+ }
753758 }
754759 $rows = $wgUser->getOption( 'rows' );
755760 $cols = $wgUser->getOption( 'cols' );

Status & tagging log