diff options
author | ahriman <ahriman@falte.red> | 2018-12-03 19:22:25 -0500 |
---|---|---|
committer | ahriman <ahriman@falte.red> | 2018-12-03 19:22:25 -0500 |
commit | 0ae8cbf5c0b1a198b963490985b7738392ebcb97 (patch) | |
tree | b2c77ae72c6b717e2b97492065196ac5ffb2d9e2 /wiki/inc/Action/Edit.php | |
parent | f57f6cc5a2d159f90168d292437dc4bd8cd7f934 (diff) | |
download | site-0ae8cbf5c0b1a198b963490985b7738392ebcb97.tar.gz |
installed dokuwiki, added to navbar, updated news
Diffstat (limited to 'wiki/inc/Action/Edit.php')
-rw-r--r-- | wiki/inc/Action/Edit.php | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/wiki/inc/Action/Edit.php b/wiki/inc/Action/Edit.php new file mode 100644 index 0000000..061c9e2 --- /dev/null +++ b/wiki/inc/Action/Edit.php @@ -0,0 +1,91 @@ +<?php + +namespace dokuwiki\Action; + +use dokuwiki\Action\Exception\ActionAbort; + +/** + * 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) { + list($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() { + html_edit(); + } + +} |