Reminder.php 4.5 KB

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