MediaGroup.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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_Extension
  24. */
  25. require_once 'Zend/Gdata/Extension.php';
  26. /**
  27. * @see Zend_Gdata_Entry
  28. */
  29. require_once 'Zend/Gdata/Entry.php';
  30. /**
  31. * @see Zend_Gdata_Media_Extension_MediaContent
  32. */
  33. require_once 'Zend/Gdata/Media/Extension/MediaContent.php';
  34. /**
  35. * @see Zend_Gdata_Media_Extension_MediaCategory
  36. */
  37. require_once 'Zend/Gdata/Media/Extension/MediaCategory.php';
  38. /**
  39. * @see Zend_Gdata_Media_Extension_MediaCopyright
  40. */
  41. require_once 'Zend/Gdata/Media/Extension/MediaCopyright.php';
  42. /**
  43. * @see Zend_Gdata_Media_Extension_MediaCredit
  44. */
  45. require_once 'Zend/Gdata/Media/Extension/MediaCredit.php';
  46. /**
  47. * @see Zend_Gdata_Media_Extension_MediaDescription
  48. */
  49. require_once 'Zend/Gdata/Media/Extension/MediaDescription.php';
  50. /**
  51. * @see Zend_Gdata_Media_Extension_MediaHash
  52. */
  53. require_once 'Zend/Gdata/Media/Extension/MediaHash.php';
  54. /**
  55. * @see Zend_Gdata_Media_Extension_MediaKeywords
  56. */
  57. require_once 'Zend/Gdata/Media/Extension/MediaKeywords.php';
  58. /**
  59. * @see Zend_Gdata_Media_Extension_MediaPlayer
  60. */
  61. require_once 'Zend/Gdata/Media/Extension/MediaPlayer.php';
  62. /**
  63. * @see Zend_Gdata_Media_Extension_MediaRating
  64. */
  65. require_once 'Zend/Gdata/Media/Extension/MediaRating.php';
  66. /**
  67. * @see Zend_Gdata_Media_Extension_MediaRestriction
  68. */
  69. require_once 'Zend/Gdata/Media/Extension/MediaRestriction.php';
  70. /**
  71. * @see Zend_Gdata_Media_Extension_MediaText
  72. */
  73. require_once 'Zend/Gdata/Media/Extension/MediaText.php';
  74. /**
  75. * @see Zend_Gdata_Media_Extension_MediaThumbnail
  76. */
  77. require_once 'Zend/Gdata/Media/Extension/MediaThumbnail.php';
  78. /**
  79. * @see Zend_Gdata_Media_Extension_MediaTitle
  80. */
  81. require_once 'Zend/Gdata/Media/Extension/MediaTitle.php';
  82. /**
  83. * This class represents the media:group element of Media RSS.
  84. * It allows the grouping of media:content elements that are
  85. * different representations of the same content. When it exists,
  86. * it is a child of an Entry (Atom) or Item (RSS).
  87. *
  88. * @category Zend
  89. * @package Zend_Gdata
  90. * @subpackage Media
  91. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  92. * @license http://framework.zend.com/license/new-bsd New BSD License
  93. */
  94. class Zend_Gdata_Media_Extension_MediaGroup extends Zend_Gdata_Extension
  95. {
  96. protected $_rootElement = 'group';
  97. protected $_rootNamespace = 'media';
  98. /**
  99. * @var array
  100. */
  101. protected $_content = array();
  102. /**
  103. * @var array
  104. */
  105. protected $_category = array();
  106. /**
  107. * @var Zend_Gdata_Media_Extension_MediaCopyright
  108. */
  109. protected $_copyright = null;
  110. /**
  111. * @var array
  112. */
  113. protected $_credit = array();
  114. /**
  115. * @var Zend_Gdata_Media_Extension_MediaDescription
  116. */
  117. protected $_description = null;
  118. /**
  119. * @var array
  120. */
  121. protected $_hash = array();
  122. /**
  123. * @var Zend_Gdata_Media_Extension_MediaKeywords
  124. */
  125. protected $_keywords = null;
  126. /**
  127. * @var array
  128. */
  129. protected $_player = array();
  130. /**
  131. * @var array
  132. */
  133. protected $_rating = array();
  134. /**
  135. * @var array
  136. */
  137. protected $_restriction = array();
  138. /**
  139. * @var array
  140. */
  141. protected $_mediaText = array();
  142. /**
  143. * @var array
  144. */
  145. protected $_thumbnail = array();
  146. /**
  147. * @var string
  148. */
  149. protected $_title = null;
  150. /**
  151. * Creates an individual MediaGroup object.
  152. */
  153. public function __construct($element = null)
  154. {
  155. $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
  156. parent::__construct($element);
  157. }
  158. /**
  159. * Retrieves a DOMElement which corresponds to this element and all
  160. * child properties. This is used to build an entry back into a DOM
  161. * and eventually XML text for sending to the server upon updates, or
  162. * for application storage/persistence.
  163. *
  164. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  165. * @return DOMElement The DOMElement representing this element and all
  166. * child properties.
  167. */
  168. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  169. {
  170. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  171. foreach ($this->_content as $content) {
  172. $element->appendChild($content->getDOM($element->ownerDocument));
  173. }
  174. foreach ($this->_category as $category) {
  175. $element->appendChild($category->getDOM($element->ownerDocument));
  176. }
  177. foreach ($this->_credit as $credit) {
  178. $element->appendChild($credit->getDOM($element->ownerDocument));
  179. }
  180. foreach ($this->_player as $player) {
  181. $element->appendChild($player->getDOM($element->ownerDocument));
  182. }
  183. foreach ($this->_rating as $rating) {
  184. $element->appendChild($rating->getDOM($element->ownerDocument));
  185. }
  186. foreach ($this->_restriction as $restriction) {
  187. $element->appendChild($restriction->getDOM($element->ownerDocument));
  188. }
  189. foreach ($this->_mediaText as $text) {
  190. $element->appendChild($text->getDOM($element->ownerDocument));
  191. }
  192. foreach ($this->_thumbnail as $thumbnail) {
  193. $element->appendChild($thumbnail->getDOM($element->ownerDocument));
  194. }
  195. if ($this->_copyright != null) {
  196. $element->appendChild(
  197. $this->_copyright->getDOM($element->ownerDocument));
  198. }
  199. if ($this->_description != null) {
  200. $element->appendChild(
  201. $this->_description->getDOM($element->ownerDocument));
  202. }
  203. foreach ($this->_hash as $hash) {
  204. $element->appendChild($hash->getDOM($element->ownerDocument));
  205. }
  206. if ($this->_keywords != null) {
  207. $element->appendChild(
  208. $this->_keywords->getDOM($element->ownerDocument));
  209. }
  210. if ($this->_title != null) {
  211. $element->appendChild(
  212. $this->_title->getDOM($element->ownerDocument));
  213. }
  214. return $element;
  215. }
  216. /**
  217. * Creates individual Entry objects of the appropriate type and
  218. * stores them in the $_entry array based upon DOM data.
  219. *
  220. * @param DOMNode $child The DOMNode to process
  221. */
  222. protected function takeChildFromDOM($child)
  223. {
  224. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  225. switch ($absoluteNodeName) {
  226. case $this->lookupNamespace('media') . ':' . 'content';
  227. $content = new Zend_Gdata_Media_Extension_MediaContent();
  228. $content->transferFromDOM($child);
  229. $this->_content[] = $content;
  230. break;
  231. case $this->lookupNamespace('media') . ':' . 'category';
  232. $category = new Zend_Gdata_Media_Extension_MediaCategory();
  233. $category->transferFromDOM($child);
  234. $this->_category[] = $category;
  235. break;
  236. case $this->lookupNamespace('media') . ':' . 'copyright';
  237. $copyright = new Zend_Gdata_Media_Extension_MediaCopyright();
  238. $copyright->transferFromDOM($child);
  239. $this->_copyright = $copyright;
  240. break;
  241. case $this->lookupNamespace('media') . ':' . 'credit';
  242. $credit = new Zend_Gdata_Media_Extension_MediaCredit();
  243. $credit->transferFromDOM($child);
  244. $this->_credit[] = $credit;
  245. break;
  246. case $this->lookupNamespace('media') . ':' . 'description';
  247. $description = new Zend_Gdata_Media_Extension_MediaDescription();
  248. $description->transferFromDOM($child);
  249. $this->_description = $description;
  250. break;
  251. case $this->lookupNamespace('media') . ':' . 'hash';
  252. $hash = new Zend_Gdata_Media_Extension_MediaHash();
  253. $hash->transferFromDOM($child);
  254. $this->_hash[] = $hash;
  255. break;
  256. case $this->lookupNamespace('media') . ':' . 'keywords';
  257. $keywords = new Zend_Gdata_Media_Extension_MediaKeywords();
  258. $keywords->transferFromDOM($child);
  259. $this->_keywords = $keywords;
  260. break;
  261. case $this->lookupNamespace('media') . ':' . 'player';
  262. $player = new Zend_Gdata_Media_Extension_MediaPlayer();
  263. $player->transferFromDOM($child);
  264. $this->_player[] = $player;
  265. break;
  266. case $this->lookupNamespace('media') . ':' . 'rating';
  267. $rating = new Zend_Gdata_Media_Extension_MediaRating();
  268. $rating->transferFromDOM($child);
  269. $this->_rating[] = $rating;
  270. break;
  271. case $this->lookupNamespace('media') . ':' . 'restriction';
  272. $restriction = new Zend_Gdata_Media_Extension_MediaRestriction();
  273. $restriction->transferFromDOM($child);
  274. $this->_restriction[] = $restriction;
  275. break;
  276. case $this->lookupNamespace('media') . ':' . 'text';
  277. $text = new Zend_Gdata_Media_Extension_MediaText();
  278. $text->transferFromDOM($child);
  279. $this->_mediaText[] = $text;
  280. break;
  281. case $this->lookupNamespace('media') . ':' . 'thumbnail';
  282. $thumbnail = new Zend_Gdata_Media_Extension_MediaThumbnail();
  283. $thumbnail->transferFromDOM($child);
  284. $this->_thumbnail[] = $thumbnail;
  285. break;
  286. case $this->lookupNamespace('media') . ':' . 'title';
  287. $title = new Zend_Gdata_Media_Extension_MediaTitle();
  288. $title->transferFromDOM($child);
  289. $this->_title = $title;
  290. break;
  291. default:
  292. parent::takeChildFromDOM($child);
  293. break;
  294. }
  295. }
  296. /**
  297. * @return array
  298. */
  299. public function getContent()
  300. {
  301. return $this->_content;
  302. }
  303. /**
  304. * @param array $value
  305. * @return Zend_Gdata_Media_MediaGroup Provides a fluent interface
  306. */
  307. public function setContent($value)
  308. {
  309. $this->_content = $value;
  310. return $this;
  311. }
  312. /**
  313. * @return array
  314. */
  315. public function getCategory()
  316. {
  317. return $this->_category;
  318. }
  319. /**
  320. * @param array $value
  321. * @return Zend_Gdata_Media_Extension_MediaGroup
  322. */
  323. public function setCategory($value)
  324. {
  325. $this->_category = $value;
  326. return $this;
  327. }
  328. /**
  329. * @return Zend_Gdata_Media_Extension_MediaCopyright
  330. */
  331. public function getCopyright()
  332. {
  333. return $this->_copyright;
  334. }
  335. /**
  336. * @param Zend_Gdata_Media_Extension_MediaCopyright $value
  337. * @return Zend_Gdata_Media_Extension_MediaGroup
  338. */
  339. public function setCopyright($value)
  340. {
  341. $this->_copyright = $value;
  342. return $this;
  343. }
  344. /**
  345. * @return array
  346. */
  347. public function getCredit()
  348. {
  349. return $this->_credit;
  350. }
  351. /**
  352. * @param array $value
  353. * @return Zend_Gdata_Media_Extension_MediaGroup
  354. */
  355. public function setCredit($value)
  356. {
  357. $this->_credit = $value;
  358. return $this;
  359. }
  360. /**
  361. * @return Zend_Gdata_Media_Extension_MediaTitle
  362. */
  363. public function getTitle()
  364. {
  365. return $this->_title;
  366. }
  367. /**
  368. * @param Zend_Gdata_Media_Extension_MediaTitle $value
  369. * @return Zend_Gdata_Media_Extension_MediaGroup
  370. */
  371. public function setTitle($value)
  372. {
  373. $this->_title = $value;
  374. return $this;
  375. }
  376. /**
  377. * @return Zend_Gdata_Media_Extension_MediaDescription
  378. */
  379. public function getDescription()
  380. {
  381. return $this->_description;
  382. }
  383. /**
  384. * @param Zend_Gdata_Media_Extension_MediaDescription $value
  385. * @return Zend_Gdata_Media_Extension_MediaGroup
  386. */
  387. public function setDescription($value)
  388. {
  389. $this->_description = $value;
  390. return $this;
  391. }
  392. /**
  393. * @return array
  394. */
  395. public function getHash()
  396. {
  397. return $this->_hash;
  398. }
  399. /**
  400. * @param array $value
  401. * @return Zend_Gdata_Media_Extension_MediaGroup
  402. */
  403. public function setHash($value)
  404. {
  405. $this->_hash = $value;
  406. return $this;
  407. }
  408. /**
  409. * @return Zend_Gdata_Media_Extension_MediaKeywords
  410. */
  411. public function getKeywords()
  412. {
  413. return $this->_keywords;
  414. }
  415. /**
  416. * @param array $value
  417. * @return Zend_Gdata_Media_Extension_MediaGroup Provides a fluent interface
  418. */
  419. public function setKeywords($value)
  420. {
  421. $this->_keywords = $value;
  422. return $this;
  423. }
  424. /**
  425. * @return array
  426. */
  427. public function getPlayer()
  428. {
  429. return $this->_player;
  430. }
  431. /**
  432. * @param array
  433. * @return Zend_Gdata_Media_Extension_MediaGroup
  434. */
  435. public function setPlayer($value)
  436. {
  437. $this->_player = $value;
  438. return $this;
  439. }
  440. /**
  441. * @return array
  442. */
  443. public function getRating()
  444. {
  445. return $this->_rating;
  446. }
  447. /**
  448. * @param array
  449. * @return Zend_Gdata_Media_Extension_MediaGroup
  450. */
  451. public function setRating($value)
  452. {
  453. $this->_rating = $value;
  454. return $this;
  455. }
  456. /**
  457. * @return array
  458. */
  459. public function getRestriction()
  460. {
  461. return $this->_restriction;
  462. }
  463. /**
  464. * @param array
  465. * @return Zend_Gdata_Media_Extension_MediaGroup
  466. */
  467. public function setRestriction($value)
  468. {
  469. $this->_restriction = $value;
  470. return $this;
  471. }
  472. /**
  473. * @return array
  474. */
  475. public function getThumbnail()
  476. {
  477. return $this->_thumbnail;
  478. }
  479. /**
  480. * @param array
  481. * @return Zend_Gdata_Media_Extension_MediaGroup
  482. */
  483. public function setThumbnail($value)
  484. {
  485. $this->_thumbnail = $value;
  486. return $this;
  487. }
  488. /**
  489. * @return array
  490. */
  491. public function getMediaText()
  492. {
  493. return $this->_mediaText;
  494. }
  495. /**
  496. * @param array
  497. * @return Zend_Gdata_Media_Extension_MediaGroup
  498. */
  499. public function setMediaText($value)
  500. {
  501. $this->_mediaText = $value;
  502. return $this;
  503. }
  504. }