|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace dokuwiki\Action; |
|
4
|
|
|
|
|
5
|
|
|
use dokuwiki\Action\Exception\ActionAbort; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class Edit |
|
9
|
|
|
* |
|
10
|
|
|
* Handle editing |
|
11
|
|
|
* |
|
12
|
|
|
* @package dokuwiki\Action |
|
13
|
|
|
*/ |
|
14
|
|
|
class Edit extends AbstractAction { |
|
15
|
|
|
|
|
16
|
|
|
/** @inheritdoc */ |
|
17
|
|
|
function minimumPermission() { |
|
|
|
|
|
|
18
|
|
|
global $INFO; |
|
19
|
|
|
if($INFO['exists']) { |
|
20
|
|
|
return AUTH_READ; // we check again below |
|
21
|
|
|
} else { |
|
22
|
|
|
return AUTH_CREATE; |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @inheritdoc falls back to 'source' if page not writable |
|
28
|
|
|
*/ |
|
29
|
|
|
public function checkPermissions() { |
|
30
|
|
|
parent::checkPermissions(); |
|
31
|
|
|
global $INFO; |
|
32
|
|
|
|
|
33
|
|
|
// no edit permission? view source |
|
34
|
|
|
if($INFO['exists'] && !$INFO['writable']) { |
|
35
|
|
|
throw new ActionAbort('source'); |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function preProcess() { |
|
40
|
|
|
global $ID; |
|
41
|
|
|
global $INFO; |
|
42
|
|
|
|
|
43
|
|
|
global $TEXT; |
|
44
|
|
|
global $RANGE; |
|
45
|
|
|
global $PRE; |
|
46
|
|
|
global $SUF; |
|
47
|
|
|
global $REV; |
|
48
|
|
|
global $SUM; |
|
49
|
|
|
global $lang; |
|
50
|
|
|
global $DATE; |
|
51
|
|
|
|
|
52
|
|
|
if(!isset($TEXT)) { |
|
53
|
|
|
if($INFO['exists']) { |
|
54
|
|
|
if($RANGE) { |
|
55
|
|
|
list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV); |
|
56
|
|
|
} else { |
|
57
|
|
|
$TEXT = rawWiki($ID, $REV); |
|
58
|
|
|
} |
|
59
|
|
|
} else { |
|
60
|
|
|
$TEXT = pageTemplate($ID); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
//set summary default |
|
65
|
|
|
if(!$SUM) { |
|
66
|
|
|
if($REV) { |
|
67
|
|
|
$SUM = sprintf($lang['restored'], dformat($REV)); |
|
68
|
|
|
} elseif(!$INFO['exists']) { |
|
69
|
|
|
$SUM = $lang['created']; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
// Use the date of the newest revision, not of the revision we edit |
|
74
|
|
|
// This is used for conflict detection |
|
75
|
|
|
if(!$DATE) $DATE = @filemtime(wikiFN($ID)); |
|
76
|
|
|
|
|
77
|
|
|
//check if locked by anyone - if not lock for my self |
|
78
|
|
|
$lockedby = checklock($ID); |
|
79
|
|
|
if($lockedby) { |
|
80
|
|
|
throw new ActionAbort('locked'); |
|
81
|
|
|
}; |
|
82
|
|
|
lock($ID); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function tplContent() { |
|
86
|
|
|
html_edit(); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.