MediaThumbnail.php 5.2 KB

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