r110738 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110737‎ | r110738 | r110739 >
Date:11:00, 6 February 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Translate/MessageGroups.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/resources/ext.translate.css (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/specials/SpecialLanguageStats.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/specials/SpecialMessageGroupStats.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Translate/MessageGroups.php
@@ -1186,6 +1186,11 @@
11871187 public static function getGroup( $id ) {
11881188 // BC with page| which is now page-
11891189 $id = strtr( $id, '|', '-' );
 1190+ /* Translatable pages use spaces, but MW occasionally likes to
 1191+ * normalize spaces to underscores */
 1192+ if ( strpos( $id, 'page-' ) === 0 ) {
 1193+ $id = strtr( $id, '_', ' ' );
 1194+ }
11901195 self::init();
11911196
11921197 global $wgTranslateEC, $wgTranslateAC, $wgTranslateCC;
Index: branches/wmf/1.18wmf1/extensions/Translate/tag/PageTranslationHooks.php
@@ -226,10 +226,12 @@
227227 $_title = Title::makeTitle( $title->getNamespace(), $title->getDBkey() . $suffix );
228228
229229 if ( $parser->getTitle()->getText() === $_title->getText() ) {
230 - $languages[] = Html::rawElement( 'b', null, "*$name* $percent" );
231 - } elseif ( $code === $userLangCode ) {
232 - $languages[] = $linker->linkKnown( $_title, Html::rawElement( 'b', null, "$name $percent" ) );
 230+ $name = Html::rawElement( 'span', array( 'class' => 'mw-pt-languages-selected' ), $name );
 231+ $languages[] = "$name $percent";
233232 } else {
 233+ if ( $code === $userLangCode ) {
 234+ $name = Html::rawElement( 'span', array( 'class' => 'mw-pt-languages-ui' ), $name );
 235+ }
234236 $languages[] = $linker->linkKnown( $_title, "$name $percent" );
235237 }
236238 }
@@ -438,7 +440,7 @@
439441
440442 $legend = Html::rawElement(
441443 'div',
442 - array( 'style' => 'font-size: x-small; text-align: center;' ),
 444+ array( 'class' => 'mw-pt-translate-header' ),
443445 $wgLang->semicolonList( $actions )
444446 ) . Html::element( 'hr' );
445447
Index: branches/wmf/1.18wmf1/extensions/Translate/specials/SpecialMessageGroupStats.php
@@ -36,9 +36,12 @@
3737 }
3838
3939 /// Overwritten from SpecialLanguageStats
40 - protected function getAllowedValues() {
41 - $groups = MessageGroups::getAllGroups();
42 - return array_keys( $groups );
 40+ protected function isValidValue( $value ) {
 41+ $group = MessageGroups::getGroup( $value );
 42+ if ( $group ) {
 43+ $this->target = $group->getId();
 44+ }
 45+ return (bool) $group;
4346 }
4447
4548 /// Overwritten from SpecialLanguageStats
Index: branches/wmf/1.18wmf1/extensions/Translate/specials/SpecialLanguageStats.php
@@ -5,7 +5,7 @@
66 * @file
77 * @author Siebrand Mazeland
88 * @author Niklas Laxström
9 - * @copyright Copyright © 2008-2011 Siebrand Mazeland, Niklas Laxström
 9+ * @copyright Copyright © 2008-2012 Siebrand Mazeland, Niklas Laxström
1010 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1111 */
1212
@@ -109,23 +109,20 @@
110110 $this->noEmpty = (bool)$params[2];
111111 }
112112
113 - // Whether the form has been submitted
114 - $submitted = $request->getVal( 'x' ) === 'D';
 113+ // Whether the form has been submitted, only relevant if not including
 114+ $submitted = !$this->including() && $request->getVal( 'x' ) === 'D';
115115
116116 // Default booleans to false if the form was submitted
117 - if ( !$this->including() ) {
118 - $this->target = $request->getVal( $this->targetValueName, $this->target );
119 - $this->noComplete = $request->getBool( 'suppresscomplete', $this->noComplete && !$submitted );
120 - $this->noEmpty = $request->getBool( 'suppressempty', $this->noEmpty && !$submitted );
121 - }
 117+ $this->target = $request->getVal( $this->targetValueName, $this->target );
 118+ $this->noComplete = $request->getBool( 'suppresscomplete', $this->noComplete && !$submitted );
 119+ $this->noEmpty = $request->getBool( 'suppressempty', $this->noEmpty && !$submitted );
122120
123121 if ( !$this->including() ) {
124122 TranslateUtils::addSpecialHelpLink( $wgOut, 'Help:Extension:Translate/Statistics_and_reporting' );
125123 $wgOut->addHTML( $this->getForm() );
126124 }
127125
128 - $allowedValues = $this->getAllowedValues();
129 - if ( in_array( $this->target, $allowedValues, true ) ) {
 126+ if ( $this->isValidValue( $this->target ) ) {
130127 $this->outputIntroduction();
131128 $output = $this->getTable();
132129 if ( $this->incomplete ) {
@@ -145,9 +142,9 @@
146143 * Return the list of allowed values for target here.
147144 * @return array
148145 */
149 - protected function getAllowedValues() {
 146+ protected function isValidValue( $value ) {
150147 $langs = Language::getLanguageNames( false );
151 - return array_keys( $langs );
 148+ return isset( $langs[$value] );
152149 }
153150
154151 /// Called when the target is unknown.
Index: branches/wmf/1.18wmf1/extensions/Translate/resources/ext.translate.css
@@ -27,3 +27,17 @@
2828 .mw-pt-languages-list {
2929 padding: 0.5em;
3030 }
 31+
 32+.mw-pt-translate-header {
 33+ font-size: x-small;
 34+ text-align: center;
 35+}
 36+
 37+/* The *stars* should be replaceable with bunnies */
 38+.mw-pt-languages-selected:before, .mw-pt-languages-selected:after {
 39+ content: '*';
 40+}
 41+
 42+.mw-pt-languages-selected, .mw-pt-languages-ui {
 43+ font-weight: bold;
 44+}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110309A bit ugly fix to allow Special:Translate/page-Foo_bar syntax for translatabl...nikerabbit17:45, 30 January 2012
r110364[Bug 34028] Special:MessageGroupStats does not work for group IDs with spacesnikerabbit07:54, 31 January 2012
r110408Use class which allows customizing stylingnikerabbit17:01, 31 January 2012
r110471Allow syntax like {{Special:MessageGroupStats|group=page-Main/sub|suppresscom...nikerabbit10:15, 1 February 2012
r110475Bug 34113: handle presentation in CSS as it should benikerabbit12:32, 1 February 2012

Status & tagging log