r99263 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99262‎ | r99263 | r99264 >
Date:21:32, 7 October 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Reduced a little code duplication
Modified paths:
  • /trunk/extensions/Translate/TranslateUtils.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialMessageGroupStats.php (modified) (history)
  • /trunk/extensions/Translate/specials/SpecialTranslate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/specials/SpecialTranslate.php
@@ -195,7 +195,7 @@
196196
197197 // These are used, in the $$g black magic below. Do not remove!
198198 $task = $this->taskSelector();
199 - $group = $this->groupSelector();
 199+ $group = TranslateUtils::groupSelector( $this->group )->getHTML();
200200 $language = $this->languageSelector();
201201 $limit = $this->limitSelector();
202202
@@ -242,20 +242,6 @@
243243
244244 /* Selectors ahead */
245245
246 - protected function groupSelector() {
247 - $groups = MessageGroups::getAllGroups();
248 - $selector = new XmlSelect( 'group', 'group' );
249 - $selector->setDefault( $this->options['group'] );
250 -
251 - foreach ( $groups as $id => $class ) {
252 - if ( MessageGroups::getGroup( $id )->exists() ) {
253 - $selector->addOption( $class->getLabel(), $id );
254 - }
255 - }
256 -
257 - return $selector->getHTML();
258 - }
259 -
260246 protected function taskSelector( $pageTranslation = false ) {
261247 $selector = new XmlSelect( 'task', 'task' );
262248 $selector->setDefault( $this->options['task'] );
Index: trunk/extensions/Translate/specials/SpecialMessageGroupStats.php
@@ -52,20 +52,6 @@
5353 return '';
5454 }
5555
56 - /// @todo duplicated code
57 - protected function groupSelector( $default ) {
58 - $groups = MessageGroups::getAllGroups();
59 - $selector = new XmlSelect( 'group', 'group', $default );
60 -
61 - foreach ( $groups as $id => $class ) {
62 - if ( MessageGroups::getGroup( $id )->exists() ) {
63 - $selector->addOption( $class->getLabel(), $id );
64 - }
65 - }
66 -
67 - return $selector->getHTML();
68 - }
69 -
7056 /// Overwriten from SpecialLanguageStats
7157 function getform() {
7258 global $wgScript;
@@ -83,7 +69,7 @@
8470 $out .= Xml::label( wfMsg( 'translate-mgs-group' ), 'group' );
8571 $out .= Html::closeElement( 'td' );
8672 $out .= Html::openElement( 'td', array( 'class' => 'mw-input' ) );
87 - $out .= $this->groupSelector( $this->target );
 73+ $out .= TranslateUtils::groupSelector( $this->target )->getHTML();
8874 $out .= Html::closeElement( 'td' );
8975 $out .= Html::closeElement( 'tr' );
9076
Index: trunk/extensions/Translate/TranslateUtils.php
@@ -218,9 +218,6 @@
219219 return $selector->getHTML();
220220 }
221221
222 - /// \array Cached message index.
223 - static $mi = null;
224 -
225222 /**
226223 * Returns the primary group message belongs to.
227224 * @param $namespace \int
@@ -321,4 +318,17 @@
322319 return "$dir/$filename";
323320 }
324321
 322+ public static function groupSelector( $default = false ) {
 323+ $groups = MessageGroups::getAllGroups();
 324+ $selector = new XmlSelect( 'group', 'group', $default );
 325+
 326+ foreach ( $groups as $id => $class ) {
 327+ if ( MessageGroups::getGroup( $id )->exists() ) {
 328+ $selector->addOption( $class->getLabel(), $id );
 329+ }
 330+ }
 331+
 332+ return $selector;
 333+ }
 334+
325335 }

Status & tagging log