MediaContent.php 3.6 KB

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