2
0

When.php 4.5 KB

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