MediaPlayer.php 4.5 KB

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