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