r22793 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22792‎ | r22793 | r22794 >
Date:09:51, 6 June 2007
Author:raymond
Status:old
Tags:
Comment:
Show result of Special:Booksources in wiki content language always,
it's normally better maintained than the generic list from the standard message files
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialBooksources.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesDe.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1003,6 +1003,7 @@
10041004 'booksources-isbn',
10051005 'booksources-go',
10061006 'booksources-text',
 1007+ 'booksources-language',
10071008 ),
10081009 'specialpages2' => array(
10091010 'categoriespagetext',
Index: trunk/phase3/includes/SpecialBooksources.php
@@ -14,14 +14,14 @@
1515 * ISBN passed to the page, if any
1616 */
1717 private $isbn = '';
18 -
 18+
1919 /**
2020 * Constructor
2121 */
2222 public function __construct() {
2323 parent::__construct( 'Booksources' );
2424 }
25 -
 25+
2626 /**
2727 * Show the special page
2828 *
@@ -31,12 +31,13 @@
3232 global $wgOut, $wgRequest;
3333 $this->setHeaders();
3434 $this->isbn = $this->cleanIsbn( $isbn ? $isbn : $wgRequest->getText( 'isbn' ) );
 35+ $this->lang = htmlspecialchars( $wgRequest->getText( 'uselang' ) );
3536 $wgOut->addWikiText( wfMsgNoTrans( 'booksources-summary' ) );
3637 $wgOut->addHtml( $this->makeForm() );
3738 if( strlen( $this->isbn ) > 0 )
3839 $this->showList();
3940 }
40 -
 41+
4142 /**
4243 * Trim ISBN and remove characters which aren't required
4344 *
@@ -46,7 +47,7 @@
4748 private function cleanIsbn( $isbn ) {
4849 return trim( preg_replace( '![^0-9X]!', '', $isbn ) );
4950 }
50 -
 51+
5152 /**
5253 * Generate a form to allow users to enter an ISBN
5354 *
@@ -64,7 +65,7 @@
6566 $form .= '</fieldset>';
6667 return $form;
6768 }
68 -
 69+
6970 /**
7071 * Determine where to get the list of book sources from,
7172 * format and output them
@@ -72,20 +73,28 @@
7374 * @return string
7475 */
7576 private function showList() {
76 - global $wgOut, $wgContLang;
77 -
 77+ global $wgOut, $wgContLang, $wgUser, $wgContLanguageCode;
 78+ $this->userLanguage = $wgUser->getOption( 'language', $wgContLanguageCode );
 79+
7880 # Hook to allow extensions to insert additional HTML,
7981 # e.g. for API-interacting plugins and so on
8082 wfRunHooks( 'BookInformation', array( $this->isbn, &$wgOut ) );
81 -
 83+
8284 # Check for a local page such as Project:Book_sources and use that if available
83 - $title = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'booksources' ) ); # Should this be wfMsgForContent()? -- RC
 85+ if ( $this->lang == '' || $this->lang == $wgContLanguageCode ) {
 86+ $title = Title::makeTitleSafe( NS_PROJECT, wfMsgForContent( 'booksources' ) ); # Show list in content language
 87+ } else {
 88+ $title = Title::makeTitleSafe( NS_PROJECT, wfMsg( 'booksources' ) ); # Show list in user language
 89+ }
8490 if( is_object( $title ) && $title->exists() ) {
8591 $rev = Revision::newFromTitle( $title );
 92+ if ( $this->userLanguage != $wgContLanguageCode && $this->lang == '' ) {
 93+ $wgOut->addWikiText( '<span class="plainlinks">' . wfMsgHtml( 'booksources-language', $this->isbn, $this->userLanguage ) . '</span>' );
 94+ }
8695 $wgOut->addWikiText( str_replace( 'MAGICNUMBER', $this->isbn, $rev->getText() ) );
8796 return true;
8897 }
89 -
 98+
9099 # Fall back to the defaults given in the language file
91100 $wgOut->addWikiText( wfMsgNoTrans( 'booksources-text' ) );
92101 $wgOut->addHtml( '<ul>' );
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1608,6 +1608,7 @@
16091609 'booksources-go' => 'Go',
16101610 'booksources-text' => 'Below is a list of links to other sites that sell new and used books, and may also have
16111611 further information about books you are looking for:',
 1612+'booksources-language' => "''The following list is written in the content language of this wiki. [{{fullurl:{{FULLPAGENAMEE}}|isbn=$1&uselang=$2}} A translations into your user language] contains normally a shortened list only.''",
16121613
16131614 'categoriespagetext' => 'The following categories exist in the wiki.',
16141615 'data' => 'Data',
Index: trunk/phase3/languages/messages/MessagesDe.php
@@ -1239,6 +1239,7 @@
12401240 'booksources-isbn' => 'ISBN:',
12411241 'booksources-go' => 'Suche',
12421242 'booksources-text' => 'Dies ist eine Liste mit Links zu Internetseiten, die neue und gebrauchte Bücher verkaufen. Dort kann es auch weitere Informationen über die Bücher geben. {{SITENAME}} ist mit keinem dieser Anbieter geschäftlich verbunden.',
 1243+'booksources-language' => "''Die nachfolgende Liste wird in der Sprache des Wikis ausgegeben. [{{fullurl:{{FULLPAGENAMEE}}|isbn=$1&uselang=$2}} Eine Liste in Ihrer Benutzersprache] enthält in der Regel nur wenige Einträge.''",
12431244
12441245 'categoriespagetext' => 'Die folgenden Kategorien existieren in {{SITENAME}}:',
12451246 'data' => 'Daten',
Index: trunk/phase3/RELEASE-NOTES
@@ -61,6 +61,9 @@
6262 * (bug 9886) Provide clear example "stub link" in Special:Preferences
6363 * (bug 10055) Populate email address and real name properties of User objects
6464 passed to the 'AbortNewAccount' hook
 65+* Show result of Special:Booksources in wiki content language always, it's
 66+ normally better maintained than the generic list from the standard message
 67+ files
6568
6669 == Bugfixes since 1.10 ==
6770

Follow-up revisions

RevisionCommit summaryAuthorDate
r22796Per talk with River on IRC:...raymond11:42, 6 June 2007
r22811Merged revisions 22791-22810 via svnmerge from...david07:26, 7 June 2007

Status & tagging log