MediaGroup.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 YouTube
  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_Media_Extension_MediaGroup
  23. */
  24. require_once 'Zend/Gdata/Media/Extension/MediaGroup.php';
  25. /**
  26. * @see Zend_Gdata_YouTube_Extension_MediaContent
  27. */
  28. require_once 'Zend/Gdata/YouTube/Extension/MediaContent.php';
  29. /**
  30. * @see Zend_Gdata_YouTube_Extension_Duration
  31. */
  32. require_once 'Zend/Gdata/YouTube/Extension/Duration.php';
  33. /**
  34. * @see Zend_Gdata_YouTube_Extension_MediaRating
  35. */
  36. require_once 'Zend/Gdata/YouTube/Extension/MediaRating.php';
  37. /**
  38. * @see Zend_Gdata_YouTube_Extension_MediaCredit
  39. */
  40. require_once 'Zend/Gdata/YouTube/Extension/MediaCredit.php';
  41. /**
  42. * @see Zend_Gdata_YouTube_Extension_Private
  43. */
  44. require_once 'Zend/Gdata/YouTube/Extension/Private.php';
  45. /**
  46. * @see Zend_Gdata_YouTube_Extension_VideoId
  47. */
  48. require_once 'Zend/Gdata/YouTube/Extension/VideoId.php';
  49. /**
  50. * @see Zend_Gdata_YouTube_Extension_Uploaded
  51. */
  52. require_once 'Zend/Gdata/YouTube/Extension/Uploaded.php';
  53. /**
  54. * This class represents the media:group element of Media RSS.
  55. * It allows the grouping of media:content elements that are
  56. * different representations of the same content. When it exists,
  57. * it is a child of an Entry (Atom) or Item (RSS).
  58. *
  59. * @category Zend
  60. * @package Zend_Gdata
  61. * @subpackage YouTube
  62. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  63. * @license http://framework.zend.com/license/new-bsd New BSD License
  64. */
  65. class Zend_Gdata_YouTube_Extension_MediaGroup extends Zend_Gdata_Media_Extension_MediaGroup
  66. {
  67. protected $_rootElement = 'group';
  68. protected $_rootNamespace = 'media';
  69. /**
  70. * @var Zend_Gdata_YouTube_Extension_Duration
  71. */
  72. protected $_duration = null;
  73. /**
  74. * @var Zend_Gdata_YouTube_Extension_Private
  75. */
  76. protected $_private = null;
  77. /**
  78. * @var Zend_Gdata_YouTube_Extension_VideoId
  79. */
  80. protected $_videoid = null;
  81. /**
  82. * @var Zend_Gdata_YouTube_Extension_MediaRating
  83. */
  84. protected $_mediarating = null;
  85. /**
  86. * @var Zend_Gdata_YouTube_Extension_MediaCredit
  87. */
  88. protected $_mediacredit = null;
  89. /**
  90. * @var Zend_Gdata_YouTube_Extension_Uploaded
  91. */
  92. protected $_uploaded = null;
  93. public function __construct($element = null)
  94. {
  95. $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  96. parent::__construct($element);
  97. }
  98. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  99. {
  100. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  101. if ($this->_duration !== null) {
  102. $element->appendChild(
  103. $this->_duration->getDOM($element->ownerDocument));
  104. }
  105. if ($this->_private !== null) {
  106. $element->appendChild(
  107. $this->_private->getDOM($element->ownerDocument));
  108. }
  109. if ($this->_videoid != null) {
  110. $element->appendChild(
  111. $this->_videoid->getDOM($element->ownerDocument));
  112. }
  113. if ($this->_uploaded != null) {
  114. $element->appendChild(
  115. $this->_uploaded->getDOM($element->ownerDocument));
  116. }
  117. if ($this->_mediacredit != null) {
  118. $element->appendChild(
  119. $this->_mediacredit->getDOM($element->ownerDocument));
  120. }
  121. if ($this->_mediarating != null) {
  122. $element->appendChild(
  123. $this->_mediarating->getDOM($element->ownerDocument));
  124. }
  125. return $element;
  126. }
  127. /**
  128. * Creates individual Entry objects of the appropriate type and
  129. * stores them in the $_entry array based upon DOM data.
  130. *
  131. * @param DOMNode $child The DOMNode to process
  132. */
  133. protected function takeChildFromDOM($child)
  134. {
  135. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  136. switch ($absoluteNodeName) {
  137. case $this->lookupNamespace('media') . ':' . 'content':
  138. $content = new Zend_Gdata_YouTube_Extension_MediaContent();
  139. $content->transferFromDOM($child);
  140. $this->_content[] = $content;
  141. break;
  142. case $this->lookupNamespace('media') . ':' . 'rating':
  143. $mediarating = new Zend_Gdata_YouTube_Extension_MediaRating();
  144. $mediarating->transferFromDOM($child);
  145. $this->_mediarating = $mediarating;
  146. break;
  147. case $this->lookupNamespace('media') . ':' . 'credit':
  148. $mediacredit = new Zend_Gdata_YouTube_Extension_MediaCredit();
  149. $mediacredit->transferFromDOM($child);
  150. $this->_mediacredit = $mediacredit;
  151. break;
  152. case $this->lookupNamespace('yt') . ':' . 'duration':
  153. $duration = new Zend_Gdata_YouTube_Extension_Duration();
  154. $duration->transferFromDOM($child);
  155. $this->_duration = $duration;
  156. break;
  157. case $this->lookupNamespace('yt') . ':' . 'private':
  158. $private = new Zend_Gdata_YouTube_Extension_Private();
  159. $private->transferFromDOM($child);
  160. $this->_private = $private;
  161. break;
  162. case $this->lookupNamespace('yt') . ':' . 'videoid':
  163. $videoid = new Zend_Gdata_YouTube_Extension_VideoId();
  164. $videoid ->transferFromDOM($child);
  165. $this->_videoid = $videoid;
  166. break;
  167. case $this->lookupNamespace('yt') . ':' . 'uploaded':
  168. $uploaded = new Zend_Gdata_YouTube_Extension_Uploaded();
  169. $uploaded ->transferFromDOM($child);
  170. $this->_uploaded = $uploaded;
  171. break;
  172. default:
  173. parent::takeChildFromDOM($child);
  174. break;
  175. }
  176. }
  177. /**
  178. * Returns the duration value of this element
  179. *
  180. * @return Zend_Gdata_YouTube_Extension_Duration
  181. */
  182. public function getDuration()
  183. {
  184. return $this->_duration;
  185. }
  186. /**
  187. * Sets the duration value of this element
  188. *
  189. * @param Zend_Gdata_YouTube_Extension_Duration $value The duration value
  190. * @return Zend_Gdata_YouTube_Extension_MediaGroup Provides a fluent
  191. * interface
  192. */
  193. public function setDuration($value)
  194. {
  195. $this->_duration = $value;
  196. return $this;
  197. }
  198. /**
  199. * Returns the videoid value of this element
  200. *
  201. * @return Zend_Gdata_YouTube_Extension_VideoId
  202. */
  203. public function getVideoId()
  204. {
  205. return $this->_videoid;
  206. }
  207. /**
  208. * Sets the videoid value of this element
  209. *
  210. * @param Zend_Gdata_YouTube_Extension_VideoId $value The video id value
  211. * @return Zend_Gdata_YouTube_Extension_MediaGroup Provides a fluent
  212. * interface
  213. */
  214. public function setVideoId($value)
  215. {
  216. $this->_videoid = $value;
  217. return $this;
  218. }
  219. /**
  220. * Returns the yt:uploaded element
  221. *
  222. * @return Zend_Gdata_YouTube_Extension_Uploaded
  223. */
  224. public function getUploaded()
  225. {
  226. return $this->_uploaded;
  227. }
  228. /**
  229. * Sets the yt:uploaded element
  230. *
  231. * @param Zend_Gdata_YouTube_Extension_Uploaded $value The uploaded value
  232. * @return Zend_Gdata_YouTube_Extension_MediaGroup Provides a fluent
  233. * interface
  234. */
  235. public function setUploaded($value)
  236. {
  237. $this->_uploaded = $value;
  238. return $this;
  239. }
  240. /**
  241. * Returns the private value of this element
  242. *
  243. * @return Zend_Gdata_YouTube_Extension_Private
  244. */
  245. public function getPrivate()
  246. {
  247. return $this->_private;
  248. }
  249. /**
  250. * Sets the private value of this element
  251. *
  252. * @param Zend_Gdata_YouTube_Extension_Private $value The private value
  253. * @return Zend_Gdata_YouTube_Extension_MediaGroup Provides a fluent
  254. * interface
  255. */
  256. public function setPrivate($value)
  257. {
  258. $this->_private = $value;
  259. return $this;
  260. }
  261. /**
  262. * Returns the rating value of this element
  263. *
  264. * @return Zend_Gdata_YouTube_Extension_MediaRating
  265. */
  266. public function getMediaRating()
  267. {
  268. return $this->_mediarating;
  269. }
  270. /**
  271. * Sets the media:rating value of this element
  272. *
  273. * @param Zend_Gdata_YouTube_Extension_MediaRating $value The rating element
  274. * @return Zend_Gdata_YouTube_Extension_MediaGroup Provides a fluent
  275. * interface
  276. */
  277. public function setMediaRating($value)
  278. {
  279. $this->_mediarating = $value;
  280. return $this;
  281. }
  282. /**
  283. * Returns the media:credit value of this element
  284. *
  285. * @return Zend_Gdata_YouTube_Extension_MediaCredit
  286. */
  287. public function getMediaCredit()
  288. {
  289. return $this->_mediacredit;
  290. }
  291. /**
  292. * Sets the media:credit value of this element
  293. *
  294. * @param Zend_Gdata_YouTube_Extension_MediaCredit $value The credit element
  295. * @return Zend_Gdata_YouTube_Extension_MediaGroup Provides a fluent
  296. * interface
  297. */
  298. public function setMediaCredit($value)
  299. {
  300. $this->_mediacredit = $value;
  301. return $this;
  302. }
  303. }