r89279 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89278‎ | r89279 | r89280 >
Date:19:04, 1 June 2011
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
better function names
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
@@ -59,12 +59,12 @@
6060 $templates = array();
6161
6262 // 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 );
 63+ $notices = CentralNoticeDB::getCampaigns( $this->project, $this->language, null, 1, 1, $this->location );
6464
6565 // Quick short circuit to show preferred campaigns
6666 if ( $notices ) {
6767 // Pull banners
68 - $templates = CentralNoticeDB::selectTemplatesAssigned( $notices );
 68+ $templates = CentralNoticeDB::selectBannersAssigned( $notices );
6969 }
7070
7171 // Didn't find any preferred banners so do an old style lookup
Index: trunk/extensions/CentralNotice/SpecialCentralNotice.php
@@ -75,7 +75,7 @@
7676 $lockedNotices = $wgRequest->getArray( 'locked' );
7777 if ( $lockedNotices ) {
7878 // Build list of campaigns to lock
79 - $unlockedNotices = array_diff( $this->getNoticesName(), $lockedNotices );
 79+ $unlockedNotices = array_diff( $this->getAllCampaignNames(), $lockedNotices );
8080
8181 // Set locked/unlocked flag accordingly
8282 foreach ( $lockedNotices as $notice ) {
@@ -86,7 +86,7 @@
8787 }
8888 // Handle updates if no post content came through (all checkboxes unchecked)
8989 } elseif ( $method !== 'addNotice' ) {
90 - $allNotices = $this->getNoticesName();
 90+ $allNotices = $this->getAllCampaignNames();
9191 foreach ( $allNotices as $notice ) {
9292 $this->updateLock( $notice, '0' );
9393 }
@@ -96,7 +96,7 @@
9797 $enabledNotices = $wgRequest->getArray( 'enabled' );
9898 if ( $enabledNotices ) {
9999 // Build list of campaigns to disable
100 - $disabledNotices = array_diff( $this->getNoticesName(), $enabledNotices );
 100+ $disabledNotices = array_diff( $this->getAllCampaignNames(), $enabledNotices );
101101
102102 // Set enabled/disabled flag accordingly
103103 foreach ( $enabledNotices as $notice ) {
@@ -107,7 +107,7 @@
108108 }
109109 // Handle updates if no post content came through (all checkboxes unchecked)
110110 } elseif ( $method !== 'addNotice' ) {
111 - $allNotices = $this->getNoticesName();
 111+ $allNotices = $this->getAllCampaignNames();
112112 foreach ( $allNotices as $notice ) {
113113 $this->updateEnabled( $notice, '0' );
114114 }
@@ -117,7 +117,7 @@
118118 $preferredNotices = $wgRequest->getArray( 'preferred' );
119119 if ( $preferredNotices ) {
120120 // Build list of campaigns to unset
121 - $unsetNotices = array_diff( $this->getNoticesName(), $preferredNotices );
 121+ $unsetNotices = array_diff( $this->getAllCampaignNames(), $preferredNotices );
122122
123123 // Set flag accordingly
124124 foreach ( $preferredNotices as $notice ) {
@@ -128,7 +128,7 @@
129129 }
130130 // Handle updates if no post content came through (all checkboxes unchecked)
131131 } elseif ( $method !== 'addNotice' ) {
132 - $allNotices = $this->getNoticesName();
 132+ $allNotices = $this->getAllCampaignNames();
133133 foreach ( $allNotices as $notice ) {
134134 $this->updatePreferred( $notice, '0' );
135135 }
@@ -198,7 +198,7 @@
199199 * Get all the campaigns in the database
200200 * @return an array of campaign names
201201 */
202 - function getNoticesName() {
 202+ function getAllCampaignNames() {
203203 $dbr = wfGetDB( DB_SLAVE );
204204 $res = $dbr->select( 'cn_notices', 'not_name', null, __METHOD__ );
205205 $notices = array();
@@ -1144,7 +1144,7 @@
11451145 $templates = array();
11461146 if ( $campaigns ) {
11471147 // Pull all banners assigned to the campaigns
1148 - $templates = CentralNoticeDB::selectTemplatesAssigned( $campaigns );
 1148+ $templates = CentralNoticeDB::selectBannersAssigned( $campaigns );
11491149 }
11501150 return $templates;
11511151 }
Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -12,7 +12,7 @@
1313 * Return campaigns in the system within given constraints
1414 * By default returns enabled campaigns, if $enabled set to false, returns both enabled and disabled campaigns
1515 */
16 - static function getNotices( $project = false, $language = false, $date = false, $enabled = true, $preferred = false, $location = false ) {
 16+ static function getCampaigns( $project = false, $language = false, $date = false, $enabled = true, $preferred = false, $location = false ) {
1717 global $wgCentralDBname;
1818
1919 $notices = array();
@@ -121,7 +121,7 @@
122122 /*
123123 * Given one or more campaign ids, return all banners bound to them
124124 */
125 - static function selectTemplatesAssigned( $campaigns ) {
 125+ static function selectBannersAssigned( $campaigns ) {
126126 global $wgCentralDBname;
127127
128128 $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );

Comments

#Comment by Brion VIBBER (talk | contribs)   17:49, 27 June 2011

Updates to modern terminology to make maintenance easier for the fundraising & devs :D

Status & tagging log