2
0

RecurrenceException.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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_EntryLink
  27. */
  28. require_once 'Zend/Gdata/Extension/EntryLink.php';
  29. /**
  30. * @see Zend_Gdata_Extension_OriginalEvent
  31. */
  32. require_once 'Zend/Gdata/Extension/OriginalEvent.php';
  33. /**
  34. * Data model class to represent an entry's recurrenceException
  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_RecurrenceException extends Zend_Gdata_Extension
  43. {
  44. protected $_rootElement = 'recurrenceException';
  45. protected $_specialized = null;
  46. protected $_entryLink = null;
  47. protected $_originalEvent = null;
  48. /**
  49. * Constructs a new Zend_Gdata_Extension_RecurrenceException object.
  50. * @param bool $specialized (optional) Whether this is a specialized exception or not.
  51. * @param Zend_Gdata_EntryLink (optional) An Event entry with details about the exception.
  52. * @param Zend_Gdata_OriginalEvent (optional) The origianl recurrent event this is an exeption to.
  53. */
  54. public function __construct($specialized = null, $entryLink = null,
  55. $originalEvent = null)
  56. {
  57. parent::__construct();
  58. $this->_specialized = $specialized;
  59. $this->_entryLink = $entryLink;
  60. $this->_originalEvent = $originalEvent;
  61. }
  62. /**
  63. * Retrieves a DOMElement which corresponds to this element and all
  64. * child properties. This is used to build an entry back into a DOM
  65. * and eventually XML text for sending to the server upon updates, or
  66. * for application storage/persistence.
  67. *
  68. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  69. * @return DOMElement The DOMElement representing this element and all
  70. * child properties.
  71. */
  72. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  73. {
  74. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  75. if ($this->_specialized !== null) {
  76. $element->setAttribute('specialized', ($this->_specialized ? "true" : "false"));
  77. }
  78. if ($this->_entryLink !== null) {
  79. $element->appendChild($this->_entryLink->getDOM($element->ownerDocument));
  80. }
  81. if ($this->_originalEvent !== null) {
  82. $element->appendChild($this->_originalEvent->getDOM($element->ownerDocument));
  83. }
  84. return $element;
  85. }
  86. /**
  87. * Given a DOMNode representing an attribute, tries to map the data into
  88. * instance members. If no mapping is defined, the name and value are
  89. * stored in an array.
  90. *
  91. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  92. */
  93. protected function takeAttributeFromDOM($attribute)
  94. {
  95. switch ($attribute->localName) {
  96. case 'specialized':
  97. if ($attribute->nodeValue == "true") {
  98. $this->_specialized = true;
  99. }
  100. else if ($attribute->nodeValue == "false") {
  101. $this->_specialized = false;
  102. }
  103. else {
  104. throw new Zend_Gdata_App_InvalidArgumentException("Expected 'true' or 'false' for gCal:selected#value.");
  105. }
  106. break;
  107. default:
  108. parent::takeAttributeFromDOM($attribute);
  109. }
  110. }
  111. /**
  112. * Creates individual Entry objects of the appropriate type and
  113. * stores them as members of this entry based upon DOM data.
  114. *
  115. * @param DOMNode $child The DOMNode to process
  116. */
  117. protected function takeChildFromDOM($child)
  118. {
  119. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  120. switch ($absoluteNodeName) {
  121. case $this->lookupNamespace('gd') . ':' . 'entryLink':
  122. $entryLink = new Zend_Gdata_Extension_EntryLink();
  123. $entryLink->transferFromDOM($child);
  124. $this->_entryLink = $entryLink;
  125. break;
  126. case $this->lookupNamespace('gd') . ':' . 'originalEvent':
  127. $originalEvent = new Zend_Gdata_Extension_OriginalEvent();
  128. $originalEvent->transferFromDOM($child);
  129. $this->_originalEvent = $originalEvent;
  130. break;
  131. default:
  132. parent::takeChildFromDOM($child);
  133. break;
  134. }
  135. }
  136. /**
  137. * Get the value for this element's Specialized attribute.
  138. *
  139. * @return bool The requested attribute.
  140. */
  141. public function getSpecialized()
  142. {
  143. return $this->_specialized;
  144. }
  145. /**
  146. * Set the value for this element's Specialized attribute.
  147. *
  148. * @param bool $value The desired value for this attribute.
  149. * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
  150. */
  151. public function setSpecialized($value)
  152. {
  153. $this->_specialized = $value;
  154. return $this;
  155. }
  156. /**
  157. * Get the value for this element's EntryLink attribute.
  158. *
  159. * @return Zend_Gdata_Extension_EntryLink The requested attribute.
  160. */
  161. public function getEntryLink()
  162. {
  163. return $this->_entryLink;
  164. }
  165. /**
  166. * Set the value for this element's EntryLink attribute.
  167. *
  168. * @param Zend_Gdata_Extension_EntryLink $value The desired value for this attribute.
  169. * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
  170. */
  171. public function setEntryLink($value)
  172. {
  173. $this->_entryLink = $value;
  174. return $this;
  175. }
  176. /**
  177. * Get the value for this element's Specialized attribute.
  178. *
  179. * @return Zend_Gdata_Extension_OriginalEvent The requested attribute.
  180. */
  181. public function getOriginalEvent()
  182. {
  183. return $this->_originalEvent;
  184. }
  185. /**
  186. * Set the value for this element's Specialized attribute.
  187. *
  188. * @param Zend_Gdata_Extension_OriginalEvent $value The desired value for this attribute.
  189. * @return Zend_Gdata_Extension_RecurrenceException The element being modified.
  190. */
  191. public function setOriginalEvent($value)
  192. {
  193. $this->_originalEvent = $value;
  194. return $this;
  195. }
  196. }