OriginalEvent.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 Gdata
  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_Extension
  23. */
  24. require_once 'Zend/Gdata/Extension.php';
  25. /**
  26. * @see Zend_Gdata_Feed
  27. */
  28. require_once 'Zend/Gdata/Feed.php';
  29. /**
  30. * @see Zend_Gdata_When
  31. */
  32. require_once 'Zend/Gdata/Extension/When.php';
  33. /**
  34. * Represents the gd:originalEvent element
  35. *
  36. * @category Zend
  37. * @package Zend_Gdata
  38. * @subpackage Gdata
  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_Extension_OriginalEvent extends Zend_Gdata_Extension
  43. {
  44. protected $_rootElement = 'originalEvent';
  45. protected $_id = null;
  46. protected $_href = null;
  47. protected $_when = null;
  48. public function __construct($id = null, $href = null, $when = null)
  49. {
  50. parent::__construct();
  51. $this->_id = $id;
  52. $this->_href = $href;
  53. $this->_when = $when;
  54. }
  55. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  56. {
  57. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  58. if ($this->_id !== null) {
  59. $element->setAttribute('id', $this->_id);
  60. }
  61. if ($this->_href !== null) {
  62. $element->setAttribute('href', $this->_href);
  63. }
  64. if ($this->_when !== null) {
  65. $element->appendChild($this->_when->getDOM($element->ownerDocument));
  66. }
  67. return $element;
  68. }
  69. protected function takeAttributeFromDOM($attribute)
  70. {
  71. switch ($attribute->localName) {
  72. case 'id':
  73. $this->_id = $attribute->nodeValue;
  74. break;
  75. case 'href':
  76. $this->_href = $attribute->nodeValue;
  77. break;
  78. default:
  79. parent::takeAttributeFromDOM($attribute);
  80. }
  81. }
  82. protected function takeChildFromDOM($child)
  83. {
  84. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  85. switch ($absoluteNodeName) {
  86. case $this->lookupNamespace('gd') . ':' . 'when';
  87. $when = new Zend_Gdata_Extension_When();
  88. $when->transferFromDOM($child);
  89. $this->_when = $when;
  90. break;
  91. default:
  92. parent::takeChildFromDOM($child);
  93. break;
  94. }
  95. }
  96. public function getId()
  97. {
  98. return $this->_id;
  99. }
  100. public function setId($value)
  101. {
  102. $this->_id = $value;
  103. return $this;
  104. }
  105. public function getHref()
  106. {
  107. return $this->_href;
  108. }
  109. public function setHref($value)
  110. {
  111. $this->_href = $value;
  112. return $this;
  113. }
  114. public function getWhen()
  115. {
  116. return $this->_when;
  117. }
  118. public function setWhen($value)
  119. {
  120. $this->_when = $value;
  121. return $this;
  122. }
  123. }