1<?php 2 3/** 4 * ODTStateElement: 5 * Base class for all elements which are added/used with class ODTState. 6 * 7 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 8 * @author LarsDW223 9 */ 10abstract class ODTStateElement 11{ 12 // General state information 13 protected $clazz = NULL; 14 protected $style_name = NULL; 15 protected $count = 0; 16 protected $parent_element = NULL; 17 protected $style_obj = NULL; 18 protected $htmlElement = NULL; 19 20 // Temp pointer for various use! Can point to different things! 21 protected $temp = NULL; 22 23 /** 24 * Constructor. 25 */ 26 public function __construct($style_name=NULL) { 27 // Empty for now. 28 // All elements call the parent constructor so it might be 29 // of use in the future... 30 } 31 32 /** 33 * Set the class to $value. 34 * 35 * @param string $value Class, e.g. 'paragraph' 36 */ 37 public function setClass($value) { 38 $this->clazz = $value; 39 } 40 41 /** 42 * Get the class. 43 * 44 * @return string Class. 45 */ 46 public function getClass() { 47 return $this->clazz; 48 } 49 50 /** 51 * Set the element count to $value. 52 * If e.g. the element is 'table', then the count specifies 53 * that this element is table number '$value'. 54 * 55 * @param string $value Count 56 */ 57 public function setCount($value) { 58 $this->count = $value; 59 } 60 61 /** 62 * Get the element count. 63 * 64 * @return integer Count. 65 */ 66 public function getCount() { 67 return $this->count; 68 } 69 70 /** 71 * Set the style name. 72 * 73 * @param string $value Style name, e.g. 'body' 74 */ 75 public function setStyleName($value) { 76 $this->style_name = $value; 77 } 78 79 /** 80 * Get the style name. 81 * 82 * @return string Style name. 83 */ 84 public function getStyleName() { 85 return $this->style_name; 86 } 87 88 /** 89 * Set the style object. 90 * 91 * @param ODTStyle $object 92 */ 93 public function setStyle($object) { 94 $this->style_obj = $object; 95 } 96 97 /** 98 * Get the style object. 99 * 100 * @return ODTStyle Style object. 101 */ 102 public function getStyle() { 103 return $this->style_obj; 104 } 105 106 /** 107 * Set temporary data for various use. 108 * 109 * @param mixed $value 110 */ 111 public function setTemp($value) { 112 $this->temp = $value; 113 } 114 115 /** 116 * Get temporary data for various use. 117 * 118 * @return mixed 119 */ 120 public function getTemp() { 121 return $this->temp; 122 } 123 124 /** 125 * Set parent of this element. 126 * 127 * @param ODTStateElement $parent_element 128 */ 129 public function setParent(ODTStateElement $parent_element) { 130 $this->parent_element = $parent_element; 131 } 132 133 /** 134 * Get parent of this element. 135 * 136 * @return ODTStateElement 137 */ 138 public function getParent() { 139 return $this->parent_element; 140 } 141 142 /** 143 * Return the elements name. 144 * 145 * @return string The ODT XML element name. 146 */ 147 abstract public function getElementName (); 148 149 /** 150 * Return string with encoded opening tag. 151 * 152 * @return string The ODT XML code to open this element. 153 */ 154 abstract public function getOpeningTag (); 155 156 /** 157 * Return string with encoded closing tag. 158 * 159 * @return string The ODT XML code to close this element. 160 */ 161 abstract public function getClosingTag (); 162 163 /** 164 * Are we in a paragraph or not? 165 * 166 * @return boolean 167 */ 168 abstract public function getInParagraph(); 169 170 /** 171 * Determine and set the parent for this element. 172 * The search starts at element $previous. 173 */ 174 abstract public function determineParent(ODTStateElement $previous); 175 176 /** 177 * Set the HTML element name pushed to the HTML stack for this ODT element. 178 * 179 * @param string $value HTML element name e.g. 'u' 180 */ 181 public function setHTMLElement($value) { 182 $this->htmlElement = $value; 183 } 184 185 /** 186 * Get the HTML element name pushed to the HTML stack for this ODT element. 187 * 188 * @return string HTML element name. 189 */ 190 public function getHTMLElement() { 191 return $this->htmlElement; 192 } 193} 194