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.
 
 
 
 
 

50 lines
922 B

  1. <?php
  2. namespace dokuwiki\Action;
  3. use dokuwiki\Ui\Editor;
  4. use dokuwiki\Ui\PageView;
  5. use dokuwiki\Draft;
  6. use dokuwiki\Ui;
  7. /**
  8. * Class Preview
  9. *
  10. * preview during editing
  11. *
  12. * @package dokuwiki\Action
  13. */
  14. class Preview extends Edit
  15. {
  16. /** @inheritdoc */
  17. public function preProcess()
  18. {
  19. header('X-XSS-Protection: 0');
  20. $this->savedraft();
  21. parent::preProcess();
  22. }
  23. /** @inheritdoc */
  24. public function tplContent()
  25. {
  26. global $TEXT;
  27. (new Editor())->show();
  28. (new PageView($TEXT))->show();
  29. }
  30. /**
  31. * Saves a draft on preview
  32. */
  33. protected function savedraft()
  34. {
  35. global $ID, $INFO;
  36. $draft = new Draft($ID, $INFO['client']);
  37. if (!$draft->saveDraft()) {
  38. $errors = $draft->getErrors();
  39. foreach ($errors as $error) {
  40. msg(hsc($error), -1);
  41. }
  42. }
  43. }
  44. }