xref: /dokuwiki/inc/Ui/PageConflict.php (revision bde2a644b7f10af4f4d8a7ca52281cd954538ea9)
1<?php
2
3namespace dokuwiki\Ui;
4
5use dokuwiki\Form\Form;
6
7/**
8 * DokuWiki Page Conflict Interface
9 *
10 * @package dokuwiki\Ui
11 */
12class PageConflict extends Ui
13{
14    protected $text;
15    protected $summary;
16
17    /**
18     * PageConflict Ui constructor
19     *
20     * @param string $text     wiki text
21     * @param string $summary  edit summary
22    */
23    public function __construct($text = '', $summary = '')
24    {
25        $this->text    = $text;
26        $this->summary = $summary;
27    }
28
29    /**
30     * Show conflict form to ask whether save anyway or cancel the page edits
31     *
32     * @author   Andreas Gohr <andi@splitbrain.org>
33     *
34     * @triggers HTMLFORM_CONFLICT_OUTPUT
35     * @return void
36     */
37    public function show()
38    {
39        global $ID;
40        global $lang;
41
42        // print intro
43        print p_locale_xhtml('conflict');
44
45        // create the form
46        $form = new Form(['id' => 'dw__editform']);
47        $form->addTagOpen('div')->addClass('no');
48        $form->setHiddenField('id', $ID);
49        $form->setHiddenField('wikitext', $this->text);
50        $form->setHiddenField('summary', $this->summary);
51
52        $form->addButton('do[save]', $lang['btn_save'] )->attrs(['type' => 'submit', 'accesskey' => 's']);
53        $form->addButton('do[cancel]', $lang['btn_cancel'] )->attrs(['type' => 'submit']);
54        $form->addTagClose('div');
55
56        // print form that might be modified by HTMLFORM_CONFLICT_OUTPUT event handlers
57        print $form->toHTML('conflict');
58
59        print '<br /><br /><br /><br />';
60
61        (new Diff($this->text, false))->show();
62    }
63
64}
65