PageDraft.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace dokuwiki\Ui;
  3. use dokuwiki\Draft;
  4. use dokuwiki\Form\Form;
  5. /**
  6. * DokuWiki Page Draft Interface
  7. *
  8. * @package dokuwiki\Ui
  9. */
  10. class PageDraft extends Ui
  11. {
  12. /**
  13. * Display the Page Draft Form
  14. * ask the user about how to handle an exisiting draft
  15. *
  16. * @author Andreas Gohr <andi@splitbrain.org>
  17. *
  18. * @return void
  19. */
  20. public function show()
  21. {
  22. global $INFO;
  23. global $lang;
  24. $draft = new Draft($INFO['id'], $INFO['client']);
  25. $text = $draft->getDraftText();
  26. // print intro
  27. print p_locale_xhtml('draft');
  28. // print difference
  29. (new PageDiff($INFO['id']))->compareWith($text)->preference('showIntro', false)->show();
  30. // create the draft form
  31. $form = new Form(['id' => 'dw__editform']);
  32. $form->addTagOpen('div')->addClass('no');
  33. $form->setHiddenField('id', $INFO['id']);
  34. $form->setHiddenField('date', $draft->getDraftDate());
  35. $form->setHiddenField('wikitext', $text);
  36. $form->addTagOpen('div')->id('draft__status');
  37. $form->addHTML($draft->getDraftMessage());
  38. $form->addTagClose('div');
  39. $form->addButton('do[recover]', $lang['btn_recover'] )->attrs(['type' => 'submit', 'tabindex' => '1']);
  40. $form->addButton('do[draftdel]', $lang['btn_draftdel'])->attrs(['type' => 'submit', 'tabindex' => '2']);
  41. $form->addButton('do[show]', $lang['btn_cancel'] )->attrs(['type' => 'submit', 'tabindex' => '3']);
  42. $form->addTagClose('div');
  43. print $form->toHTML('Draft');
  44. }
  45. }