PlaylistVideoEntry.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_YouTube_VideoEntry
  23. */
  24. require_once 'Zend/Gdata/YouTube/VideoEntry.php';
  25. /**
  26. * @see Zend_Gdata_YouTube_Extension_Position
  27. */
  28. require_once 'Zend/Gdata/YouTube/Extension/Position.php';
  29. /**
  30. * Represents the YouTube video playlist flavor of an Atom entry
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage YouTube
  35. * @copyright Copyright (c) 2005-2008 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_PlaylistVideoEntry extends Zend_Gdata_YouTube_VideoEntry
  39. {
  40. protected $_entryClassName = 'Zend_Gdata_YouTube_PlaylistVideoEntry';
  41. /**
  42. * Position of the entry in the feed, as specified by the user
  43. *
  44. * @var Zend_Gdata_YouTube_Extension_Position
  45. */
  46. protected $_position = null;
  47. /**
  48. * Creates a Playlist video entry, representing an individual video
  49. * in a list of videos contained within a specific playlist
  50. *
  51. * @param DOMElement $element (optional) DOMElement from which this
  52. * object should be constructed.
  53. */
  54. public function __construct($element = null)
  55. {
  56. $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
  57. parent::__construct($element);
  58. }
  59. /**
  60. * Retrieves a DOMElement which corresponds to this element and all
  61. * child properties. This is used to build an entry back into a DOM
  62. * and eventually XML text for sending to the server upon updates, or
  63. * for application storage/persistence.
  64. *
  65. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  66. * @return DOMElement The DOMElement representing this element and all
  67. * child properties.
  68. */
  69. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  70. {
  71. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  72. if ($this->_position !== null) {
  73. $element->appendChild($this->_position->getDOM($element->ownerDocument));
  74. }
  75. return $element;
  76. }
  77. /**
  78. * Creates individual Entry objects of the appropriate type and
  79. * stores them in the $_entry array based upon DOM data.
  80. *
  81. * @param DOMNode $child The DOMNode to process
  82. */
  83. protected function takeChildFromDOM($child)
  84. {
  85. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  86. switch ($absoluteNodeName) {
  87. case $this->lookupNamespace('yt') . ':' . 'position':
  88. $position = new Zend_Gdata_YouTube_Extension_Position();
  89. $position->transferFromDOM($child);
  90. $this->_position = $position;
  91. break;
  92. default:
  93. parent::takeChildFromDOM($child);
  94. break;
  95. }
  96. }
  97. /**
  98. * Sets the array of embedded feeds related to the video
  99. *
  100. * @param Zend_Gdata_YouTube_Extension_Position $position
  101. * The position of the entry in the feed, as specified by the user.
  102. * @return Zend_Gdata_YouTube_PlaylistVideoEntry Provides a fluent interface
  103. */
  104. public function setPosition($position = null)
  105. {
  106. $this->_position = $position;
  107. return $this;
  108. }
  109. /**
  110. * Returns the position of the entry in the feed, as specified by the user
  111. *
  112. * @return Zend_Gdata_YouTube_Extension_Position The position
  113. */
  114. public function getPosition()
  115. {
  116. return $this->_position;
  117. }
  118. }