https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112699

Revision: 112699
Author:   nikerabbit
Date:     2012-02-29 16:03:18 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
Cleanups to r112668

Modified Paths:
--------------
    trunk/extensions/Translate/PageTranslation.i18n.php
    trunk/extensions/Translate/tag/SpecialPageTranslation.php

Modified: trunk/extensions/Translate/PageTranslation.i18n.php
===================================================================
--- trunk/extensions/Translate/PageTranslation.i18n.php 2012-02-29 15:36:10 UTC 
(rev 112698)
+++ trunk/extensions/Translate/PageTranslation.i18n.php 2012-02-29 16:03:18 UTC 
(rev 112699)
@@ -64,11 +64,12 @@
        'tpt-other-pages' => '{{PLURAL:$1|An old version of this page is|Older 
versions of these pages are}} marked for translation,
 but the latest {{PLURAL:$1|version|versions}} cannot be marked for 
translation.',
        'tpt-discouraged-pages' => '{{PLURAL:$1|This page has|These pages 
have}} been discouraged from further translation.',
-       'tpt-select-prioritylangs' => 'Preferred languages (comma-separated 
language codes): ',
-       'tpt-select-prioritylangs-force' => 'Limit translation to these 
languages alone',
-       'tpt-select-prioritylangs-reason' => 'Reason for setting this set of 
preferred languages (optional): ',
-       'tpt-sections-prioritylangs' => 'Preferred Languages',
-       
+
+       'tpt-select-prioritylangs' => 'Comma separated list of language codes:',
+       'tpt-select-prioritylangs-force' => 'Prevent translations to other 
languages',
+       'tpt-select-prioritylangs-reason' => 'Reason:',
+       'tpt-sections-prioritylangs' => 'Priority languages',
+
        'tpt-rev-mark' => 'mark for translation',
        'tpt-rev-unmark' => 'remove from translation',
        'tpt-rev-discourage' => 'discourage',
@@ -245,7 +246,7 @@
        'tpt-select-prioritylangs' => 'Label for the input box to enter 
preferred languages',
        'tpt-select-prioritylangs-force' => 'Label for the checkbox to make the 
translation restriction',
        'tpt-select-prioritylangs-reason' => 'Label for the textbox to enter 
reason for restriction',
-       'tpt-sections-prioritylangs' => 'Section title in  
[[Special:PageTranslation]]',
+       'tpt-sections-prioritylangs' => 'Section title in 
[[Special:PageTranslation]]',
        '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]]',
        '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]]',
        '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]]',

Modified: trunk/extensions/Translate/tag/SpecialPageTranslation.php
===================================================================
--- trunk/extensions/Translate/tag/SpecialPageTranslation.php   2012-02-29 
15:36:10 UTC (rev 112698)
+++ trunk/extensions/Translate/tag/SpecialPageTranslation.php   2012-02-29 
16:03:18 UTC (rev 112699)
@@ -439,7 +439,7 @@
         * @param $sections array
         */
        public function showPage( TranslatablePage $page, Array $sections ) {
-               global $wgOut, $wgContLang;
+               global $wgOut, $wgContLang, $wgLang;
 
                $wgOut->setSubtitle( Linker::link( $page->getTitle() ) );
                $wgOut->addModules( 'ext.translate.special.pagetranslation' );
@@ -529,21 +529,7 @@
                        }
                }
 
-               $priorityLangs = TranslateMetadata::get( 
$page->getMessageGroupId(), 'prioritylangs' );
-               $priorityForce = TranslateMetadata::get( 
$page->getMessageGroupId(), 'priorityforce' );
-               $priorityReason = TranslateMetadata::get( 
$page->getMessageGroupId(), 'priorityreason' );
-               $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-prioritylangs' );
-               $langSelector = Xml::languageSelector( $wgContLang-> getCode() 
);
-               $priorityLangsInput = Html::element( 'input', array( 'id' => 
'tpt-prioritylangs', 'size' => '50', 'name' => 'prioritylangs', 'value' => 
$priorityLangs , ) );
-               if ( $priorityForce === 'on' ) {
-                       $forceLimit = Html::element( 'input', array( 'id' => 
'tpt-priority-forcelimit', 'type' => 'checkbox', 'name' => 'forcelimit', 
'checked' => 'checked' )  );
-               } else {
-               $forceLimit = Html::element( 'input', array( 'id' => 
'tpt-priority-forcelimit', 'type' => 'checkbox', 'name' => 'forcelimit' ) );
-               }
-               $priorityReasonTextArea = Html::element( 'textarea', array( 
'id' => 'tpt-priority-reason', 'name' => 'priorityreason' ), $priorityReason  );
-               $forceLimitLabel = Html::element( 'label', array( 'id' => 
'tpt-priority-forcelimit-label', 'for' => 'tpt-priority-forcelimit' ), 
wfMsgHtml( 'tpt-select-prioritylangs-force' ) );
-               $wgOut->addHTML( wfMsgHtml( 'tpt-select-prioritylangs' ) . 
$langSelector[1] . $priorityLangsInput );
-               $wgOut->addHTML( '<br/>' . $forceLimit . $forceLimitLabel . 
'<br/>' . wfMsgHtml( 'tpt-select-prioritylangs-reason' ) . 
$priorityReasonTextArea . '<br/>' );
+               $this->priorityLanguagesForm( $page );
 
                $wgOut->addHTML(
                        Xml::submitButton( wfMsg( 'tpt-submit' ) ) .
@@ -551,6 +537,45 @@
                );
        }
 
+       protected function priorityLanguagesForm( TranslatablePage $page ) {
+               global $wgOut, $wgContLang, $wgLang;
+               $groupId = $page->getMessageGroupId();
+               $wgOut->wrapWikiMsg( '==$1==', 'tpt-sections-prioritylangs' );
+
+               $langSelector = Xml::languageSelector( $wgContLang->getCode(), 
false, $wgLang->getCode() );
+
+               $hLangs = Xml::inputLabelSep(
+                       wfMsg( 'tpt-select-prioritylangs' ),
+                       'prioritylangs', // name
+                       'tpt-prioritylangs', // id
+                       50,
+                       TranslateMetadata::get( $groupId, 'prioritylangs' )
+               );
+
+               $hForce = Xml::checkLabel(
+                       wfMsg( 'tpt-select-prioritylangs-force' ),
+                       'forcelimit', // name
+                       'tpt-priority-forcelimit', // id
+                       TranslateMetadata::get( $groupId, 'priorityforce' ) === 
'on'
+               );
+
+               $hReason = Xml::inputLabelSep(
+                       wfMsg( 'tpt-select-prioritylangs-reason' ),
+                       'priorityreason', // name
+                       'tpt-priority-reason', // id
+                       50, // size
+                       TranslateMetadata::get( $groupId, 'priorityreason' )
+               );
+
+               $wgOut->addHTML(
+                       "<table>" .
+                       "<tr><td class='mw-label'>$hLangs[0]</td><td 
class='mw-input'>$hLangs[1]$langSelector[1]</td></tr>" .
+                       "<tr><td></td><td class='mw-inout'>$hForce</td></tr>" .
+                       "<tr><td class='mw-label'>$hReason[0]</td><td 
class='mw-input'>$hReason[1]</td></tr>" .
+                       "</table>"
+               );
+       }
+
        /**
         * This function does the heavy duty of marking a page.
         * - Updates the source page with section markers.
@@ -636,11 +661,6 @@
                $page->addMarkedTag( $newrevision, $changed );
                $this->addFuzzyTags( $page, $changed );
 
-               // Save the priority languages if any
-               $priorityLangs = trim( $wgRequest->getVal( 'prioritylangs' ) );
-               $priorityForce = $wgRequest->getVal( 'forcelimit' );
-               $priorityReason = $wgRequest->getVal( 'priorityreason' );
-
                global $wgUser;
                $logger = new LogPage( 'pagetranslation' );
                $params = array(
@@ -649,17 +669,19 @@
                        'changed' => count( $changed ),
                );
                $logger->addEntry( 'mark', $page->getTitle(), null, array( 
serialize( $params ) ) );
-               if (  $priorityLangs ) {
+
+
+               // Save the priority languages if any
+               $priorityLangs = trim( $wgRequest->getVal( 'prioritylangs' ) );
+               $priorityForce = $wgRequest->getCheck( 'forcelimit' );
+               $priorityReason = $wgRequest->getVal( 'priorityreason' );
+               // FIXME: does not log removals
+               if ( $priorityLangs ) {
                        $groupId = $page->getMessageGroupId();
+                       // FIXME: does not normalise input to a,b,c,d
                        TranslateMetadata::set( $groupId, 'prioritylangs', 
trim( $priorityLangs, ',' ) );
-                       if ( $priorityForce ) {
-                               TranslateMetadata::set( $groupId, 
'priorityforce', $priorityForce );
-                       } else {
-                               TranslateMetadata::set( $groupId, 
'priorityforce', 'off' );
-                       }
-                       if ( trim( $priorityReason ) ) {
-                               TranslateMetadata::set( $groupId, 
'priorityreason', $priorityReason );
-                       }
+                       TranslateMetadata::set( $groupId, 'priorityforce', 
$priorityForce ? 'on' : 'off' );
+                       TranslateMetadata::set( $groupId, 'priorityreason', 
trim( $priorityReason ) );
                        $params = array(
                                'user' => $wgUser->getName(),
                                'languages' => $priorityLangs,


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to