jenkins-bot has submitted this change and it was merged.

Change subject: Move NewsletterTablePager class to own file
......................................................................


Move NewsletterTablePager class to own file

Change-Id: I57bad95009583bd910a740827883ad678f6bc3c5
---
M extension.json
A includes/NewsletterTablePager.php
M includes/SpecialNewsletters.php
3 files changed, 109 insertions(+), 108 deletions(-)

Approvals:
  01tonythomas: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 96fb84f..0bc8d59 100644
--- a/extension.json
+++ b/extension.json
@@ -32,7 +32,7 @@
                "SpecialNewsletterManage": 
"includes/SpecialNewsletterManage.php",
                "SpecialNewsletters": "includes/SpecialNewsletters.php",
                "EchoNewsletterFormatter": 
"includes/EchoNewsletterFormatter.php",
-               "NewsletterTablePager": "includes/SpecialNewsletters.php",
+               "NewsletterTablePager": "includes/NewsletterTablePager.php",
                "ApiNewsletter": "includes/ApiNewsletter.php",
                "ApiNewsletterManage": "includes/ApiNewsletterManage.php",
                "NewsletterManageTable": "includes/NewsletterManageTable.php"
diff --git a/includes/NewsletterTablePager.php 
b/includes/NewsletterTablePager.php
new file mode 100644
index 0000000..6dd10ed
--- /dev/null
+++ b/includes/NewsletterTablePager.php
@@ -0,0 +1,108 @@
+<?php
+
+class NewsletterTablePager extends TablePager {
+
+       public function getFieldNames() {
+               static $headers = null;
+               if ( is_null( $headers ) ) {
+                       $headers = array();
+                       foreach ( SpecialNewsletters::$fields as $field => 
$property ) {
+                               $headers[$field] = $this->msg( 
"newsletter-header-$property" )->text();
+                       }
+               }
+
+               return $headers;
+       }
+
+       public function getQueryInfo() {
+               $info = array(
+                       'tables' => array( 'nl_newsletters' ),
+                       'fields' => array(
+                               'nl_name',
+                               'nl_desc',
+                               'nl_id',
+                       ),
+               );
+
+               return $info;
+       }
+
+       public function formatValue( $field, $value ) {
+               switch ( $field ) {
+                       case 'nl_name':
+                               $dbr = wfGetDB( DB_SLAVE );
+                               $res = $dbr->select(
+                                       'nl_newsletters',
+                                       array( 'nl_main_page_id' ),
+                                       array( 'nl_name' => $value ),
+                                       __METHOD__
+                               );
+
+                               $mainPageId = '';
+                               foreach ( $res as $row ) {
+                                       $mainPageId = $row->nl_main_page_id;
+                               }
+
+                               $url = $mainPageId ? Title::newFromID( 
$mainPageId )->getFullURL() : "#";
+
+                               return '<a href="' . $url . '">' . $value . 
'</a>';
+                       case 'nl_desc':
+                               return $value;
+                       case 'subscriber_count':
+                               return HTML::element(
+                                       'input',
+                                       array(
+                                               'type' => 'textbox',
+                                               'readonly' => 'true',
+                                               'id' => 'newsletter-' . 
$this->mCurrentRow->nl_id,
+                                               'value' => in_array(
+                                                       
$this->mCurrentRow->nl_id,
+                                                       
SpecialNewsletters::$allSubscribedNewsletterId
+                                               ) ?
+                                                       
SpecialNewsletters::$subscriberCount[$this->mCurrentRow->nl_id] : 0,
+
+                                       )
+                               );
+                       case 'action' :
+                               $radioSubscribe = Html::element(
+                                               'input',
+                                               array(
+                                                       'type' => 'radio',
+                                                       'name' => 'nl_id-' . 
$this->mCurrentRow->nl_id,
+                                                       'value' => 'subscribe',
+                                                       'checked' => in_array(
+                                                               
$this->mCurrentRow->nl_id,
+                                                               
SpecialNewsletters::$subscribedNewsletterId
+                                                       ) ? true : false,
+                                               )
+                                       ) . $this->msg( 
'newsletter-subscribe-button-label' );
+                               $radioUnSubscribe = Html::element(
+                                               'input',
+                                               array(
+                                                       'type' => 'radio',
+                                                       'name' => 'nl_id-' . 
$this->mCurrentRow->nl_id,
+                                                       'value' => 
'unsubscribe',
+                                                       'checked' => in_array(
+                                                               
$this->mCurrentRow->nl_id,
+                                                               
SpecialNewsletters::$subscribedNewsletterId
+                                                       ) ? false : true,
+                                               )
+                                       ) . $this->msg( 
'newsletter-unsubscribe-button-label' );
+
+                               return $radioSubscribe . $radioUnSubscribe;
+               }
+       }
+
+       public function endQuery( $value ) {
+               $this->getOutput()->addWikiMsg( 
'newsletter-create-confirmation' );
+       }
+
+       public function getDefaultSort() {
+               return 'nl_name';
+       }
+
+       public function isFieldSortable( $field ) {
+               return false;
+       }
+
+}
diff --git a/includes/SpecialNewsletters.php b/includes/SpecialNewsletters.php
index 28c8f7f..36fbdcd 100644
--- a/includes/SpecialNewsletters.php
+++ b/includes/SpecialNewsletters.php
@@ -73,110 +73,3 @@
                }
        }
 }
-
-class NewsletterTablePager extends TablePager {
-
-       public function getFieldNames() {
-               static $headers = null;
-               if ( is_null( $headers ) ) {
-                       $headers = array();
-                       foreach ( SpecialNewsletters::$fields as $field => 
$property ) {
-                               $headers[$field] = $this->msg( 
"newsletter-header-$property" )->text();
-                       }
-               }
-
-               return $headers;
-       }
-
-       public function getQueryInfo() {
-               $info = array(
-                       'tables' => array( 'nl_newsletters' ),
-                       'fields' => array(
-                               'nl_name',
-                               'nl_desc',
-                               'nl_id',
-                       ),
-               );
-
-               return $info;
-       }
-
-       public function formatValue( $field, $value ) {
-               switch ( $field ) {
-                       case 'nl_name':
-                               $dbr = wfGetDB( DB_SLAVE );
-                               $res = $dbr->select(
-                                       'nl_newsletters',
-                                       array( 'nl_main_page_id' ),
-                                       array( 'nl_name' => $value ),
-                                       __METHOD__
-                               );
-
-                               $mainPageId = '';
-                               foreach ( $res as $row ) {
-                                       $mainPageId = $row->nl_main_page_id;
-                               }
-
-                               $url = $mainPageId ? Title::newFromID( 
$mainPageId )->getFullURL() : "#";
-
-                               return '<a href="' . $url . '">' . $value . 
'</a>';
-                       case 'nl_desc':
-                               return $value;
-                       case 'subscriber_count':
-                               return HTML::element(
-                                       'input',
-                                       array(
-                                               'type' => 'textbox',
-                                               'readonly' => 'true',
-                                               'id' => 'newsletter-' . 
$this->mCurrentRow->nl_id,
-                                               'value' => in_array(
-                                                       
$this->mCurrentRow->nl_id,
-                                                       
SpecialNewsletters::$allSubscribedNewsletterId
-                                               ) ?
-                                                       
SpecialNewsletters::$subscriberCount[$this->mCurrentRow->nl_id] : 0,
-
-                                       )
-                               );
-                       case 'action' :
-                               $radioSubscribe = Html::element(
-                                               'input',
-                                               array(
-                                                       'type' => 'radio',
-                                                       'name' => 'nl_id-' . 
$this->mCurrentRow->nl_id,
-                                                       'value' => 'subscribe',
-                                                       'checked' => in_array(
-                                                               
$this->mCurrentRow->nl_id,
-                                                               
SpecialNewsletters::$subscribedNewsletterId
-                                                       ) ? true : false,
-                                               )
-                                       ) . $this->msg( 
'newsletter-subscribe-button-label' );
-                               $radioUnSubscribe = Html::element(
-                                               'input',
-                                               array(
-                                                       'type' => 'radio',
-                                                       'name' => 'nl_id-' . 
$this->mCurrentRow->nl_id,
-                                                       'value' => 
'unsubscribe',
-                                                       'checked' => in_array(
-                                                               
$this->mCurrentRow->nl_id,
-                                                               
SpecialNewsletters::$subscribedNewsletterId
-                                                       ) ? false : true,
-                                               )
-                                       ) . $this->msg( 
'newsletter-unsubscribe-button-label' );
-
-                               return $radioSubscribe . $radioUnSubscribe;
-               }
-       }
-
-       public function endQuery( $value ) {
-               $this->getOutput()->addWikiMsg( 
'newsletter-create-confirmation' );
-       }
-
-       public function getDefaultSort() {
-               return 'nl_name';
-       }
-
-       public function isFieldSortable( $field ) {
-               return false;
-       }
-
-}

-- 
To view, visit https://gerrit.wikimedia.org/r/234122
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I57bad95009583bd910a740827883ad678f6bc3c5
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Newsletter
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: 01tonythomas <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to