From cd488ce9530031035be8b410c27a5bea84707dfe Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Wed, 6 Jun 2007 09:51:38 +0000 Subject: [PATCH] Show result of Special:Booksources in wiki content language always, it's normally better maintained than the generic list from the standard message files --- RELEASE-NOTES | 3 +++ includes/SpecialBooksources.php | 29 +++++++++++++++++++---------- languages/messages/MessagesDe.php | 1 + languages/messages/MessagesEn.php | 1 + maintenance/language/messages.inc | 1 + 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ca20d16817..3acf0f8851 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -61,6 +61,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 9886) Provide clear example "stub link" in Special:Preferences * (bug 10055) Populate email address and real name properties of User objects passed to the 'AbortNewAccount' hook +* Show result of Special:Booksources in wiki content language always, it's + normally better maintained than the generic list from the standard message + files == Bugfixes since 1.10 == diff --git a/includes/SpecialBooksources.php b/includes/SpecialBooksources.php index 1903a8a5dc..3538289124 100644 --- a/includes/SpecialBooksources.php +++ b/includes/SpecialBooksources.php @@ -14,14 +14,14 @@ class SpecialBookSources extends SpecialPage { * ISBN passed to the page, if any */ private $isbn = ''; - + /** * Constructor */ public function __construct() { parent::__construct( 'Booksources' ); } - + /** * Show the special page * @@ -31,12 +31,13 @@ class SpecialBookSources extends SpecialPage { global $wgOut, $wgRequest; $this->setHeaders(); $this->isbn = $this->cleanIsbn( $isbn ? $isbn : $wgRequest->getText( 'isbn' ) ); + $this->lang = htmlspecialchars( $wgRequest->getText( 'uselang' ) ); $wgOut->addWikiText( wfMsgNoTrans( 'booksources-summary' ) ); $wgOut->addHtml( $this->makeForm() ); if( strlen( $this->isbn ) > 0 ) $this->showList(); } - + /** * Trim ISBN and remove characters which aren't required * @@ -46,7 +47,7 @@ class SpecialBookSources extends SpecialPage { private function cleanIsbn( $isbn ) { return trim( preg_replace( '![^0-9X]!', '', $isbn ) ); } - + /** * Generate a form to allow users to enter an ISBN * @@ -64,7 +65,7 @@ class SpecialBookSources extends SpecialPage { $form .= ''; return $form; } - + /** * Determine where to get the list of book sources from, * format and output them @@ -72,20 +73,28 @@ class SpecialBookSources extends SpecialPage { * @return string */ private function showList() { - global $wgOut, $wgContLang; - + global $wgOut, $wgContLang, $wgUser, $wgContLanguageCode; + $this->userLanguage = $wgUser->getOption( 'language', $wgContLanguageCode ); + # Hook to allow extensions to insert additional HTML, # e.g. for API-interacting plugins and so on wfRunHooks( 'BookInformation', array( $this->isbn, &$wgOut ) ); - + # Check for a local page such as Project:Book_sources and use that if available - $title = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'booksources' ) ); # Should this be wfMsgForContent()? -- RC + if ( $this->lang == '' || $this->lang == $wgContLanguageCode ) { + $title = Title::makeTitleSafe( NS_PROJECT, wfMsgForContent( 'booksources' ) ); # Show list in content language + } else { + $title = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'booksources' ) ); # Show list in user language + } if( is_object( $title ) && $title->exists() ) { $rev = Revision::newFromTitle( $title ); + if ( $this->userLanguage != $wgContLanguageCode && $this->lang == '' ) { + $wgOut->addWikiText( '' . wfMsgHtml( 'booksources-language', $this->isbn, $this->userLanguage ) . '' ); + } $wgOut->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) ); return true; } - + # Fall back to the defaults given in the language file $wgOut->addWikiText( wfMsgNoTrans( 'booksources-text' ) ); $wgOut->addHtml( '