2
0

MediaGroup.php 15 KB

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