r76358 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76357‎ | r76358 | r76359 >
Date:00:08, 9 November 2010
Author:kaldari
Status:resolved (Comments)
Tags:
Comment:
more work towards multi-project selection - bug 20229
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.i18n.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -20,6 +20,7 @@
2121 'commons',
2222 'meta',
2323 'wikispecies',
 24+ 'test'
2425 );
2526
2627 // Enable the notice-hosting infrastructure on this wiki...
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -285,7 +285,7 @@
286286 * Show all campaigns found in the database, show "Add a campaign" form
287287 */
288288 function listNotices() {
289 - global $wgOut, $wgUser, $wgLang, $wgRequest;
 289+ global $wgOut, $wgUser, $wgLang, $wgRequest, $wgNoticeProjects;
290290
291291 // Get connection
292292 $dbr = wfGetDB( DB_SLAVE );
@@ -362,8 +362,12 @@
363363 $projects = $this->getNoticeProjects( $row->not_name );
364364 $project_count = count( $projects );
365365 $projectList = '';
366 - if ( $project_count > 2 ) {
367 - $projectList = wfMsg ( 'centralnotice-multiple', $project_count );
 366+ if ( $project_count > 1 ) {
 367+ if ( $project_count == count( $wgNoticeProjects ) ) {
 368+ $projectList = wfMsg ( 'centralnotice-all-projects' );
 369+ } else {
 370+ $projectList = wfMsg ( 'centralnotice-multiple', $project_count );
 371+ }
368372 } elseif ( $project_count > 0 ) {
369373 $projectList = $wgLang->commaList( $projects );
370374 }
Index: trunk/extensions/CentralNotice/CentralNotice.i18n.php
@@ -34,7 +34,8 @@
3535 'centralnotice-add-template' => 'Add a banner',
3636 'centralnotice-show-notices' => 'Show campaigns',
3737 'centralnotice-list-templates' => 'List banners',
38 - 'centralnotice-multiple' => 'multiple ($1)',
 38+ 'centralnotice-multiple' => 'Multiple ($1)',
 39+ 'centralnotice-all-projects' => 'All projects',
3940 'centralnotice-language-listing' => '$1 - $2',
4041 'centralnotice-translations' => 'Translations',
4142 'centralnotice-translate-to' => 'Translate to',

Follow-up revisions

RevisionCommit summaryAuthorDate
r76361finishing work towards multi-project selection - bug 20229kaldari00:39, 9 November 2010
r76462updates to r76356 and r76358kaldari19:27, 10 November 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r68666updating mySQL set-up script for multi-language support (bug 20229), deleting...kaldari17:01, 28 June 2010
r76347work towards bug 20229kaldari23:02, 8 November 2010
r76351more work towards multi-project selection - bug 20229kaldari23:29, 8 November 2010
r76356more work towards multi-project selection - bug 20229kaldari23:57, 8 November 2010

Comments

#Comment by Catrope (talk | contribs)   14:32, 10 November 2010
-				if ( $project_count > 2 ) {
-					$projectList = wfMsg ( 'centralnotice-multiple', $project_count );
+				if ( $project_count > 1 ) {
+					if ( $project_count == count( $wgNoticeProjects ) ) {
+						$projectList = wfMsg ( 'centralnotice-all-projects' );
+					} else {
+						$projectList = wfMsg ( 'centralnotice-multiple', $project_count );
+					}
 				} elseif ( $project_count > 0 ) {
 					$projectList = $wgLang->commaList( $projects );

This means commaList() is only called in case there's exactly one project, not when there's two. Also, assuming that $project_count == count ( $wgNoticeProjects ) means that all projects were selected doesn't sound right to me: this could do weird things when projects are deleted from $wgNoticeProjects or when invalid projects are inserted (this is trivial because the submitted project array is never validated against $wgNoticeProjects, that should be fixed too).

#Comment by Kaldari (talk | contribs)   19:29, 10 November 2010

The commaList was in case I decided to change 2 to 3 at some point, but you're right that it isn't necessary. I've removed it and fixed the other issues in r76462.

Status & tagging log