Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
PrepareTranslatablePageSpecialPage.php
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\PageTranslation;
5
6use DifferenceEngine;
7use Html;
8use SpecialPage;
9
15class PrepareTranslatablePageSpecialPage extends SpecialPage {
16 public function __construct() {
17 parent::__construct( 'PagePreparation', 'pagetranslation' );
18 }
19
20 protected function getGroupName() {
21 return 'translation';
22 }
23
24 public function execute( $par ) {
25 $request = $this->getRequest();
26 $output = $this->getOutput();
27 $this->setHeaders();
28 $this->checkPermissions();
29 $this->outputHeader();
30 $inputValue = htmlspecialchars( $request->getText( 'page', $par ) );
31 $pagenamePlaceholder = $this->msg( 'pp-pagename-placeholder' )->escaped();
32 $prepareButtonValue = $this->msg( 'pp-prepare-button-label' )->escaped();
33 $saveButtonValue = $this->msg( 'pp-save-button-label' )->escaped();
34 $cancelButtonValue = $this->msg( 'pp-cancel-button-label' )->escaped();
35 $summaryValue = $this->msg( 'pp-save-summary' )->inContentLanguage()->escaped();
36 $output->addModules( 'ext.translate.special.pagepreparation' );
37 $output->addModuleStyles( [
38 'ext.translate.specialpages.styles',
39 'jquery.uls.grid'
40 ] );
41
42 $out = '';
43 $diff = new DifferenceEngine( $this->getContext() );
44 $diffHeader = $diff->addHeader( ' ', $this->msg( 'pp-diff-old-header' )->escaped(),
45 $this->msg( 'pp-diff-new-header' )->escaped() );
46
47 $out = <<<HTML
48<div class="mw-tpp-sp-container grid">
49 <form class="mw-tpp-sp-form row" name="mw-tpp-sp-input-form" action="">
50 <input id="pp-summary" type="hidden" value="{$summaryValue}" />
51 <input name="page" id="page" class="mw-searchInput mw-ui-input"
52 placeholder="{$pagenamePlaceholder}" value="{$inputValue}"/>
53 <button id="action-prepare" class="mw-ui-button mw-ui-progressive" type="button">
54 {$prepareButtonValue}</button>
55 <button id="action-save" class="mw-ui-button mw-ui-progressive hide" type="button">
56 {$saveButtonValue}</button>
57 <button id="action-cancel" class="mw-ui-button mw-ui-quiet hide" type="button">
58 {$cancelButtonValue}</button>
59 </form>
60 <div class="messageDiv hide"></div>
61 <div class="divDiff hide">
62 {$diffHeader}
63 </div>
64</div>
65HTML;
66 $output->addHTML( $out );
67 $output->addHTML(
68 Html::errorBox(
69 $this->msg( 'tux-nojs' )->plain(),
70 '',
71 'tux-nojs'
72 )
73 );
74 }
75}