SDT.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @see https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2018 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Element;
  18. /**
  19. * Structured document tag (SDT) element
  20. *
  21. * @since 0.12.0
  22. */
  23. class SDT extends Text
  24. {
  25. /**
  26. * Form field type: comboBox|dropDownList|date
  27. *
  28. * @var string
  29. */
  30. private $type;
  31. /**
  32. * Value
  33. *
  34. * @var string|bool|int
  35. */
  36. private $value;
  37. /**
  38. * CheckBox/DropDown list entries
  39. *
  40. * @var array
  41. */
  42. private $listItems = array();
  43. /**
  44. * Alias
  45. *
  46. * @var string
  47. */
  48. private $alias;
  49. /**
  50. * Tag
  51. *
  52. * @var string
  53. */
  54. private $tag;
  55. /**
  56. * Create new instance
  57. *
  58. * @param string $type
  59. * @param mixed $fontStyle
  60. * @param mixed $paragraphStyle
  61. */
  62. public function __construct($type, $fontStyle = null, $paragraphStyle = null)
  63. {
  64. parent::__construct(null, $fontStyle, $paragraphStyle);
  65. $this->setType($type);
  66. }
  67. /**
  68. * Get type
  69. *
  70. * @return string
  71. */
  72. public function getType()
  73. {
  74. return $this->type;
  75. }
  76. /**
  77. * Set type
  78. *
  79. * @param string $value
  80. * @return self
  81. */
  82. public function setType($value)
  83. {
  84. $enum = array('plainText', 'comboBox', 'dropDownList', 'date');
  85. $this->type = $this->setEnumVal($value, $enum, 'comboBox');
  86. return $this;
  87. }
  88. /**
  89. * Get value
  90. *
  91. * @return string|bool|int
  92. */
  93. public function getValue()
  94. {
  95. return $this->value;
  96. }
  97. /**
  98. * Set value
  99. *
  100. * @param string|bool|int $value
  101. * @return self
  102. */
  103. public function setValue($value)
  104. {
  105. $this->value = $value;
  106. return $this;
  107. }
  108. /**
  109. * Get listItems
  110. *
  111. * @return array
  112. */
  113. public function getListItems()
  114. {
  115. return $this->listItems;
  116. }
  117. /**
  118. * Set listItems
  119. *
  120. * @param array $value
  121. * @return self
  122. */
  123. public function setListItems($value)
  124. {
  125. $this->listItems = $value;
  126. return $this;
  127. }
  128. /**
  129. * Get tag
  130. *
  131. * @return string
  132. */
  133. public function getTag()
  134. {
  135. return $this->tag;
  136. }
  137. /**
  138. * Set tag
  139. *
  140. * @param string $tag
  141. * @return self
  142. */
  143. public function setTag($tag)
  144. {
  145. $this->tag = $tag;
  146. return $this;
  147. }
  148. /**
  149. * Get alias
  150. *
  151. * @return string
  152. */
  153. public function getAlias()
  154. {
  155. return $this->alias;
  156. }
  157. /**
  158. * Set alias
  159. *
  160. * @param string $alias
  161. * @return self
  162. */
  163. public function setAlias($alias)
  164. {
  165. $this->alias = $alias;
  166. return $this;
  167. }
  168. }