PageConflict.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace dokuwiki\Ui;
  3. use dokuwiki\Form\Form;
  4. /**
  5. * DokuWiki Page Conflict Interface
  6. *
  7. * @package dokuwiki\Ui
  8. */
  9. class PageConflict extends Ui
  10. {
  11. protected $text;
  12. protected $summary;
  13. /**
  14. * PageConflict Ui constructor
  15. *
  16. * @param string $text wiki text
  17. * @param string $summary edit summary
  18. */
  19. public function __construct($text = '', $summary = '')
  20. {
  21. $this->text = $text;
  22. $this->summary = $summary;
  23. }
  24. /**
  25. * Show conflict form to ask whether save anyway or cancel the page edits
  26. *
  27. * @author Andreas Gohr <andi@splitbrain.org>
  28. *
  29. * @return void
  30. */
  31. public function show()
  32. {
  33. global $INFO;
  34. global $lang;
  35. // print intro
  36. print p_locale_xhtml('conflict');
  37. // create the form
  38. $form = new Form(['id' => 'dw__editform']);
  39. $form->addTagOpen('div')->addClass('no');
  40. $form->setHiddenField('id', $INFO['id']);
  41. $form->setHiddenField('wikitext', $this->text);
  42. $form->setHiddenField('summary', $this->summary);
  43. $form->addButton('do[save]', $lang['btn_save'] )->attrs(['type' => 'submit', 'accesskey' => 's']);
  44. $form->addButton('do[cancel]', $lang['btn_cancel'] )->attrs(['type' => 'submit']);
  45. $form->addTagClose('div');
  46. print $form->toHTML('Conflict');
  47. print '<br /><br /><br /><br />';
  48. // print difference
  49. (new PageDiff($INFO['id']))->compareWith($this->text)->preference('showIntro', false)->show();
  50. }
  51. }