MediaText.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage Media
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Gdata_App_Extension
  23. */
  24. require_once 'Zend/Gdata/App/Extension.php';
  25. /**
  26. * Represents the media:text element
  27. *
  28. * @category Zend
  29. * @package Zend_Gdata
  30. * @subpackage Media
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Gdata_Media_Extension_MediaText extends Zend_Gdata_Extension
  35. {
  36. protected $_rootElement = 'text';
  37. protected $_rootNamespace = 'media';
  38. /**
  39. * @var string
  40. */
  41. protected $_type = null;
  42. /**
  43. * @var string
  44. */
  45. protected $_lang = null;
  46. /**
  47. * @var string
  48. */
  49. protected $_start = null;
  50. /**
  51. * @var string
  52. */
  53. protected $_end = null;
  54. /**
  55. * Constructs a new MediaText element
  56. *
  57. * @param $text string
  58. * @param $type string
  59. * @param $lang string
  60. * @param $start string
  61. * @param $end string
  62. */
  63. public function __construct($text = null, $type = null, $lang = null,
  64. $start = null, $end = null)
  65. {
  66. $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
  67. parent::__construct();
  68. $this->_text = $text;
  69. $this->_type = $type;
  70. $this->_lang = $lang;
  71. $this->_start = $start;
  72. $this->_end = $end;
  73. }
  74. /**
  75. * Retrieves a DOMElement which corresponds to this element and all
  76. * child properties. This is used to build an entry back into a DOM
  77. * and eventually XML text for sending to the server upon updates, or
  78. * for application storage/persistence.
  79. *
  80. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  81. * @return DOMElement The DOMElement representing this element and all
  82. * child properties.
  83. */
  84. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  85. {
  86. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  87. if ($this->_type !== null) {
  88. $element->setAttribute('type', $this->_type);
  89. }
  90. if ($this->_lang !== null) {
  91. $element->setAttribute('lang', $this->_lang);
  92. }
  93. if ($this->_start !== null) {
  94. $element->setAttribute('start', $this->_start);
  95. }
  96. if ($this->_end !== null) {
  97. $element->setAttribute('end', $this->_end);
  98. }
  99. return $element;
  100. }
  101. /**
  102. * Given a DOMNode representing an attribute, tries to map the data into
  103. * instance members. If no mapping is defined, the name and value are
  104. * stored in an array.
  105. *
  106. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  107. */
  108. protected function takeAttributeFromDOM($attribute)
  109. {
  110. switch ($attribute->localName) {
  111. case 'type':
  112. $this->_type = $attribute->nodeValue;
  113. break;
  114. case 'lang':
  115. $this->_lang = $attribute->nodeValue;
  116. break;
  117. case 'start':
  118. $this->_start = $attribute->nodeValue;
  119. break;
  120. case 'end':
  121. $this->_end = $attribute->nodeValue;
  122. break;
  123. default:
  124. parent::takeAttributeFromDOM($attribute);
  125. }
  126. }
  127. /**
  128. * @return string
  129. */
  130. public function getType()
  131. {
  132. return $this->_type;
  133. }
  134. /**
  135. * @param string $value
  136. * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface
  137. */
  138. public function setType($value)
  139. {
  140. $this->_type = $value;
  141. return $this;
  142. }
  143. /**
  144. * @return string
  145. */
  146. public function getLang()
  147. {
  148. return $this->_lang;
  149. }
  150. /**
  151. * @param string $value
  152. * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface
  153. */
  154. public function setLang($value)
  155. {
  156. $this->_lang = $value;
  157. return $this;
  158. }
  159. /**
  160. * @return string
  161. */
  162. public function getStart()
  163. {
  164. return $this->_start;
  165. }
  166. /**
  167. * @param string $value
  168. * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface
  169. */
  170. public function setStart($value)
  171. {
  172. $this->_start = $value;
  173. return $this;
  174. }
  175. /**
  176. * @return string
  177. */
  178. public function getEnd()
  179. {
  180. return $this->_end;
  181. }
  182. /**
  183. * @param string $value
  184. * @return Zend_Gdata_Media_Extension_MediaText Provides a fluent interface
  185. */
  186. public function setEnd($value)
  187. {
  188. $this->_end = $value;
  189. return $this;
  190. }
  191. }