Index: trunk/extensions/Translate/tag/SpecialPageTranslation.php |
— | — | @@ -439,7 +439,7 @@ |
440 | 440 | * @param $sections array |
441 | 441 | */ |
442 | 442 | public function showPage( TranslatablePage $page, Array $sections ) { |
443 | | - global $wgOut, $wgContLang; |
| 443 | + global $wgOut, $wgContLang, $wgLang; |
444 | 444 | |
445 | 445 | $wgOut->setSubtitle( Linker::link( $page->getTitle() ) ); |
446 | 446 | $wgOut->addModules( 'ext.translate.special.pagetranslation' ); |
— | — | @@ -529,21 +529,7 @@ |
530 | 530 | } |
531 | 531 | } |
532 | 532 | |
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 ); |
548 | 534 | |
549 | 535 | $wgOut->addHTML( |
550 | 536 | Xml::submitButton( wfMsg( 'tpt-submit' ) ) . |
— | — | @@ -551,6 +537,45 @@ |
552 | 538 | ); |
553 | 539 | } |
554 | 540 | |
| 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 | + |
555 | 580 | /** |
556 | 581 | * This function does the heavy duty of marking a page. |
557 | 582 | * - Updates the source page with section markers. |
— | — | @@ -636,11 +661,6 @@ |
637 | 662 | $page->addMarkedTag( $newrevision, $changed ); |
638 | 663 | $this->addFuzzyTags( $page, $changed ); |
639 | 664 | |
640 | | - // Save the priority languages if any |
641 | | - $priorityLangs = trim( $wgRequest->getVal( 'prioritylangs' ) ); |
642 | | - $priorityForce = $wgRequest->getVal( 'forcelimit' ); |
643 | | - $priorityReason = $wgRequest->getVal( 'priorityreason' ); |
644 | | - |
645 | 665 | global $wgUser; |
646 | 666 | $logger = new LogPage( 'pagetranslation' ); |
647 | 667 | $params = array( |
— | — | @@ -649,17 +669,19 @@ |
650 | 670 | 'changed' => count( $changed ), |
651 | 671 | ); |
652 | 672 | $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 ) { |
654 | 681 | $groupId = $page->getMessageGroupId(); |
| 682 | + // FIXME: does not normalise input to a,b,c,d |
655 | 683 | 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 ) ); |
664 | 686 | $params = array( |
665 | 687 | 'user' => $wgUser->getName(), |
666 | 688 | 'languages' => $priorityLangs, |
Index: trunk/extensions/Translate/PageTranslation.i18n.php |
— | — | @@ -64,11 +64,12 @@ |
65 | 65 | 'tpt-other-pages' => '{{PLURAL:$1|An old version of this page is|Older versions of these pages are}} marked for translation, |
66 | 66 | but the latest {{PLURAL:$1|version|versions}} cannot be marked for translation.', |
67 | 67 | '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 | + |
73 | 74 | 'tpt-rev-mark' => 'mark for translation', |
74 | 75 | 'tpt-rev-unmark' => 'remove from translation', |
75 | 76 | 'tpt-rev-discourage' => 'discourage', |
— | — | @@ -245,7 +246,7 @@ |
246 | 247 | 'tpt-select-prioritylangs' => 'Label for the input box to enter preferred languages', |
247 | 248 | 'tpt-select-prioritylangs-force' => 'Label for the checkbox to make the translation restriction', |
248 | 249 | '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]]', |
250 | 251 | '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]]', |
251 | 252 | '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]]', |
252 | 253 | '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]]', |