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