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