http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90897

Revision: 90897
Author:   kaldari
Date:     2011-06-27 18:39:28 +0000 (Mon, 27 Jun 2011)
Log Message:
-----------
follow-up to r83746 - move static method into DB class

Modified Paths:
--------------
    trunk/extensions/CentralNotice/CentralNotice.db.php
    trunk/extensions/CentralNotice/CentralNotice.php
    trunk/extensions/CentralNotice/SpecialBannerLoader.php
    trunk/extensions/CentralNotice/SpecialNoticeTemplate.php

Modified: trunk/extensions/CentralNotice/CentralNotice.db.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.db.php 2011-06-27 18:34:56 UTC 
(rev 90896)
+++ trunk/extensions/CentralNotice/CentralNotice.db.php 2011-06-27 18:39:28 UTC 
(rev 90897)
@@ -171,6 +171,22 @@
        }
        
        /*
+        * See if a given banner exists in the database
+        */
+       public static function bannerExists( $bannerName ) {
+                global $wgCentralDBname;
+                $dbr = wfGetDB( DB_SLAVE, array(), $wgCentralDBname );
+
+                $eBannerName = htmlspecialchars( $bannerName );
+                $row = $dbr->selectRow( 'cn_templates', 'tmp_name', array( 
'tmp_name' => $eBannerName ) );
+                if ( $row ) {
+                       return true;
+                } else {
+                       return false;
+                }
+       }
+       
+       /*
         * Return all of the available countries for geotargeting
         * (This should probably be moved to a core database table at some 
point.)
         */

Modified: trunk/extensions/CentralNotice/CentralNotice.php
===================================================================
--- trunk/extensions/CentralNotice/CentralNotice.php    2011-06-27 18:34:56 UTC 
(rev 90896)
+++ trunk/extensions/CentralNotice/CentralNotice.php    2011-06-27 18:39:28 UTC 
(rev 90897)
@@ -109,13 +109,13 @@
        $wgAutoloadClasses['CentralNotice'] = $dir . 'SpecialCentralNotice.php';
        $wgAutoloadClasses['CentralNoticeDB'] = $dir . 'CentralNotice.db.php';
        $wgAutoloadClasses['TemplatePager'] = $dir . 'TemplatePager.php';
-       $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 
'SpecialNoticeTemplate.php';
 
        if ( $wgNoticeInfrastructure ) {
                $wgSpecialPages['CentralNotice'] = 'CentralNotice';
                $wgSpecialPageGroups['CentralNotice'] = 'wiki'; // Wiki data 
and tools"
 
                $wgSpecialPages['NoticeTemplate'] = 'SpecialNoticeTemplate';
+               $wgAutoloadClasses['SpecialNoticeTemplate'] = $dir . 
'SpecialNoticeTemplate.php';
 
                $wgSpecialPages['BannerAllocation'] = 'SpecialBannerAllocation';
                $wgAutoloadClasses['SpecialBannerAllocation'] = $dir . 
'SpecialBannerAllocation.php';

Modified: trunk/extensions/CentralNotice/SpecialBannerLoader.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialBannerLoader.php      2011-06-27 
18:34:56 UTC (rev 90896)
+++ trunk/extensions/CentralNotice/SpecialBannerLoader.php      2011-06-27 
18:39:28 UTC (rev 90897)
@@ -64,7 +64,7 @@
         */
        function getJsNotice( $bannerName ) {
                // Make sure the banner exists
-               if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) {
+               if ( CentralNoticeDB::bannerExists( $bannerName ) ) {
                        $this->bannerName = $bannerName;
                        $bannerHtml = '';
                        $bannerHtml .= preg_replace_callback(
@@ -90,7 +90,7 @@
         */
        function getHtmlNotice( $bannerName ) {
                // Make sure the banner exists
-               if ( SpecialNoticeTemplate::templateExists( $bannerName ) ) {
+               if ( CentralNoticeDB::bannerExists( $bannerName ) ) {
                        $this->bannerName = $bannerName;
                        $bannerHtml = '';
                        $bannerHtml .= preg_replace_callback(

Modified: trunk/extensions/CentralNotice/SpecialNoticeTemplate.php
===================================================================
--- trunk/extensions/CentralNotice/SpecialNoticeTemplate.php    2011-06-27 
18:34:56 UTC (rev 90896)
+++ trunk/extensions/CentralNotice/SpecialNoticeTemplate.php    2011-06-27 
18:39:28 UTC (rev 90897)
@@ -960,18 +960,5 @@
                $wgOut->wrapWikiMsg( "<div class='cn-error'>\n$1\n</div>", 
$message );
                $this->centralNoticeError = true;
        }
-       
-       public static function templateExists( $templateName ) {
-                global $wgCentralDBname;
-                $dbr = wfGetDB( DB_SLAVE,  array(), $wgCentralDBname );
 
-                $eTemplateName = htmlspecialchars( $templateName );
-                $row = $dbr->selectRow( 'cn_templates', 'tmp_name', 
-                        array( 'tmp_name' => $eTemplateName ) );
-                if ( $row ) {
-                       return true;
-                } else {
-                       return false;
-                }
-       }
 }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to