blob: ea883b4632d66d394db846163d90dd4bfee749e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php
namespace dokuwiki\Menu\Item;
class Edit extends AbstractItem {
/** @inheritdoc */
public function __construct() {
global $ACT;
global $INFO;
global $REV;
parent::__construct();
if($ACT == 'show' || $ACT == 'search') {
$this->method = 'post';
if($INFO['writable']) {
$this->accesskey = 'e';
if(!empty($INFO['draft'])) {
$this->type = 'draft';
$this->params['do'] = 'draft';
} else {
$this->params['rev'] = $REV;
if(!$INFO['exists']) {
$this->type = 'create';
}
}
} else {
if(!actionOK($this->type)) throw new \RuntimeException("action disabled: source");
$params['rev'] = $REV;
$this->type = 'source';
$this->accesskey = 'v';
}
} else {
$this->params = array('do' => '');
$this->type = 'show';
$this->accesskey = 'v';
}
$this->setIcon();
}
/**
* change the icon according to what type the edit button has
*/
protected function setIcon() {
$icons = array(
'edit' => '01-edit_pencil.svg',
'create' => '02-create_pencil.svg',
'draft' => '03-draft_android-studio.svg',
'show' => '04-show_file-document.svg',
'source' => '05-source_file-xml.svg',
);
if(isset($icons[$this->type])) {
$this->svg = DOKU_INC . 'lib/images/menu/' . $icons[$this->type];
}
}
}
|