1<?php
2
3require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php';
4
5/**
6 * ODTElementListHeader:
7 * Class for handling the list header element.
8 *
9 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
10 * @author  LarsDW223
11 */
12class ODTElementListHeader extends ODTStateElement
13{
14    // List item state data
15    protected $in_list_item = false;
16    protected $list_item_level = 0;
17
18    /**
19     * Constructor.
20     */
21    public function __construct($level=0) {
22        parent::__construct();
23        $this->setClass ('list-item');
24        $this->setListItemLevel ($level);
25    }
26
27    /**
28     * Return the elements name.
29     *
30     * @return string The ODT XML element name.
31     */
32    public function getElementName () {
33        return ('text:list-header');
34    }
35
36    /**
37     * Return string with encoded opening tag.
38     *
39     * @return string The ODT XML code to open this element.
40     */
41    public function getOpeningTag () {
42        return '<text:list-header>';
43    }
44
45    /**
46     * Return string with encoded closing tag.
47     *
48     * @return string The ODT XML code to close this element.
49     */
50    public function getClosingTag () {
51        return '</text:list-header>';
52    }
53
54    /**
55     * Are we in a paragraph or not?
56     * As a list item we are not.
57     *
58     * @return boolean
59     */
60    public function getInParagraph() {
61        return false;
62    }
63
64    /**
65     * Determine and set the parent for this element.
66     * As a list item the list element is our parent.
67     *
68     * @param ODTStateElement $previous
69     */
70    public function determineParent(ODTStateElement $previous) {
71        while (isset($previous)) {
72            if ($previous->getClass() == 'list') {
73                break;
74            }
75            $previous = $previous->getParent();
76        }
77        $this->setParent($previous);
78    }
79
80    /**
81     * Set the level for an list item
82     *
83     * @param integer $value
84     */
85    public function setListItemLevel($value) {
86        $this->list_item_level = $value;
87    }
88
89    /**
90     * Get level of a list item
91     *
92     * @return integer
93     */
94    public function getListItemLevel() {
95        return $this->list_item_level;
96    }
97
98    /**
99     * Return the list to which this list item belongs.
100     *
101     * @return ODTStateElement
102     */
103    public function getList () {
104        return $this->getParent();
105    }
106}
107