r76361 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76360‎ | r76361 | r76362 >
Date:00:39, 9 November 2010
Author:kaldari
Status:ok
Tags:
Comment:
finishing work towards multi-project selection - bug 20229
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialBannerListLoader.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialCentralNotice.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialBannerListLoader.php
@@ -56,32 +56,18 @@
5757 * Generate JSON for the specified site
5858 */
5959 function getJsonList() {
60 -
61 - // Quick short circuit to be able to show preferred notices
6260 $templates = array();
63 -
64 - if ( $this->language == 'en' && $this->project != null ) {
65 - // See if we have any preferred notices for all of en
66 - $notices = CentralNoticeDB::getNotices( null, 'en', null, 1, 1, $this->location );
67 -
68 - if ( $notices ) {
69 - // Pull banners
70 - $templates = CentralNoticeDB::selectTemplatesAssigned( $notices );
71 - }
 61+
 62+ // See if we have any preferred campaigns for this language and project
 63+ $notices = CentralNoticeDB::getNotices( $this->project, $this->language, null, 1, 1, $this->location );
 64+
 65+ // Quick short circuit to show preferred campaigns
 66+ if ( $notices ) {
 67+ // Pull banners
 68+ $templates = CentralNoticeDB::selectTemplatesAssigned( $notices );
7269 }
7370
74 - if ( !$templates && $this->project == 'wikipedia' ) {
75 - // See if we have any preferred notices for this language wikipedia
76 - $notices = CentralNoticeDB::getNotices( 'wikipedia', $this->language,
77 - false, 1, 1, $this->location );
78 -
79 - if ( $notices ) {
80 - // Pull banners
81 - $templates = CentralNoticeDB::selectTemplatesAssigned( $notices );
82 - }
83 - }
84 -
85 - // Didn't find any preferred matches so do an old style lookup
 71+ // Didn't find any preferred banners so do an old style lookup
8672 if ( !$templates ) {
8773 $templates = CentralNotice::selectNoticeTemplates(
8874 $this->project, $this->language, $this->location );
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -1070,6 +1070,7 @@
10711071 $campaignResults1 = $dbr->select(
10721072 array(
10731073 'cn_notices',
 1074+ 'cn_notice_projects',
10741075 'cn_notice_languages'
10751076 ),
10761077 array(
@@ -1080,9 +1081,10 @@
10811082 "not_end >= $encTimestamp",
10821083 'not_enabled = 1', // enabled
10831084 'not_geo = 0', // not geotargeted
 1085+ 'np_notice_id = cn_notices.not_id',
 1086+ 'np_project' => $project,
10841087 'nl_notice_id = cn_notices.not_id',
1085 - 'nl_language' => $language,
1086 - 'not_project' => array( '', $project )
 1088+ 'nl_language' => $language
10871089 ),
10881090 __METHOD__
10891091 );
@@ -1100,6 +1102,7 @@
11011103 $campaignResults2 = $dbr->select(
11021104 array(
11031105 'cn_notices',
 1106+ 'cn_notice_projects',
11041107 'cn_notice_languages',
11051108 'cn_notice_countries'
11061109 ),
@@ -1113,9 +1116,10 @@
11141117 'not_geo = 1', // geotargeted
11151118 'nc_notice_id = cn_notices.not_id',
11161119 'nc_country' => $location,
 1120+ 'np_notice_id = cn_notices.not_id',
 1121+ 'np_project' => $project,
11171122 'nl_notice_id = cn_notices.not_id',
1118 - 'nl_language' => $language,
1119 - 'not_project' => array( '', $project )
 1123+ 'nl_language' => $language
11201124 ),
11211125 __METHOD__
11221126 );
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -27,17 +27,23 @@
2828 }
2929
3030 $tables = array( 'cn_notices' );
 31+ if ( $project ) {
 32+ $tables[] = 'cn_notice_projects';
 33+ }
3134 if ( $language ) {
3235 $tables[] = 'cn_notice_languages';
3336 }
3437
3538 $conds = array(
36 - 'not_project' => array( '', $project ),
3739 'not_geo' => 0,
3840 "not_start <= $encTimestamp",
3941 "not_end >= $encTimestamp",
4042 );
4143 // Use whatever conditional arguments got passed in
 44+ if ( $project ) {
 45+ $conds[] = 'np_notice_id = cn_notices.not_id';
 46+ $conds['np_project'] = $project;
 47+ }
4248 if ( $language ) {
4349 $conds[] = 'nl_notice_id = cn_notices.not_id';
4450 $conds['nl_language'] = $language;
@@ -65,19 +71,25 @@
6672 // If a location is passed, also pull geotargeted campaigns that match the location
6773 if ( $location ) {
6874 $tables = array( 'cn_notices', 'cn_notice_countries' );
 75+ if ( $project ) {
 76+ $tables[] = 'cn_notice_projects';
 77+ }
6978 if ( $language ) {
7079 $tables[] = 'cn_notice_languages';
7180 }
7281
7382 // Use whatever conditional arguments got passed in
7483 $conds = array(
75 - 'not_project' => array( '', $project ),
7684 'not_geo' => 1,
7785 'nc_notice_id = cn_notices.not_id',
7886 'nc_country' => $location,
7987 "not_start <= $encTimestamp",
8088 "not_end >= $encTimestamp",
8189 );
 90+ if ( $project ) {
 91+ $conds[] = 'np_notice_id = cn_notices.not_id';
 92+ $conds['np_project'] = $project;
 93+ }
8294 if ( $language ) {
8395 $conds[] = "nl_notice_id = cn_notices.not_id";
8496 $conds['nl_language'] = $language;

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
r76358more work towards multi-project selection - bug 20229kaldari00:08, 9 November 2010

Status & tagging log