Index: trunk/extensions/CentralNotice/CentralNotice.db.php |
— | — | @@ -171,6 +171,22 @@ |
172 | 172 | } |
173 | 173 | |
174 | 174 | /* |
| 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 | + /* |
175 | 191 | * Return all of the available countries for geotargeting |
176 | 192 | * (This should probably be moved to a core database table at some point.) |
177 | 193 | */ |
Index: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php |
— | — | @@ -960,18 +960,5 @@ |
961 | 961 | $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", $message ); |
962 | 962 | $this->centralNoticeError = true; |
963 | 963 | } |
964 | | - |
965 | | - public static function templateExists( $templateName ) { |
966 | | - global $wgCentralDBname; |
967 | | - $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname ); |
968 | 964 | |
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 | | - } |
978 | 965 | } |
Index: trunk/extensions/CentralNotice/CentralNotice.php |
— | — | @@ -109,13 +109,13 @@ |
110 | 110 | $wgAutoloadClasses['CentralNotice'] = $dir . 'SpecialCentralNotice.php'; |
111 | 111 | $wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php'; |
112 | 112 | $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php'; |
113 | | - $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 'SpecialNoticeTemplate.php'; |
114 | 113 | |
115 | 114 | if ( $wgNoticeInfrastructure ) { |
116 | 115 | $wgSpecialPages['CentralNotice'] = 'CentralNotice'; |
117 | 116 | $wgSpecialPageGroups['CentralNotice'] = 'wiki'; // Wiki data and tools" |
118 | 117 | |
119 | 118 | $wgSpecialPages['NoticeTemplate'] = 'SpecialNoticeTemplate'; |
| 119 | + $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 'SpecialNoticeTemplate.php'; |
120 | 120 | |
121 | 121 | $wgSpecialPages['BannerAllocation'] = 'SpecialBannerAllocation'; |
122 | 122 | $wgAutoloadClasses['SpecialBannerAllocation'] = $dir . 'SpecialBannerAllocation.php'; |
Index: trunk/extensions/CentralNotice/SpecialBannerLoader.php |
— | — | @@ -64,7 +64,7 @@ |
65 | 65 | */ |
66 | 66 | function getJsNotice( $bannerName ) { |
67 | 67 | // Make sure the banner exists |
68 | | - if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) { |
| 68 | + if ( CentralNoticeDB::bannerExists( $bannerName ) ) { |
69 | 69 | $this->bannerName = $bannerName; |
70 | 70 | $bannerHtml = ''; |
71 | 71 | $bannerHtml .= preg_replace_callback( |
— | — | @@ -90,7 +90,7 @@ |
91 | 91 | */ |
92 | 92 | function getHtmlNotice( $bannerName ) { |
93 | 93 | // Make sure the banner exists |
94 | | - if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) { |
| 94 | + if ( CentralNoticeDB::bannerExists( $bannerName ) ) { |
95 | 95 | $this->bannerName = $bannerName; |
96 | 96 | $bannerHtml = ''; |
97 | 97 | $bannerHtml .= preg_replace_callback( |