1<?php
2/**
3 * FarmSync DokuWiki Plugin
4 *
5 * @author Michael Große <grosse@cosmocode.de>
6 * @license GPL 2
7 */
8
9namespace dokuwiki\plugin\farmsync\meta;
10
11use dokuwiki\Form\Form;
12
13/**
14 * Display conflicts in page updates
15 */
16class PageConflict extends UpdateResults {
17
18    private $_conflictingBlocks;
19
20    /**
21     * @return int
22     */
23    public function getConflictingBlocks() {
24        return $this->_conflictingBlocks;
25    }
26
27    /**
28     * @param int $conflictingBlocks
29     */
30    public function setConflictingBlocks($conflictingBlocks) {
31        $this->_conflictingBlocks = $conflictingBlocks;
32    }
33
34    /**
35     * Adds conflict resolution form
36     *
37     * @return string
38     */
39    public function getResultLine() {
40        $result = parent::getResultLine();
41        $form = new Form();
42        $form->attr('data-animal', $this->getAnimal())->attr("data-page", $this->getItem());
43        $form->addButton("theirs", $this->helper->getLang('button:keep'));
44        $form->addButton("override", $this->helper->getLang('button:overwrite'));
45        $form->addButton("edit", $this->helper->getLang('button:edit'));
46        $form->addButton("diff", $this->helper->getLang('button:diff'));
47        $form->addTagOpen('div')->addClass('editconflict');
48        $form->addTagOpen('div')->attr("style", "display:flex");
49        $form->addTextarea('editarea')->val($this->getFinalText());
50        $form->addTagOpen('div')->addClass('conflictlist');
51        $form->addHTML('<h4>' . $this->helper->getLang('heading:conflicts') . '</h4>');
52        $form->addHTML('<ol></ol>');
53        $form->addTagClose('div');
54        $form->addTagClose('div');
55        $form->addTagClose('div');
56        $form->addTextarea('backup')->val($this->getFinalText())->attr("style", "display:none;");
57        $form->addButton("save", "save")->attr("style", "display:none;");
58        $form->addButton("cancel", "cancel")->attr("style", "display:none;");
59        $result .= $form->toHTML();
60        return $result;
61    }
62}
63