Adamw has submitted this change and it was merged.
Change subject: Unifying BannerMessageGroup Code
......................................................................
Unifying BannerMessageGroup Code
Just a little bit of cleanup.
Change-Id: Ied40e3e5269ceffbb48c3d6a3b8ece411d478d7b
---
M CentralNotice.php
M includes/BannerMessageGroup.php
2 files changed, 48 insertions(+), 48 deletions(-)
Approvals:
Adamw: Verified; Looks good to me, approved
diff --git a/CentralNotice.php b/CentralNotice.php
index 00074c3..355048a 100644
--- a/CentralNotice.php
+++ b/CentralNotice.php
@@ -304,8 +304,8 @@
if ( $wgNoticeUseTranslateExtension ) {
$wgAutoloadClasses[ 'BannerMessageGroup' ] =
$includeDir . 'BannerMessageGroup.php';
- $wgHooks[ 'TranslatePostInitGroups' ][ ] =
'efRegisterMessageGroups';
- $wgHooks[ 'TranslateEventMessageGroupStateChange' ][] =
array( 'BannerMessageGroup::updateBannerGroupStateHook' );
+ $wgHooks[ 'TranslatePostInitGroups' ][ ] =
'BannerMessageGroup::registerGroupHook';
+ $wgHooks[ 'TranslateEventMessageGroupStateChange' ][] =
'BannerMessageGroup::updateBannerGroupStateHook';
}
$wgSpecialPages[ 'CentralNotice' ] = 'CentralNotice';
@@ -499,52 +499,6 @@
function efCentralNoticeUnitTests( &$files ) {
$files[ ] = __DIR__ . '/tests/ApiAllocationsTest.php';
$files[ ] = __DIR__ . '/tests/CentralNoticeTest.php';
- return true;
-}
-
-/**
- * TranslatePostInitGroups hook handler
- * Add banner message groups to the list of message groups that should be
- * translated through the Translate extension.
- *
- * @param array $list
- * @return bool
- */
-function efRegisterMessageGroups( &$list ) {
- global $wgCentralDBname;
- $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname );
-
- // Create the base aggregate group
- $conf = array();
- $conf['BASIC'] = array(
- 'id' => BannerMessageGroup::TRANSLATE_GROUP_NAME_BASE,
- 'label' => 'CentralNotice Banners',
- 'description' => '{{int:centralnotice-aggregate-group-desc}}',
- 'meta' => 1,
- 'class' => 'AggregateMessageGroup',
- 'namespace' => NS_CN_BANNER,
- );
- $conf['GROUPS'] = array();
-
- // Find all the banners marked for translation
- $tables = array( 'page', 'revtag' );
- $vars = array( 'page_id', 'page_namespace', 'page_title', );
- $conds = array( 'page_id=rt_page', 'rt_type' => RevTag::getType(
'banner:translate' ) );
- $options = array( 'GROUP BY' => 'rt_page' );
- $res = $dbr->select( $tables, $vars, $conds, __METHOD__, $options );
-
- foreach ( $res as $r ) {
- $grp = new BannerMessageGroup( $r->page_namespace,
$r->page_title );
- $id = $grp::getTranslateGroupName( $r->page_title );
- $list[$id] = $grp;
-
- // Add the banner group to the aggregate group
- $conf['GROUPS'][] = $id;
- }
-
- // Update the subgroup meta with any new groups since the last time
this was run
- $list[$conf['BASIC']['id']] = MessageGroupBase::factory( $conf );
-
return true;
}
diff --git a/includes/BannerMessageGroup.php b/includes/BannerMessageGroup.php
index 11aad67..374b7df 100644
--- a/includes/BannerMessageGroup.php
+++ b/includes/BannerMessageGroup.php
@@ -189,4 +189,50 @@
return new MessageGroupStates( $conf );
}
+
+ /**
+ * TranslatePostInitGroups hook handler
+ * Add banner message groups to the list of message groups that should
be
+ * translated through the Translate extension.
+ *
+ * @param array $list
+ * @return bool
+ */
+ public static function registerGroupHook( &$list ) {
+ global $wgCentralDBname;
+ $dbr = wfGetDB( DB_MASTER, array(), $wgCentralDBname );
+
+ // Create the base aggregate group
+ $conf = array();
+ $conf['BASIC'] = array(
+ 'id' => BannerMessageGroup::TRANSLATE_GROUP_NAME_BASE,
+ 'label' => 'CentralNotice Banners',
+ 'description' =>
'{{int:centralnotice-aggregate-group-desc}}',
+ 'meta' => 1,
+ 'class' => 'AggregateMessageGroup',
+ 'namespace' => NS_CN_BANNER,
+ );
+ $conf['GROUPS'] = array();
+
+ // Find all the banners marked for translation
+ $tables = array( 'page', 'revtag' );
+ $vars = array( 'page_id', 'page_namespace', 'page_title', );
+ $conds = array( 'page_id=rt_page', 'rt_type' =>
RevTag::getType( 'banner:translate' ) );
+ $options = array( 'GROUP BY' => 'rt_page' );
+ $res = $dbr->select( $tables, $vars, $conds, __METHOD__,
$options );
+
+ foreach ( $res as $r ) {
+ $grp = new BannerMessageGroup( $r->page_namespace,
$r->page_title );
+ $id = $grp::getTranslateGroupName( $r->page_title );
+ $list[$id] = $grp;
+
+ // Add the banner group to the aggregate group
+ $conf['GROUPS'][] = $id;
+ }
+
+ // Update the subgroup meta with any new groups since the last
time this was run
+ $list[$conf['BASIC']['id']] = MessageGroupBase::factory( $conf
);
+
+ return true;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/57657
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied40e3e5269ceffbb48c3d6a3b8ece411d478d7b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
Gerrit-Reviewer: Adamw <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits