Failed Conditions
Pull Request — master (#3198)
by
unknown
04:14
created

PageDraft   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 7

1 Method

Rating   Name   Duplication   Size   Complexity  
A show() 0 33 1
1
<?php
2
3
namespace dokuwiki\Ui;
4
5
use dokuwiki\Extension\Event;
6
use dokuwiki\Form\Form;
7
8
/**
9
 * DokuWiki Page Draft Interface
10
 *
11
 * @package dokuwiki\Ui
12
 */
13
class PageDraft extends Ui
14
{
15
    /**
16
     * Display the Page Draft Form
17
     * ask the user about how to handle an exisiting draft
18
     *
19
     * @author   Andreas Gohr <[email protected]>
20
     *
21
     * @triggers HTML_DRAFTFORM_OUTPUT
22
     * @return void
23
     */
24
    public function show()
25
    {
26
        global $INFO;
27
        global $ID;
28
        global $lang;
29
30
        $draft = new \dokuwiki\Draft($ID, $INFO['client']);
31
        $text  = $draft->getDraftText();
32
33
        // print intro
34
        print p_locale_xhtml('draft');
35
36
        (new Diff($text, false))->show();
37
38
        // create the draft form
39
        $form = new Form(['id' => 'dw__editform']);
40
        $form->addTagOpen('div')->addClass('no');
41
        $form->setHiddenField('id', $ID);
42
        $form->setHiddenField('date', $draft->getDraftDate());
43
        $form->setHiddenField('wikitext', $text);
44
45
        $form->addTagOpen('div')->id('draft__status');
46
        $form->addHTML($draft->getDraftMessage());
47
        $form->addTagClose('div');
48
        $form->addButton('do[recover]',  $lang['btn_recover'] )->attrs(['type' => 'submit', 'tabindex' => '1']);
49
        $form->addButton('do[draftdel]', $lang['btn_draftdel'])->attrs(['type' => 'submit', 'tabindex' => '2']);
50
        $form->addButton('do[show]',     $lang['btn_cancel']  )->attrs(['type' => 'submit', 'tabindex' => '3']);
51
        $form->addTagClose('div');
52
53
        // emit HTML_DRAFTFORM_OUTPUT event
54
        Event::createAndTrigger('HTML_DRAFTFORM_OUTPUT', $form, null, false);
55
        print $form->toHTML();
56
    }
57
58
}
59