Who.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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_AttendeeStatus
  27. */
  28. require_once 'Zend/Gdata/Extension/AttendeeStatus.php';
  29. /**
  30. * @see Zend_Gdata_Extension_AttendeeType
  31. */
  32. require_once 'Zend/Gdata/Extension/AttendeeType.php';
  33. /**
  34. * @see Zend_Gdata_Extension_EntryLink
  35. */
  36. require_once 'Zend/Gdata/Extension/EntryLink.php';
  37. /**
  38. * Data model class to represent a participant
  39. *
  40. * @category Zend
  41. * @package Zend_Gdata
  42. * @subpackage Gdata
  43. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  44. * @license http://framework.zend.com/license/new-bsd New BSD License
  45. */
  46. class Zend_Gdata_Extension_Who extends Zend_Gdata_Extension
  47. {
  48. protected $_rootElement = 'who';
  49. protected $_email = null;
  50. protected $_rel = null;
  51. protected $_valueString = null;
  52. protected $_attendeeStatus = null;
  53. protected $_attendeeType = null;
  54. protected $_entryLink = null;
  55. /**
  56. * Constructs a new Zend_Gdata_Extension_Who object.
  57. * @param string $email (optional) Email address.
  58. * @param string $rel (optional) Relationship description.
  59. * @param string $valueString (optional) Simple string describing this person.
  60. * @param Zend_Gdata_Extension_AttendeeStatus $attendeeStatus (optional) The status of the attendee.
  61. * @param Zend_Gdata_Extension_AttendeeType $attendeeType (optional) The type of the attendee.
  62. * @param string $entryLink URL pointing to an associated entry (Contact kind) describing this person.
  63. */
  64. public function __construct($email = null, $rel = null, $valueString = null,
  65. $attendeeStatus = null, $attendeeType = null, $entryLink = null)
  66. {
  67. parent::__construct();
  68. $this->_email = $email;
  69. $this->_rel = $rel;
  70. $this->_valueString = $valueString;
  71. $this->_attendeeStatus = $attendeeStatus;
  72. $this->_attendeeType = $attendeeType;
  73. $this->_entryLink = $entryLink;
  74. }
  75. /**
  76. * Retrieves a DOMElement which corresponds to this element and all
  77. * child properties. This is used to build an entry back into a DOM
  78. * and eventually XML text for sending to the server upon updates, or
  79. * for application storage/persistence.
  80. *
  81. * @param DOMDocument $doc The DOMDocument used to construct DOMElements
  82. * @return DOMElement The DOMElement representing this element and all
  83. * child properties.
  84. */
  85. public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
  86. {
  87. $element = parent::getDOM($doc, $majorVersion, $minorVersion);
  88. if ($this->_email !== null) {
  89. $element->setAttribute('email', $this->_email);
  90. }
  91. if ($this->_rel !== null) {
  92. $element->setAttribute('rel', $this->_rel);
  93. }
  94. if ($this->_valueString !== null) {
  95. $element->setAttribute('valueString', $this->_valueString);
  96. }
  97. if ($this->_attendeeStatus !== null) {
  98. $element->appendChild($this->_attendeeStatus->getDOM($element->ownerDocument));
  99. }
  100. if ($this->_attendeeType !== null) {
  101. $element->appendChild($this->_attendeeType->getDOM($element->ownerDocument));
  102. }
  103. if ($this->_entryLink !== null) {
  104. $element->appendChild($this->_entryLink->getDOM($element->ownerDocument));
  105. }
  106. return $element;
  107. }
  108. /**
  109. * Given a DOMNode representing an attribute, tries to map the data into
  110. * instance members. If no mapping is defined, the name and value are
  111. * stored in an array.
  112. *
  113. * @param DOMNode $attribute The DOMNode attribute needed to be handled
  114. */
  115. protected function takeAttributeFromDOM($attribute)
  116. {
  117. switch ($attribute->localName) {
  118. case 'email':
  119. $this->_email = $attribute->nodeValue;
  120. break;
  121. case 'rel':
  122. $this->_rel = $attribute->nodeValue;
  123. break;
  124. case 'valueString':
  125. $this->_valueString = $attribute->nodeValue;
  126. break;
  127. default:
  128. parent::takeAttributeFromDOM($attribute);
  129. }
  130. }
  131. /**
  132. * Creates individual Entry objects of the appropriate type and
  133. * stores them as members of this entry based upon DOM data.
  134. *
  135. * @param DOMNode $child The DOMNode to process
  136. */
  137. protected function takeChildFromDOM($child)
  138. {
  139. $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
  140. switch ($absoluteNodeName) {
  141. case $this->lookupNamespace('gd') . ':' . 'attendeeStatus':
  142. $attendeeStatus = new Zend_Gdata_Extension_AttendeeStatus();
  143. $attendeeStatus->transferFromDOM($child);
  144. $this->_attendeeStatus = $attendeeStatus;
  145. break;
  146. case $this->lookupNamespace('gd') . ':' . 'attendeeType':
  147. $attendeeType = new Zend_Gdata_Extension_AttendeeType();
  148. $attendeeType->transferFromDOM($child);
  149. $this->_attendeeType = $attendeeType;
  150. break;
  151. case $this->lookupNamespace('gd') . ':' . 'entryLink':
  152. $entryLink = new Zend_Gdata_Extension_EntryLink();
  153. $entryLink->transferFromDOM($child);
  154. $this->_entryLink = $entryLink;
  155. break;
  156. default:
  157. parent::takeChildFromDOM($child);
  158. break;
  159. }
  160. }
  161. /**
  162. * Retrieves a human readable string describing this attribute's value.
  163. *
  164. * @return string The attribute value.
  165. */
  166. public function __toString()
  167. {
  168. if ($this->_valueString != null) {
  169. return $this->_valueString;
  170. }
  171. else {
  172. return parent::__toString();
  173. }
  174. }
  175. /**
  176. * Get the value for this element's ValueString attribute.
  177. *
  178. * @return string The requested attribute.
  179. */
  180. public function getValueString()
  181. {
  182. return $this->_valueString;
  183. }
  184. /**
  185. * Set the value for this element's ValueString attribute.
  186. *
  187. * @param string $value The desired value for this attribute.
  188. * @return Zend_Gdata_Extension_Who The element being modified.
  189. */
  190. public function setValueString($value)
  191. {
  192. $this->_valueString = $value;
  193. return $this;
  194. }
  195. /**
  196. * Get the value for this element's Email attribute.
  197. *
  198. * @return string The requested attribute.
  199. */
  200. public function getEmail()
  201. {
  202. return $this->_email;
  203. }
  204. /**
  205. * Set the value for this element's Email attribute.
  206. *
  207. * @param string $value The desired value for this attribute.
  208. * @return Zend_Gdata_Extension_Who The element being modified.
  209. */
  210. public function setEmail($value)
  211. {
  212. $this->_email = $value;
  213. return $this;
  214. }
  215. /**
  216. * Get the value for this element's Rel attribute.
  217. *
  218. * @return string The requested attribute.
  219. */
  220. public function getRel()
  221. {
  222. return $this->_rel;
  223. }
  224. /**
  225. * Set the value for this element's Rel attribute.
  226. *
  227. * @param string $value The desired value for this attribute.
  228. * @return Zend_Gdata_Extension_Who The element being modified.
  229. */
  230. public function setRel($value)
  231. {
  232. $this->_rel = $value;
  233. return $this;
  234. }
  235. /**
  236. * Get this entry's AttendeeStatus element.
  237. *
  238. * @return Zend_Gdata_Extension_AttendeeStatus The requested entry.
  239. */
  240. public function getAttendeeStatus()
  241. {
  242. return $this->_attendeeStatus;
  243. }
  244. /**
  245. * Set the child's AttendeeStatus element.
  246. *
  247. * @param Zend_Gdata_Extension_AttendeeStatus $value The desired value for this attribute.
  248. * @return Zend_Gdata_Extension_Who The element being modified.
  249. */
  250. public function setAttendeeStatus($value)
  251. {
  252. $this->_attendeeStatus = $value;
  253. return $this;
  254. }
  255. /**
  256. * Get this entry's AttendeeType element.
  257. *
  258. * @return Zend_Gdata_Extension_AttendeeType The requested entry.
  259. */
  260. public function getAttendeeType()
  261. {
  262. return $this->_attendeeType;
  263. }
  264. /**
  265. * Set the child's AttendeeType element.
  266. *
  267. * @param Zend_Gdata_Extension_AttendeeType $value The desired value for this attribute.
  268. * @return Zend_Gdata_Extension_Who The element being modified.
  269. */
  270. public function setAttendeeType($value)
  271. {
  272. $this->_attendeeType = $value;
  273. return $this;
  274. }
  275. }