r112699 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112698‎ | r112699 | r112700 >
Date:16:03, 29 February 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Cleanups to r112668
Modified paths:
  • /trunk/extensions/Translate/PageTranslation.i18n.php (modified) (history)
  • /trunk/extensions/Translate/tag/SpecialPageTranslation.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php
@@ -439,7 +439,7 @@
440440 * @param $sections array
441441 */
442442 public function showPage( TranslatablePage $page, Array $sections ) {
443 - global $wgOut, $wgContLang;
 443+ global $wgOut, $wgContLang, $wgLang;
444444
445445 $wgOut->setSubtitle( Linker::link( $page->getTitle() ) );
446446 $wgOut->addModules( 'ext.translate.special.pagetranslation' );
@@ -529,21 +529,7 @@
530530 }
531531 }
532532
533 - $priorityLangs = TranslateMetadata::get( $page->getMessageGroupId(), 'prioritylangs' );
534 - $priorityForce = TranslateMetadata::get( $page->getMessageGroupId(), 'priorityforce' );
535 - $priorityReason = TranslateMetadata::get( $page->getMessageGroupId(), 'priorityreason' );
536 - $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-prioritylangs' );
537 - $langSelector = Xml::languageSelector( $wgContLang-> getCode() );
538 - $priorityLangsInput = Html::element( 'input', array( 'id' => 'tpt-prioritylangs', 'size' => '50', 'name' => 'prioritylangs', 'value' => $priorityLangs , ) );
539 - if ( $priorityForce === 'on' ) {
540 - $forceLimit = Html::element( 'input', array( 'id' => 'tpt-priority-forcelimit', 'type' => 'checkbox', 'name' => 'forcelimit', 'checked' => 'checked' ) );
541 - } else {
542 - $forceLimit = Html::element( 'input', array( 'id' => 'tpt-priority-forcelimit', 'type' => 'checkbox', 'name' => 'forcelimit' ) );
543 - }
544 - $priorityReasonTextArea = Html::element( 'textarea', array( 'id' => 'tpt-priority-reason', 'name' => 'priorityreason' ), $priorityReason );
545 - $forceLimitLabel = Html::element( 'label', array( 'id' => 'tpt-priority-forcelimit-label', 'for' => 'tpt-priority-forcelimit' ), wfMsgHtml( 'tpt-select-prioritylangs-force' ) );
546 - $wgOut->addHTML( wfMsgHtml( 'tpt-select-prioritylangs' ) . $langSelector[1] . $priorityLangsInput );
547 - $wgOut->addHTML( '<br/>' . $forceLimit . $forceLimitLabel . '<br/>' . wfMsgHtml( 'tpt-select-prioritylangs-reason' ) . $priorityReasonTextArea . '<br/>' );
 533+ $this->priorityLanguagesForm( $page );
548534
549535 $wgOut->addHTML(
550536 Xml::submitButton( wfMsg( 'tpt-submit' ) ) .
@@ -551,6 +537,45 @@
552538 );
553539 }
554540
 541+ protected function priorityLanguagesForm( TranslatablePage $page ) {
 542+ global $wgOut, $wgContLang, $wgLang;
 543+ $groupId = $page->getMessageGroupId();
 544+ $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-prioritylangs' );
 545+
 546+ $langSelector = Xml::languageSelector( $wgContLang->getCode(), false, $wgLang->getCode() );
 547+
 548+ $hLangs = Xml::inputLabelSep(
 549+ wfMsg( 'tpt-select-prioritylangs' ),
 550+ 'prioritylangs', // name
 551+ 'tpt-prioritylangs', // id
 552+ 50,
 553+ TranslateMetadata::get( $groupId, 'prioritylangs' )
 554+ );
 555+
 556+ $hForce = Xml::checkLabel(
 557+ wfMsg( 'tpt-select-prioritylangs-force' ),
 558+ 'forcelimit', // name
 559+ 'tpt-priority-forcelimit', // id
 560+ TranslateMetadata::get( $groupId, 'priorityforce' ) === 'on'
 561+ );
 562+
 563+ $hReason = Xml::inputLabelSep(
 564+ wfMsg( 'tpt-select-prioritylangs-reason' ),
 565+ 'priorityreason', // name
 566+ 'tpt-priority-reason', // id
 567+ 50, // size
 568+ TranslateMetadata::get( $groupId, 'priorityreason' )
 569+ );
 570+
 571+ $wgOut->addHTML(
 572+ "<table>" .
 573+ "<tr><td class='mw-label'>$hLangs[0]</td><td class='mw-input'>$hLangs[1]$langSelector[1]</td></tr>" .
 574+ "<tr><td></td><td class='mw-inout'>$hForce</td></tr>" .
 575+ "<tr><td class='mw-label'>$hReason[0]</td><td class='mw-input'>$hReason[1]</td></tr>" .
 576+ "</table>"
 577+ );
 578+ }
 579+
555580 /**
556581 * This function does the heavy duty of marking a page.
557582 * - Updates the source page with section markers.
@@ -636,11 +661,6 @@
637662 $page->addMarkedTag( $newrevision, $changed );
638663 $this->addFuzzyTags( $page, $changed );
639664
640 - // Save the priority languages if any
641 - $priorityLangs = trim( $wgRequest->getVal( 'prioritylangs' ) );
642 - $priorityForce = $wgRequest->getVal( 'forcelimit' );
643 - $priorityReason = $wgRequest->getVal( 'priorityreason' );
644 -
645665 global $wgUser;
646666 $logger = new LogPage( 'pagetranslation' );
647667 $params = array(
@@ -649,17 +669,19 @@
650670 'changed' => count( $changed ),
651671 );
652672 $logger->addEntry( 'mark', $page->getTitle(), null, array( serialize( $params ) ) );
653 - if ( $priorityLangs ) {
 673+
 674+
 675+ // Save the priority languages if any
 676+ $priorityLangs = trim( $wgRequest->getVal( 'prioritylangs' ) );
 677+ $priorityForce = $wgRequest->getCheck( 'forcelimit' );
 678+ $priorityReason = $wgRequest->getVal( 'priorityreason' );
 679+ // FIXME: does not log removals
 680+ if ( $priorityLangs ) {
654681 $groupId = $page->getMessageGroupId();
 682+ // FIXME: does not normalise input to a,b,c,d
655683 TranslateMetadata::set( $groupId, 'prioritylangs', trim( $priorityLangs, ',' ) );
656 - if ( $priorityForce ) {
657 - TranslateMetadata::set( $groupId, 'priorityforce', $priorityForce );
658 - } else {
659 - TranslateMetadata::set( $groupId, 'priorityforce', 'off' );
660 - }
661 - if ( trim( $priorityReason ) ) {
662 - TranslateMetadata::set( $groupId, 'priorityreason', $priorityReason );
663 - }
 684+ TranslateMetadata::set( $groupId, 'priorityforce', $priorityForce ? 'on' : 'off' );
 685+ TranslateMetadata::set( $groupId, 'priorityreason', trim( $priorityReason ) );
664686 $params = array(
665687 'user' => $wgUser->getName(),
666688 'languages' => $priorityLangs,
Index: trunk/extensions/Translate/PageTranslation.i18n.php
@@ -64,11 +64,12 @@
6565 'tpt-other-pages' => '{{PLURAL:$1|An old version of this page is|Older versions of these pages are}} marked for translation,
6666 but the latest {{PLURAL:$1|version|versions}} cannot be marked for translation.',
6767 'tpt-discouraged-pages' => '{{PLURAL:$1|This page has|These pages have}} been discouraged from further translation.',
68 - 'tpt-select-prioritylangs' => 'Preferred languages (comma-separated language codes): ',
69 - 'tpt-select-prioritylangs-force' => 'Limit translation to these languages alone',
70 - 'tpt-select-prioritylangs-reason' => 'Reason for setting this set of preferred languages (optional): ',
71 - 'tpt-sections-prioritylangs' => 'Preferred Languages',
72 -
 68+
 69+ 'tpt-select-prioritylangs' => 'Comma separated list of language codes:',
 70+ 'tpt-select-prioritylangs-force' => 'Prevent translations to other languages',
 71+ 'tpt-select-prioritylangs-reason' => 'Reason:',
 72+ 'tpt-sections-prioritylangs' => 'Priority languages',
 73+
7374 'tpt-rev-mark' => 'mark for translation',
7475 'tpt-rev-unmark' => 'remove from translation',
7576 'tpt-rev-discourage' => 'discourage',
@@ -245,7 +246,7 @@
246247 'tpt-select-prioritylangs' => 'Label for the input box to enter preferred languages',
247248 'tpt-select-prioritylangs-force' => 'Label for the checkbox to make the translation restriction',
248249 'tpt-select-prioritylangs-reason' => 'Label for the textbox to enter reason for restriction',
249 - 'tpt-sections-prioritylangs' => 'Section title in [[Special:PageTranslation]]',
 250+ 'tpt-sections-prioritylangs' => 'Section title in [[Special:PageTranslation]]',
250251 'tpt-rev-mark' => 'Possible page action and link text in [[Special:PageTranslation]]. In parenthesis after page name. [[Image:Page translation admin view.png|thumb|Admin view]]',
251252 'tpt-rev-unmark' => 'Possible page action and link text in [[Special:PageTranslation]]. In parenthesis after page name. [[Image:Page translation admin view.png|thumb|Admin view]]',
252253 'tpt-rev-discourage' => 'Possible page action and link text in [[Special:PageTranslation]]. In parenthesis after page name. [[Image:Page translation admin view.png|thumb|Admin view]]',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112668UI for the language restriction for page translation...santhosh05:33, 29 February 2012

Status & tagging log