Preview.php 867 B

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