PlaylistVideoEntry.php 4.1 KB

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