MediaPlayer.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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:player 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_MediaPlayer extends Zend_Gdata_Extension
  35. {
  36. protected $_rootElement = 'player';
  37. protected $_rootNamespace = 'media';
  38. /**
  39. * @var string
  40. */
  41. protected $_url = null;
  42. /**
  43. * @var int
  44. */
  45. protected $_width = null;
  46. /**
  47. * @var int
  48. */
  49. protected $_height = null;
  50. /**
  51. * Constructs a new MediaPlayer element
  52. *
  53. * @param string $url
  54. * @param int $width
  55. * @param int $height
  56. */
  57. public function __construct($url = null, $width = null, $height = null)
  58. {
  59. $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
  60. parent::__construct();
  61. $this->_url = $url;
  62. $this->_width = $width;
  63. $this->_height = $height;
  64. }
  65. /**
  66. * Retrieves a DOMElement which corresponds to this element and all
  67. * child properties. This is used to build an entry back into a DOM
  68. * and eventually XML text for sending to the server upon updates, or
  69. * for application storage/persistence.
  70. *
  71. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  72. * @return DOMElement The DOMElement representing this element and all
  73. * child properties.
  74. */
  75. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  76. {
  77. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  78. if ($this->_url !== null) {
  79. $element->setAttribute('url', $this->_url);
  80. }
  81. if ($this->_width !== null) {
  82. $element->setAttribute('width', $this->_width);
  83. }
  84. if ($this->_height !== null) {
  85. $element->setAttribute('height', $this->_height);
  86. }
  87. return $element;
  88. }
  89. /**
  90. * Given a DOMNode representing an attribute, tries to map the data into
  91. * instance members. If no mapping is defined, the name and value are
  92. * stored in an array.
  93. *
  94. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  95. */
  96. protected function takeAttributeFromDOM($attribute)
  97. {
  98. switch ($attribute->localName) {
  99. case 'url':
  100. $this->_url = $attribute->nodeValue;
  101. break;
  102. case 'width':
  103. $this->_width = $attribute->nodeValue;
  104. break;
  105. case 'height':
  106. $this->_height = $attribute->nodeValue;
  107. break;
  108. default:
  109. parent::takeAttributeFromDOM($attribute);
  110. }
  111. }
  112. /**
  113. * @return string
  114. */
  115. public function getUrl()
  116. {
  117. return $this->_url;
  118. }
  119. /**
  120. * @param string $value
  121. * @return Zend_Gdata_Media_Extension_MediaPlayer Provides a fluent interface
  122. */
  123. public function setUrl($value)
  124. {
  125. $this->_url = $value;
  126. return $this;
  127. }
  128. /**
  129. * @return int
  130. */
  131. public function getWidth()
  132. {
  133. return $this->_width;
  134. }
  135. /**
  136. * @param int $value
  137. * @return Zend_Gdata_Media_Extension_MediaPlayer Provides a fluent interface
  138. */
  139. public function setWidth($value)
  140. {
  141. $this->_width = $value;
  142. return $this;
  143. }
  144. /**
  145. * @return int
  146. */
  147. public function getHeight()
  148. {
  149. return $this->_height;
  150. }
  151. /**
  152. * @param int $value
  153. * @return Zend_Gdata_Media_Extension_MediaPlayer Provides a fluent interface
  154. */
  155. public function setHeight($value)
  156. {
  157. $this->_height = $value;
  158. return $this;
  159. }
  160. }