Entry.php 3.8 KB

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