Completed
Pull Request — master (#3222)
by
unknown
03:30
created

Revert   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A getLinkAttributes() 0 6 1
1
<?php
2
3
namespace dokuwiki\Menu\Item;
4
5
/**
6
 * Class Revert
7
 *
8
 * Quick revert to the currently shown page revision
9
 */
10
class Revert extends AbstractItem {
11
12
    /** @inheritdoc */
13
    public function __construct() {
14
        global $REV;
15
        global $INFO;
16
        parent::__construct();
17
18
        if(!$REV || !$INFO['writable']) {
19
            throw new \RuntimeException('revert not available');
20
        }
21
        $this->params['rev'] = $REV;
22
        $this->params['sectok'] = getSecurityToken();
23
        $this->svg = DOKU_INC . 'lib/images/menu/06-revert_replay.svg';
24
    }
25
26
    /** @inheritdoc */
27
    public function getLinkAttributes($classprefix = 'menuitem ') {
28
        global $lang;
29
        $attr = parent::getLinkAttributes($classprefix);
30
        $attr['onclick'] = 'javascript:return confirm("'.hsc($lang['js']['restore_confirm']).'")';
31
        return $attr;
32
    }
33
34
}
35