2
0

Reminder.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. * Implements the gd:reminder element used to set/retrieve notifications
  27. *
  28. * @category Zend
  29. * @package Zend_Gdata
  30. * @subpackage Gdata
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Gdata_Extension_Reminder extends Zend_Gdata_Extension
  35. {
  36. protected $_rootElement = 'reminder';
  37. protected $_absoluteTime = null;
  38. protected $_method = null;
  39. protected $_days = null;
  40. protected $_hours = null;
  41. protected $_minutes = null;
  42. public function __construct($absoluteTime = null, $method = null, $days = null,
  43. $hours = null, $minutes = null)
  44. {
  45. parent::__construct();
  46. $this->_absoluteTime = $absoluteTime;
  47. $this->_method = $method;
  48. $this->_days = $days;
  49. $this->_hours = $hours;
  50. $this->_minutes = $minutes;
  51. }
  52. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  53. {
  54. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  55. if ($this->_absoluteTime !== null) {
  56. $element->setAttribute('absoluteTime', $this->_absoluteTime);
  57. }
  58. if ($this->_method !== null) {
  59. $element->setAttribute('method', $this->_method);
  60. }
  61. if ($this->_days !== null) {
  62. $element->setAttribute('days', $this->_days);
  63. }
  64. if ($this->_hours !== null) {
  65. $element->setAttribute('hours', $this->_hours);
  66. }
  67. if ($this->_minutes !== null) {
  68. $element->setAttribute('minutes', $this->_minutes);
  69. }
  70. return $element;
  71. }
  72. protected function takeAttributeFromDOM($attribute)
  73. {
  74. switch ($attribute->localName) {
  75. case 'absoluteTime':
  76. $this->_absoluteTime = $attribute->nodeValue;
  77. break;
  78. case 'method':
  79. $this->_method = $attribute->nodeValue;
  80. break;
  81. case 'days':
  82. $this->_days = $attribute->nodeValue;
  83. break;
  84. case 'hours':
  85. $this->_hours = $attribute->nodeValue;
  86. break;
  87. case 'minutes':
  88. $this->_minutes = $attribute->nodeValue;
  89. break;
  90. default:
  91. parent::takeAttributeFromDOM($attribute);
  92. }
  93. }
  94. public function __toString()
  95. {
  96. $s;
  97. if ($absoluteTime)
  98. $s = "at" . $absoluteTime;
  99. else if ($days)
  100. $s = "in" . $days . "days";
  101. else if ($hours)
  102. $s = "in" . $hours . "hours";
  103. else if ($minutes)
  104. $s = "in" . $minutes . "minutes";
  105. return $method . $s;
  106. }
  107. public function getAbsoluteTime()
  108. {
  109. return $this->_absoluteTime;
  110. }
  111. public function setAbsoluteTime($value)
  112. {
  113. $this->_absoluteTime = $value;
  114. return $this;
  115. }
  116. public function getDays()
  117. {
  118. return $this->_days;
  119. }
  120. public function setDays($value)
  121. {
  122. $this->_days = $value;
  123. return $this;
  124. }
  125. public function getHours()
  126. {
  127. return $this->_hours;
  128. }
  129. public function setHours($value)
  130. {
  131. $this->_hours = $value;
  132. return $this;
  133. }
  134. public function getMinutes()
  135. {
  136. return $this->_minutes;
  137. }
  138. public function setMinutes($value)
  139. {
  140. $this->_minutes = $value;
  141. return $this;
  142. }
  143. public function getMethod()
  144. {
  145. return $this->_method;
  146. }
  147. public function setMethod($value)
  148. {
  149. $this->_method = $value;
  150. return $this;
  151. }
  152. }