2
0

Entry.php 3.8 KB

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