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