8 * This source file is subject to the new BSD license that is bundled
9 * with this package in the file LICENSE.txt.
10 * It is also available through the world-wide-web at this URL:
11 * http://framework.zend.com/license/new-bsd
12 * If you did not receive a copy of the license and are unable to
13 * obtain it through the world-wide-web, please send an email
14 * to license@zend.com so we can send you a copy immediately.
19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
20 * @license http://framework.zend.com/license/new-bsd New BSD License
25 * @see Zend_Gdata_Extension
27 require_once 'Zend/Gdata/Extension.php';
30 * @see Zend_Gdata_Extension_AttendeeStatus
32 require_once 'Zend/Gdata/Extension/AttendeeStatus.php';
35 * @see Zend_Gdata_Extension_AttendeeType
37 require_once 'Zend/Gdata/Extension/AttendeeType.php';
40 * @see Zend_Gdata_Extension_EntryLink
42 require_once 'Zend/Gdata/Extension/EntryLink.php';
45 * Data model class to represent a participant
50 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
51 * @license http://framework.zend.com/license/new-bsd New BSD License
53 class Zend_Gdata_Extension_Who extends Zend_Gdata_Extension
56 protected $_rootElement = 'who';
57 protected $_email = null;
58 protected $_rel = null;
59 protected $_valueString = null;
60 protected $_attendeeStatus = null;
61 protected $_attendeeType = null;
62 protected $_entryLink = null;
65 * Constructs a new Zend_Gdata_Extension_Who object.
66 * @param string $email (optional) Email address.
67 * @param string $rel (optional) Relationship description.
68 * @param string $valueString (optional) Simple string describing this person.
69 * @param Zend_Gdata_Extension_AttendeeStatus $attendeeStatus (optional) The status of the attendee.
70 * @param Zend_Gdata_Extension_AttendeeType $attendeeType (optional) The type of the attendee.
71 * @param string $entryLink URL pointing to an associated entry (Contact kind) describing this person.
73 public function __construct($email = null, $rel = null, $valueString = null,
74 $attendeeStatus = null, $attendeeType = null, $entryLink = null)
76 parent::__construct();
77 $this->_email = $email;
79 $this->_valueString = $valueString;
80 $this->_attendeeStatus = $attendeeStatus;
81 $this->_attendeeType = $attendeeType;
82 $this->_entryLink = $entryLink;
86 * Retrieves a DOMElement which corresponds to this element and all
87 * child properties. This is used to build an entry back into a DOM
88 * and eventually XML text for sending to the server upon updates, or
89 * for application storage/persistence.
91 * @param DOMDocument $doc The DOMDocument used to construct DOMElements
92 * @return DOMElement The DOMElement representing this element and all
95 public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
97 $element = parent::getDOM($doc, $majorVersion, $minorVersion);
98 if ($this->_email !== null) {
99 $element->setAttribute('email', $this->_email);
101 if ($this->_rel !== null) {
102 $element->setAttribute('rel', $this->_rel);
104 if ($this->_valueString !== null) {
105 $element->setAttribute('valueString', $this->_valueString);
107 if ($this->_attendeeStatus !== null) {
108 $element->appendChild($this->_attendeeStatus->getDOM($element->ownerDocument));
110 if ($this->_attendeeType !== null) {
111 $element->appendChild($this->_attendeeType->getDOM($element->ownerDocument));
113 if ($this->_entryLink !== null) {
114 $element->appendChild($this->_entryLink->getDOM($element->ownerDocument));
120 * Given a DOMNode representing an attribute, tries to map the data into
121 * instance members. If no mapping is defined, the name and value are
122 * stored in an array.
124 * @param DOMNode $attribute The DOMNode attribute needed to be handled
126 protected function takeAttributeFromDOM($attribute)
128 switch ($attribute->localName) {
130 $this->_email = $attribute->nodeValue;
133 $this->_rel = $attribute->nodeValue;
136 $this->_valueString = $attribute->nodeValue;
139 parent::takeAttributeFromDOM($attribute);
144 * Creates individual Entry objects of the appropriate type and
145 * stores them as members of this entry based upon DOM data.
147 * @param DOMNode $child The DOMNode to process
149 protected function takeChildFromDOM($child)
151 $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
152 switch ($absoluteNodeName) {
153 case $this->lookupNamespace('gd') . ':' . 'attendeeStatus':
154 $attendeeStatus = new Zend_Gdata_Extension_AttendeeStatus();
155 $attendeeStatus->transferFromDOM($child);
156 $this->_attendeeStatus = $attendeeStatus;
158 case $this->lookupNamespace('gd') . ':' . 'attendeeType':
159 $attendeeType = new Zend_Gdata_Extension_AttendeeType();
160 $attendeeType->transferFromDOM($child);
161 $this->_attendeeType = $attendeeType;
163 case $this->lookupNamespace('gd') . ':' . 'entryLink':
164 $entryLink = new Zend_Gdata_Extension_EntryLink();
165 $entryLink->transferFromDOM($child);
166 $this->_entryLink = $entryLink;
169 parent::takeChildFromDOM($child);
175 * Retrieves a human readable string describing this attribute's value.
177 * @return string The attribute value.
179 public function __toString()
181 if ($this->_valueString != null) {
182 return $this->_valueString;
185 return parent::__toString();
190 * Get the value for this element's ValueString attribute.
192 * @return string The requested attribute.
194 public function getValueString()
196 return $this->_valueString;
200 * Set the value for this element's ValueString attribute.
202 * @param string $value The desired value for this attribute.
203 * @return Zend_Gdata_Extension_Who The element being modified.
205 public function setValueString($value)
207 $this->_valueString = $value;
212 * Get the value for this element's Email attribute.
214 * @return string The requested attribute.
216 public function getEmail()
218 return $this->_email;
222 * Set the value for this element's Email attribute.
224 * @param string $value The desired value for this attribute.
225 * @return Zend_Gdata_Extension_Who The element being modified.
227 public function setEmail($value)
229 $this->_email = $value;
234 * Get the value for this element's Rel attribute.
236 * @return string The requested attribute.
238 public function getRel()
244 * Set the value for this element's Rel attribute.
246 * @param string $value The desired value for this attribute.
247 * @return Zend_Gdata_Extension_Who The element being modified.
249 public function setRel($value)
251 $this->_rel = $value;
256 * Get this entry's AttendeeStatus element.
258 * @return Zend_Gdata_Extension_AttendeeStatus The requested entry.
260 public function getAttendeeStatus()
262 return $this->_attendeeStatus;
266 * Set the child's AttendeeStatus element.
268 * @param Zend_Gdata_Extension_AttendeeStatus $value The desired value for this attribute.
269 * @return Zend_Gdata_Extension_Who The element being modified.
271 public function setAttendeeStatus($value)
273 $this->_attendeeStatus = $value;
278 * Get this entry's AttendeeType element.
280 * @return Zend_Gdata_Extension_AttendeeType The requested entry.
282 public function getAttendeeType()
284 return $this->_attendeeType;
288 * Set the child's AttendeeType element.
290 * @param Zend_Gdata_Extension_AttendeeType $value The desired value for this attribute.
291 * @return Zend_Gdata_Extension_Who The element being modified.
293 public function setAttendeeType($value)
295 $this->_attendeeType = $value;