http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72440
Revision: 72440
Author: nikerabbit
Date: 2010-09-05 14:53:40 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
Add optional aggregate group for all translatable pages
Modified Paths:
--------------
trunk/extensions/Translate/Groups.php
Added Paths:
-----------
trunk/extensions/Translate/groups/PageTranslationAgg.yaml
Modified: trunk/extensions/Translate/Groups.php
===================================================================
--- trunk/extensions/Translate/Groups.php 2010-09-05 14:50:28 UTC (rev
72439)
+++ trunk/extensions/Translate/Groups.php 2010-09-05 14:53:40 UTC (rev
72440)
@@ -455,9 +455,7 @@
class AggregateMessageGroup extends MessageGroupBase {
public function exists() {
- /**
- * Group exists if there are any subgroups.
- */
+ // Group exists if there are any subgroups.
$exists = (bool) $this->conf['GROUPS'];
if ( !$exists ) {
@@ -488,6 +486,7 @@
if ( !isset( $this->groups ) ) {
$groups = array();
$ids = (array) $this->conf['GROUPS'];
+ $ids = $this->expandWildcards( $ids );
foreach ( $ids as $id ) {
// Do not try to include self and go to
infinite loop.
@@ -507,6 +506,34 @@
return $this->groups;
}
+ /**
+ * If the list of group ids contains wildcards, this function will match
+ * them against the list of all supported groups and return matched
group
+ * names.
+ * @param $ids \list{String}
+ * @return \list{String}
+ */
+ protected function expandWildcards( $ids ) {
+ $hasWild = false;
+ foreach ( $ids as $id ) {
+ if ( strpos( $id, '*' ) !== false ) {
+ $hasWild = true;
+ break;
+ }
+ }
+
+ if ( !$hasWild ) return $ids;
+
+ $matcher = new StringMatcher( '', $ids );
+ $all = array();
+ foreach ( MessageGroups::singleton()->getGroups() as $id => $_
) {
+ if ( $matcher->match( $id ) ) {
+ $all[] = $id;
+ }
+ }
+ return $all;
+ }
+
public function initCollection( $code ) {
$messages = array();
foreach ( $this->getGroups() as $group ) {
Added: trunk/extensions/Translate/groups/PageTranslationAgg.yaml
===================================================================
--- trunk/extensions/Translate/groups/PageTranslationAgg.yaml
(rev 0)
+++ trunk/extensions/Translate/groups/PageTranslationAgg.yaml 2010-09-05
14:53:40 UTC (rev 72440)
@@ -0,0 +1,15 @@
+# Enable this group if you want to have aggregate group for all page
+# page translation groups. You can also add this configuration:
+# $wgTranslateGroupStructure['/^page/'] = array( 'page' );
+
+BASIC:
+ id: page-0-all
+ label: All translatable pages
+ display: page
+ meta: yes
+ class: AggregateMessageGroup
+ description: 'All translatable pages'
+ namespace: NS_TRANSLATIONS
+
+GROUPS:
+ - page|*
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs