Completed
Push — master ( d4a8e6...69a81a )
by Andreas
16s
created

Preview::tplContent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\Action;
4
5
/**
6
 * Class Preview
7
 *
8
 * preview during editing
9
 *
10
 * @package dokuwiki\Action
11
 */
12
class Preview extends Edit {
13
14
    /** @inheritdoc */
15
    public function preProcess() {
16
        header('X-XSS-Protection: 0');
17
        $this->savedraft();
18
        parent::preProcess();
19
    }
20
21
    /** @inheritdoc */
22
    public function tplContent() {
23
        global $TEXT;
24
        html_edit();
25
        html_show($TEXT);
26
    }
27
28
    /**
29
     * Saves a draft on preview
30
     */
31
    protected function savedraft() {
32
        global $ID, $INFO;
33
        $draft = new \dokuwiki\Draft($ID, $INFO['client']);
34
        if (!$draft->saveDraft()) {
35
            $errors = $draft->getErrors();
36
            foreach ($errors as $error) {
37
                msg(hsc($error), -1);
38
            }
39
        }
40
    }
41
42
}
43