Failed Conditions
Push — master ( 96da53...0afbc1 )
by Andreas
06:02 queued 03:20
created

PageConflict   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A show() 0 25 1
1
<?php
2
3
namespace dokuwiki\Ui;
4
5
use dokuwiki\Form\Form;
6
7
/**
8
 * DokuWiki Page Conflict Interface
9
 *
10
 * @package dokuwiki\Ui
11
 */
12
class 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 <[email protected]>
33
     *
34
     * @return void
35
     */
36
    public function show()
37
    {
38
        global $ID;
39
        global $lang;
40
41
        // print intro
42
        print p_locale_xhtml('conflict');
43
44
        // create the form
45
        $form = new Form(['id' => 'dw__editform']);
46
        $form->addTagOpen('div')->addClass('no');
47
        $form->setHiddenField('id', $ID);
48
        $form->setHiddenField('wikitext', $this->text);
49
        $form->setHiddenField('summary', $this->summary);
50
51
        $form->addButton('do[save]', $lang['btn_save'] )->attrs(['type' => 'submit', 'accesskey' => 's']);
52
        $form->addButton('do[cancel]', $lang['btn_cancel'] )->attrs(['type' => 'submit']);
53
        $form->addTagClose('div');
54
55
        print $form->toHTML('Conflict');
56
57
        print '<br /><br /><br /><br />';
58
59
        (new Diff($this->text, false))->show();
60
    }
61
62
}
63