1<?php 2 3require_once DOKU_PLUGIN.'odt/ODT/elements/ODTStateElement.php'; 4 5/** 6 * ODTElementList: 7 * Class for handling the list element. 8 * 9 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 10 * @author LarsDW223 11 */ 12class ODTElementList extends ODTStateElement 13{ 14 // List state data 15 protected $continue_numbering; 16 protected $in_list = false; 17 protected $list_first_paragraph = true; 18 protected $list_paragraph_pos = -1; 19 20 /** 21 * Constructor. 22 */ 23 public function __construct($style_name=NULL, $continue=false) { 24 parent::__construct(); 25 $this->setClass ('list'); 26 if (isset($style_name)) { 27 $this->setStyleName ($style_name); 28 } 29 $this->setContinueNumbering ($continue); 30 } 31 32 /** 33 * Return the elements name. 34 * 35 * @return string The ODT XML element name. 36 */ 37 public function getElementName () { 38 return ('text:list'); 39 } 40 41 /** 42 * Return string with encoded opening tag. 43 * 44 * @return string The ODT XML code to open this element. 45 */ 46 public function getOpeningTag () { 47 $encoded = '<text:list text:style-name="'.$this->getStyleName().'"'; 48 if ($this->getContinueNumbering()) { 49 $encoded .= ' text:continue-numbering="true" '; 50 } else { 51 if ($this->in_list === false) { 52 $encoded .= ' text:continue-numbering="false" '; 53 } 54 } 55 $encoded .= '>'; 56 return $encoded; 57 } 58 59 /** 60 * Return string with encoded closing tag. 61 * 62 * @return string The ODT XML code to close this element. 63 */ 64 public function getClosingTag () { 65 return '</text:list>'; 66 } 67 68 /** 69 * Are we in a paragraph or not? 70 * As a list we are not. 71 * 72 * @return boolean 73 */ 74 public function getInParagraph() { 75 return false; 76 } 77 78 /** 79 * Determine and set the parent for this element. 80 * As a list the previous element is our parent. 81 * 82 * @param ODTStateElement $previous 83 */ 84 public function determineParent(ODTStateElement $previous) { 85 $this->setParent($previous); 86 87 // Check if this is a nested list 88 while (isset($previous)) { 89 if ($previous->getClass() == 'list') { 90 break; 91 } 92 $previous = $previous->getParent(); 93 } 94 if (isset($previous)) { 95 // Yes, nested list. 96 $this->in_list = true; 97 } 98 } 99 100 /** 101 * Set continue numbering to $value 102 * 103 * @param bool $value 104 */ 105 public function setContinueNumbering($value) { 106 $this->continue_numbering = $value; 107 } 108 109 /** 110 * Get continue numbering to $value 111 * 112 * @return bool 113 */ 114 public function getContinueNumbering() { 115 return $this->continue_numbering; 116 } 117 118 /** 119 * Set flag if the next paragraph will be the first in the list 120 * 121 * @param boolean $value 122 */ 123 public function setListFirstParagraph($value) { 124 $this->list_first_paragraph = $value; 125 } 126 127 /** 128 * Get flag if the next paragraph will be the first in the list 129 * 130 * @return boolean 131 */ 132 public function getListFirstParagraph() { 133 return $this->list_first_paragraph; 134 } 135 136 /** 137 * Set position of last opened paragraph in the list 138 * 139 * @param integer $value 140 */ 141 public function setListLastParagraphPosition($value) { 142 $this->list_paragraph_pos = $value; 143 } 144 145 /** 146 * Get position of last opened paragraph in the list 147 * 148 * @return integer 149 */ 150 public function getListLastParagraphPosition() { 151 return $this->list_paragraph_pos; 152 } 153} 154