r65878 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65877‎ | r65878 | r65879 >
Date:21:08, 3 May 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Use Xml class more, and use <strong> instead of <big>
Modified paths:
  • /trunk/extensions/Translate/SpecialImportTranslations.php (modified) (history)
  • /trunk/extensions/Translate/SpecialLanguageStats.php (modified) (history)
  • /trunk/extensions/Translate/SpecialMagic.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialLanguageStats.php
@@ -64,56 +64,43 @@
6565 $out .= Xml::openElement( 'fieldset' );
6666 $out .= Xml::element( 'legend', null, wfMsg( 'translate-language-code' ) );
6767 $out .= Xml::openElement( 'table', array( 'id' => 'langcodeselect', 'class' => 'allpages' ) );
68 - $out .= "<tr>
69 - <td class='mw-label'>" .
70 - Xml::label( wfMsg( 'translate-language-code-field-name' ), 'code' ) .
71 - "</td>
72 - <td class='mw-input'>" .
73 - Xml::input( 'code', 30, str_replace( '_', ' ', $code ), array( 'id' => 'code' ) ) .
74 - "</td></tr><tr><td colspan='2'>" .
75 - Xml::checkLabel( wfMsg( 'translate-suppress-complete' ), 'suppresscomplete', 'suppresscomplete', $suppressComplete ) .
76 - "</td>" .
77 - "</tr>" .
78 - "<tr>" .
79 - "<td class='mw-input'>" .
80 - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
81 - "</td>
82 - </tr>";
 68+
 69+ $out .= Xml::openElement( 'tr' );
 70+ $out .= Xml::openElement( 'td', array( 'class' => 'mw-label' ) );
 71+ $out .= Xml::label( wfMsg( 'translate-language-code-field-name' ), 'code' );
 72+ $out .= Xml::closeElement( 'td' );
 73+ $out .= Xml::openElement( 'td', array( 'class' => 'mw-input' ) );
 74+ $out .= Xml::input( 'code', 30, str_replace( '_', ' ', $code ), array( 'id' => 'code' ) );
 75+ $out .= Xml::closeElement( 'td' );
 76+ $out .= Xml::closeElement( 'tr' );
 77+
 78+ $out .= Xml::openElement( 'tr' );
 79+ $out .= Xml::openElement( 'td', array( 'colspan' => 2 ) );
 80+ $out .= Xml::checkLabel( wfMsg( 'translate-suppress-complete' ), 'suppresscomplete', 'suppresscomplete', $suppressComplete );
 81+ $out .= Xml::closeElement( 'td' );
 82+ $out .= Xml::closeElement( 'tr' );
 83+
 84+ $out .= Xml::openElement( 'tr' );
 85+ $out .= Xml::openElement( 'td', array( 'class' => 'mw-input' ) );
 86+ $out .= Xml::submitButton( wfMsg( 'allpagessubmit' ) );
 87+ $out .= Xml::closeElement( 'td' );
 88+ $out .= Xml::closeElement( 'tr' );
 89+
8390 $out .= Xml::closeElement( 'table' );
8491 $out .= Xml::closeElement( 'fieldset' );
8592 $out .= Xml::closeElement( 'form' );
8693 $out .= Xml::closeElement( 'div' );
 94+
8795 return $out;
8896 }
8997
90 - # Statistics table heading
91 - function heading() {
92 - return '<table class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;" width="100%">' . "\n";
93 - }
9498
95 - # Statistics table footer
96 - function footer() {
97 - return "</table>\n";
98 - }
99 -
100 - # Statistics table row start
101 - function blockstart() {
102 - return "\t<tr>\n";
103 - }
104 -
105 - # Statistics table row end
106 - function blockend() {
107 - return "\t</tr>\n";
108 - }
109 -
11099 # Statistics table element (heading or regular cell)
111 - function element( $in, $heading = false, $bgcolor = '' ) {
112 - if ( $heading ) {
113 - $element = '<th>' . $in . '</th>';
114 - } else if ( $bgcolor ) {
115 - $element = '<td bgcolor="#' . $bgcolor . '">' . $in . '</td>';
 100+ function element( $in, $bgcolor = '' ) {
 101+ if ( $bgcolor ) {
 102+ $element = Xml::element( 'td', array( 'bgcolor' => "#" . $bgcolor ), $in );
116103 } else {
117 - $element = '<td>' . $in . '</td>';
 104+ $element = Xml::element( 'td', null, $in );
118105 }
119106 return "\t\t" . $element . "\n";
120107 }
@@ -159,14 +146,21 @@
160147 $out = wfMsgExt( 'languagestats-stats-for', array( 'parse', 'replaceafter' ), $languageName, $rcInLangLink );
161148
162149 # Create table header
163 - $out .= $this->heading();
164 - $out .= $this->blockstart();
165 - $out .= $this->element( wfMsg( 'translate-page-group' ), true );
166 - $out .= $this->element( wfMsg( 'translate-total' ), true );
167 - $out .= $this->element( wfMsg( 'translate-untranslated' ), true );
168 - $out .= $this->element( wfMsg( 'translate-percentage-complete' ), true );
169 - $out .= $this->element( wfMsg( 'translate-percentage-fuzzy' ), true );
170 - $out .= $this->blockend();
 150+ $out .= Xml::openElement( 'table', array(
 151+ 'class' => "sortable wikitable",
 152+ 'border' => '2',
 153+ 'cellpadding' => '4',
 154+ 'cellspacing' => '0',
 155+ 'style' => "background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;",
 156+ 'width' => "100%"
 157+ );
 158+ $out .= Xml::openElement( 'tr' );
 159+ $out .= Xml::element( 'th', null, wfMsg( 'translate-page-group' ) );
 160+ $out .= Xml::element( 'th' null, wfMsg( 'translate-total' ) );
 161+ $out .= Xml::element( 'th', null, wfMsg( 'translate-untranslated' ) );
 162+ $out .= Xml::element( 'th', null, wfMsg( 'translate-percentage-complete' ) );
 163+ $out .= Xml::element( 'th', null, wfMsg( 'translate-percentage-fuzzy' ) );
 164+ $out .= Xml::closeElement( 'tr' );
171165
172166 return $out;
173167 }
@@ -248,7 +242,7 @@
249243
250244 // Bold for meta groups
251245 if( $g->isMeta() ) {
252 - $groupLabel = "<b>" . $groupLabel . "</b>";
 246+ $groupLabel = Xml::element( 'b', null, $groupLabel );
253247 }
254248
255249 $translateGroupLink = $wgUser->getSkin()->link(
@@ -260,18 +254,18 @@
261255 $queryParameters
262256 );
263257
264 - $out .= $this->blockstart();
265 - $out .= $this->element( $translateGroupLink );
266 - $out .= $this->element( $total );
267 - $out .= $this->element( $total - $translated );
268 - $out .= $this->element( $translatedPercentage, false, $translatedPercentage == $errorString ? '' : $this->getBackgroundColour( $translated, $total ) );
269 - $out .= $this->element( $fuzzyPercentage, false, $translatedPercentage == $errorString ? '' : $this->getBackgroundColour( $fuzzy, $total, true ) );
270 - $out .= $this->blockend();
 258+ $out .= Xml::openElement( 'tr' );
 259+ $out .= Xml::element( 'td', null, $translateGroupLink );
 260+ $out .= Xml::element( 'td', null, $total );
 261+ $out .= Xml::element( 'td', null, $total - $translated );
 262+ $out .= $this->element( $translatedPercentage, $translatedPercentage == $errorString ? '' : $this->getBackgroundColour( $translated, $total ) );
 263+ $out .= $this->element( $fuzzyPercentage, $translatedPercentage == $errorString ? '' : $this->getBackgroundColour( $fuzzy, $total, true ) );
 264+ $out .= Xml::closeElement( 'tr' );
271265 }
272266
273267 if ( $out ) {
274268 $out = $this->createHeader( $code ) . $out;
275 - $out .= $this->footer();
 269+ $out .= Xml::closeElement( 'table' );
276270 } else {
277271 $out = wfMsgExt( 'translate-nothing-to-do', 'parse' );
278272 }
Index: trunk/extensions/Translate/SpecialImportTranslations.php
@@ -119,7 +119,9 @@
120120 ) ) .
121121 Xml::hidden( 'token', $this->user->editToken() ) .
122122 Xml::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
123 - "\n<table><tr><td>\n"
 123+ Xml::openElement( 'table' ) .
 124+ Xml::openElement( 'tr' ) .
 125+ Xml::openElement( 'td' );
124126 );
125127
126128 $class = array( 'class' => 'mw-translate-import-inputs' );
@@ -128,11 +130,12 @@
129131 Xml::radioLabel( wfMsg( 'translate-import-from-url' ),
130132 'upload-type', 'url', 'mw-translate-up-url',
131133 $this->request->getText( 'upload-type' ) === 'url' ) .
132 - "\n</td><td>\n" .
 134+ "\n" . Xml::closeElement( 'td' ) . Xml::openElement( 'td' ) . "\n" .
133135 Xml::input( 'upload-url', 50,
134136 $this->request->getText( 'upload-url' ),
135137 array( 'id' => 'mw-translate-up-url-input' ) + $class ) .
136 - "\n</td></tr><tr><td>\n"
 138+ "\n" . . Xml::closeElement( 'td' ) . Xml::closeElement( 'tr' ) .
 139+ Xml::openElement( 'tr' ) . Xml::openElement( 'td' ) . "\n"
137140 );
138141 }
139142
@@ -140,19 +143,21 @@
141144 Xml::radioLabel( wfMsg( 'translate-import-from-wiki' ),
142145 'upload-type', 'wiki', 'mw-translate-up-wiki',
143146 $this->request->getText( 'upload-type' ) === 'wiki' ) .
144 - "\n</td><td>\n" .
 147+ "\n" . Xml::closeElement( 'td' ) . Xml::openElement( 'td' ) . "\n" .
145148 Xml::input( 'upload-wiki', 50,
146149 $this->request->getText( 'upload-wiki', 'File:' ),
147150 array( 'id' => 'mw-translate-up-wiki-input' ) + $class ) .
148 - "\n</td></tr><tr><td>\n" .
 151+ "\n" . . Xml::closeElement( 'td' ) . Xml::closeElement( 'tr' ) .
 152+ Xml::openElement( 'tr' ) . Xml::openElement( 'td' ) . "\n" .
149153 Xml::radioLabel( wfMsg( 'translate-import-from-local' ),
150154 'upload-type', 'local', 'mw-translate-up-local',
151155 $this->request->getText( 'upload-type' ) === 'local' ) .
152 - "\n</td><td>\n" .
 156+ "\n" . Xml::closeElement( 'td' ) . Xml::openElement( 'td' ) . "\n" .
153157 Xml::input( 'upload-local', 50,
154158 $this->request->getText( 'upload-local' ),
155159 array( 'type' => 'file', 'id' => 'mw-translate-up-local-input' ) + $class ) .
156 - "\n</td></tr></table>\n" .
 160+ "\n" . . Xml::closeElement( 'td' ) . Xml::closeElement( 'tr' ) .
 161+ Xml::closeElement( 'table' ) .
157162 Xml::submitButton( wfMsg( 'translate-import-load' ) ) .
158163 Xml::closeElement( 'form' )
159164 );
Index: trunk/extensions/Translate/SpecialMagic.php
@@ -157,7 +157,7 @@
158158 return;
159159 } else {
160160 $o->save( $wgRequest );
161 - $wgOut->wrapWikiMsg( '<big><b>$1</b></big>', 'translate-magic-saved' );
 161+ $wgOut->wrapWikiMsg( '<strong><b>$1</b></strong>', 'translate-magic-saved' );
162162 $wgOut->addHTML( $o->output() );
163163 return;
164164 }

Status & tagging log