r62278 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62277‎ | r62278 | r62279 >
Date:23:05, 10 February 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Use MessageWebImporter::makeSectionElement only, and remove it from ManageGroups and SpecialPageTranslation classes
Modified paths:
  • /trunk/extensions/Translate/SpecialManageGroups.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)
  • /trunk/extensions/Translate/utils/MessageWebImporter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialManageGroups.php
@@ -87,17 +87,6 @@
8888 }
8989 }
9090
91 - protected function makeSectionElement( $legend, $type, $content ) {
92 - $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" );
93 - $legendParams = array( 'class' => 'mw-translate-manage-legend' );
94 - $contentParams = array( 'class' => 'mw-tpt-sp-content' );
95 -
96 - return Xml::tags( 'div', $containerParams,
97 - Xml::tags( 'div', $legendParams, $legend ) .
98 - Xml::tags( 'div', $contentParams, $content )
99 - );
100 - }
101 -
10291 public function getTitle() {
10392 return SpecialPage::getTitleFor( 'Translate', 'manage' );
10493 }
@@ -166,7 +155,7 @@
167156
168157 $text = TranslateUtils::convertWhiteSpaceToHTML( $value );
169158
170 - $changed[] = $this->makeSectionElement( $name, 'new', $text );
 159+ $changed[] = MessageWebImporter::makeSectionElement( $name, 'new', $text );
171160 } else {
172161 if ( $fuzzy ) {
173162 $old = TRANSLATE_FUZZY . $old;
@@ -241,7 +230,7 @@
242231 implode( ' ', $act )
243232 );
244233
245 - $changed[] = $this->makeSectionElement( $name, $type, $text );
 234+ $changed[] = MessageWebImporter::makeSectionElement( $name, $type, $text );
246235 }
247236 }
248237
@@ -258,7 +247,7 @@
259248
260249 $text = TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() );
261250
262 - $changed[] = $this->makeSectionElement( $name, 'deleted', $text );
 251+ $changed[] = MessageWebImporter::makeSectionElement( $name, 'deleted', $text );
263252 }
264253 }
265254
Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -4,9 +4,11 @@
55 * There are two modes 1) list of all pages 2) review mode for one page.
66 *
77 * @author Niklas Laxström
8 - * @copyright Copyright © 2009 Niklas Laxström
 8+ * @author Siebrand Mazeland
 9+ * @copyright Copyright © 2009-2010 Niklas Laxström, Siebrand Mazeland
910 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
1011 */
 12+
1113 class SpecialPageTranslation extends SpecialPage {
1214 function __construct() {
1315 SpecialPage::SpecialPage( 'PageTranslation' );
@@ -284,7 +286,17 @@
285287 $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() );
286288 }
287289
288 - $this->makeSectionElement( $name, $s->type, $text );
 290+ $type = $s->type;
 291+ $wgOut->addHTML( MessageWebImporter::makeSectionElement(
 292+ $name,
 293+ $type,
 294+ $text,
 295+ array(
 296+ 'container' => 'mw-tpt-sp-section mw-tpt-sp-section-type-{$type}',
 297+ 'legend' => 'mw-tpt-sp-legend',
 298+ 'content' => 'mw-tpt-sp-content'
 299+ )
 300+ ) );
289301 }
290302
291303 $deletedSections = $page->getParse()->getDeletedSections();
@@ -292,8 +304,18 @@
293305 $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-deleted' );
294306 foreach ( $deletedSections as $s ) {
295307 $name = wfMsgHtml( 'tpt-section-deleted', htmlspecialchars( $s->id ) );
 308+ $type = $s->type;
296309 $text = TranslateUtils::convertWhiteSpaceToHTML( $s->getText() );
297 - $this->makeSectionElement( $name, $s->type, $text );
 310+ $wgOut->addHTML( MessageWebImporter::makeSectionElement(
 311+ $name,
 312+ $type,
 313+ $text,
 314+ array(
 315+ 'container' => 'mw-tpt-sp-section mw-tpt-sp-section-type-{$type}',
 316+ 'legend' => 'mw-tpt-sp-legend',
 317+ 'content' => 'mw-tpt-sp-content'
 318+ )
 319+ ) );
298320 }
299321 }
300322
@@ -324,21 +346,6 @@
325347 );
326348 }
327349
328 - protected function makeSectionElement( $legend, $type, $content ) {
329 - global $wgOut;
330 -
331 - $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" );
332 - $legendParams = array( 'class' => 'mw-tpt-sp-legend' );
333 - $contentParams = array( 'class' => 'mw-tpt-sp-content' );
334 -
335 - $wgOut->addHTML(
336 - Xml::tags( 'div', $containerParams,
337 - Xml::tags( 'div', $legendParams, $legend ) .
338 - Xml::tags( 'div', $contentParams, $content )
339 - )
340 - );
341 - }
342 -
343350 /**
344351 * This function does the heavy duty of marking a page.
345352 * - Updates the source page with section markers.
Index: trunk/extensions/Translate/utils/MessageWebImporter.php
@@ -153,7 +153,7 @@
154154 '<code style="font-weight:normal;">' . htmlspecialchars( $key ) . '</code>'
155155 );
156156 $text = TranslateUtils::convertWhiteSpaceToHTML( $value );
157 - $changed[] = $this->makeSectionElement( $name, 'new', $text );
 157+ $changed[] = self::makeSectionElement( $name, 'new', $text );
158158 } else {
159159 $diff->setText( $old, $value );
160160 $text = $diff->getDiff( '', '' );
@@ -219,7 +219,7 @@
220220 implode( ' ', $act )
221221 );
222222
223 - $changed[] = $this->makeSectionElement( $name, $type, $text );
 223+ $changed[] = self::makeSectionElement( $name, $type, $text );
224224 }
225225 }
226226
@@ -234,7 +234,7 @@
235235 '<code style="font-weight:normal;">' . htmlspecialchars( $s ) . '</code>'
236236 );
237237 $text = TranslateUtils::convertWhiteSpaceToHTML( $collection[$s]->translation() );
238 - $changed[] = $this->makeSectionElement( $name, 'deleted', $text );
 238+ $changed[] = self::makeSectionElement( $name, 'deleted', $text );
239239 }
240240 }
241241
@@ -417,14 +417,38 @@
418418 return Title::makeTitleSafe( $ns, $titlekey );
419419 }
420420
421 - protected function makeSectionElement( $legend, $type, $content ) {
422 - $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" );
423 - $legendParams = array( 'class' => 'mw-translate-manage-legend' );
424 - $contentParams = array( 'class' => 'mw-tpt-sp-content' );
 421+ /**
 422+ * Make section elements
 423+ *
 424+ * @param $legend String: contents of legend
 425+ * @param $type String: contents of type class
 426+ * @param $content String: contents of content class
 427+ * @param $params Array: array of key-value pairs to override the standard class names
 428+ *
 429+ * @return section element
 430+ */
 431+ public static function makeSectionElement( $legend, $type, $content, $params = array() ) {
 432+ if( isset( $params['container'] ) {
 433+ $containerParams = array( 'class' => $params['container'] );
 434+ } else {
 435+ $containerParams = array( 'class' => "mw-tpt-sp-section mw-tpt-sp-section-type-{$type}" );
 436+ }
425437
426 - return Xml::tags( 'div', $containerParams,
427 - Xml::tags( 'div', $legendParams, $legend ) .
428 - Xml::tags( 'div', $contentParams, $content )
 438+ if( isset( $params['legend'] ) {
 439+ $legendParams = array( 'class' => $params['legend'] );
 440+ } else {
 441+ $legendParams = array( 'class' => 'mw-translate-manage-legend' );
 442+ }
 443+
 444+ if( isset( $params['content'] ) {
 445+ $contentParams = array( 'class' => $params['content'] );
 446+ } else {
 447+ $contentParams = array( 'class' => 'mw-tpt-sp-content' );
 448+ }
 449+
 450+ return Xml::tags(
 451+ 'div', $containerParams,
 452+ Xml::tags( 'div', $legendParams, $legend ) . Xml::tags( 'div', $contentParams, $content )
429453 );
430454 }
431455

Follow-up revisions

RevisionCommit summaryAuthorDate
r62279* fix syntax errors in MessageWebImporter.php from r62278...siebrand23:10, 10 February 2010

Status & tagging log