You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

97 lines
2.1 KiB

  1. <?php
  2. namespace dokuwiki\Action;
  3. use dokuwiki\Ui\Editor;
  4. use dokuwiki\Action\Exception\ActionAbort;
  5. use dokuwiki\Ui;
  6. /**
  7. * Class Edit
  8. *
  9. * Handle editing
  10. *
  11. * @package dokuwiki\Action
  12. */
  13. class Edit extends AbstractAction
  14. {
  15. /** @inheritdoc */
  16. public function minimumPermission()
  17. {
  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. * @inheritdoc falls back to 'source' if page not writable
  27. */
  28. public function checkPreconditions()
  29. {
  30. parent::checkPreconditions();
  31. global $INFO;
  32. // no edit permission? view source
  33. if ($INFO['exists'] && !$INFO['writable']) {
  34. throw new ActionAbort('source');
  35. }
  36. }
  37. /** @inheritdoc */
  38. public function preProcess()
  39. {
  40. global $ID;
  41. global $INFO;
  42. global $TEXT;
  43. global $RANGE;
  44. global $PRE;
  45. global $SUF;
  46. global $REV;
  47. global $SUM;
  48. global $lang;
  49. global $DATE;
  50. if (!isset($TEXT)) {
  51. if ($INFO['exists']) {
  52. if ($RANGE) {
  53. [$PRE, $TEXT, $SUF] = rawWikiSlices($RANGE, $ID, $REV);
  54. } else {
  55. $TEXT = rawWiki($ID, $REV);
  56. }
  57. } else {
  58. $TEXT = pageTemplate($ID);
  59. }
  60. }
  61. //set summary default
  62. if (!$SUM) {
  63. if ($REV) {
  64. $SUM = sprintf($lang['restored'], dformat($REV));
  65. } elseif (!$INFO['exists']) {
  66. $SUM = $lang['created'];
  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. //check if locked by anyone - if not lock for my self
  73. $lockedby = checklock($ID);
  74. if ($lockedby) {
  75. throw new ActionAbort('locked');
  76. }
  77. lock($ID);
  78. }
  79. /** @inheritdoc */
  80. public function tplContent()
  81. {
  82. (new Editor())->show();
  83. }
  84. }