2
0

MediaContent.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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_MediaContent
  23. */
  24. require_once 'Zend/Gdata/Media/Extension/MediaContent.php';
  25. /**
  26. * Represents the media:content element of Media RSS.
  27. * Represents media objects. Multiple media objects representing
  28. * the same content can be represented using a
  29. * media:group (Zend_Gdata_Media_Extension_MediaGroup) element.
  30. *
  31. * @category Zend
  32. * @package Zend_Gdata
  33. * @subpackage YouTube
  34. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  35. * @license http://framework.zend.com/license/new-bsd New BSD License
  36. */
  37. class Zend_Gdata_YouTube_Extension_MediaContent extends Zend_Gdata_Media_Extension_MediaContent
  38. {
  39. protected $_rootElement = 'content';
  40. protected $_rootNamespace = 'media';
  41. /*
  42. * Format of the video
  43. * Optional.
  44. *
  45. * @var int
  46. */
  47. protected $_format = null;
  48. function __construct() {
  49. $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  50. parent::__construct();
  51. }
  52. /**
  53. * Retrieves a DOMElement which corresponds to this element and all
  54. * child properties. This is used to build an entry back into a DOM
  55. * and eventually XML text for sending to the server upon updates, or
  56. * for application storage/persistence.
  57. *
  58. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  59. * @return DOMElement The DOMElement representing this element and all
  60. * child properties.
  61. */
  62. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  63. {
  64. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  65. if ($this->_format!= null) {
  66. $element->setAttributeNS($this->lookupNamespace('yt'), 'yt:format', $this->_format);
  67. }
  68. return $element;
  69. }
  70. /**
  71. * Given a DOMNode representing an attribute, tries to map the data into
  72. * instance members. If no mapping is defined, the name and value are
  73. * stored in an array.
  74. *
  75. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  76. */
  77. protected function takeAttributeFromDOM($attribute)
  78. {
  79. $absoluteAttrName = $attribute->namespaceURI . ':' . $attribute->localName;
  80. if ($absoluteAttrName == $this->lookupNamespace('yt') . ':' . 'format') {
  81. $this->_format = $attribute->nodeValue;
  82. } else {
  83. parent::takeAttributeFromDOM($attribute);
  84. }
  85. }
  86. /**
  87. * Returns the format of the media
  88. * Optional.
  89. *
  90. * @return int The format of the media
  91. */
  92. public function getFormat()
  93. {
  94. return $this->_format;
  95. }
  96. /**
  97. * Sets the format of the media
  98. *
  99. * @param int $value Format of the media
  100. * @return Zend_Gdata_YouTube_Extension_MediaContent Provides a fluent interface
  101. *
  102. */
  103. public function setFormat($value)
  104. {
  105. $this->_format = $value;
  106. return $this;
  107. }
  108. }