summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/Translate/specials/SpecialPagePreparation.php
blob: 3c0cbb2b8c6673788056178add3ee622cf7a0d59 (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
<?php
/**
 * Contains code for special page Special:PagePreparation
 *
 * @file
 * @author Pratik Lahoti
 * @copyright Copyright © 2014 Pratik Lahoti
 * @license GPL-2.0+
 */

class SpecialPagePreparation extends SpecialPage {
	public function __construct() {
		parent::__construct( 'PagePreparation', 'pagetranslation' );
	}

	protected function getGroupName() {
		return 'wiki';
	}

	public function execute( $par ) {
		$request = $this->getRequest();
		$output = $this->getOutput();
		$this->setHeaders();
		$this->checkPermissions();

		$inputValue = htmlspecialchars( $request->getText( 'page', $par ) );
		$pagenamePlaceholder = $this->msg( 'pp-pagename-placeholder' )->escaped();
		$prepareButtonValue = $this->msg( 'pp-prepare-button-label' )->escaped();
		$saveButtonValue = $this->msg( 'pp-save-button-label' )->escaped();
		$cancelButtonValue = $this->msg( 'pp-cancel-button-label' )->escaped();
		$summaryValue = $this->msg( 'pp-save-summary' )->inContentLanguage()->escaped();
		$output->addModules( 'ext.translate.special.pagepreparation' );
		$output->addModuleStyles( 'jquery.uls.grid' );

		$out = '';
		$diff = new DifferenceEngine( $this->getContext() );
		$diffHeader = $diff->addHeader( ' ', $this->msg( 'pp-diff-old-header' )->escaped(),
			$this->msg( 'pp-diff-new-header' )->escaped() );

		$out = <<<HTML
<div class="grid">
	<form class="mw-tpp-sp-form row" name="mw-tpp-sp-input-form" action="">
		<input id="pp-summary" type="hidden" value="{$summaryValue}" />
		<input name="page" id="page" class="mw-searchInput mw-ui-input"
			placeholder="{$pagenamePlaceholder}" value="{$inputValue}"/>
		<button id="action-prepare" class="mw-ui-button mw-ui-primary" type="button">
			{$prepareButtonValue}</button>
		<button id="action-save" class="mw-ui-button mw-ui-constructive hide" type="button">
			{$saveButtonValue}</button>
		<button id="action-cancel" class="mw-ui-button mw-ui-quiet hide" type="button">
			{$cancelButtonValue}</button>
	</form>
	<div class="messageDiv hide"></div>
	<div class="divDiff hide">
		{$diffHeader}
	</div>
</div>
HTML;
		$output->addHTML( $out );
	}
}