summaryrefslogtreecommitdiff
blob: 0585ac8446836b881d4ac3e6683f3e5b6fcf8311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php

class TuxMessageTable extends ContextSource {
	protected $group;
	protected $language;

	public function __construct( IContextSource $context, MessageGroup $group, $language ) {
		$this->setContext( $context );
		$this->group = $group;
		$this->language = $language;
	}

	public function fullTable() {
		$modules = [];
		Hooks::run( 'TranslateBeforeAddModules', [ &$modules ] );
		$this->getOutput()->addModules( $modules );

		$sourceLang = Language::factory( $this->group->getSourceLanguage() );
		$targetLang = Language::factory( $this->language );
		$batchSize = 100;

		$list = Html::element( 'div', [
			'class' => 'row tux-messagelist',
			'data-grouptype' => get_class( $this->group ),
			'data-sourcelangcode' => $sourceLang->getCode(),
			'data-sourcelangdir' => $sourceLang->getDir(),
			'data-targetlangcode' => $targetLang->getCode(),
			'data-targetlangdir' => $targetLang->getDir(),
		] );

		$groupId = htmlspecialchars( $this->group->getId() );
		$msg = $this->msg( 'tux-messagetable-loading-messages' )
			->numParams( $batchSize )
			->escaped();

		$loader = <<<HTML
<div class="tux-messagetable-loader hide" data-messagegroup="$groupId" data-pagesize="$batchSize">
	<span class="tux-loading-indicator"></span>
	<div class="tux-messagetable-loader-info">$msg</div>
</div>
HTML;

		$hideOwn = $this->msg( 'tux-editor-proofreading-hide-own-translations' )->escaped();
		$clearTranslated = $this->msg( 'tux-editor-clear-translated' )->escaped();
		$modeTranslate = $this->msg( 'tux-editor-translate-mode' )->escaped();
		$modePage = $this->msg( 'tux-editor-page-mode' )->escaped();
		$modeProofread = $this->msg( 'tux-editor-proofreading-mode' )->escaped();

		$actionbar = <<<HTML
<div class="tux-action-bar hide row">
	<div class="three columns tux-message-list-statsbar" data-messagegroup="$groupId"></div>
	<div class="three columns text-center">
		<button class="toggle button tux-proofread-own-translations-button hide-own hide">
			$hideOwn
		</button>
		<button class="toggle button tux-editor-clear-translated hide">$clearTranslated</button>
	</div>
	<div class="six columns tux-view-switcher text-center">
		<button class="toggle down translate-mode-button">$modeTranslate
		</button><button class="toggle down page-mode-button">$modePage
		</button><button class="toggle hide proofread-mode-button">$modeProofread
		</button>
	</div>
</div>
HTML;

		// Actual message table is fetched and rendered at client side. This just provides
		// the loader and action bar.
		return $list . $loader . $actionbar;
	}
}