blob: e8ac347b2dfe452c2fe0aac603757ab14445b3cd (
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
<?php
namespace dokuwiki\Action;
use dokuwiki\Ui\Editor;
use dokuwiki\Action\Exception\ActionAbort;
use dokuwiki\Ui;
/**
* Class Edit
*
* Handle editing
*
* @package dokuwiki\Action
*/
class Edit extends AbstractAction
{
/** @inheritdoc */
public function minimumPermission()
{
global $INFO;
if ($INFO['exists']) {
return AUTH_READ; // we check again below
} else {
return AUTH_CREATE;
}
}
/**
* @inheritdoc falls back to 'source' if page not writable
*/
public function checkPreconditions()
{
parent::checkPreconditions();
global $INFO;
// no edit permission? view source
if ($INFO['exists'] && !$INFO['writable']) {
throw new ActionAbort('source');
}
}
/** @inheritdoc */
public function preProcess()
{
global $ID;
global $INFO;
global $TEXT;
global $RANGE;
global $PRE;
global $SUF;
global $REV;
global $SUM;
global $lang;
global $DATE;
if (!isset($TEXT)) {
if ($INFO['exists']) {
if ($RANGE) {
[$PRE, $TEXT, $SUF] = rawWikiSlices($RANGE, $ID, $REV);
} else {
$TEXT = rawWiki($ID, $REV);
}
} else {
$TEXT = pageTemplate($ID);
}
}
//set summary default
if (!$SUM) {
if ($REV) {
$SUM = sprintf($lang['restored'], dformat($REV));
} elseif (!$INFO['exists']) {
$SUM = $lang['created'];
}
}
// Use the date of the newest revision, not of the revision we edit
// This is used for conflict detection
if (!$DATE) $DATE = @filemtime(wikiFN($ID));
//check if locked by anyone - if not lock for my self
$lockedby = checklock($ID);
if ($lockedby) {
throw new ActionAbort('locked');
}
lock($ID);
}
/** @inheritdoc */
public function tplContent()
{
(new Editor())->show();
}
}
|