When.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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_Extension_Reminder
  27. */
  28. require_once 'Zend/Gdata/Extension/Reminder.php';
  29. /**
  30. * Represents the gd:when element
  31. *
  32. * @category Zend
  33. * @package Zend_Gdata
  34. * @subpackage Gdata
  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_Extension_When extends Zend_Gdata_Extension
  39. {
  40. protected $_rootElement = 'when';
  41. protected $_reminders = array();
  42. protected $_startTime = null;
  43. protected $_valueString = null;
  44. protected $_endTime = null;
  45. public function __construct($startTime = null, $endTime = null,
  46. $valueString = null, $reminders = null)
  47. {
  48. parent::__construct();
  49. $this->_startTime = $startTime;
  50. $this->_endTime = $endTime;
  51. $this->_valueString = $valueString;
  52. $this->_reminders = $reminders;
  53. }
  54. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  55. {
  56. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  57. if ($this->_startTime !== null) {
  58. $element->setAttribute('startTime', $this->_startTime);
  59. }
  60. if ($this->_endTime !== null) {
  61. $element->setAttribute('endTime', $this->_endTime);
  62. }
  63. if ($this->_valueString !== null) {
  64. $element->setAttribute('valueString', $this->_valueString);
  65. }
  66. if ($this->_reminders !== null) {
  67. foreach ($this->_reminders as $reminder) {
  68. $element->appendChild(
  69. $reminder->getDOM($element->ownerDocument));
  70. }
  71. }
  72. return $element;
  73. }
  74. protected function takeChildFromDOM($child)
  75. {
  76. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  77. switch ($absoluteNodeName) {
  78. case $this->lookupNamespace('gd') . ':' . 'reminder';
  79. $reminder = new Zend_Gdata_Extension_Reminder();
  80. $reminder->transferFromDOM($child);
  81. $this->_reminders[] = $reminder;
  82. break;
  83. default:
  84. parent::takeChildFromDOM($child);
  85. break;
  86. }
  87. }
  88. protected function takeAttributeFromDOM($attribute)
  89. {
  90. switch ($attribute->localName) {
  91. case 'startTime':
  92. $this->_startTime = $attribute->nodeValue;
  93. break;
  94. case 'endTime':
  95. $this->_endTime = $attribute->nodeValue;
  96. break;
  97. case 'valueString':
  98. $this->_valueString = $attribute->nodeValue;
  99. break;
  100. default:
  101. parent::takeAttributeFromDOM($attribute);
  102. }
  103. }
  104. public function __toString()
  105. {
  106. if ($this->_valueString)
  107. return $this->_valueString;
  108. else {
  109. return 'Starts: ' . $this->getStartTime() . ' ' .
  110. 'Ends: ' . $this->getEndTime();
  111. }
  112. }
  113. public function getStartTime()
  114. {
  115. return $this->_startTime;
  116. }
  117. public function setStartTime($value)
  118. {
  119. $this->_startTime = $value;
  120. return $this;
  121. }
  122. public function getEndTime()
  123. {
  124. return $this->_endTime;
  125. }
  126. public function setEndTime($value)
  127. {
  128. $this->_endTime = $value;
  129. return $this;
  130. }
  131. public function getValueString()
  132. {
  133. return $this->_valueString;
  134. }
  135. public function setValueString($value)
  136. {
  137. $this->_valueString = $value;
  138. return $this;
  139. }
  140. public function getReminders()
  141. {
  142. return $this->_reminders;
  143. }
  144. public function setReminders($value)
  145. {
  146. $this->_reminders = $value;
  147. return $this;
  148. }
  149. }