Who.php 9.0 KB

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