r90897 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90896‎ | r90897 | r90898 >
Date:18:39, 27 June 2011
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
follow-up to r83746 - move static method into DB class
Modified paths:
  • /trunk/extensions/CentralNotice/CentralNotice.db.php (modified) (history)
  • /trunk/extensions/CentralNotice/CentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialBannerLoader.php (modified) (history)
  • /trunk/extensions/CentralNotice/SpecialNoticeTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/CentralNotice.db.php
@@ -171,6 +171,22 @@
172172 }
173173
174174 /*
 175+ * See if a given banner exists in the database
 176+ */
 177+ public static function bannerExists( $bannerName ) {
 178+ global $wgCentralDBname;
 179+ $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
 180+
 181+ $eBannerName = htmlspecialchars( $bannerName );
 182+ $row = $dbr->selectRow( 'cn_templates', 'tmp_name', array( 'tmp_name' => $eBannerName ) );
 183+ if ( $row ) {
 184+ return true;
 185+ } else {
 186+ return false;
 187+ }
 188+ }
 189+
 190+ /*
175191 * Return all of the available countries for geotargeting
176192 * (This should probably be moved to a core database table at some point.)
177193 */
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
@@ -960,18 +960,5 @@
961961 $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", $message );
962962 $this->centralNoticeError = true;
963963 }
964 -
965 - public static function templateExists( $templateName ) {
966 - global $wgCentralDBname;
967 - $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
968964
969 - $eTemplateName = htmlspecialchars( $templateName );
970 - $row = $dbr->selectRow( 'cn_templates', 'tmp_name',
971 - array( 'tmp_name' => $eTemplateName ) );
972 - if ( $row ) {
973 - return true;
974 - } else {
975 - return false;
976 - }
977 - }
978965 }
Index: trunk/extensions/CentralNotice/CentralNotice.php
@@ -109,13 +109,13 @@
110110 $wgAutoloadClasses['CentralNotice'] = $dir . 'SpecialCentralNotice.php';
111111 $wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php';
112112 $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php';
113 - $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 'SpecialNoticeTemplate.php';
114113
115114 if ( $wgNoticeInfrastructure ) {
116115 $wgSpecialPages['CentralNotice'] = 'CentralNotice';
117116 $wgSpecialPageGroups['CentralNotice'] = 'wiki'; // Wiki data and tools"
118117
119118 $wgSpecialPages['NoticeTemplate'] = 'SpecialNoticeTemplate';
 119+ $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 'SpecialNoticeTemplate.php';
120120
121121 $wgSpecialPages['BannerAllocation'] = 'SpecialBannerAllocation';
122122 $wgAutoloadClasses['SpecialBannerAllocation'] = $dir . 'SpecialBannerAllocation.php';
Index: trunk/extensions/CentralNotice/SpecialBannerLoader.php
@@ -64,7 +64,7 @@
6565 */
6666 function getJsNotice( $bannerName ) {
6767 // Make sure the banner exists
68 - if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) {
 68+ if ( CentralNoticeDB::bannerExists( $bannerName ) ) {
6969 $this->bannerName = $bannerName;
7070 $bannerHtml = '';
7171 $bannerHtml .= preg_replace_callback(
@@ -90,7 +90,7 @@
9191 */
9292 function getHtmlNotice( $bannerName ) {
9393 // Make sure the banner exists
94 - if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) {
 94+ if ( CentralNoticeDB::bannerExists( $bannerName ) ) {
9595 $this->bannerName = $bannerName;
9696 $bannerHtml = '';
9797 $bannerHtml .= preg_replace_callback(

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83746Load SpecialNoticeTemplate class also on non-infrastructure wikis....saper03:29, 12 March 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   18:48, 27 June 2011

Looks good!

Status & tagging log