MediaGroup.php 9.7 KB

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