r106942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106941‎ | r106942 | r106943 >
Date:11:52, 21 December 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
I18n #321: UI for making translatable pages discouraged/encouraged
http://translatewiki.net/wiki/File:Page_translation_admin_view.png
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
@@ -34,9 +34,11 @@
3535
3636 global $wgRequest, $wgOut, $wgUser;
3737 $this->user = $wgUser;
 38+ $request = $wgRequest;
3839
3940 $target = $wgRequest->getText( 'target', $parameters );
4041 $revision = $wgRequest->getInt( 'revision', 0 );
 42+ $action = $request->getVal( 'do' );
4143
4244 // No specific page or invalid input
4345 $title = Title::newFromText( $target );
@@ -69,7 +71,26 @@
7072 return;
7173 }
7274
73 - if ( $revision === -1 ) {
 75+ if ( $action === 'discourage' || $action === 'encourage' ) {
 76+ $id = TranslatablePage::getMessageGroupIdFromTitle( $title );
 77+ $dbw = wfGetDB( DB_MASTER );
 78+ $table = 'translate_groupreviews';
 79+ $row = array(
 80+ 'tgr_group' => $id,
 81+ 'tgr_lang' => '*priority',
 82+ 'tgr_state' => 'discouraged',
 83+ );
 84+ if ( $action === 'encourage' ) {
 85+ $dbw->delete( $table, $row, __METHOD__ );
 86+ } else {
 87+ $index = array( 'tgr_group', 'tgr_lang' );
 88+ $dbw->replace( $table, array( $index ), $row, __METHOD__ );
 89+ }
 90+ $this->listPages();
 91+ return;
 92+ }
 93+
 94+ if ( $action === 'unmark' ) {
7495 $page = TranslatablePage::newFromTitle( $title );
7596 $page->removeTags();
7697 $page->getTitle()->invalidateCache();
@@ -230,7 +251,7 @@
231252 $out->addHtml( '<ol>' );
232253 foreach ( $pages as $page ) {
233254 $link = $linker->link( $page['title'] );
234 - $acts = $this->actionLinks( $page['title'], $page['tp:tag'], $page['latest'], 'new' );
 255+ $acts = $this->actionLinks( $page, 'proposed' );
235256 $out->addHtml( "<li>$link $acts</li>" );
236257 }
237258 $out->addHtml( '</ol>' );
@@ -243,13 +264,11 @@
244265 $out->addHtml( '<ol>' );
245266 foreach ( $pages as $page ) {
246267 $link = $linker->link( $page['title'] );
247 - $canUpdate = 'old';
248268 if ( $page['tp:mark'] !== $page['tp:tag'] ) {
249269 $link = "<b>$link</b>";
250 - $canUpdate = 'new';
251270 }
252271
253 - $acts = $this->actionLinks( $page['title'], $page['tp:tag'], $page['latest'], $canUpdate );
 272+ $acts = $this->actionLinks( $page, 'active' );
254273 $out->addHtml( "<li>$link $acts</li>" );
255274 }
256275 $out->addHtml( '</ol>' );
@@ -262,7 +281,7 @@
263282 $out->addHtml( '<ol>' );
264283 foreach ( $pages as $page ) {
265284 $link = $linker->link( $page['title'] );
266 - $acts = $this->actionLinks( $page['title'], $page['tp:tag'], $page['latest'], 'stuck' );
 285+ $acts = $this->actionLinks( $page, 'broken' );
267286 $out->addHtml( "<li>$link $acts</li>" );
268287 }
269288 $out->addHtml( '</ol>' );
@@ -275,13 +294,11 @@
276295 $out->addHtml( '<ol>' );
277296 foreach ( $pages as $page ) {
278297 $link = $linker->link( $page['title'] );
279 - $canUpdate = 'old';
280298 if ( $page['tp:mark'] !== $page['tp:tag'] ) {
281299 $link = "<b>$link</b>";
282 - $canUpdate = 'new';
283300 }
284301
285 - $acts = $this->actionLinks( $page['title'], $page['tp:tag'], $page['latest'], $canUpdate );
 302+ $acts = $this->actionLinks( $page, 'discouraged' );
286303 $out->addHtml( "<li>$link $acts</li>" );
287304 }
288305 $out->addHtml( '</ol>' );
@@ -290,45 +307,71 @@
291308 }
292309
293310 /**
294 - * @param $title Title
295 - * @param $rev
296 - * @param $latest
297 - * @param $old string
 311+ * @param $page array
 312+ * @param $type string
298313 * @return string
299314 */
300 - protected function actionLinks( $title, $rev, $latest, $type = 'old' ) {
 315+ protected function actionLinks( array $page, $type ) {
301316 $actions = array();
302317 $linker = class_exists( 'DummyLinker' ) ? new DummyLinker : new Linker;
303318
 319+ $title = $page['title'];
 320+
304321 if ( $this->user->isAllowed( 'pagetranslation' ) ) {
305322 $token = $this->user->editToken();
306323
307 - if (
308 - ( $type === 'new' && $latest === $rev ) ||
309 - ( $type === 'old' && $latest !== $rev )
310 - ) {
 324+ $pending = $type === 'active' && $page['latest'] !== $page['tp:mark'];
 325+ if ( $type === 'proposed' || $pending ) {
311326 $actions[] = $linker->link(
312327 $this->getTitle(),
313 - wfMsgHtml( 'tpt-rev-mark-new' ),
 328+ wfMsgHtml( 'tpt-rev-mark' ),
314329 array(),
315330 array(
 331+ 'do' => 'mark',
316332 'target' => $title->getPrefixedText(),
317333 'revision' => $title->getLatestRevId(),
318334 'token' => $token,
319335 )
320336 );
321 - } elseif ( $type === 'stuck' ) {
 337+ } elseif ( $type === 'broken' ) {
322338 $actions[] = $linker->link(
323339 $this->getTitle(),
324340 wfMsgHtml( 'tpt-rev-unmark' ),
325341 array(),
326342 array(
 343+ 'do' => 'unmark',
327344 'target' => $title->getPrefixedText(),
328345 'revision' => -1,
329346 'token' => $token,
330347 )
331348 );
332349 }
 350+
 351+ if ( $type === 'active' ) {
 352+ $actions[] = $linker->link(
 353+ $this->getTitle(),
 354+ wfMsgHtml( 'tpt-rev-discourage' ),
 355+ array( 'title' => wfMsg( 'tpt-rev-discourage-tooltip' ) ),
 356+ array(
 357+ 'do' => 'discourage',
 358+ 'target' => $title->getPrefixedText(),
 359+ 'revision' => -1,
 360+ 'token' => $token,
 361+ )
 362+ );
 363+ } elseif ( $type === 'discouraged' ) {
 364+ $actions[] = $linker->link(
 365+ $this->getTitle(),
 366+ wfMsgHtml( 'tpt-rev-encourage' ),
 367+ array( 'title' => wfMsg( 'tpt-rev-encourage-tooltip' ) ),
 368+ array(
 369+ 'do' => 'encourage',
 370+ 'target' => $title->getPrefixedText(),
 371+ 'revision' => -1,
 372+ 'token' => $token,
 373+ )
 374+ );
 375+ }
333376 }
334377
335378 if ( !count( $actions ) ) {
Index: trunk/extensions/Translate/PageTranslation.i18n.php
@@ -64,9 +64,17 @@
6565 but the latest {{PLURAL:$1|version|versions}} cannot be marked for translation.',
6666 'tpt-discouraged-pages' => '{{PLURAL:$1|This page has|These pages have}} been discouraged from further translation.',
6767
68 - 'tpt-rev-mark-new' => 'mark this version for translation',
69 - 'tpt-rev-unmark' => 'remove this page from translation',
 68+ 'tpt-rev-mark' => 'mark for translation',
 69+ 'tpt-rev-unmark' => 'remove from translation',
 70+ 'tpt-rev-discourage' => 'discourage',
 71+ 'tpt-rev-encourage' => 'restore',
7072
 73+ 'tpt-rev-mark-tooltip' => 'Mark the latest version of this page for translation.',
 74+ 'tpt-rev-unmark-tooltip' => 'Remove this page from translation.',
 75+ 'tpt-rev-discourage-tooltip' => 'Discourage further translations on this page.',
 76+ 'tpt-rev-encourage-tooltip' => 'Restore this page to normal translation.',
 77+
 78+
7179 # Source and translation page headers
7280 'translate-tag-translate-link-desc' => 'Translate this page',
7381 'translate-tag-markthis' => 'Mark this page for translation',
@@ -196,7 +204,7 @@
197205 * @author Umherirrender
198206 */
199207 $messages['qqq'] = array(
200 - 'pagetranslation' => 'Title of [[Special:PageTranslation]] and its name in [[Special:SpecialPages]].',
 208+ 'pagetranslation' => 'Title of [[Special:PageTranslation]] and its name in [[Special:SpecialPages]]. [[Image:Page translation admin view.png|thumb|Admin view]]',
201209 'right-pagetranslation' => '{{doc-right|pagetranslation}}',
202210 'tpt-desc' => '{{desc}}',
203211 'tpt-sections-oldnew' => '"New and existing" refers to the sum of: (a) new translation units in a translatable page, plus (b) the already existing ones from previous version of a translatable page.',
@@ -204,14 +212,14 @@
205213 $2 is a count of sections which can be used with PLURAL,
206214 $3 is an URL.',
207215 'tpt-mark-summary' => 'This message is used as an edit summary.',
208 - 'tpt-new-pages-title' => 'Header in [[Special:PageTranslation]]',
209 - 'tpt-old-pages-title' => 'Header in [[Special:PageTranslation]]',
210 - 'tpt-other-pages-title' => 'Header in [[Special:PageTranslation]]',
211 - 'tpt-discouraged-pages-title' => 'Header in [[Special:PageTranslation]]',
212 - 'tpt-new-pages' => '$1 is the number of pages in the following list.',
213 - 'tpt-old-pages' => 'The words "some version" refer to "one version of the page", or "a single version of each of the pages", respectively. Each page can have either one or none of its versions marked for translaton. $1 is the number of pages',
214 - 'tpt-other-pages' => '$1 is the number of pages in the following list.',
215 - 'tpt-discouraged-pages' => '$1 is the number of pages in the following list.',
 216+ 'tpt-new-pages-title' => 'Header in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 217+ 'tpt-old-pages-title' => 'Header in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 218+ 'tpt-other-pages-title' => 'Header in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 219+ 'tpt-discouraged-pages-title' => 'Header in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 220+ 'tpt-new-pages' => '$1 is the number of pages in the following list. [[Image:Page translation admin view.png|thumb|Admin view]]',
 221+ 'tpt-old-pages' => 'The words "some version" refer to "one version of the page", or "a single version of each of the pages", respectively. Each page can have either one or none of its versions marked for translaton. $1 is the number of pages [[Image:Page translation admin view.png|thumb|Admin view]]',
 222+ 'tpt-other-pages' => '$1 is the number of pages in the following list. [[Image:Page translation admin view.png|thumb|Admin view]]',
 223+ 'tpt-discouraged-pages' => '$1 is the number of pages in the following list. [[Image:Page translation admin view.png|thumb|Admin view]]',
216224 'translate-tag-markthisagain' => '"has changes" is to be understood as "has been altered/edited"',
217225 'translate-tag-hasnew' => '"has changes" is to be understood as "has been altered/edited"',
218226 'tpt-languages-legend' => 'The caption of a language selector displayed using <code>&lt;languages /&gt;</code>, e.g. on [[Project list]].',
@@ -233,6 +241,16 @@
234242 'pt-deletepage-action-check' => 'This is a button label. "List" is an imperative verb.',
235243 'pt-deletepage-current' => '{{Identical|Page name}}',
236244 'pt-deletepage-reason' => '{{Identical|Reason}}',
 245+
 246+ '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]]',
 247+ '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]]',
 248+ '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]]',
 249+ 'tpt-rev-encourage' => 'Possible page action and link text in [[Special:PageTranslation]]. In parenthesis after page name. [[Image:Page translation admin view.png|thumb|Admin view]]',
 250+
 251+ 'tpt-rev-mark-tooltip' => 'Tooltip for page action link text in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 252+ 'tpt-rev-unmark-tooltip' => 'Tooltip for page action link text in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 253+ 'tpt-rev-discourage-tooltip' => 'Tooltip for page action link text in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
 254+ 'tpt-rev-encourage-tooltip' => 'Tooltip for page action link text in [[Special:PageTranslation]] [[Image:Page translation admin view.png|thumb|Admin view]]',
237255 );
238256
239257 /** ꢱꣃꢬꢵꢯ꣄ꢡ꣄ꢬꢵ (ꢱꣃꢬꢵꢯ꣄ꢡ꣄ꢬꢵ)

Follow-up revisions

RevisionCommit summaryAuthorDate
r107148Followup r106942 - I added new tooltips but forgot to use two of themnikerabbit09:48, 23 December 2011

Status & tagging log